:root {
  --bg: #F4F3EC;
  --card: #FBFAF6;
  --ink: #15211A;
  --muted: #5B665F;
  --line: #D8D6CB;
  --brand: #2E7D4F;
  --brand-ink: #F4F3EC;
  --brand-soft: #E6EBE2;
  --warn: #B5541A;
  --warn-soft: #FBEEDF;
  --bad: #A33B3B;
  --bad-soft: #F8E5E3;
  --focus: #5B5FC7;
  --shadow: 0 1px 2px rgba(21, 33, 26, .06), 0 4px 16px rgba(21, 33, 26, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1A14;
    --card: #17251D;
    --ink: #E8EEE9;
    --muted: #A7B6AC;
    --line: #2C3F33;
    --brand: #5DB984;
    --brand-ink: #0F1A14;
    --brand-soft: #1F3528;
    --warn: #F2A65A;
    --warn-soft: #3A2A1C;
    --bad: #F08A80;
    --bad-soft: #3A2020;
    --focus: #9EA2F0;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.link { color: var(--brand); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 36px; height: 36px; }
.brand-title { font-weight: 700; }
.brand-sub { font-size: .8rem; color: var(--muted); }
.who { display: flex; align-items: center; gap: 12px; font-size: .9rem; flex-wrap: wrap; justify-content: flex-end; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.card.narrow { max-width: 520px; margin: 48px auto; text-align: center; }
.card.error { border-color: var(--bad); }

fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
legend.step { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 12px; padding: 0; }
legend.step > span:first-child {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  display: inline-grid; place-items: center; font-size: .85rem;
}

.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.type {
  text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 2px;
}
.type b { font-size: .98rem; }
.type small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.type:hover { border-color: var(--brand); }
.type[aria-checked="true"] { border: 2px solid var(--brand); background: var(--brand-soft); padding: 11px 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=search], input[type=date], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type=file] { font: inherit; color: var(--ink); max-width: 100%; }
input, select, textarea { min-width: 0; max-width: 100%; }
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; }
.check input { margin-top: 4px; width: 18px; height: 18px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.summary { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg); font-size: .9rem; }
.summary dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }

.review { border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 12px 14px; margin: 4px 0 16px; font-size: .95rem; }
.review:empty { display: none; }
.review .what { font-weight: 700; }
.review .effect { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.formerror { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 10px 12px; }

.actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: wait; }

.done { text-align: center; padding: 24px 0 8px; }
.tick { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 28px; margin: 0 auto 12px; }

.aside-head { display: flex; align-items: center; justify-content: space-between; }
.filters { display: flex; gap: 8px; margin: 8px 0 12px; }
.chip { font: inherit; font-size: .82rem; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.recent li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .88rem; }
.recent .t { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 2px; }
.recent .m { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.pill { white-space: nowrap; display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.pill.ok { background: var(--brand-soft); color: var(--brand); }
.pill.wait { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill.hold { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); margin: 0 auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 24px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--card); }

@media (max-width: 520px) {
  main { padding: 16px 12px 32px; }
  .card { padding: 18px; }
  .topbar { padding: 10px 14px; }
  .who { font-size: .8rem; gap: 8px; }
}

/* Visit picker: type to search, matches drop down underneath */
.combo { position: relative; }
.combo > label { font-weight: 600; font-size: .9rem; }
.combo input[type=text] {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
.combo-list {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px;
  list-style: none; max-height: 340px; overflow-y: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(21, 33, 26, .14);
}
.combo-group { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; }
.combo-opt { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.combo-opt .main { font-size: .92rem; }
.combo-opt .sub { font-size: .8rem; color: var(--muted); }
.combo-opt:hover, .combo-opt[aria-selected="true"] { background: var(--brand-soft); }
.combo-empty { padding: 10px; font-size: .88rem; color: var(--muted); }
@media (prefers-color-scheme: dark) { .combo-list { box-shadow: 0 8px 24px rgba(0, 0, 0, .5); } }

/* Control Centre (1.4.0) */
.mainnav { display: flex; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.navtab { font: inherit; font-weight: 600; background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 12px 10px; cursor: pointer; }
.navtab.on { color: var(--ink); border-bottom-color: var(--brand); }
.navtab:hover { color: var(--ink); }
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cc-head h1 { margin-bottom: 2px; }
.cc-head p { margin: 0; }
.cc-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cc-tools .filters { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--ink); }
.kpi .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .82rem; color: var(--muted); }
.kpi.bad { border-left-color: var(--bad); } .kpi.bad .n { color: var(--bad); }
.kpi.hold { border-left-color: var(--warn); } .kpi.hold .n { color: var(--warn); }
.kpi.zero .n { color: var(--muted); }
.kpi:hover { border-color: var(--brand); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.subtab { font: inherit; font-size: .88rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.subtab.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.cc-panel h2.gap { margin-top: 22px; }
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.eqsearch { font: inherit; width: 100%; max-width: 420px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); margin: 4px 0 8px; }
.brief { white-space: pre-wrap; font: inherit; font-size: .88rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0 0; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
@media (max-width: 600px) { .kpi .n { font-size: 1.3rem; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Recent update details (1.4.0) */
.recent details.more > summary { list-style: none; cursor: pointer; }
.recent details.more > summary::-webkit-details-marker { display: none; }
.recent details.more > summary .t::after { content: "▸"; color: var(--muted); margin-left: auto; font-size: .8rem; }
.recent details.more[open] > summary .t::after { content: "▾"; }
.recent .more-body { margin-top: 8px; font-size: .82rem; }
.recent .more-body dl { grid-template-columns: 96px 1fr; }
.recent .more-body dt.sep, .recent .more-body dd.sep { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-weight: 600; }

/* Timelines (1.4.1): ported from the old dashboard's Gantt views */
:root { --plan: #4A5BC4; --alt: #2B7A8C; --grey: #9AA39C; --grid: #E4E2D8; }
@media (prefers-color-scheme: dark) { :root { --plan: #9EA8F2; --alt: #6CC3D5; --grey: #6E7D73; --grid: #24352A; } }
.tl { position: relative; margin: 6px 0 4px; }
.tl svg { display: block; width: 100%; height: auto; overflow: visible; }
.tl text { font-family: inherit; }
.tl-axis { font-size: 11px; fill: var(--muted); }
.tl-grid { stroke: var(--grid); stroke-width: 1; }
.tl-sep { stroke: var(--grid); }
.tl-bg { fill: transparent; }
.tl-row, .eq-row { cursor: pointer; outline: none; }
.tl-row:hover .tl-bg, .tl-row:focus .tl-bg, .eq-row:hover .tl-bg, .eq-row:focus .tl-bg, .eq-row.on .tl-bg { fill: var(--brand-soft); }
.tl-label { font-size: 12.5px; fill: var(--ink); font-weight: 600; }
.tl-sub { font-size: 11px; fill: var(--muted); }
.tl-note { font-size: 11px; fill: var(--muted); font-style: italic; }
.tl-note.end { text-anchor: end; font-style: normal; }
.tl-late { font-size: 11px; fill: var(--bad); font-weight: 600; }
.tl-term { fill: var(--grey); opacity: .6; }
.tl-today { stroke: var(--ink); stroke-dasharray: 4 4; opacity: .7; }
.tl-todayl { font-size: 11px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 4px; }
.tl-flag { stroke: var(--bad); stroke-width: 2; }
.tl-flagp { fill: var(--bad); }
.tl-row { --c: var(--plan); }
.tl-row.bad { --c: var(--bad); } .tl-row.warn { --c: var(--warn); } .tl-row.ok { --c: var(--brand); }
.tl-row.alt { --c: var(--alt); } .tl-row.muted { --c: var(--grey); } .tl-row.plan { --c: var(--plan); }
.tl-mark { fill: var(--c); }
.tl-band { fill: var(--c); opacity: .3; }
.tl-due { fill: var(--card); stroke: var(--c); stroke-width: 2; }
.tl-lead { stroke: var(--c); stroke-opacity: .6; stroke-dasharray: 3 3; stroke-width: 1.5; }
.tl-leaddot { fill: var(--card); stroke: var(--c); stroke-width: 1.5; }
.tl-tick { stroke: var(--c); stroke-width: 2; stroke-linecap: round; }
.eq-seg.bad { fill: var(--bad); } .eq-seg.warn { fill: var(--warn); } .eq-seg.ok { fill: var(--brand); } .eq-seg.muted { fill: var(--grey); }
.tl-tip { position: absolute; z-index: 5; max-width: 300px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .8rem; line-height: 1.35; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); pointer-events: none; }
.tl-tip b { display: block; margin-bottom: 3px; }
.tl-tip .k { color: var(--muted); }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); margin: 4px 0 6px; }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--plan); }
.tl-legend .sw.bad { background: var(--bad); } .tl-legend .sw.warn { background: var(--warn); } .tl-legend .sw.ok { background: var(--brand); }
.tl-legend .sw.alt { background: var(--alt); } .tl-legend .sw.muted { background: var(--grey); }
.tl-legend .sw.band { opacity: .4; }
.tl-legend .sw.term { height: 4px; border-radius: 2px; }
.tl-legend .sw.due { background: transparent; border: 2px solid var(--warn); transform: rotate(45deg); width: 9px; height: 9px; border-radius: 1px; }
.tl-legend .sw.flag { width: 3px; border-radius: 0; background: var(--bad); }
.cc-panel h3 { font-size: 1rem; margin: 18px 0 2px; }

/* 1.5.0 asset forms */
.radios { display: grid; gap: 2px; margin: 0 0 10px; }
.subopts { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; margin: 0 0 12px; }
