/* ASYAD Contract Lifecycle & Renewal Manager — design tokens.
   Palette taken from the register workbook's own theme (navy header + Excel accent
   set) because no official corporate theme asset was supplied (U-11). Every colour
   is a token: components never hardcode a hex value. Fonts are system-only —
   no webfont request, no CDN, so the app renders identically with no network. */
:root {
  --navy: #17365D;
  --navy-700: #12294A;
  --navy-900: #0E1F38;
  --blue: #4F81BD;
  --red: #C0504D;
  --green: #9BBB59;
  --purple: #8064A2;
  --teal: #4BACC6;
  --orange: #F79646;

  --c-navy: var(--navy);
  --c-blue: var(--blue);
  --c-red: var(--red);
  --c-green: var(--green);
  --c-purple: var(--purple);
  --c-teal: var(--teal);
  --c-orange: var(--orange);
  --c-neutral: #8296AC;

  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --surface-sunk: #EEF2F7;
  --border: #E2E7EE;
  --border-strong: #CBD5E1;
  --text: #1A2230;
  --text-2: #46566B;
  --muted: #6B7C93;
  --track: #E8EDF3;
  --focus: #2F6FB5;
  --shadow-sm: 0 1px 2px rgba(16, 32, 56, .06), 0 1px 3px rgba(16, 32, 56, .04);
  --shadow-md: 0 4px 12px rgba(16, 32, 56, .08), 0 1px 3px rgba(16, 32, 56, .05);
  --shadow-lg: 0 18px 40px rgba(11, 26, 48, .18);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: Calibri, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sidebar-w: 252px;
  --topbar-h: 68px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

[data-theme="dark"] {
  --bg: #0E1620;
  --surface: #16212E;
  --surface-2: #1B2734;
  --surface-sunk: #111A25;
  --border: #263241;
  --border-strong: #35455A;
  --text: #E7EDF5;
  --text-2: #B7C4D4;
  --muted: #8CA0B8;
  --track: #22303F;
  --navy: #1B4573;
  --blue: #6FA3DD;
  --red: #E0716E;
  --green: #A8C97A;
  --purple: #A389C6;
  --teal: #6EC5DC;
  --orange: #FBAE6B;
  --c-navy: #4F81BD;
  --c-red: #E0716E;
  --c-green: #A8C97A;
  --focus: #6FA3DD;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.15rem, 2.4vw, 1.42rem); }
h2 { font-size: clamp(1.02rem, 2vw, 1.16rem); }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--focus); }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.mono { font-family: var(--mono); font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link {
  position: absolute; left: 8px; top: -44px; z-index: 200; background: var(--navy); color: #fff;
  padding: 8px 14px; border-radius: var(--radius-sm); transition: top .18s var(--ease);
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
@media print {
  .sidebar, .topbar-tools, .appfoot, .filterbar { display: none !important; }
  .content { margin: 0 !important; }
  body { background: #fff; }
}

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-900) 100%);
  color: #EAF1F9; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 14px 18px;
}
.brand { display: grid; grid-template-columns: auto 1fr; gap: 10px 10px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.brand img { grid-row: 1; border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .95rem; letter-spacing: .01em; }
.brand-text span { font-size: .76rem; color: #A8C0DC; }
.brand-flag {
  grid-column: 1 / -1; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: #F5C27A; border: 1px dashed rgba(245, 194, 122, .55); border-radius: 999px;
  padding: 2px 8px; justify-self: start; cursor: help;
}
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: #CBD9E9; text-decoration: none; font-size: .905rem; border: 1px solid transparent;
  cursor: pointer; transition: background .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, .09); color: #fff; transform: translateX(2px); }
.nav-item[aria-current="page"] { background: rgba(79, 129, 189, .34); color: #fff; border-color: rgba(140, 178, 224, .45); font-weight: 600; }
.nav-item svg { flex: none; opacity: .92; }
.nav-count {
  margin-left: auto; font-size: .72rem; font-variant-numeric: tabular-nums; background: rgba(255, 255, 255, .16);
  border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center;
}
.nav-count.tone-critical { background: var(--red); color: #fff; }
.nav-count.tone-high { background: var(--orange); color: #24160A; }
.sidebar-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.offline-card {
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .13);
  border-radius: var(--radius); padding: 9px 11px; font-size: .74rem; color: #C6D6E8; cursor: help;
}
.offline-card strong { display: flex; align-items: center; gap: 6px; color: #fff; font-size: .78rem; margin-bottom: 3px; }
.offline-card .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(155, 187, 89, .25); }
.disclaimer-mini { font-size: .68rem; color: #93A9C2; line-height: 1.4; margin: 0; }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; }
.topbar-title p { margin: 0; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.who {
  width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--navy) 14%, var(--surface));
  color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: .78rem; cursor: help;
  border: 1px solid var(--border);
}
[data-theme="dark"] .who { color: #CFE0F3; background: rgba(79, 129, 189, .22); }
main { padding: 18px 20px 8px; flex: 1; min-width: 0; }
.appfoot {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 20px 16px;
  font-size: .74rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 12px;
}
.nav-toggle { display: none; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .865rem; font-weight: 600; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .btn-primary { background: #2F6FB5; border-color: #2F6FB5; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunk); box-shadow: none; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-warn { background: var(--orange); border-color: var(--orange); color: #24160A; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--text); transform: translateY(-1px); }

.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .875rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover { border-color: var(--blue); }
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); outline: none; }
.input[aria-invalid="true"] { border-color: var(--red); }
.search { width: 268px; padding-left: 30px; }
textarea.input { min-height: 82px; resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: .72rem; color: var(--muted); }
.field-error { font-size: .74rem; color: var(--red); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: .735rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent; background: var(--surface-sunk); color: var(--text-2);
}
.badge-danger { background: color-mix(in srgb, var(--c-red) 16%, transparent); color: var(--c-red); border-color: color-mix(in srgb, var(--c-red) 34%, transparent); }
.badge-warn { background: color-mix(in srgb, var(--c-orange) 20%, transparent); color: #8A4A08; border-color: color-mix(in srgb, var(--c-orange) 40%, transparent); }
.badge-info { background: color-mix(in srgb, var(--c-blue) 16%, transparent); color: var(--c-blue); border-color: color-mix(in srgb, var(--c-blue) 34%, transparent); }
.badge-ok { background: color-mix(in srgb, var(--c-green) 20%, transparent); color: #4E6B1B; border-color: color-mix(in srgb, var(--c-green) 40%, transparent); }
.badge-neutral { background: var(--surface-sunk); color: var(--muted); border-color: var(--border); }
.badge-purple { background: color-mix(in srgb, var(--c-purple) 16%, transparent); color: var(--c-purple); border-color: color-mix(in srgb, var(--c-purple) 34%, transparent); }
[data-theme="dark"] .badge-warn { color: #F5C27A; }
[data-theme="dark"] .badge-ok { color: #B9D48C; }
.badge-solid.badge-danger { background: var(--c-red); color: #fff; }
.badge-solid.badge-warn { background: var(--c-orange); color: #24160A; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .76rem; color: var(--text-2);
}
.chip strong { color: var(--text); font-variant-numeric: tabular-nums; }
.mono-chip { font-family: var(--mono); font-size: .76rem; background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 6px; }

/* ---------- panels, grids, KPIs ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.panel-title { display: flex; align-items: center; gap: 8px; font-size: .94rem; }
.panel-head > :last-child:not(.panel-title) { margin-left: auto; }
.panel-body { padding: 14px 16px; }
.panel-body.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .span-2 { grid-column: span 1; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent, var(--navy)); }
.kpi-label { font-size: .755rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: clamp(1.5rem, 3vw, 1.95rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-meta { font-size: .755rem; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.kpi.kpi-danger { --accent: var(--c-red); }
.kpi.kpi-warn { --accent: var(--c-orange); }
.kpi.kpi-ok { --accent: var(--c-green); }
.kpi.kpi-info { --accent: var(--c-blue); }
.kpi.kpi-purple { --accent: var(--c-purple); }
.kpi.kpi-teal { --accent: var(--c-teal); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-height: 68vh; border-top: 1px solid var(--border); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
table.data th, table.data td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .055em; white-space: nowrap; font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text); background: var(--surface-sunk); }
table.data thead th .sort-mark { opacity: .55; margin-left: 4px; font-size: .68rem; }
table.data tbody tr { cursor: pointer; transition: background .13s var(--ease); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--blue) 9%, transparent); }
table.data tbody tr:focus-visible { background: color-mix(in srgb, var(--blue) 14%, transparent); }
table.data tbody tr[aria-selected="true"] { background: color-mix(in srgb, var(--blue) 15%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact th, table.data.compact td { padding: 5px 8px; font-size: .8rem; }
.cell-strong { font-weight: 600; }
.cell-sub { display: block; font-size: .73rem; color: var(--muted); }
.risk-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.deadline { font-weight: 700; font-variant-numeric: tabular-nums; }
.deadline.is-overdue { color: var(--c-red); }
.deadline.is-near { color: #A8560B; }
[data-theme="dark"] .deadline.is-near { color: var(--orange); }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: .88rem; }

/* ---------- charts (inline SVG / CSS only) ---------- */
.barchart { display: flex; flex-direction: column; gap: 7px; }
.barchart-row { display: grid; grid-template-columns: minmax(96px, 34%) 1fr 42px; align-items: center; gap: 9px; font-size: .8rem; }
.barchart-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barchart-track { height: 12px; background: var(--track); border-radius: 999px; overflow: hidden; }
.barchart-fill { height: 100%; border-radius: 999px; background: var(--c-navy); transition: width .4s var(--ease); }
.barchart-fill.tone-critical { background: var(--c-red); }
.barchart-fill.tone-high { background: var(--c-orange); }
.barchart-fill.tone-medium { background: var(--c-blue); }
.barchart-fill.tone-warning { background: var(--c-teal); }
.barchart-fill.tone-info { background: var(--c-neutral); }
.barchart-fill.tone-ok { background: var(--c-green); }
.barchart-fill.tone-purple { background: var(--c-purple); }
.barchart-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-num { font-family: var(--font); font-size: 26px; font-weight: 700; fill: var(--text); }
.donut-cap { font-family: var(--font); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; min-width: 170px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c-navy); flex: none; }
.legend-dot.tone-critical { background: var(--c-red); } .legend-dot.tone-high { background: var(--c-orange); }
.legend-dot.tone-medium { background: var(--c-blue); } .legend-dot.tone-warning { background: var(--c-teal); }
.legend-dot.tone-info { background: var(--c-neutral); } .legend-dot.tone-ok { background: var(--c-green); }
.legend-dot.tone-purple { background: var(--c-purple); }
.legend-label { color: var(--text-2); }
.legend-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { height: 7px; background: var(--track); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-blue), var(--c-teal)); }

/* ---------- timeline bars ---------- */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-row { display: grid; grid-template-columns: 118px 1fr; gap: 10px; align-items: center; font-size: .79rem; }
.tl-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 20px; background: var(--track); border-radius: var(--radius-sm); overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.tl-seg.term { background: color-mix(in srgb, var(--c-blue) 55%, transparent); }
.tl-seg.before { background: color-mix(in srgb, var(--c-teal) 45%, transparent); }
.tl-seg.now { width: 2px; background: var(--c-red); border-radius: 0; }
.tl-seg.due { width: 3px; background: var(--navy); border-radius: 0; }
[data-theme="dark"] .tl-seg.due { background: #9DC0E8; }

/* ---------- alert / action lists ---------- */
.issue-list { display: flex; flex-direction: column; }
.issue {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: start;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.issue:last-child { border-bottom: 0; }
.issue:hover { background: color-mix(in srgb, var(--blue) 7%, transparent); }
.issue-bar { align-self: stretch; border-radius: 999px; background: var(--c-neutral); }
.issue.critical .issue-bar { background: var(--c-red); }
.issue.high .issue-bar { background: var(--c-orange); }
.issue.medium .issue-bar { background: var(--c-blue); }
.issue.warning .issue-bar { background: var(--c-teal); }
.issue.info .issue-bar { background: var(--c-neutral); }
.issue-title { font-weight: 600; font-size: .87rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.issue-detail { font-size: .79rem; color: var(--text-2); margin-top: 2px; }
.issue-meta { display: flex; gap: 8px; align-items: center; font-size: .73rem; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.issue-right { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.alert-item { display: grid; grid-template-columns: auto 1fr; gap: 9px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.alert-item:last-child { border-bottom: 0; }
.alert-item .alert-title { font-weight: 600; font-size: .84rem; }
.alert-item .alert-sub { font-size: .75rem; color: var(--muted); }
.sev-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.sev-icon.critical { background: color-mix(in srgb, var(--c-red) 18%, transparent); color: var(--c-red); }
.sev-icon.high { background: color-mix(in srgb, var(--c-orange) 22%, transparent); color: #8A4A08; }
.sev-icon.medium { background: color-mix(in srgb, var(--c-blue) 18%, transparent); color: var(--c-blue); }
.sev-icon.warning { background: color-mix(in srgb, var(--c-teal) 20%, transparent); color: #1E6E82; }
.sev-icon.info { background: var(--surface-sunk); color: var(--muted); }
[data-theme="dark"] .sev-icon.high { color: var(--orange); }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.filterbar .field { min-width: 148px; flex: 0 1 auto; }
.filterbar .field.grow { flex: 1 1 220px; }
.filter-summary { font-size: .78rem; color: var(--muted); margin-left: auto; align-self: center; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .76rem; color: var(--text-2); cursor: pointer; transition: all .15s var(--ease);
}
.pill:hover { border-color: var(--blue); transform: translateY(-1px); }
.pill[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }

/* ---------- workflow board ---------- */
.stage-strip { display: grid; grid-auto-flow: column; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage-col { min-width: 190px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 10px; }
.stage-col h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; }
.stage-col .stage-note { font-size: .72rem; color: var(--muted); margin: 5px 0 8px; }
.stage-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c-navy); border-radius: var(--radius-sm); padding: 7px 9px; margin-bottom: 6px; cursor: pointer; font-size: .8rem; transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.stage-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stage-card.critical { border-left-color: var(--c-red); }
.stage-card.high { border-left-color: var(--c-orange); }
.stage-card.medium { border-left-color: var(--c-blue); }
.stage-card.warning { border-left-color: var(--c-teal); }
.stage-steps { display: flex; flex-direction: column; gap: 2px; }
.step-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px dashed var(--border); font-size: .83rem; }
.step-row:last-child { border-bottom: 0; }
.step-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--surface-sunk); color: var(--muted); }
.step-num.done { background: color-mix(in srgb, var(--c-green) 25%, transparent); color: #4E6B1B; }
.step-num.current { background: color-mix(in srgb, var(--c-blue) 22%, transparent); color: var(--c-blue); }
.step-num.blocked { background: color-mix(in srgb, var(--c-red) 18%, transparent); color: var(--c-red); }
.step-num.na { opacity: .5; }
.gate-note { font-size: .76rem; color: var(--muted); }
.blocker-list { margin: 0; padding-left: 18px; font-size: .82rem; color: var(--text-2); }
.blocker-list li { margin-bottom: 3px; }

/* ---------- drawer ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 90; display: grid; grid-template-columns: 1fr minmax(420px, 62vw); }
.drawer-scrim { background: rgba(8, 18, 32, .48); }
.drawer { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideIn .26s var(--ease); }
@keyframes slideIn { from { transform: translateX(26px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 18px; z-index: 3; display: flex; gap: 12px; align-items: flex-start; }
.drawer-head .close { margin-left: auto; }
.drawer-body { padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 16px; }
.drawer h2 { font-size: 1.08rem; }
.drawer h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 7px; }
.dl { display: grid; grid-template-columns: minmax(150px, 42%) 1fr; gap: 4px 12px; font-size: .84rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.dl dd.mono { font-weight: 400; }
.trace { font-size: .78rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trace-row { display: grid; grid-template-columns: 46px minmax(120px, 1fr) 1.4fr; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.trace-row:last-child { border-bottom: 0; }
.trace-row:nth-child(odd) { background: var(--surface-2); }
.trace-rule { font-weight: 700; color: var(--navy); }
[data-theme="dark"] .trace-rule { color: #9DC0E8; }
.trace-note { color: #A8560B; }
[data-theme="dark"] .trace-note { color: var(--orange); }

/* ---------- modal, toast, alerts popover, states ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 120; background: rgba(8, 18, 32, .5); display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(680px, 96vw); max-height: 90vh; display: flex; flex-direction: column; animation: popIn .2s var(--ease); }
@keyframes popIn { from { transform: scale(.97) translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1rem; }
.modal-head .btn-ghost { margin-left: auto; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 92vw); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c-blue); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 13px; font-size: .855rem; animation: toastIn .24s var(--ease); }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }
.toast-success { border-left-color: var(--c-green); } .toast-success svg { color: var(--c-green); }
.toast-error { border-left-color: var(--c-red); } .toast-error svg { color: var(--c-red); }
.toast-warn { border-left-color: var(--c-orange); } .toast-warn svg { color: var(--c-orange); }
.toast-info svg { color: var(--c-blue); }
.toast svg { flex: none; margin-top: 1px; }
.toast-msg { min-width: 0; }

.alert-pop {
  position: fixed; top: calc(var(--topbar-h) + 6px); right: 18px; z-index: 95; width: min(440px, 94vw);
  max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.alert-pop h3 { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin-bottom: 8px; }

.loading-state, .error-state { display: flex; flex-direction: column; gap: 10px; padding: 26px; align-items: flex-start; }
.skeleton-row { height: 16px; width: min(560px, 90%); border-radius: 6px; background: linear-gradient(90deg, var(--surface-sunk) 25%, var(--track) 50%, var(--surface-sunk) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-row.short { width: min(320px, 60%); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.callout { border: 1px solid var(--border); border-left: 4px solid var(--c-blue); background: var(--surface-2); border-radius: var(--radius); padding: 10px 13px; font-size: .83rem; }
.callout.warn { border-left-color: var(--c-orange); }
.callout.danger { border-left-color: var(--c-red); }
.callout.ok { border-left-color: var(--c-green); }
.callout strong { display: block; margin-bottom: 3px; }
.callout ul { margin: 5px 0 0; padding-left: 18px; }

@media (max-width: 1080px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 0 minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 100; width: 262px; transform: translateX(-104%); transition: transform .24s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-grid; }
  .search { width: 180px; }
  .drawer-wrap { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
@media (max-width: 720px) {
  main { padding: 12px 12px 6px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-title p { display: none; }
  .search { width: 128px; }
  .kpi-value { font-size: 1.45rem; }
  .filterbar .field { min-width: 128px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
