/* REMS concept — "Redwings Ledger" (see ../REMS design plan.md)
   Primary reference: Orderful "precision on white"; details from Mews; Redwings brand tokens. */

:root {
  --canvas: #F7F7F7;
  --surface: #FFFFFF;
  --ink: #212529;
  --text: #2F2F2F;
  --text-2: #5F666D;
  --text-3: #6C757D;
  --line: #DBDBDB;
  --line-soft: #ECECEC;

  --action: #E10000;        /* primary button fill ONLY */
  --action-hover: #A40000;
  --danger: #B42828;        /* destructive/error text, icon, outline ONLY */
  --due: #F5C969;           /* due soon */
  --select: #E9F0FF;        /* selection + info */
  --select-line: #AAC0EB;
  --done: #EAF2E5;
  --done-ink: #4F6B2E;

  --radius: 6px;
  --radius-input: 4px;
  --shadow-raised: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px -1px rgba(0,0,0,.10);
  --shadow-float: 0 8px 24px rgba(0,0,0,.12);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --sidebar: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 15px/22px var(--font);
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
.num, table, .tabular { font-variant-numeric: tabular-nums; }
.eqno { letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 13px; line-height: 18px; }
.caption { font-size: 12px; line-height: 16px; color: var(--text-2); }
.overline { font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; text-wrap: balance; }
h1 { font-size: 24px; line-height: 32px; font-weight: 700; }
h2 { font-size: 20px; line-height: 28px; font-weight: 700; }
h3 { font-size: 17px; line-height: 24px; font-weight: 600; }
h4 { font-size: 15px; line-height: 22px; font-weight: 600; }
p { margin: 0; }
.ph, .ph-fill { font-size: 18px; line-height: 1; vertical-align: -3px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .logo { padding: 4px 8px 20px; }
.sidebar .logo img { width: 150px; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--canvas); }
.nav a[aria-current="page"] { background: var(--canvas); color: var(--ink); font-weight: 700; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--text-2); }
.sidebar .spacer { flex: 1; }
.sidebar .me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line-soft); margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.concept-tag { margin: 12px 8px 0; font-size: 11px; line-height: 16px; color: var(--text-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 32px;
  background: rgba(247,247,247,.92); backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--line-soft);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { color: var(--line); }
.topbar .search { margin-left: auto; position: relative; width: min(420px, 40vw); }
.topbar .search input { width: 100%; height: 38px; padding: 0 64px 0 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.topbar .search .ph { position: absolute; left: 11px; top: 10px; color: var(--text-2); }
.kbd { position: absolute; right: 8px; top: 8px; font-size: 11px; line-height: 20px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--text-2); background: var(--canvas); }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-float);
  padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-results a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); text-decoration: none; }
.search-results a:hover, .search-results a.active { background: var(--select); }
.search-results .hint { padding: 8px; }

.view { padding: 28px 32px 120px; max-width: 1440px; width: 100%; }
.view.flush { padding: 0 0 120px; max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .lede { margin-top: 4px; color: var(--text-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid transparent; font-weight: 700; font-size: 14px; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-secondary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); border-color: #c5c5c5; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #FBEFEF; }
.btn-text { background: none; border: 0; padding: 0 4px; height: auto; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 38px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }
.btn .ph { font-size: 16px; vertical-align: 0; }

/* Later-phase placeholder */
.phase-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; border: 1px dashed #9AA0A6; color: var(--text-2); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.later { opacity: .55; cursor: not-allowed; }
.later:hover { background: inherit; }

/* ---------- Pills & chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--tint, #EFEFEF); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--dot, #6C757D); }
.st-resident { --dot: #1597B8; --tint: #E3F4F9; }
.st-boarding { --dot: #D99A1E; --tint: #FDF4E1; }
.st-external { --dot: #7A4E9E; --tint: #F1EAF7; }
.st-rehomed  { --dot: #6F8F45; --tint: #EAF2E5; }
.st-archived { --dot: #8A1726; --tint: #F6E7E9; }
.st-deceased { --dot: #6C757D; --tint: #EFEFEF; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--ink); font-size: 12px; font-weight: 700; color: var(--ink); background: var(--surface); white-space: nowrap; }
.chip .ph { font-size: 14px; vertical-align: 0; }
.due { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.due .ph { font-size: 14px; vertical-align: 0; }
.due-over { color: var(--danger); border: 1px solid var(--danger); background: var(--surface); }
.due-soon { background: var(--due); color: var(--ink); }
.due-done { background: var(--done); color: var(--done-ink); }
.due-later { background: var(--canvas); color: var(--text-2); border: 1px solid var(--line); }

/* Filter chips / segmented */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.fchip:hover { border-color: #c5c5c5; }
.fchip.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.fchip .ph { font-size: 14px; vertical-align: 0; }

/* ---------- Photos ---------- */
.photo { width: var(--s, 40px); height: var(--s, 40px); border-radius: var(--radius); object-fit: cover; flex: none; background: #DDE3DA; }
.photo-ph { width: var(--s, 40px); height: var(--s, 40px); border-radius: var(--radius); flex: none; display: grid; place-items: center; position: relative;
  background: #EFEFEC; color: var(--text-2); font-weight: 700; font-size: calc(var(--s, 40px) * .32); border: 1px solid var(--line); }
.photo-ph::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: calc(var(--s, 40px) * .2); height: calc(var(--s, 40px) * .2); border-radius: 999px; background: var(--coat, #8B4F2A); border: 1.5px solid #fff; }
.photo-ph img.photo { position: absolute; inset: 0; }
.photo-ph:has(img) { border-color: transparent; color: transparent; }
.photo-ph:has(img)::after { display: none; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who .name { font-weight: 700; color: var(--ink); }
.who .sub { font-size: 13px; color: var(--text-2); }
.who a { text-decoration: none; }
.who a:hover .name { text-decoration: underline; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 16px; }
.section + .section { margin-top: 28px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; }
.grid-2 > * { min-width: 0; }
.grid-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.divider { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-tools { display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 14px 10px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-selected="true"], .tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.tab .n { font-size: 12px; font-weight: 600; color: var(--text-2); }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; padding: 10px 12px; font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); border-bottom: 1px solid var(--line-soft); background: var(--surface); white-space: nowrap; }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #FAFAFA; }
table.data tr.sel { background: var(--select); }
table.data tr.last-viewed td:first-child { box-shadow: inset 3px 0 0 var(--select-line); } /* meaning: last record you opened */
table.data .chk { width: 44px; padding-right: 0; }
table.data .kebab { width: 44px; text-align: right; }
.table-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--text-2); }
.table-foot .pager { margin-left: auto; display: flex; gap: 6px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }
.sort-note { font-size: 12px; color: var(--text-2); margin-left: auto; padding: 10px 0; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: var(--radius); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--canvas); color: var(--ink); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink); }
.field .opt { font-weight: 400; color: var(--text-2); }
.field .help { font-size: 12px; line-height: 16px; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--surface);
}
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256'%3E%3Cpath fill='%235F666D' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32Z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.textarea { min-height: 88px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: #c5c5c5; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.err { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; line-height: 18px; color: var(--danger); font-weight: 600; }
.err .ph { font-size: 16px; vertical-align: -2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--select); border: 1px solid var(--select-line); font-size: 14px; line-height: 20px; color: var(--ink); }
.callout .ph { font-size: 18px; flex: none; margin-top: 1px; }
.callout.warn { background: #FDF4E1; border-color: var(--due); }
.callout.locked { background: var(--canvas); border-color: var(--line); }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.radio-card:hover { border-color: #c5c5c5; }
.radio-card input { margin-top: 3px; accent-color: var(--ink); }
.radio-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.radio-card .t { font-weight: 700; color: var(--ink); }
.radio-card .d { font-size: 13px; color: var(--text-2); }

/* ---------- Key facts (record right panel) ---------- */
.facts dl { margin: 0; }
.fact { display: grid; grid-template-columns: 24px 120px minmax(0,1fr); gap: 8px; align-items: start; padding: 7px 0; font-size: 14px; line-height: 20px; }
.fact .ph { color: var(--text-2); font-size: 16px; margin-top: 2px; }
.fact dt { color: var(--text-2); }
.fact dd { margin: 0; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Record ---------- */
.rec-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 24px 32px 0; }
.rec-top { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.rec-top .photo, .rec-top .photo-ph { --s: 96px; }
.rec-id { min-width: 0; flex: 1; }
.rec-id .name { font-size: 32px; line-height: 38px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.rec-id .meta { display: flex; flex-wrap: wrap; gap: 6px 0; align-items: center; margin-top: 8px; color: var(--text-2); font-size: 14px; }
.rec-id .meta > span { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.rec-id .meta > span + span::before { content: ""; width: 4px; height: 4px; border-radius: 999px; background: #C4C4C4; margin: 0 12px; }
.rec-id .flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rec-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rec-tabs { margin-top: 20px; }
.rec-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: calc(100vh - 260px); }
.rec-main { padding: 24px 32px; min-width: 0; }
.rec-aside { background: var(--surface); border-left: 1px solid var(--line); padding: 20px 20px 40px; }
.rec-aside h3 { margin-bottom: 8px; }
.rec-aside .block + .block { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line-soft); }

/* Timeline */
.tl-month { margin: 20px 0 8px; }
.tl-month:first-child { margin-top: 0; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); }
.tl-title { font-weight: 700; color: var(--ink); }
.tl-detail { color: var(--text); margin-top: 2px; }
.tl-meta { font-size: 13px; color: var(--text-2); margin-top: 4px; display: flex; gap: 6px 12px; flex-wrap: wrap; }
.tl-meta b { color: var(--ink); font-weight: 600; }
.tl-item.new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--select); } to { background: transparent; } }

/* ---------- Drawer, dialog, toast, bulk bar ---------- */
.scrim { position: fixed; inset: 0; background: rgba(33,37,41,.32); z-index: 40; opacity: 0; transition: opacity .2s ease-out; }
.scrim.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 50;
  background: var(--surface); box-shadow: var(--shadow-float); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease-out; border-radius: var(--radius) 0 0 var(--radius);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.drawer-head .kbd { position: static; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--surface); }
.dialog {
  position: fixed; left: 50%; top: 50%; z-index: 50; width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, -48%); opacity: 0; transition: transform .2s ease-out, opacity .2s ease-out;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-float);
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
}
.dialog.open { transform: translate(-50%, -50%); opacity: 1; }
.dialog .drawer-body { padding: 20px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 16px); opacity: 0;
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-float); transition: transform .15s ease-out, opacity .15s ease-out; max-width: calc(100vw - 32px);
}
.toast.open { transform: translate(-50%, 0); opacity: 1; }
.toast button { background: none; border: 0; color: #fff; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }
.toast .ph { color: #A5BB80; }
.bulkbar {
  position: fixed; left: calc(50% + var(--sidebar) / 2); bottom: 20px; z-index: 35; transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-float);
  transition: transform .15s ease-out, opacity .15s ease-out; max-width: calc(100vw - var(--sidebar) - 32px); flex-wrap: wrap;
}
.bulkbar.open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.bulkbar .count { font-weight: 700; color: var(--ink); padding-right: 6px; border-right: 1px solid var(--line-soft); margin-right: 2px; white-space: nowrap; }
.bulkbar .input, .bulkbar .select { min-height: 32px; height: 32px; padding-top: 4px; padding-bottom: 4px; width: auto; font-size: 13px; }
.menu {
  position: absolute; z-index: 45; min-width: 200px; padding: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-float);
}
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; text-align: left; border-radius: 4px; cursor: pointer; text-decoration: none; font-size: 14px; }
.menu button:hover, .menu a:hover { background: var(--canvas); }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 0; }

/* ---------- Board ---------- */
.board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.col { flex: 0 0 290px; background: #EFEFEF; border-radius: var(--radius); padding: 10px; scroll-snap-align: start; }
.col.drop { outline: 2px dashed var(--ink); outline-offset: -2px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; }
.col-head h3 { font-size: 15px; line-height: 22px; }
.col-head .n { font-size: 13px; color: var(--text-2); }
.col-head .icon-btn { margin-left: auto; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.hcard {
  display: grid; grid-template-columns: 40px minmax(0,1fr) 20px; gap: 10px; align-items: center;
  padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; user-select: none;
}
.hcard:hover { box-shadow: var(--shadow-raised); }
.hcard.sel { background: var(--select); border-color: var(--select-line); }
.hcard.dragging { opacity: .5; }
.hcard .nm { font-weight: 700; color: var(--ink); line-height: 20px; }
.hcard .sub { font-size: 12px; color: var(--text-2); line-height: 16px; }
.hcard .flags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.hcard .flags .chip { height: 20px; font-size: 11px; padding: 0 7px; }
.hcard input[type="checkbox"] { margin: 0; }

/* ---------- Stepper (intake) ---------- */
.wizard { display: grid; grid-template-columns: 240px minmax(0, 720px); gap: 40px; }
.steps { list-style: none; margin: 0; padding: 0; position: sticky; top: 92px; align-self: start; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; color: var(--text-2); font-weight: 600; }
.steps .dot { width: 26px; height: 26px; border-radius: 999px; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 12px; flex: none; background: var(--surface); }
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.steps li.current { color: var(--ink); }
.steps li.current .dot { border-color: var(--ink); box-shadow: 0 0 0 3px var(--select); }
.wizard-bar { position: fixed; left: var(--sidebar); right: 0; bottom: 0; z-index: 30; display: flex; gap: 8px; align-items: center; padding: 12px 32px; background: var(--surface); border-top: 1px solid var(--line); }
.wizard-bar .right { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Home ---------- */
.greet { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.big-search { position: relative; margin-bottom: 28px; }
.big-search input { width: 100%; height: 52px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 16px 0 46px; font-size: 16px; }
.big-search .ph { position: absolute; left: 16px; top: 16px; font-size: 20px; color: var(--text-2); }
.task { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.task .who { flex: 1 1 240px; }
.task:last-child { border-bottom: 0; }
.recent { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.recent a { display: flex; flex-direction: column; gap: 6px; text-decoration: none; width: 88px; flex: none; }
.recent .photo, .recent .photo-ph { --s: 88px; }
.recent span { font-weight: 700; font-size: 13px; color: var(--ink); }
.stat { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 12px; }
.stat:last-child { border-bottom: 0; }
.stat .n { font-size: 20px; font-weight: 700; color: var(--ink); min-width: 36px; }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-box { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 36px 28px; }
.signin-box img.logo { width: 190px; margin-bottom: 28px; }
.ms-btn { width: 100%; height: 46px; margin-top: 24px; gap: 12px; }
.ms-logo { width: 18px; height: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ms-logo i { display: block; }

/* ---------- Fixes panel ---------- */
.fixes-btn { white-space: nowrap; }
.fix { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.fix:last-child { border-bottom: 0; }
.fix .id { font-weight: 700; color: var(--ink); font-size: 13px; padding: 2px 0; text-align: center; border: 1px solid var(--line); border-radius: 4px; height: 24px; line-height: 18px; }
.fix .p { color: var(--text-2); font-size: 13px; line-height: 18px; }
.fix .s { color: var(--ink); font-weight: 600; margin-top: 2px; }

/* ---------- Matrix (roles) ---------- */
table.matrix td, table.matrix th { text-align: center; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; min-width: 230px; }
.yes { color: var(--done-ink); }
.no { color: var(--text-3); }

/* ---------- Roadmap ---------- */
.road-group + .road-group { margin-top: 32px; }
.road-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); align-items: center; }
.road-item:last-child { border-bottom: 0; }
.src { font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* ---------- Files ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 120px; width: 100%; border: 1.5px dashed #B9BEC3; border-radius: var(--radius); background: var(--canvas); color: var(--text-2); cursor: pointer; font-weight: 600; }
.dropzone:hover { border-color: var(--ink); color: var(--ink); }
.dropzone .ph { font-size: 22px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; align-items: start; }
.photo-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo-grid .dropzone { min-height: 160px; }
.menu .later { pointer-events: none; }

/* ---------- Bottom tabs (phone) ---------- */
.bottom-tabs { display: none; }

/* ---------- Responsive: small laptop / tablet ---------- */
@media (max-width: 1100px) and (min-width: 761px) {
  :root { --sidebar: 72px; }
  .sidebar { padding: 16px 8px; align-items: center; }
  .sidebar .logo { padding: 4px 0 20px; }
  .sidebar .logo img { width: 54px; }
  .nav { width: 100%; }
  .nav a { justify-content: center; padding: 10px; font-size: 0; gap: 0; }
  .nav a .ph, .nav a .ph-fill { font-size: 20px; }
  .nav .count, .sidebar .phase-tag, .sidebar .me > div, .sidebar .me > a, .concept-tag { display: none; }
  .sidebar .me { justify-content: center; padding: 12px 0 4px; }
  .topbar { padding: 0 20px; }
  .view { padding: 24px 20px 120px; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .rec-head { padding: 20px 20px 0; }
  .rec-main { padding: 20px; }
  .rec-body { grid-template-columns: 1fr; }
  .rec-aside { border-left: 0; border-top: 1px solid var(--line); }
  .wizard { grid-template-columns: 1fr; gap: 16px; }
  .steps { position: static; display: flex; gap: 16px; flex-wrap: wrap; }
  .wizard-bar { padding: 12px 20px; }
  .hide-md { display: none; }
}

/* ---------- Responsive: phone ---------- */
@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 16px; height: 56px; gap: 10px; }
  .topbar .mobile-logo { display: block !important; width: 96px; }
  .crumbs { display: none; }
  .topbar .search { width: auto; flex: 1; margin-left: 0; }
  .topbar .search input { padding-right: 12px; }
  .kbd { display: none; }
  .fixes-btn span { display: none; }
  .view { padding: 20px 16px 120px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .btn { height: 44px; }
  .btn-sm { height: 36px; }
  .bottom-tabs {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--text-2); }
  .bottom-tabs a .ph, .bottom-tabs a .ph-fill { font-size: 22px; }
  .bottom-tabs a[aria-current="page"] { color: var(--ink); }

  /* tables become rows */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
  table.data td { padding: 0; border: 0; }
  table.data td.chk, table.data td.kebab, table.data td.hide-sm { display: none; }
  table.data td.c-name { grid-column: 1; }
  table.data td.c-status { grid-column: 2; grid-row: 1; align-self: center; }
  table.data td.c-loc { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); padding-left: 52px; margin-top: -4px; }
  .table-foot .pager { display: none; }

  .rec-head { padding: 16px 16px 0; }
  .rec-top .photo, .rec-top .photo-ph { --s: 72px; }
  .rec-id .name { font-size: 26px; line-height: 32px; }
  .rec-actions { width: 100%; }
  .rec-actions .btn-primary { flex: 1; }
  .rec-body { grid-template-columns: 1fr; }
  .rec-main { padding: 16px; }
  .rec-aside { border-left: 0; border-top: 1px solid var(--line); order: -1; padding: 16px; }
  .fact { grid-template-columns: 24px 110px minmax(0,1fr); }

  .drawer { width: 100vw; border-radius: 0; }
  .bulkbar { left: 50%; bottom: 76px; max-width: calc(100vw - 16px); }
  .wizard { grid-template-columns: 1fr; gap: 16px; }
  .steps { position: static; display: flex; gap: 12px; overflow-x: auto; }
  .steps li { flex: none; }
  .wizard-bar { left: 0; bottom: 64px; padding: 10px 16px; }
  .col { flex-basis: 84vw; }
  .toast { bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.rec-id .desc { margin-top: 6px; color: var(--text-2); font-size: 14px; }

/* ---------- Plain sections (no box) ---------- */
.sec { margin-top: 32px; }
.sec:first-child { margin-top: 0; }
.sec-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sec-head .right { margin-left: auto; }
.sec .stat { padding-left: 0; padding-right: 0; }
.rec-body { background: var(--surface); }
.list-plain { border-top: 1px solid var(--line); }
.list-plain .road-item { padding-left: 0; padding-right: 0; }
