/* Minimal base styling. Capacity-band and risk colors live here as CSS vars so
   views and SVG charts can share them (SPEC §4.5, §4.8). */
:root {
    --green: #2e7d32;
    --amber: #f9a825;
    --red: #c62828;
    --dev: #1565c0;
    --qa: #f9a825;
    --bg: #ffffff;
    --fg: #1a1a1a;
    --muted: #666;
    --border: #ddd;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
    margin: 0;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.45;
}

main {
    padding: 1rem 1.5rem;
}

nav {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: #f5f5f5;
    border-bottom: 1px solid var(--border);
}

nav a {
    color: var(--fg);
    text-decoration: none;
    font-weight: 500;
}

nav a:hover {
    text-decoration: underline;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.35rem 0.5rem;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background: #fafafa;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Projects editing surface */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-actions {
    display: flex;
    gap: 0.6rem;
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin: 0.75rem 0;
}

.filters label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 0.2rem;
}

.filters select,
.filters input {
    font: inherit;
    padding: 0.2rem 0.3rem;
}

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

table.projects {
    font-size: 0.85rem;
}

table.projects td.num,
table.projects th:nth-child(n+6):nth-child(-n+9) {
    text-align: right;
    white-space: nowrap;
}

table.projects td.notes {
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td.actions, th.actions {
    white-space: nowrap;
    text-align: right;
}

.field-error {
    display: block;
    color: var(--red);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

/* Buttons */
.btn, .btn-sm {
    cursor: pointer;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 5px;
    font: inherit;
}

.btn {
    padding: 0.4rem 0.8rem;
    font-weight: 600;
    background: var(--dev);
    color: #fff;
    border-color: var(--dev);
}

.btn-sm {
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
}

.btn-sm.danger {
    color: var(--red);
    border-color: #e6b3b3;
}

.btn-sm.danger:hover {
    background: #fdecec;
}

/* Capacity Dashboard */
.toggles {
    display: flex;
    gap: 1.5rem;
    margin: 0.75rem 0 1.25rem;
    padding: 0.6rem 0.9rem;
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: fit-content;
}

.toggles label {
    cursor: pointer;
    user-select: none;
}

table.capacity {
    font-size: 0.8rem;
    white-space: nowrap;
}

table.capacity td.num, table.capacity th.num {
    text-align: right;
}

table.capacity td.team, table.capacity th.team {
    text-align: left;
    font-weight: 600;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
}

table.capacity .subtotal {
    background: #f4f7fb;
    font-weight: 600;
}

table.capacity tr.alloc-row td.team {
    vertical-align: top;
    border-bottom: 2px solid var(--border);
}

table.capacity tr.util-row td {
    border-bottom: 2px solid #ccc;
}

/* Utilization bands (§4.5) */
.band-green { background: #e6f4ea; color: #1e6e34; }
.band-amber { background: #fff4d6; color: #8a6100; }
.band-red   { background: #fde2e1; color: #b3261e; font-weight: 600; }

h2 { margin-top: 1.75rem; }

/* Gantt timeline */
.risk-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0 1.5rem;
}

.tile {
    min-width: 6.5rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.tile.wide { min-width: 16rem; }
.tile-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.tile-sub { font-size: 0.82rem; margin-top: 0.15rem; }

.tile.risk-atrisk { background: #fde2e1; border-color: #f0b6b3; }
.tile.risk-tight { background: #fff4d6; border-color: #f0d893; }
.tile.risk-ontrack { background: #e6f4ea; border-color: #aed6bb; }

table.gantt {
    font-size: 0.78rem;
    white-space: nowrap;
}

table.gantt th.month {
    width: 1.4rem;
    padding: 0.2rem 0.1rem;
    font-weight: 500;
    text-align: center;
}

table.gantt th.year-group {
    text-align: center;
    background: #eef1f5;
}

table.gantt td.date { font-variant-numeric: tabular-nums; }
table.gantt td.num, table.gantt th.num { text-align: right; }

table.gantt .sticky-col {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
    text-align: left;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.gantt thead .sticky-col { z-index: 3; background: #fafafa; }

td.mcell {
    width: 1.4rem;
    min-width: 1.4rem;
    padding: 0;
    border: 1px solid #eee;
}

/* Gantt cell colors (§5.3) */
.g-dev   { background: var(--dev); }
.g-qa    { background: var(--qa); }
.g-devqa { background: linear-gradient(135deg, var(--dev) 0 50%, var(--qa) 50% 100%); }
.g-past  { background: var(--red); }

/* Slack risk text colors */
.risk-atrisk  { color: var(--red); font-weight: 600; }
.risk-tight   { color: #8a6100; }
.risk-ontrack { color: var(--green); }

.legend {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    color: var(--muted);
}
.legend .swatch {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 0.2rem;
}
.legend .swatch-line {
    display: inline-block;
    width: 1rem;
    border-top: 2px solid;
    vertical-align: middle;
    margin-right: 0.2rem;
}
.bar-delivery-legend { border-top: 2px dashed #333; }
.bar-today-legend { border-color: #6a1b9a; }

/* SVG Gantt */
.gantt-svg td.timeline-cell, .gantt-svg th.timeline-head { padding: 0; vertical-align: middle; }
.gantt-axis, .gantt-bars { display: block; }
.axis-grid { stroke: #eee; stroke-width: 1; }
.axis-month { font-size: 8px; fill: #aaa; }
.axis-year { font-size: 10px; fill: #555; font-weight: 600; }
.axis-today { stroke: #6a1b9a; stroke-width: 1.5; }
svg rect.bar-dev { fill: var(--dev); }
svg rect.bar-qa { fill: var(--qa); }
svg rect.bar-past { fill: var(--red); }
svg line.bar-delivery { stroke: #333; stroke-width: 1; stroke-dasharray: 2 2; }
.muted-note { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }

/* Exec Summary */
table.grid-table {
    width: auto;
    min-width: 32rem;
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
}
table.grid-table td.num, table.grid-table th.num { text-align: right; white-space: nowrap; }
table.grid-table tr.subtotal td { background: #f4f7fb; font-weight: 600; }

.variance-high { font-weight: 700; color: var(--red); }

.util-pair { display: flex; flex-wrap: wrap; gap: 2rem; }
.util-table h3 { margin: 0.25rem 0 0.5rem; font-size: 1rem; }
.util-table { flex: 1; min-width: 24rem; }

/* Settings */
.settings-section {
    margin: 1.5rem 0 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fcfcfc;
}
.settings-section h2 { margin-top: 0; }
.settings-section input.num { width: 7rem; }
.settings-section .btn { margin-top: 0.75rem; }
.settings-section h3 { margin: 1.25rem 0 0.25rem; font-size: 1rem; }

.inline-add {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}
.inline-add select, .inline-add input { padding: 0.25rem 0.4rem; font: inherit; }
.inline-add input.num { width: 5rem; }

.flash {
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.flash-ok   { background: #e6f4ea; color: #1e6e34; border: 1px solid #aed6bb; }
.flash-err  { background: #fde2e1; color: #b3261e; border: 1px solid #f0b6b3; }
.flash-warn { background: #fff4d6; color: #8a6100; border: 1px solid #f0d893; }

/* Missing recommended data on the Projects table (§5.1) */
table.projects td.missing {
    background: #fde2e1;
    color: #b3261e;
    text-align: center;
    font-weight: 600;
}
.scenario-switcher { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; }
.scenario-switcher select { padding: .15rem .3rem; }
.scenario-bar .inline-add { display: inline-flex; gap: .4rem; margin-right: .6rem; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; padding: 1.25rem 1.5rem; border-radius: 6px; max-width: 560px; width: 90%; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }
.modal .import-modes { border: none; padding: 0; margin: .75rem 0; display: flex; flex-direction: column; gap: .4rem; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    font-weight: 600;
    gap: 0.25rem;
}

.form-grid input,
.form-grid select {
    font: inherit;
    font-weight: 400;
    padding: 0.25rem 0.35rem;
    box-sizing: border-box;
    width: 100%;
}

.modal-form {
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
}

/* Auth / login pages */
.auth-main {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 8vh;
}

.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 22rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
}

.auth-card h1 {
    margin-top: 0;
    font-size: 1.4rem;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1rem;
}

.auth-card label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.auth-card input {
    font: inherit;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    box-sizing: border-box;
    width: 100%;
}
