:root {
  --bg: #F5F2EC;
  --surface: #FFFFFF;
  --surface-2: #FBF9F4;
  --border: #E2DCD0;
  --border-strong: #C9C0AE;
  --ink: #1A2233;
  --ink-2: #3E4557;
  --muted: #77778A;
  --accent: #C15A1F;
  --accent-ink: #FFFFFF;
  --accent-soft: #F4D9C7;
  --good: #2F7A5F;
  --good-soft: #DDEDE5;
  --warn: #B5842A;
  --warn-soft: #F4E7C7;
  --bad: #A04141;
  --bad-soft: #F0D7D7;
  --info: #3D6A9E;
  --info-soft: #DCE7F4;
  --shadow-sm: 0 1px 2px rgba(20, 28, 44, .06);
  --shadow-md: 0 6px 24px -12px rgba(20, 28, 44, .18);
  --radius: 8px;
  --radius-sm: 5px;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1420; --surface: #161D2C; --surface-2: #1B2334;
    --border: #24304A; --border-strong: #35446A;
    --ink: #ECE9E2; --ink-2: #C2C6D3; --muted: #8892AC;
    --accent: #E48449; --accent-ink: #1A0F06; --accent-soft: #3C2515;
    --good: #63C29B; --good-soft: #17362A;
    --warn: #E4B85F; --warn-soft: #3B2E10;
    --bad: #E48282;  --bad-soft: #3B1C1C;
    --info: #7BA9DA; --info-soft: #16233A;
    --shadow-md: 0 10px 30px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0E1420; --surface: #161D2C; --surface-2: #1B2334;
  --border: #24304A; --border-strong: #35446A;
  --ink: #ECE9E2; --ink-2: #C2C6D3; --muted: #8892AC;
  --accent: #E48449; --accent-ink: #1A0F06; --accent-soft: #3C2515;
  --good: #63C29B; --good-soft: #17362A;
  --warn: #E4B85F; --warn-soft: #3B2E10;
  --bad: #E48282;  --bad-soft: #3B1C1C;
  --info: #7BA9DA; --info-soft: #16233A;
  --shadow-md: 0 10px 30px -14px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-md);
}
.login-card .brand-mark { margin-bottom: 14px; }
.login-card h1 { font-family: var(--display); font-size: 20px; margin: 4px 0 4px; letter-spacing: -0.01em; }
.login-card .muted { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { width: 100%; justify-content: center; padding: 10px 12px; }
.login-error {
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad);
  padding: 8px 10px; border-radius: 5px; font-size: 12.5px;
}

/* Shell */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
@media (max-width: 900px) { .app { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
@media (max-width: 900px) { .sidebar { position: static; height: auto; } }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -.02em;
}
.brand-name { font-family: var(--display); font-weight: 600; font-size: 15px; }
.brand-sub  { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

/* The menu scrolls on its own so Theme / Sign out stay pinned at the bottom on short screens. */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.nav-section { color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 10px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
  cursor: pointer; border: none; background: transparent;
  text-align: left; width: 100%; font-size: 13.5px;
  transition: background .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--ink); }
.nav-item .badge {
  margin-left: auto; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; padding: 1px 6px; border-radius: 999px; font-weight: 600;
}
.nav-item .badge.warn { background: var(--warn); color: #fff; }

.sidebar-foot { margin-top: auto; flex-shrink: 0; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.topbar .crumb { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 14px 4px 4px; border-radius: 999px;
}
.userchip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 11px;
}
.userchip span { font-weight: 600; font-size: 13px; }

.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
@media (max-width: 900px) { .content { padding: 16px; } }

/* Cards / grid */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 12px; font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: -.005em; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: -8px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px)  { .g-4, .g-3, .g-2 { grid-template-columns: 1fr; } }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat .val { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }
.stat .val .u { color: var(--muted); font-size: 13px; font-weight: 500; margin-left: 4px; }
.stat .delta { font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.tbl th {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; background: var(--surface-2);
}
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 13px; cursor: pointer; transition: transform .06s, background .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(0.95); background: var(--accent); }
.btn.good { background: var(--good); color: #fff; border-color: transparent; }
.btn.bad  { background: var(--bad);  color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 12px; }

.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font-size: 13.5px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent;
}
.pill.good  { background: var(--good-soft); color: var(--good); }
.pill.warn  { background: var(--warn-soft); color: var(--warn); }
.pill.bad   { background: var(--bad-soft);  color: var(--bad); }
.pill.info  { background: var(--info-soft); color: var(--info); }
.pill.muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

.ts-week {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.ts-head {
  display: grid; grid-template-columns: minmax(260px, 2.4fr) repeat(7, 1fr) 80px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
}
.ts-head > div { padding: 10px; border-right: 1px solid var(--border); }
.ts-head > div:last-child { border-right: none; text-align: right; }
.ts-row {
  display: grid; grid-template-columns: minmax(260px, 2.4fr) repeat(7, 1fr) 80px;
  border-bottom: 1px solid var(--border);
}
.ts-row > div { padding: 6px 8px; border-right: 1px solid var(--border); display: flex; align-items: center; min-height: 46px; }
.ts-row > div:last-child { border-right: none; justify-content: flex-end; font-family: var(--mono); font-weight: 600; color: var(--ink-2); }
.ts-row select {
  border: 1px solid var(--border-strong); background: var(--surface-2);
  width: 100%; outline: none; font-weight: 500; color: var(--ink);
  padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.ts-row select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); background: var(--surface); }
.ts-row input[type=number] {
  width: 100%; min-height: 32px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  padding: 6px 8px; text-align: right; font-family: var(--mono);
  font-size: 13px; border-radius: 4px; color: var(--ink);
  cursor: text; outline: none;
  -moz-appearance: textfield;
}
.ts-row input[type=number]::-webkit-outer-spin-button,
.ts-row input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ts-row input[type=number]:hover { border-color: var(--accent); }
.ts-row input[type=number]:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft); }
.ts-row input[type=number]:disabled { background: transparent; border-color: transparent; color: var(--muted); cursor: not-allowed; }
.ts-row select:disabled { background: transparent; border-color: transparent; color: var(--muted); cursor: not-allowed; }
/* Hour cell: input on top, description status underneath */
.ts-row > div.ts-cell { flex-direction: column; align-items: stretch; justify-content: center; gap: 3px; }
.ts-desc-flag {
  border: none; background: none; padding: 0; cursor: pointer;
  font-size: 10.5px; font-weight: 600; text-align: left; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ts-desc-flag[hidden] { display: none; }
.ts-desc-flag.missing { color: var(--bad); }
.ts-desc-flag.ok { color: var(--good); }
.ts-desc-flag:hover { text-decoration: underline; }

/* Work descriptions list under the grid */
.ts-desc { border-top: 1px solid var(--border); padding: 12px 16px 6px; }
.ts-desc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.ts-desc-sub { color: var(--muted); font-size: 12px; margin-left: 8px; }
.ts-desc-count { font-size: 12px; font-weight: 600; }
.ts-desc-count.missing { color: var(--bad); }
.ts-desc-count.ok { color: var(--good); }
.ts-desc-empty { color: var(--muted); font-size: 12.5px; padding: 6px 0 10px; }
.ts-desc-item {
  display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: start;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-left: 3px solid var(--good); border-radius: 6px; background: var(--surface);
}
.ts-desc-item.missing { border-left-color: var(--bad); background: var(--bad-soft); }
.ts-desc-meta { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 2px; font-size: 12.5px; }
.ts-desc-day { font-weight: 700; white-space: nowrap; }
.ts-desc-hrs { grid-column: 1 / -1; font-family: var(--mono); color: var(--muted); font-size: 12px; }
.ts-desc-proj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-desc-item textarea {
  width: 100%; min-height: 54px; resize: vertical; box-sizing: border-box;
  padding: 8px 10px; border-radius: 5px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13.5px; line-height: 1.45;
}
.ts-desc-item textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ts-desc-item textarea:disabled { background: transparent; border-color: transparent; color: var(--ink); resize: none; padding-left: 0; }
@media (max-width: 760px) { .ts-desc-item { grid-template-columns: 1fr; } }
.ts-row.total { background: var(--surface-2); font-weight: 600; }
.ts-row.total > div { min-height: 36px; }
@media (max-width: 900px) {
  .ts-head, .ts-row { grid-template-columns: minmax(160px,2fr) repeat(7,1fr) 80px; font-size: 11px; }
}

.ts-actions {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 16px; background: var(--surface-2); border-top: 1px solid var(--border);
}
.ts-actions .total-box { margin-left: auto; font-family: var(--mono); font-weight: 600; }
.ts-actions .total-box .u { color: var(--muted); font-weight: 500; margin-left: 4px; }

.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.week-nav .wk-title { font-family: var(--display); font-weight: 600; font-size: 15px; }
.week-nav .wk-sub { color: var(--muted); font-size: 12px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(15,20,32,.5);
  display: grid; place-items: center; padding: 20px; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 640px;
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-md);
}
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 15px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input.search {
  padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font-size: 13px; min-width: 220px;
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.proj-code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.kv dd { margin: 0; font-weight: 500; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress.good > span { background: var(--good); }
.progress.warn > span { background: var(--warn); }
.progress.bad  > span { background: var(--bad); }

.alert-row { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.alert-row .icon {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--warn-soft); color: var(--warn); flex-shrink: 0; font-weight: 700;
}
.alert-row.info .icon { background: var(--info-soft); color: var(--info); }
.alert-row.bad  .icon { background: var(--bad-soft);  color: var(--bad); }
.alert-row.good .icon { background: var(--good-soft); color: var(--good); }
.alert-row .body .t { font-weight: 600; }
.alert-row .body .d { color: var(--muted); font-size: 12px; margin-top: 2px; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.thread .msg { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.thread .msg .who { font-weight: 600; font-size: 12px; }
.thread .msg .when { color: var(--muted); font-size: 11px; margin-left: 8px; }
.thread .msg .txt { margin-top: 4px; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 180px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { font-family: var(--display); font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

.lock-note {
  padding: 12px 14px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid var(--warn); border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start;
}

.rp-checklist {
  max-height: 160px; overflow-y: auto;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 6px 2px;
}
.rp-check {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; font-size: 13px; font-weight: 500; cursor: pointer;
  text-transform: none; letter-spacing: normal; color: var(--ink);
}
.rp-check:hover { background: var(--surface-2); }
.rp-check input { cursor: pointer; }

.tag {
  display: inline-block; padding: 1px 6px; font-size: 10.5px; font-weight: 600;
  border-radius: 3px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .04em;
}
.flex { display: flex; }
.flex.gap { gap: 10px; }
.flex.between { justify-content: space-between; }
.flex.center { align-items: center; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Section headings on the Projects & AMCs page */
.section-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-family: var(--display); font-size: 17px; font-weight: 600; }
.section-head .section-sub { color: var(--muted); font-size: 12px; }

/* Timesheet: weekend columns (days 5–6 of every work week) and days before the start date */
.ts-head > div.ts-weekend { background: color-mix(in srgb, var(--muted) 10%, transparent); }
.ts-row > div.ts-weekend { background: color-mix(in srgb, var(--muted) 7%, transparent); }
.ts-head > div.ts-prestart, .ts-row > div.ts-prestart { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--muted) 12%, transparent) 6px 12px); }
.ts-row > div.ts-prestart input { opacity: .5; }
