:root {
    --navy: #1e2a46;
    --navy-light: #2c3b60;
    --amber: #f49a24;
    --amber-dark: #d9820f;
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e1e4ea;
    --text: #1c2333;
    --text-muted: #6b7280;
    --green: #1f9d55;
    --red: #d64545;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--amber-dark); }

header.topbar {
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    gap: 20px;
    flex-wrap: nowrap;
}

header.topbar .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}
header.topbar .brand .wordmark { font-weight: 700; font-size: 16px; letter-spacing: .01em; color: #fff; }
header.topbar .brand .brand-sep { color: #57628a; font-weight: 300; }
header.topbar .brand .brand-tag { font-size: 12px; color: #cfd6e6; text-transform: uppercase; letter-spacing: .04em; }

nav.tabs {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
nav.tabs a {
    color: #cfd6e6;
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
}
nav.tabs a.active {
    background: var(--bg);
    color: var(--navy);
    font-weight: 600;
}
nav.tabs a:hover:not(.active) { color: #fff; }

.userbox {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #cfd6e6;
}
.userbox .role-badge {
    background: var(--amber);
    color: var(--navy);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}
.userbox a { color: #cfd6e6; }
.userbox a:hover { color: #fff; }

main { padding: 24px; max-width: 1800px; margin: 0 auto; }

h1 { font-size: 22px; color: var(--navy); margin: 0 0 4px; }
h2 { font-size: 17px; color: var(--navy); margin: 24px 0 10px; }
.subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    display: inline-block;
    background: var(--amber);
    color: var(--navy);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.btn:hover { background: var(--amber-dark); color: #fff; }
.btn.secondary { background: var(--card); color: var(--navy); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); color: var(--navy); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.flash {
    background: #fff4de;
    border: 1px solid var(--amber);
    color: #7a5300;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.board {
    display: grid;
    gap: 12px;
    overflow-x: auto;
}
.board-scroll-sync {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    margin-bottom: 6px;
}
.board-scroll-sync > div {
    height: 1px;
}
.column {
    background: #eceef2;
    border-radius: 8px;
    padding: 8px;
    min-height: 200px;
    max-height: calc(100vh - 210px);
    overflow-y: auto;
}
.column h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--navy);
    margin: 2px 4px 6px;
    display: flex;
    justify-content: space-between;
}
.column h3 .count { color: var(--text-muted); font-weight: 400; }
.column .col-total { font-size: 10px; color: var(--text-muted); margin: -4px 4px 6px; }

.card {
    background: var(--card);
    border-radius: 5px;
    padding: 6px 8px;
    margin-bottom: 5px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card .client { font-weight: 700; font-size: 12px; color: var(--navy); }
.card .deal-name { font-size: 11px; color: var(--text-muted); margin: 1px 0 3px; }
.card .value { font-weight: 700; color: var(--navy); font-size: 12px; }
.card .meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.card .status-detail { font-size: 10px; color: var(--text); margin-top: 3px; font-style: italic; }
.card .card-actions { margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card select { font-size: 12px; padding: 3px 4px; border-radius: 4px; border: 1px solid var(--border); background: #fff; color: var(--text); max-width: 100%; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 6px;
    overflow: hidden;
    font-size: 13px;
}
table.data th, table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
table.data th {
    background: #eceef2;
    color: var(--navy);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
table.data tr:hover td { background: #fafbfc; }
table.data input[type=number], table.data input[type=text] {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    max-width: 640px;
}
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.form-row input[type=text], .form-row input[type=number], .form-row input[type=date],
.form-row select, .form-row textarea, .form-row input[type=password] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.form-row textarea { min-height: 70px; }
.form-inline { display: flex; align-items: center; gap: 8px; }
.form-inline label { margin: 0; text-transform: none; font-weight: 400; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

details.collapsible { margin-bottom: 14px; }
details.collapsible summary {
    cursor: pointer;
    color: var(--navy);
    font-weight: 700;
    font-size: 13px;
    padding: 6px 10px;
    background: #eceef2;
    border-radius: 6px;
    list-style: none;
    user-select: none;
}
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible[open] summary { border-radius: 6px 6px 0 0; }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
.stat-tile .stat-val { font-size: 22px; font-weight: 700; color: var(--navy); }
.stat-tile .stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.dash-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}
@media (max-width: 900px) {
    .dash-cols { grid-template-columns: 1fr; }
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}
.login-card {
    background: var(--card);
    padding: 36px;
    border-radius: 10px;
    width: 320px;
    text-align: center;
}
.login-card .brand-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.login-card .brand-logo .wordmark { color: #7a7a7a; font-weight: 700; font-size: 24px; letter-spacing: .01em; }
.login-card p.tag { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.badge.yes { background: #dff5e6; color: var(--green); }
.badge.no { background: #f1f2f5; color: var(--text-muted); }

.timeline-item { border-left: 2px solid var(--amber); padding: 4px 0 4px 14px; margin-bottom: 12px; }
.timeline-item .when { font-size: 11px; color: var(--text-muted); }
.timeline-item .subj { font-weight: 700; font-size: 13px; color: var(--navy); }
.timeline-item .body { font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
.type-tag { font-size: 10px; text-transform: uppercase; background: #eceef2; padding: 1px 6px; border-radius: 8px; margin-left: 6px; color: var(--text-muted); }

.helptext { font-size: 12px; color: var(--text-muted); background: #eef1f7; border-radius: 6px; padding: 10px 12px; margin-bottom: 16px; }
.totals-row td { font-weight: 700; background: #eceef2; }
.required-hours-row td, .agents-required-row td { font-weight: 600; background: #f4f5f7; color: var(--navy); }
.required-hours-row input, .agents-required-row input { width: 56px; padding: 2px 4px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; }

tr.missing-dates td { background: #fffaeb; }
tr.missing-dates:hover td { background: #fef3c7; }

tr.live-row td { background: #dff5e6; }
tr.live-row:hover td { background: #c9edd6; }
tr.live-row.missing-dates td { background: #fdf0d5; }

tr.completed-row td { color: var(--text-muted); text-decoration: line-through; background: #f8f9fb; }
tr.completed-row a { color: var(--text-muted); }

.bar-chart { margin-bottom: 18px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bar-label { width: 150px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); text-align: right; }
.bar-track { flex: 1; background: #eceef2; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--amber); border-radius: 4px; min-width: 2px; transition: width .3s; }
.bar-count { width: 28px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--navy); }

tr.month-row th { background: var(--navy); color: #fff; text-align: center; font-size: 11px; letter-spacing: .03em; padding: 4px 6px; }

table.data td.project-cell { white-space: nowrap; }

table.data td.zebra-col, table.data th.zebra-col { background: #eef1f7; }
table.data tr:hover td.zebra-col { background: #e1e6f2; }
table.data tr.totals-row td.zebra-col { background: #dfe2ea; }
table.data tr.live-row td.zebra-col { background: #c9edd6; }
table.data tr.live-row.missing-dates td.zebra-col { background: #fbe6b8; }

/* Frozen-pane grids (Capacity Planner, Financial Forecast): frozen header rows +
   frozen first two columns, so the project label and the top headers stay visible
   while scrolling a very wide/tall table. Reusable via .frozen-scroll/.frozen-table. */
.frozen-scroll {
    overflow: auto;
    max-height: 72vh;
    border: 1px solid var(--border);
    border-radius: 6px;
}
table.data.frozen-table {
    border-radius: 0;
    /* table.data sets overflow:hidden for rounded corners, but that makes the
       table itself act as the sticky containing block instead of .frozen-scroll,
       so frozen headers/columns would scroll away with the table. Undo it here. */
    overflow: visible;
}
.frozen-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}
/* :where() carries zero specificity, so this only ever supplies a fallback background
   for cells nothing else colours (plain rows) - any state-based rule elsewhere in this
   file (zebra-col, live-row, totals-row, month-row dividers, table.data th, etc.),
   including ones added after this block, wins automatically without needing a matching
   override here. Avoids the whack-a-mole of enumerating every row state by hand. */
.frozen-table :where(th:nth-child(1), th:nth-child(2), td:nth-child(1), td:nth-child(2)) {
    position: sticky;
    z-index: 2;
    background: var(--card);
}
.frozen-table :where(th:nth-child(1), td:nth-child(1)) { left: 0; }
.frozen-table :where(th:nth-child(2), td:nth-child(2)) { left: var(--col1-width, 260px); }

.task-label {
    color: var(--navy);
    text-decoration: underline dotted;
    text-decoration-color: var(--border);
    cursor: pointer;
}
.task-label:hover { color: var(--amber-dark); }

.desc-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.desc-modal-box {
    background: var(--card);
    border-radius: 8px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.desc-modal-box h3 { margin: 0 0 10px; color: var(--navy); font-size: 16px; }
.desc-modal-box p { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; }
.desc-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}
.desc-modal-close:hover { color: var(--navy); }

.wide-modal-box {
    max-width: 900px;
    width: 92%;
    height: 88vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
}
.wide-modal-scroll {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    border-radius: 6px;
    margin-top: 6px;
    background: var(--card);
}

@media print {
    header.topbar, .no-print { display: none !important; }
    main { padding: 0; }
    body { background: #fff; }
    .print-only { display: block !important; }
}
.print-only { display: none; }

.link-danger {
    background: none;
    border: none;
    color: var(--red);
    font-size: 11px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
}
.link-danger:hover { color: #a83030; }
