/* Design tokens (spec §2.3: one stylesheet, no page-specific CSS)
   Design language v2 (canvas "P&P Design Language"): Bricolage Grotesque display
   + Figtree UI, one action blue on every screen, entity branding only in the
   dark sidebar, saturated colour reserved for problems. Light + dark mode. */
:root {
  --c-bg: #f7f8fa;
  --c-surface: #ffffff;
  --c-surface-2: #f2f4f8;
  --c-border: #e6e8ee;
  --c-border-strong: #d5d9e2;
  --c-text: #1e1f24;
  --c-muted: #5c6370;
  --c-primary: #3d6ce7;
  --c-primary-dark: #2f56c0;
  --c-green: #0b7a46;
  --c-red: #c22945;
  --c-amber: #fdab3d;
  --c-amber-ink: #513005;
  --c-blue: #2f63c7;
  --c-purple: #8a46c8;
  --c-gray: #5c6370;
  --c-side: #1e2a3d;
  --c-side-text: #bac7d9;
  --c-accent: #ffd166;
  --t-green-bg: #e2f6ea;  --t-green-fg: #17784a;
  --t-blue-bg: #e7efff;   --t-blue-fg: #2b57c4;
  --t-red-bg: #fbe4e8;    --t-red-fg: #b32944;
  --t-amber-bg: #fdf0dd;  --t-amber-fg: #a05e03;
  --t-purple-bg: #f0e9fb; --t-purple-fg: #6544ad;
  --t-pink-bg: #f9e7f1;   --t-pink-fg: #a23a72;
  --t-gray-bg: #eef0f4;   --t-gray-fg: #5c6370;
  --chip-bg: #f2f4f8;
  --row-hover: #f8faff;
  --focus-ring: #a9c3f0;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --radius: 12px;      /* cards, panels, tables */
  --radius-btn: 8px;   /* buttons, inputs, kanban headers */
  --radius-sm: 6px;    /* mini chips */
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-hover: 0 2px 6px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 34px rgba(16, 24, 40, .26);
  --font-ui: "Figtree", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bricolage Grotesque", "Figtree", "Segoe UI", Arial, sans-serif;
}
html[data-mode="dark"] {
  --c-bg: #14161b;
  --c-surface: #1d2027;
  --c-surface-2: #252a33;
  --c-border: #2e3340;
  --c-border-strong: #3c4352;
  --c-text: #e7e9ee;
  --c-muted: #9aa3b2;
  --t-green-bg: rgba(23, 120, 74, .22);  --t-green-fg: #5fd39a;
  --t-blue-bg: rgba(47, 99, 199, .25);   --t-blue-fg: #9db9f5;
  --t-red-bg: rgba(194, 41, 69, .22);    --t-red-fg: #f090a6;
  --t-amber-bg: rgba(253, 171, 61, .16); --t-amber-fg: #f5b95e;
  --t-purple-bg: rgba(138, 70, 200, .22); --t-purple-fg: #c9a6ef;
  --t-pink-bg: rgba(176, 67, 124, .22);   --t-pink-fg: #ef9ec7;
  --t-gray-bg: rgba(154, 163, 178, .14); --t-gray-fg: #aeb6c4;
  --chip-bg: #2a3040;
  --row-hover: #222836;
  --focus-ring: #3d5aa6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--c-bg); color: var(--c-text);
  font: 14px/1.5 var(--font-ui); }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin: 0 0 var(--s-4);
  letter-spacing: -.015em; }
h1 .count { color: var(--c-muted); font-weight: 500; font-size: 18px; font-family: var(--font-ui); }
h2 { font-size: 12px; margin: var(--s-5) 0 var(--s-3); color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.subtitle { margin: 4px 0 0; font-size: 13px; max-width: 72ch; }

/* ---- App shell: fixed sidebar + topbar + fluid canvas ---- */
.shell { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--c-side); color: var(--c-side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  padding: var(--s-4) var(--s-3); overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800;
  font-family: var(--font-display); font-size: 15px; letter-spacing: -.01em; padding: 4px 10px 14px; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-logo { padding: 8px 10px 16px; }
.sidebar .brand-logo img { width: 100%; max-width: 176px; height: auto; display: block; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px;
  height: 28px; border-radius: 7px; background: var(--c-accent); color: var(--c-side);
  font-weight: 800; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-label { margin: 14px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: #8296b0; }
.sidebar nav a, .sidebar-foot a { color: var(--c-side-text); padding: 7px 10px;
  border-radius: var(--radius-btn); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sidebar nav a:hover, .sidebar-foot a:hover { color: #fff; background: rgba(255,255,255,.08);
  text-decoration: none; }
.sidebar nav a.active, .sidebar-foot a.active { color: #fff; background: rgba(255,255,255,.14);
  box-shadow: inset 2px 0 0 var(--c-accent); }
.sidebar .pill { margin-left: auto; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: var(--s-3);
  margin-top: var(--s-3); display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 10px 2px; }
.me-name { flex: 1; color: #e8eef6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar button.linklike { background: none; border: 0; color: var(--c-side-text); cursor: pointer;
  font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: var(--radius-sm); }
.sidebar button.linklike:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Topbar: global search + appearance toggle, on every authenticated screen */
.topbar { height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: var(--s-3);
  padding: 0 40px 0 var(--s-5); background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 50; }
.topbar form { flex: 0 1 460px; display: flex; align-items: center; gap: 8px; position: relative; }
.topbar input[type="search"] { width: 100%; padding: 6px 58px 6px 12px; border-radius: 999px;
  background: var(--c-surface-2); border-color: transparent; font-size: 13px; }
.topbar input[type="search"]:focus { background: var(--c-surface); }
.topbar .kbd { position: absolute; right: 12px; pointer-events: none; }
.kbd { font-size: 11px; font-weight: 600; color: var(--c-muted); background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 6px; line-height: 17px; }
.topbar .right { display: flex; align-items: center; gap: var(--s-2); }
.scope-form select { padding: 5px 10px; font-size: 13px; font-weight: 600; border-radius: 999px;
  background: var(--c-surface-2); border-color: transparent; color: var(--c-text); }
.icon-btn { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center;
  justify-content: center; border: 0; background: transparent; border-radius: var(--radius-sm);
  color: var(--c-muted); font-size: 15px; cursor: pointer; }
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
html[data-mode="dark"] .mode-sun { display: inline; }
html[data-mode="dark"] .mode-moon { display: none; }
.mode-sun { display: none; }

main { flex: 1; min-width: 0; padding: var(--s-5) 40px var(--s-6); max-width: 1280px; width: 100%; }
main.anon { margin: 0 auto; padding: var(--s-5); max-width: 560px; }

.pill { display: inline-block; min-width: 18px; text-align: center; padding: 0 5px; border-radius: 999px;
  background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; }

/* ID / code chips — Figtree 600, never monospace (design language v2) */
.idchip { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--chip-bg); color: var(--c-text); font-size: 12px; font-weight: 600;
  letter-spacing: .01em; white-space: nowrap; }

/* Avatars */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  flex: 0 0 26px; vertical-align: middle; }
td .avatar { margin-right: 8px; }
.page-head .avatar { width: 40px; height: 40px; font-size: 15px; flex-basis: 40px; }

/* Messages */
.messages { list-style: none; margin: 0 0 var(--s-4); padding: 0; }
.messages li { padding: var(--s-2) var(--s-3); border-radius: var(--radius-btn); margin-bottom: var(--s-2);
  background: var(--t-blue-bg); border: 1px solid var(--c-border); overflow-wrap: anywhere; }
.messages li.success { background: var(--t-green-bg); }
.messages li.warning { background: var(--t-amber-bg); }
.messages li.error { background: var(--t-red-bg); }

/* Banner */
a.banner { display: block; margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4);
  background: var(--t-amber-bg); border: 1px solid var(--c-border); border-radius: var(--radius);
  color: var(--c-text); }
a.banner:hover { text-decoration: none; border-color: var(--c-amber); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s-4); display: flex; flex-direction: column; }
.card h3 { margin: 0 0 var(--s-3); font-size: 14px; font-weight: 700; }
.card table { width: 100%; }
.card td { padding: 3px 0; }
.card td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .card-link { display: inline-block; margin-top: auto; padding-top: var(--s-3); font-size: 13px; }
a.card-link-block { color: var(--c-text); }
a.card-link-block:hover { text-decoration: none; border-color: var(--c-primary); box-shadow: var(--shadow-hover); }
a.card-link-block p { margin: 0; }

/* Panels */
.panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-4); }
.panel > h2:first-child { margin-top: 0; }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.override { background: var(--c-surface-2); }
details.override > summary { color: var(--c-muted); font-weight: 500; }

/* Tables — list rows */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data th, table.data td { padding: 10px var(--s-3); text-align: left;
  border-bottom: 1px solid var(--c-border); }
table.data th { color: var(--c-muted); font-weight: 700; white-space: nowrap; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; background: var(--c-surface); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td, table.data tr:hover td { background: var(--row-hover); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td a { font-weight: 600; }
table.data tr.group-row td { background: var(--c-surface-2); color: var(--c-muted); font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding-top: 7px; padding-bottom: 7px; }
table.data tr.group-row:hover td { background: var(--c-surface-2); }
.list-meta { margin-bottom: var(--s-2); font-size: 13px; }

/* Matrix — saturated colour only where there is a problem (deficits) */
table.matrix td, table.matrix th { text-align: center; }
table.matrix .role-col { text-align: left; position: sticky; left: 0; background: var(--c-surface); z-index: 1; }
table.matrix tr:hover .role-col { background: var(--row-hover); }
td.cell-short { background: var(--t-red-bg); }
td.cell-short .cap-main { color: var(--t-red-fg); }
.cap-ok { color: var(--t-green-fg); }
.gap-pos { color: var(--c-red); }
.gap-zero { color: var(--c-green); }
.gap-neg { color: var(--t-amber-fg); }
.cap-main { display: block; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cap-detail { display: block; color: var(--c-muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-hire { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; background: var(--c-red); color: #fff; }
.chip-hire.amber { background: var(--c-amber); color: var(--c-amber-ink); }
.legend { margin-top: var(--s-3); font-size: 13px; }
.month-nav a.btn { padding: 6px 10px; }

/* Badges — WCAG AA soft pairs */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: var(--t-gray-bg); color: var(--t-gray-fg); white-space: nowrap; font-weight: 600; }
.badge-green { background: var(--t-green-bg); color: var(--t-green-fg); }
.badge-blue { background: var(--t-blue-bg); color: var(--t-blue-fg); }
.badge-red { background: var(--t-red-bg); color: var(--t-red-fg); }
.badge-amber { background: var(--t-amber-bg); color: var(--t-amber-fg); }
.badge-purple { background: var(--t-purple-bg); color: var(--t-purple-fg); }
.badge-pink { background: var(--t-pink-bg); color: var(--t-pink-fg); }

/* Project colour dot */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px;
  vertical-align: baseline; }

/* Tabs — one pattern everywhere: 2px underline in the action colour */
.tabs { display: flex; gap: var(--s-4); border-bottom: 1px solid var(--c-border); margin-bottom: var(--s-4); }
.tabs a { padding: 8px 2px; color: var(--c-muted); font-weight: 600; border-bottom: 2px solid transparent;
  margin-bottom: -1px; }
.tabs a:hover { color: var(--c-text); text-decoration: none; }
.tabs a.active { color: var(--c-text); border-color: var(--c-primary); }

/* Kanban — candidate pipeline board */
.kanban { display: flex; gap: var(--s-3); align-items: flex-start; overflow-x: auto;
  padding-bottom: var(--s-3); }
.kb-col { flex: 1 0 220px; max-width: 300px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px;
  border-radius: var(--radius-btn); color: #fff; font-weight: 700; font-size: 13px; }
.kb-head .kb-count { font-weight: 600; opacity: .85; font-size: 12px; }
.kb-gray { background: var(--c-gray); }
.kb-green { background: var(--c-green); }
.kb-blue { background: var(--c-blue); }
.kb-red { background: var(--c-red); }
.kb-purple { background: var(--c-purple); }
.kb-pink { background: #b0437c; }
.kb-amber { background: var(--c-amber); color: var(--c-amber-ink); }
.kb-amber .kb-count { opacity: 1; color: var(--c-amber-ink); }
.kb-cards { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-2) 0;
  min-height: 60px; border-radius: var(--radius-btn); }
.kb-col.dragover .kb-cards { outline: 2px dashed var(--c-primary); outline-offset: 2px;
  background: var(--row-hover); }
.kb-card { display: block; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-btn); padding: 10px 12px; color: var(--c-text); box-shadow: var(--shadow); }
.kb-card:hover { text-decoration: none; box-shadow: var(--shadow-hover); border-color: var(--c-border-strong); }
.kb-card strong { display: block; font-weight: 600; margin-bottom: 2px; }
.kb-card .meta { color: var(--c-muted); font-size: 12px; }
.kb-card[draggable="true"] { cursor: grab; }
.kb-empty { border: 1px dashed var(--c-border-strong); border-radius: var(--radius-btn);
  color: var(--c-muted); font-size: 12px; text-align: center; padding: var(--s-4) var(--s-2); }

/* Filters & forms */
form.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); align-items: end; }
form.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
  color: var(--c-muted); font-weight: 600; }
input, select, textarea { font-family: var(--font-ui); font-size: inherit; padding: 7px 10px;
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-btn);
  background: var(--c-surface); color: var(--c-text); }
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--c-primary); }
button, .btn { font-family: var(--font-ui); font-size: inherit; font-weight: 600; padding: 7px 14px;
  border-radius: var(--radius-btn); cursor: pointer; border: 1px solid var(--c-border-strong);
  background: var(--c-surface); color: var(--c-text); display: inline-block;
  transition: background .12s ease, border-color .12s ease; }
button:hover, .btn:hover { background: var(--c-surface-2); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--c-primary-dark); }
button.danger { background: var(--c-surface); border-color: var(--c-red); color: var(--c-red); }
button.danger:hover { background: var(--t-red-bg); }
.btn-row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
summary.btn { list-style: none; width: max-content; }
summary.btn::-webkit-details-marker { display: none; }

form.stacked p, form.stacked .field { margin: 0 0 var(--s-3); display: flex; flex-direction: column;
  gap: 4px; max-width: 480px; }
form.stacked label { font-weight: 600; }
.manage-link { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--c-primary);
  border: 1px solid var(--c-border); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.manage-link:hover { background: var(--t-blue-bg); text-decoration: none; }

/* Multi-select dropdown: a checkbox group presented as a select-like control */
details.multiselect { position: relative; }
details.multiselect > summary { list-style: none; cursor: pointer; padding: 7px 32px 7px 10px;
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-btn);
  background: var(--c-surface); color: var(--c-muted); font-weight: 400; position: relative;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.multiselect > summary::-webkit-details-marker { display: none; }
details.multiselect > summary::after { content: ""; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px; border-right: 1.5px solid var(--c-muted);
  border-bottom: 1.5px solid var(--c-muted); transform: translateY(-70%) rotate(45deg); }
details.multiselect > summary.has-value { color: var(--c-text); }
details.multiselect[open] > summary { border-color: var(--c-primary); }
details.multiselect .ms-menu { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 100%; max-height: 260px; overflow-y: auto; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius-btn); box-shadow: var(--shadow-lg);
  padding: var(--s-2) var(--s-3); }
details.multiselect .ms-menu ul { display: block; }
details.multiselect .ms-menu label { white-space: nowrap; border-radius: var(--radius-sm);
  padding: 5px 6px; }
details.multiselect .ms-menu label:hover { background: var(--row-hover); }
.req { color: var(--c-red); margin-left: 2px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-red); }
.helptext { color: var(--c-muted); font-size: 12px; font-weight: 400; }
.errorlist { color: var(--c-red); margin: 0; padding-left: var(--s-4); font-size: 13px; }
.form-panel { max-width: 640px; }
/* checkbox groups (skills, roles, entities) render as chip-like columns */
.field ul { list-style: none; margin: 2px 0 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 12px; }
.field ul label { font-weight: 450; display: flex; gap: 7px; align-items: center; padding: 3px 0; }
.field input[type="checkbox"] { accent-color: var(--c-primary); width: 15px; height: 15px; }

/* Definition grid */
dl.props { display: grid; grid-template-columns: 180px 1fr; gap: 6px var(--s-4); margin: 0; }
dl.props dt { color: var(--c-muted); }
dl.props dd { margin: 0; }

/* Timeline */
ul.timeline { list-style: none; margin: 0; padding: 0; }
ul.timeline li { padding: var(--s-2) 0 var(--s-2) var(--s-4); border-left: 2px solid var(--c-border); position: relative; }
ul.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--c-primary); }
ul.timeline .meta { color: var(--c-muted); font-size: 12px; }

/* Approvals queue — Review (open the item) is the primary action */
.approval-row { display: flex; gap: var(--s-3) var(--s-4); align-items: center;
  flex-wrap: wrap; padding: var(--s-3) var(--s-4); margin-bottom: var(--s-2); }
.approval-what { flex: 1 1 320px; min-width: 0; }
.approval-item { font-weight: 600; }
.approval-what .meta { font-size: 12px; margin-top: 2px; }
.approval-actions { flex: 0 1 auto; }
.approval-actions input[name="note"] { width: 200px; }

/* Flow strip */
.flow-panel h2 { margin-top: 0; }
ol.flow { list-style: none; counter-reset: flow; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--s-2); }
ol.flow li { counter-increment: flow; position: relative; flex: 1 1 170px; display: flex; }
ol.flow li a { flex: 1; display: block; padding: var(--s-3) var(--s-3) var(--s-3) 38px;
  border: 1px solid var(--c-border); border-radius: var(--radius); color: var(--c-text);
  background: var(--c-surface-2); position: relative; }
ol.flow li a::before { content: counter(flow); position: absolute; left: 10px; top: 12px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--c-side); color: var(--c-accent);
  font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
ol.flow li a:hover { text-decoration: none; border-color: var(--c-primary); background: var(--row-hover); }
ol.flow li a strong { display: block; margin-bottom: 2px; }
ol.flow li a span { color: var(--c-muted); font-size: 12px; line-height: 1.4; display: block; }

/* Inline hints */
.hint { margin: var(--s-2) 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--radius-btn);
  background: var(--c-surface-2); border: 1px solid var(--c-border); color: var(--c-muted);
  font-size: 13px; max-width: 480px; }
.hint-avail { background: var(--t-green-bg); border-color: var(--c-border); color: var(--c-text); }

/* Misc */
.muted { color: var(--c-muted); }
.crumbs { margin: 0 0 var(--s-2); font-size: 13px; }
.empty { padding: var(--s-6); text-align: center; color: var(--c-muted); background: var(--c-surface);
  border: 1px dashed var(--c-border-strong); border-radius: var(--radius); }
.empty p { margin: 0 0 var(--s-2); }
.empty p:last-child { margin-bottom: 0; }
.empty strong { color: var(--c-text); }
.pagination { margin-top: var(--s-3); display: flex; gap: var(--s-2); align-items: center; }
.right { margin-left: auto; }
.page-head { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-4); }
.page-head h1 { margin: 0; }
.page-head .badge { margin-top: 7px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-4); align-items: start; }

/* Search results */
.search-hit { display: flex; align-items: center; gap: var(--s-2); padding: 8px 0;
  border-bottom: 1px solid var(--c-border); }
.search-hit:last-child { border-bottom: 0; }
.search-hit .meta { color: var(--c-muted); font-size: 12px; margin-left: auto; }

/* Responsive: sidebar becomes a top bar */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row;
    flex-wrap: wrap; align-items: center; gap: 2px; padding: var(--s-2) var(--s-3); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .sidebar-foot { border-top: 0; margin: 0; padding: 0; flex-direction: row; align-items: center; }
  .me { padding: 0 0 0 8px; }
  .me-name { display: none; }
  .topbar { position: static; padding: 0 var(--s-4); }
  main { padding: var(--s-4); }
  .two-col { grid-template-columns: 1fr; }
  .approval-row { align-items: stretch; flex-direction: column; }
  dl.props { grid-template-columns: 130px 1fr; }
}

/* Login */
.login-box { max-width: 360px; margin: 14vh auto 0; }
.login-logo { width: 176px; height: auto; display: block; margin-bottom: 14px; }
.anon-mode { position: fixed; top: 14px; right: 16px; }
html[data-mode="dark"] .logo-on-light, .logo-on-dark { display: none; }
html[data-mode="dark"] .logo-on-dark { display: block; }
.login-box h1 { font-size: 20px; }

/* Guided tour */
.tour-backdrop { position: fixed; inset: 0; background: rgba(12, 20, 33, .55); z-index: 900; }
.tour-highlight { position: relative; z-index: 901; outline: 3px solid var(--c-accent); border-radius: var(--radius-sm);
  background: rgba(255, 209, 102, .15); }
.tour-tip { position: absolute; z-index: 902; width: 320px; background: var(--c-surface);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--s-4); color: var(--c-text); }
.tour-tip h3 { margin: 0 0 var(--s-2); font-size: 15px; }
.tour-tip p { margin: 0 0 var(--s-3); }
.tour-count { color: var(--c-muted); font-size: 12px; margin-bottom: var(--s-1); }
.tour-buttons { display: flex; gap: var(--s-2); align-items: center; }
.tour-buttons .tour-skip { margin-left: auto; color: var(--c-muted); font-size: 13px; }

/* ---- Home v3: persona-scoped, queue-first ---- */
.home-bar { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--c-surface-2); border-radius: 999px; padding: 3px; }
.seg a { padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--c-muted); }
.seg a:hover { color: var(--c-text); text-decoration: none; }
.seg a.active { color: var(--c-text); background: var(--c-surface); box-shadow: 0 1px 2px rgba(16,24,40,.10); font-weight: 700; }
.seg-count { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px;
  padding: 0 5px; margin-left: 5px; border-radius: 999px; background: var(--t-red-bg); color: var(--t-red-fg);
  font-size: 10.5px; font-weight: 800; vertical-align: 1px; }
.home-grid { display: flex; gap: var(--s-4); align-items: flex-start; }
.home-main { flex: 1 1 64%; min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.home-rail { flex: 1 1 36%; min-width: 260px; display: flex; flex-direction: column; gap: var(--s-4); }
.hcard { position: relative; }
.hcard-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 10px; }
.hcard-head h2 { margin: 0; }
.hcard-tools { margin-left: auto; visibility: hidden; }
.customizing .hcard-tools { visibility: visible; }
.customizing .hcard { outline: 2px dashed var(--c-border-strong); outline-offset: 2px; cursor: grab; }
.customizing .hcard.dragging { opacity: .5; }
.hcard.user-hidden { display: none; }
.customizing .hcard.user-hidden { display: block; opacity: .45; }
.linklike-btn { border: 0; background: none; color: var(--c-primary); font: inherit; font-size: 12.5px;
  font-weight: 600; cursor: pointer; padding: 0 4px; }

.qrow { display: flex; align-items: center; gap: var(--s-3); padding: 11px 18px; border-top: 1px solid var(--c-border); }
.qicon { width: 34px; height: 34px; border-radius: var(--radius-btn); display: inline-flex; align-items: center;
  justify-content: center; flex-shrink: 0; }
.qicon-approve { background: var(--t-blue-bg); color: var(--t-blue-fg); }
.qicon-gap { background: var(--t-red-bg); color: var(--t-red-fg); }
.qicon-hold, .qicon-overdue { background: var(--t-amber-bg); color: var(--t-amber-fg); }
.qicon-join { background: var(--t-pink-bg); color: var(--t-pink-fg); }
.qwhat { flex: 1; min-width: 0; }
.qwhat strong { display: block; font-weight: 600; font-size: 14px; }
.qmeta { display: block; color: var(--c-muted); font-size: 12px; margin-top: 1px; }
.qmore { display: block; padding: 10px 18px; border-top: 1px solid var(--c-border); font-size: 13px; font-weight: 600; }

.loop { display: flex; align-items: stretch; gap: 2px; }
.loop a { flex: 1; text-align: center; padding: 10px 4px; border-radius: 10px; color: var(--c-text); }
.loop a:hover { text-decoration: none; background: var(--row-hover); }
.loop-n { display: block; font-family: var(--font-display); font-size: 21px; font-weight: 800; }
.loop-l { display: block; font-size: 11px; color: var(--c-muted); font-weight: 600; }
.loop-arrow { align-self: center; color: var(--c-border-strong); font-weight: 700; }
.loop-gap { background: var(--t-red-bg); }
.loop-gap .loop-n, .loop-gap .loop-l { color: var(--t-red-fg); }
.loop-gap.ok { background: none; }
.loop-gap.ok .loop-n, .loop-gap.ok .loop-l { color: var(--t-green-fg); }
.loop-join .loop-n, .loop-join .loop-l { color: var(--t-green-fg); }

.pipe-row { display: flex; gap: var(--s-2); }
.pipe-cell { flex: 1; min-width: 0; }
.pipe-cell .kb-head { border-radius: var(--radius-btn); }
.pipe-cell:hover { text-decoration: none; filter: brightness(1.05); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.stat { display: block; padding: 8px 0; color: var(--c-text); border-radius: var(--radius-sm); }
.stat:hover { text-decoration: none; background: var(--row-hover); }
.stat-n { display: block; font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.stat-l { display: block; font-size: 12px; color: var(--c-muted); font-weight: 600; }
.stat-c { display: block; font-size: 11.5px; color: var(--c-muted); }
.tone-green { color: var(--t-green-fg); }
.tone-amber { color: var(--t-amber-fg); }
.tone-red { color: var(--t-red-fg); }

.fun-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.fun-l { width: 92px; font-size: 12px; color: var(--c-muted); font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.fun-bar { flex: 1; height: 16px; border-radius: 5px; background: var(--c-surface-2); overflow: hidden; }
.fun-fill { display: block; height: 100%; border-radius: 5px; min-width: 2px; }
.fun-n { width: 24px; text-align: right; font-size: 12.5px; font-weight: 700; }

.act-row { display: flex; gap: 10px; padding: 7px 0; align-items: flex-start; color: var(--c-text); }
.act-row:hover { text-decoration: none; background: var(--row-hover); border-radius: var(--radius-sm); }
.act-row .avatar { width: 24px; height: 24px; font-size: 10px; flex: 0 0 24px; }
.act-text { font-size: 12.5px; line-height: 1.45; min-width: 0; }

/* People: profile drawer beside the list */
.split { display: flex; gap: var(--s-4); align-items: flex-start; }
.split > .split-list { flex: 1; min-width: 0; }
.drawer { width: 360px; flex: 0 0 360px; position: sticky; top: 70px; }
.drawer:empty { display: none; }
.drawer-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow-hover); padding: var(--s-4) var(--s-5); }
.drawer-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.drawer-head .avatar { width: 44px; height: 44px; font-size: 16px; flex-basis: 44px; }
.drawer-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.drawer-sub { font-size: 12.5px; color: var(--c-muted); }
.drawer-close { margin-left: auto; }
table.data tr[hx-get] { cursor: pointer; }

/* Approval chain stepper */
ol.stepper { list-style: none; margin: var(--s-3) 0; padding: 0; display: flex; gap: 0; }
ol.stepper li { flex: 1; position: relative; text-align: center; padding-top: 26px; font-size: 12px; }
ol.stepper li::before { content: ""; position: absolute; top: 8px; left: 50%; width: 100%; height: 2px;
  background: var(--c-border); }
ol.stepper li:last-child::before { display: none; }
ol.stepper li::after { content: ""; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%; background: var(--c-surface);
  border: 2px solid var(--c-border-strong); box-sizing: border-box; }
ol.stepper li.done::after { background: var(--c-green); border-color: var(--c-green); }
ol.stepper li.done::before { background: var(--c-green); }
ol.stepper li.rejected::after { background: var(--c-red); border-color: var(--c-red); }
ol.stepper li.current::after { background: var(--c-surface); border-color: var(--c-primary); }
ol.stepper li.current { font-weight: 700; }
ol.stepper li.skipped { color: var(--c-muted); }
ol.stepper .step-sub { display: block; color: var(--c-muted); font-weight: 400; font-size: 11px; }

/* Capacity: cell side panel */
.cap-layout { display: flex; gap: var(--s-4); align-items: flex-start; }
.cap-layout > .cap-table { flex: 1; min-width: 0; }
#cell-panel { width: 320px; flex: 0 0 320px; position: sticky; top: 70px; }
#cell-panel:empty { display: none; }
td.cell-short { cursor: pointer; }
td.cell-short:hover { outline: 2px solid var(--c-red); outline-offset: -2px; }
.free-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.free-row .free-pct { margin-left: auto; font-weight: 700; color: var(--t-green-fg); }

/* Same-page management dialog (Create / edit pills) */
dialog#modal { border: 0; border-radius: var(--radius); padding: 0; width: min(600px, 92vw);
  background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-lg); }
dialog#modal::backdrop { background: rgba(12, 20, 33, .45); }
#modal-body { padding: 20px 24px 22px; max-height: 72vh; overflow-y: auto; }
#modal-body h2:first-child { margin-top: 0; }
#modal-x { position: absolute; top: 10px; right: 12px; z-index: 1; }
.modal-saved { background: var(--t-green-bg); color: var(--t-green-fg); border-radius: var(--radius-btn);
  padding: 8px 12px; font-size: 13px; font-weight: 600; margin-bottom: var(--s-3); }
.modal-hint { color: var(--c-muted); font-size: 12px; margin-top: var(--s-3); }

/* Temporary defect capture for team testing (general.feedback_enabled) */
#fb-btn { position: fixed; right: 18px; bottom: 18px; z-index: 60; border: 1px solid var(--c-border);
  border-radius: 999px; padding: 8px 14px; background: var(--c-surface); color: var(--c-text);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-lg); }
#fb-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
dialog#fb-dialog { border: 0; border-radius: var(--radius); padding: 20px 24px 22px; width: min(480px, 92vw);
  background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-lg); }
dialog#fb-dialog::backdrop { background: rgba(12, 20, 33, .45); }
#fb-dialog h3 { margin: 0 0 4px; }
#fb-dialog textarea { width: 100%; box-sizing: border-box; margin-top: 10px; }
.fb-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 12px; }
.fb-reply { display: flex; align-items: center; gap: 8px; }
.fb-reply input { width: 100%; min-width: 160px; font-size: 12.5px; }

/* Sectioned forms + sticky save bar */
.form-section { margin: var(--s-5) 0 var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--c-border); }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
form.stacked .save-bar { position: sticky; bottom: 0; background: var(--c-surface); padding: var(--s-3) 0;
  margin-top: var(--s-4); border-top: 1px solid var(--c-border); }

/* One authored moment: content rises into place (240ms expo-out, staggered) */
@media (prefers-reduced-motion: no-preference) {
  main > * { animation: rise .24s cubic-bezier(.16, 1, .3, 1) both; }
  main > *:nth-child(2) { animation-delay: 40ms; }
  main > *:nth-child(3) { animation-delay: 80ms; }
  main > *:nth-child(4) { animation-delay: 120ms; }
  main > *:nth-child(n+5) { animation-delay: 160ms; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .home-grid { flex-direction: column; }
  .home-rail { min-width: 0; width: 100%; }
  .split, .cap-layout { flex-direction: column; }
  .drawer, #cell-panel { width: 100%; flex: none; position: static; }
}

/* ---- Entity branding lives only in the sidebar (one action colour everywhere) ---- */
.brand-tag { font-size: 10.5px; color: #8296b0; padding: 0 10px 12px; margin-top: -10px; }
body[data-theme="neekan"] { --c-side: #16294d; --c-accent: #ffffff; }
body[data-theme="neekan"] .brand-mark { background: #fff; color: #16294d; }
body[data-theme="neekan"] .brand { text-transform: lowercase; letter-spacing: .01em; }
body[data-theme="neekan"] ol.flow li a::before { color: #fff; }
body[data-theme="udu"] { --c-side: #121820; --c-accent: #1aa7f0; }
body[data-theme="udu"] .brand-mark { background: #1aa7f0; color: #fff; }
body[data-theme="udu"] ol.flow li a::before { color: #fff; }

/* ---- project tasks: gantt + task detail ---- */
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gantt { position: relative; display: grid; gap: 6px; }
.gantt-row { display: grid; grid-template-columns: 240px 1fr; align-items: center; gap: 10px; }
.gantt-label { display: flex; gap: 6px; align-items: center; font-size: 13px;
  white-space: nowrap; overflow: hidden; }
.gantt-track { position: relative; height: 16px; border-radius: 999px; background: var(--c-surface-2); }
.gantt-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 999px; min-width: 8px; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--c-red); opacity: .55; z-index: 1; }
@media (max-width: 720px) { .gantt-row { grid-template-columns: 130px 1fr; } }
.gantt-track { overflow: hidden; }
/* the rise animation makes every main>* child a stacking context, so the tabs row
   must sit above later siblings or its Reports dropdown paints underneath them */
.tabs-split { display: flex; align-items: center; position: relative; z-index: 30; }
.tabs-split .report-menu { margin-left: auto; position: relative; }
.report-menu summary { list-style: none; cursor: pointer; }
.report-menu summary::-webkit-details-marker { display: none; }
.report-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; }
.report-menu-list a { padding: 7px 10px; border-radius: 6px; text-decoration: none; }
.report-menu-list a:hover { background: var(--c-surface-2); }
