/* Milroy Construction OS — Executive Project Lifecycle
   ---------------------------------------------------------------------------
   Colour discipline (spec section 61): lifecycle stage communicates POSITION
   only. Health, timer and blockers each get their own, separate indicator.
   Stage chips are therefore deliberately neutral-grey — never green/red. */

:root {
  /* Brand palette sampled from milroyconstruction.com
     Navy #1A3A52 and Sand #C2B6A0 are the two brand colours.

     Note on Sand: white-on-sand is roughly 2:1 contrast. That reads fine on a
     marketing hero, but this is a data-dense screen read at a glance, so Sand
     is used for accents, rules, focus and highlights -- not as a background
     behind small text. Navy carries the text-bearing buttons. */
  --bg:            #f4f5f6;
  --surface:       #ffffff;
  --surface-2:     #f9f9f9;
  --surface-3:     #f5f5f5;
  --border:        #e0e0e0;
  --border-strong: #cccccc;

  --text:          #333333;
  --text-2:        #666666;
  --text-3:        #8a8d93;
  --text-inv:      #ffffff;

  --brand:         #1a3a52;   /* Milroy navy */
  --brand-2:       #142e42;   /* navy, pressed */
  --brand-3:       #24506f;   /* navy, lifted */
  --brand-soft:    #e9eef2;   /* navy tint: selected rows */

  --accent:        #c2b6a0;   /* Milroy sand */
  --accent-2:      #a99c82;   /* sand, pressed */
  --accent-soft:   #f4f1ea;   /* sand tint */

  /* Health colours stay semantic rather than brand-derived, warmed slightly
     to sit alongside the navy/sand palette. */
  --green:  #16704a;  --green-bg:  #e6f2ec;  --green-br:  #b5d6c5;
  --yellow: #8a5a09;  --yellow-bg: #fbf1de;  --yellow-br: #e8cfa4;
  --red:    #a8291f;  --red-bg:    #fbeae8;  --red-br:    #eebfba;
  --grey:   #666666;  --grey-bg:   #f0f0f0;  --grey-br:   #d8d8d8;

  --radius:   5px;            /* matches the site's button radius */
  --radius-s: 4px;
  --shadow-1: 0 1px 2px rgba(26,58,82,.06), 0 1px 3px rgba(26,58,82,.08);
  --shadow-2: 0 4px 14px rgba(26,58,82,.12);
  --shadow-3: -12px 0 40px rgba(26,58,82,.18);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -.005em; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 3px; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--brand); color: var(--text-inv);
  border-bottom: 2px solid var(--accent);          /* the sand rule from the logo */
  box-shadow: var(--shadow-1);
}
/* The real Milroy logo, recoloured for dark chrome: sand rules and chevron
   kept, the grey wordmark reversed to white, paper knocked out to transparent.
   Sized by height so the 400x168 source stays crisp on retina. */
.topbar .logo { display: flex; align-items: center; }
.topbar .logo:hover { text-decoration: none; }
.topbar .logo-img { height: 34px; width: auto; display: block; }
@media (max-width: 900px) { .topbar .logo-img { height: 28px; } }
.topbar nav { display: flex; gap: 2px; margin-left: 12px; }
.topbar nav a {
  color: rgba(255,255,255,.82); padding: 6px 12px; border-radius: var(--radius-s);
  font-weight: 550; font-size: 13.5px;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: rgba(255,255,255,.85); text-align: right; line-height: 1.25; }
.topbar .who strong { display: block; color: #fff; font-size: 13px; }
.topbar .btn-plain {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
  color: #fff; padding: 6px 12px; border-radius: var(--radius-s); cursor: pointer; font-size: 13px;
}
.topbar .btn-plain:hover { background: rgba(255,255,255,.24); }

.page { padding: 20px 24px 64px; max-width: 1800px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* --------------------------------------------------------------- KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; text-align: left; transition: .12s; position: relative;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.kpi.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.kpi.active::after {
  content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px;
  background: var(--accent); border-radius: var(--radius) var(--radius) 0 0;
}
.kpi .k-value { font-family: var(--display); }
.kpi .k-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 25px; font-weight: 680; margin-top: 5px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .k-value.currency { font-size: 19px; }
.kpi.tone-danger  .k-value { color: var(--red); }
.kpi.tone-warning .k-value { color: var(--yellow); }
.kpi.zero .k-value { color: var(--text-3); }

/* ----------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 14px;
}
.toolbar .grow { flex: 1; }
.field { display: flex; align-items: center; gap: 6px; }
.field label { font-size: 12px; color: var(--text-3); font-weight: 600; }
select, input[type=text], input[type=date], input[type=number], input[type=email], input[type=password], textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  padding: 6px 9px; font-size: 13px; min-width: 0;
}
select:hover, input:hover { border-color: var(--text-3); }
textarea { width: 100%; resize: vertical; min-height: 66px; font-family: inherit; }
.search-input { min-width: 230px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  padding: 7px 13px; border-radius: var(--radius-s); cursor: pointer; font-weight: 560; font-size: 13px;
  transition: .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn { border-width: 1.5px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
/* Sand button: brand accent, but dark text so it stays legible */
.btn-accent { background: var(--accent); border-color: var(--accent-2); color: #33302a; }
.btn-accent:hover { background: var(--accent-2); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-link { background: none; border: none; color: var(--brand); padding: 0; cursor: pointer; font-weight: 560; }
.btn-link:hover { text-decoration: underline; }

.chip-toggle {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-weight: 560; color: var(--text-2);
}
.chip-toggle:hover { border-color: var(--text-3); }
.chip-toggle.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-toggle.on.danger { background: var(--red); border-color: var(--red); }

/* ------------------------------------------------------------------- table */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; box-shadow: var(--shadow-1);
}
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 5; background: var(--surface-2);
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--text); background: var(--surface-3); }
table.grid thead th .arrow { color: var(--brand); margin-left: 3px; }
table.grid tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tbody tr.selected td { background: var(--brand-soft); }
table.grid tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr.attention td:first-child { box-shadow: inset 3px 0 0 var(--red); }

.p-name { font-weight: 620; color: var(--text); }
.p-meta { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-3); }
.empty-cell { color: var(--text-3); font-style: italic; font-size: 12.5px; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 640; border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-green  { color: var(--green);  background: var(--green-bg);  border-color: var(--green-br); }
.b-yellow { color: var(--yellow); background: var(--yellow-bg); border-color: var(--yellow-br); }
.b-red    { color: var(--red);    background: var(--red-bg);    border-color: var(--red-br); }
.b-grey, .b-neutral, .b-unrated { color: var(--grey); background: var(--grey-bg); border-color: var(--grey-br); }
.badge.override-mark::after { content: "✎"; font-size: 10px; opacity: .85; }

/* stage chip: neutral by design — position, not health (spec section 61) */
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--radius-s);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 620; color: var(--text-2); white-space: nowrap;
}
.stage-chip .seq {
  font-family: var(--mono); font-size: 10px; color: var(--text-inv);
  background: var(--brand); border-radius: 3px; padding: 0 4px; line-height: 15px;
}
.hold-flag {
  background: var(--grey-bg); color: var(--grey); border: 1px solid var(--grey-br);
  font-size: 10.5px; font-weight: 750; letter-spacing: .05em; padding: 1px 6px; border-radius: 3px;
}
.blocker-flag {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 650;
  color: var(--red); background: var(--red-bg); border: 1px solid var(--red-br);
  padding: 2px 7px; border-radius: 999px;
}
.blocker-flag.sev-medium, .blocker-flag.sev-low {
  color: var(--yellow); background: var(--yellow-bg); border-color: var(--yellow-br);
}
.warn-flag { font-size: 11.5px; color: var(--yellow); font-weight: 620; }

.timer-cell { display: flex; align-items: baseline; gap: 6px; }
.timer-days { font-weight: 660; font-variant-numeric: tabular-nums; }
.timer-target { font-size: 11.5px; color: var(--text-3); }

.progress { display: flex; align-items: center; gap: 7px; min-width: 92px; }
.progress .bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress .bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.progress .pct { font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }

.overdue { color: var(--red); font-weight: 620; }
.due-soon { color: var(--yellow); font-weight: 600; }

/* ------------------------------------------------------------------ matrix */
.matrix-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-1); margin-bottom: 14px; }
table.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.matrix th { background: var(--surface-2); padding: 8px 6px; border-bottom: 1px solid var(--border);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; }
table.matrix th.proj-col { text-align: left; padding-left: 12px; min-width: 210px; position: sticky; left: 0; z-index: 6; }
table.matrix td { padding: 0; border-bottom: 1px solid var(--border); text-align: center; }
table.matrix td.proj-cell { text-align: left; padding: 7px 12px; position: sticky; left: 0; background: var(--surface); z-index: 4; border-right: 1px solid var(--border); }
table.matrix tbody tr:hover td { background: var(--surface-2); }
table.matrix tbody tr:hover td.proj-cell { background: var(--surface-2); }
table.matrix tbody tr { cursor: pointer; }
.cell-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; }
.cell-complete { color: var(--green); background: var(--green-bg); font-weight: 700; }
.cell-current  { color: #fff; background: var(--brand); font-weight: 700; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--accent); }
.cell-skipped  { color: var(--text-3); }
.cell-future   { color: var(--border-strong); }

/* ------------------------------------------------------------------ drawer */
.scrim { position: fixed; inset: 0; background: rgba(16,24,40,.34); z-index: 60; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0 } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 94vw); z-index: 61;
  background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  animation: slide .18s cubic-bezier(.32,.72,.35,1);
}
@keyframes slide { from { transform: translateX(100%) } }
.drawer-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.drawer-head .row1 { display: flex; align-items: flex-start; gap: 12px; }
.drawer-head h2 { font-size: 18px; flex: 1; }
.drawer-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.drawer-head .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; align-items: center; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: var(--radius-s); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 40px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; flex-wrap: wrap; }

.sec { margin-bottom: 22px; }
.sec > h3 {
  font-family: var(--sans); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  margin-bottom: 9px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 11px 16px; }
.kv .item .k { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kv .item .v { font-size: 14px; font-weight: 600; margin-top: 2px; }
.kv .item .v.small { font-size: 13px; font-weight: 500; }
.clickable { cursor: pointer; border-bottom: 1px dashed var(--border-strong); display: inline-block; }
.clickable:hover { color: var(--brand); border-bottom-color: var(--brand); }

.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; background: var(--surface); margin-bottom: 8px; }
.card.flat { background: var(--surface-2); }
.card .card-title { font-weight: 620; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card .card-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.card.alert-red { border-left: 3px solid var(--red); }
.card.alert-yellow { border-left: 3px solid var(--yellow); }
.card.alert-green { border-left: 3px solid var(--green); }

.empty {
  padding: 16px; text-align: center; color: var(--text-3); font-size: 13px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty.tight { padding: 11px; font-size: 12.5px; }

.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { padding: 5px 0 5px 18px; position: relative; font-size: 13px; color: var(--text-2); }
.attention-list li::before { content: "▸"; position: absolute; left: 3px; color: var(--red); }

.signal-row { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 13px; }

/* ------------------------------------------------------------------- modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(16,24,40,.42); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-2); width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 10px 10px; }
.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 12px; font-weight: 640; color: var(--text-2); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-row .hint { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.checkline input { width: auto; }

.alert { padding: 10px 12px; border-radius: var(--radius-s); font-size: 13px; margin-bottom: 13px; border: 1px solid; }
.alert-err  { background: var(--red-bg); border-color: var(--red-br); color: var(--red); }
.alert-warn { background: var(--yellow-bg); border-color: var(--yellow-br); color: var(--yellow); }
.alert-info { background: var(--brand-soft); border-color: #c6d6e9; color: var(--brand-2); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.gate-item { display: flex; align-items: flex-start; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.gate-item:last-child { border-bottom: none; }
.gate-item input { margin-top: 3px; width: auto; }
.gate-label { flex: 1; font-size: 13px; }
.req-hard { font-size: 10px; font-weight: 750; color: var(--red); background: var(--red-bg); border: 1px solid var(--red-br); padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; }
.req-soft { font-size: 10px; font-weight: 700; color: var(--text-3); background: var(--surface-3); border: 1px solid var(--border-strong); padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; }

/* --------------------------------------------------------------- workspace */
.ws-head { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-1); }
.ws-head .top { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.ws-head h1 { font-size: 20px; }
.ws-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.ws-tabs a { padding: 9px 14px; font-size: 13.5px; font-weight: 570; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.ws-tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.ws-tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.cols { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); margin-bottom: 14px; }
.panel > header { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.panel > header h3 { font-size: 13.5px; flex: 1; }
.panel > .panel-body { padding: 14px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 5px; bottom: 5px; width: 2px; background: var(--border); }
.timeline .tl-item { position: relative; padding: 8px 0; }
.timeline .tl-item::before {
  content: ""; position: absolute; left: -20px; top: 14px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline .tl-item.open::before { background: var(--brand); border-color: var(--brand); }
.tl-date { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tl-body { font-size: 13px; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 9px 11px; }
.stat .s-k { font-size: 10.5px; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.stat .s-v { font-family: var(--display); font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------- misc */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1e232b; color: #fff; padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-2); font-size: 13px; max-width: 520px; animation: rise .16s; }
.toast.err { background: var(--red); }
.toast.ok  { background: var(--green); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #1a3a52 0%, #142e42 60%, #102637 100%);
}
.login-card {
  background: var(--surface); border-radius: 6px; box-shadow: var(--shadow-2);
  padding: 28px 30px 30px; width: 100%; border-top: 4px solid var(--accent);
}
.login-stack { width: min(410px, 100%); display: flex; flex-direction: column; gap: 24px; }
.login-logo { display: flex; justify-content: center; }
.login-logo img { width: 260px; max-width: 82%; height: auto; display: block; }
.login-eyebrow {
  font-family: var(--display); font-size: 10.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--text-3);
  text-align: center; margin-bottom: 20px;
}
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }

.loading { padding: 50px; text-align: center; color: var(--text-3); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg) } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.hide-sm { }
@media (max-width: 1180px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .page { padding: 14px 12px 60px; }
  .hide-sm { display: none !important; }
  /* Spec section 14: full-screen on mobile. Anchoring to both edges is exact,
     whereas 100vw can disagree with the layout viewport (scrollbars, pinch-zoom). */
  .drawer { left: 0; right: 0; width: auto; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .who { display: none; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .toolbar, .drawer, .scrim, .kpi { break-inside: avoid; }
  body { background: #fff; }
}
