/* DemoCo Enterprise Operations Portal: back-office styling. DEMO / SYNTHETIC. Self-contained, works offline. */

:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --navy-ink: #a9bccf;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #d6dce4;
  --border-soft: #e6eaef;
  --border-strong: #b9c3cf;
  --text: #1a2433;
  --text-2: #3c4a5c;
  --muted: #5a6778;
  --accent: #2a5d8f;
  --accent-hover: #224d77;
  --accent-soft: #e6eef7;
  --accent-ink: #1d4a76;
  --ribbon: #f2a93b;
  --ribbon-ink: #2b1b00;
  --radius: 3px;
  --radius-sm: 2px;
  --shadow-lg: 0 8px 24px rgba(11, 37, 69, 0.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* pill palette: background / border / text */
  --amber-bg: #fff4dc; --amber-bd: #ecc06a; --amber-tx: #744700;
  --blue-bg: #e7effa; --blue-bd: #a8c2e4; --blue-tx: #1c4d86;
  --green-bg: #e5f3ea; --green-bd: #9ccfae; --green-tx: #1d6537;
  --red-bg: #fbe8e6; --red-bd: #e5a69f; --red-tx: #982318;
  --orange-bg: #fdeee1; --orange-bd: #eeb383; --orange-tx: #85420e;
  --slate-bg: #eef1f5; --slate-bd: #c6ced9; --slate-tx: #45526a;
  --violet-bg: #efebf7; --violet-bd: #c4b6e0; --violet-tx: #52388f;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
::selection { background: #c7d9ec; }
a { color: var(--accent-ink); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid #2f7bd0; outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); }
.mono { font-size: 0.92em; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.tnum, .amount, .ref { font-variant-numeric: tabular-nums; }
.amount { white-space: nowrap; }
.ref { font-family: var(--mono); font-size: 12px; }
.ref-plain { color: var(--text-2); }
.wrap-text { white-space: normal; overflow-wrap: anywhere; min-width: 150px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.spacer { flex: 1 1 0; }
.icon { flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.boot, .noscript { padding: 48px; text-align: center; color: var(--muted); }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 60; background: var(--surface); padding: 6px 10px; border-radius: var(--radius); }
.skip-link:focus { top: 8px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 500 12.5px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color 100ms ease-out, border-color 100ms ease-out;
}
.btn:hover { background: var(--surface-2); border-color: #9eabba; color: var(--text); }
.btn:active { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-block { width: 100%; height: 34px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: #9b2419; border-color: #9b2419; color: #fff; }
.btn-danger:hover { background: #7f1c13; border-color: #7f1c13; color: #fff; }
.btn-danger-outline { color: #982318; border-color: #dba59e; }
.btn-danger-outline:hover { background: var(--red-bg); border-color: #c98b83; color: #982318; }
.btn-header { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.btn-header:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.7); color: #fff; }
.btn[aria-busy="true"]::before {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite;
}
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: #9db8d6; color: var(--accent-ink); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none;
  border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted);
  font: 17px/1 var(--font); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.link {
  border: 0; padding: 0; background: none; cursor: pointer; color: var(--accent-ink); font: inherit; text-align: left;
  text-decoration: underline; text-decoration-color: #a9c0d8; text-underline-offset: 2px;
}
.link:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
.link.ref { font-family: var(--mono); font-size: 12px; }
.caret { font-size: 10px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- pills, tags */

.pill {
  display: inline-flex; align-items: center; height: 19px; padding: 0 7px;
  border: 1px solid var(--slate-bd); border-radius: var(--radius-sm);
  background: var(--slate-bg); color: var(--slate-tx);
  font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; letter-spacing: 0.01em;
}
.pill-amber { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber-tx); }
.pill-blue { background: var(--blue-bg); border-color: var(--blue-bd); color: var(--blue-tx); }
.pill-green { background: var(--green-bg); border-color: var(--green-bd); color: var(--green-tx); }
.pill-red { background: var(--red-bg); border-color: var(--red-bd); color: var(--red-tx); }
.pill-orange { background: var(--orange-bg); border-color: var(--orange-bd); color: var(--orange-tx); }
.pill-slate { background: var(--slate-bg); border-color: var(--slate-bd); color: var(--slate-tx); }
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
  border: 1px solid var(--slate-bd); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--slate-tx); font-size: 11px; line-height: 1; white-space: nowrap;
}
.tag-blue { border-color: var(--blue-bd); color: var(--blue-tx); background: var(--blue-bg); }
.tag-green { border-color: var(--green-bd); color: var(--green-tx); background: var(--green-bg); }
.tag-red { border-color: var(--red-bd); color: var(--red-tx); background: var(--red-bg); }
.tag-orange { border-color: var(--orange-bd); color: var(--orange-tx); background: var(--orange-bg); }
.tag-violet { border-color: var(--violet-bd); color: var(--violet-tx); background: var(--violet-bg); }
.tag-demo { border-color: var(--amber-bd); color: var(--amber-tx); background: var(--amber-bg); font-weight: 600; }
.tag-inline { margin-left: 6px; vertical-align: 1px; }
.tags { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tags.wrap { display: flex; gap: 6px; }
.method {
  display: inline-block; min-width: 42px; padding: 1px 5px; border-radius: var(--radius-sm);
  font: 600 10.5px/1.5 var(--mono); text-align: center; background: var(--slate-bg); color: var(--slate-tx); border: 1px solid var(--slate-bd);
}
.method-post { background: var(--blue-bg); color: var(--blue-tx); border-color: var(--blue-bd); }
.arrow { color: var(--muted); padding: 0 3px; }
.status-change { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.count {
  display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 600; line-height: 18px; vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}
.ref-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--accent-ink); cursor: pointer; font: inherit;
}
.ref-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.ref-chip-plain { color: var(--text-2); cursor: default; background: var(--surface-2); border-style: dashed; }
.ref-chip-plain:hover { border-color: var(--border-strong); background: var(--surface-2); }

/* ---------------------------------------------------------------- shell: ribbon, header, demo strip */

.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.masthead { flex: none; position: relative; z-index: 30; }
.env-ribbon {
  padding: 3px 16px; background: var(--ribbon); color: var(--ribbon-ink);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-align: center; line-height: 16px;
  border-bottom: 1px solid #c9861c;
}
.portal-header {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 16px;
  background: var(--navy); color: #fff; border-bottom: 1px solid #061a33;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; flex: none; }
.brand:hover { color: #fff; }
.brand-name { font-size: 14px; font-weight: 650; letter-spacing: 0.005em; white-space: nowrap; }
.gsearch { position: relative; flex: 0 1 300px; min-width: 170px; display: flex; align-items: center; margin-left: 12px; }
.gsearch-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: #5a6778; display: flex; pointer-events: none; }
.gsearch-input {
  width: 100%; height: 30px; padding: 0 10px 0 30px; border: 1px solid #0a1f3a; border-radius: var(--radius);
  background: #fff; color: var(--text); font: 12.5px var(--font);
}
.gsearch-input::placeholder { color: #7a8697; }
.gsearch-input:focus-visible { outline: 2px solid #7fb2e8; outline-offset: 1px; }
.gsearch-results {
  position: absolute; top: calc(100% + 6px); left: 0; width: min(520px, 90vw); max-height: 420px; overflow-y: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.gsearch-results > .loading { padding: 14px; }
.gsearch-head { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border-soft); background: var(--surface-2); }
.gsearch-list { list-style: none; margin: 0; padding: 4px; }
.gsearch-hit {
  display: grid; grid-template-columns: auto auto auto minmax(0, 1fr); align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer; font: 12.5px var(--font); color: var(--text);
}
.gsearch-hit:hover, .gsearch-hit:focus-visible { background: var(--accent-soft); outline: none; }
.gsearch-type { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.gsearch-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.gsearch-warn { padding: 8px 12px; font-size: 12px; color: var(--red-tx); border-top: 1px solid var(--border-soft); }
.biz-clock { display: flex; flex-direction: column; line-height: 1.25; flex: none; }
.biz-clock-label { display: flex; align-items: center; gap: 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--navy-ink); }
.biz-clock-row { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.biz-clock-date, .biz-clock-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock-offset {
  padding: 0 5px; border-radius: var(--radius-sm); background: var(--ribbon); color: var(--ribbon-ink);
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; text-transform: none; line-height: 15px; white-space: nowrap;
}
.secured { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--navy-ink); white-space: nowrap; flex: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.18); min-width: 0; flex: 0 1 auto; }
.user-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: #1f4e79; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
}
.user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--navy-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.demo-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 38px; padding: 4px 16px;
  background: #e7ecf2; border-bottom: 1px solid #c9d2dd;
}
.demo-strip-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--slate-tx); }
.demo-strip-clock { font-size: 12.5px; color: var(--text-2); }
.demo-strip-clock.is-ahead { color: var(--amber-tx); font-weight: 600; }

/* ---------------------------------------------------------------- layout, navigation, footer */

.layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.rail { overflow-y: auto; padding: 6px 0 16px; background: var(--surface); border-right: 1px solid var(--border); }
.nav-group { display: flex; flex-direction: column; }
.nav-group + .nav-group { margin-top: 4px; border-top: 1px solid var(--border-soft); }
.nav-group-label { padding: 12px 16px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: #6a7788; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 29px; padding: 4px 14px 4px 16px; color: var(--text-2); text-decoration: none; font-size: 13px;
}
.nav-link:hover { background: #f1f4f8; color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--navy); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-badge { min-width: 20px; padding: 0 5px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; border: 1px solid; }
.nav-badge-amber { background: var(--amber-bg); color: var(--amber-tx); border-color: var(--amber-bd); }
.nav-badge-red { background: var(--red-bg); color: var(--red-tx); border-color: var(--red-bd); }
.nav-badge-orange { background: var(--orange-bg); color: var(--orange-tx); border-color: var(--orange-bd); }
.main { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; outline: none; }
.page { flex: 1 0 auto; padding: 18px 24px 32px; min-width: 0; }
.portal-footer {
  flex: none; padding: 10px 24px; border-top: 1px solid var(--border); background: var(--surface);
  font-size: 11.5px; color: var(--muted); letter-spacing: 0.01em;
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.crumb { font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: #6a7788; margin-bottom: 3px; }
.page-title { font-size: 19px; font-weight: 650; color: var(--navy); outline: none; }
.page-sub { margin-top: 3px; color: var(--muted); max-width: 900px; font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------------- panels, notices, banners */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; min-width: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.panel-title { font-size: 13.5px; font-weight: 650; color: var(--navy); }
.panel-sub { margin-top: 1px; font-size: 12px; color: var(--muted); }
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-actions:empty { display: none; }
.panel-actions .input { width: auto; min-width: 200px; }
.panel-body { padding: 12px 14px 14px; min-width: 0; }
.panel-body > .table-wrap, .panel-body > .flush > .table-wrap { margin: -12px -14px -14px; border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .input[type="search"] { width: 360px; max-width: 100%; }
.toolbar select.input { width: auto; }
.notice { margin-bottom: 14px; padding: 9px 12px; border: 1px solid #c3d4e8; border-left: 3px solid var(--accent); border-radius: var(--radius); background: #f2f6fb; color: var(--text-2); font-size: 12.5px; }
.notice p + p { margin-top: 3px; }
.notice-warn { border-color: var(--amber-bd); border-left-color: #c98a12; background: #fff9ec; }
.help-inline { margin: -4px 0 12px; color: var(--muted); font-size: 12.5px; }
.banner-host:empty { display: none; }
.banner {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--green-bd); border-left: 4px solid #2e8b57; border-radius: var(--radius); background: var(--green-bg);
}
.banner-warn { border-color: var(--amber-bd); border-left-color: #c98a12; background: var(--amber-bg); }
.banner-body { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.banner-body strong { font-size: 13px; color: var(--text); }
.banner-status { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tabs */

.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; margin-bottom: -1px;
  border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: none;
  font: 500 13px var(--font); color: var(--muted); cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--navy); font-weight: 600; background: var(--surface); border-color: var(--border); box-shadow: inset 0 2px 0 var(--accent); }
.tab-count { padding: 0 5px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 600; line-height: 17px; font-variant-numeric: tabular-nums; }
.tab-panel { outline: none; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th {
  position: sticky; top: 0; z-index: 1; padding: 7px 10px; background: var(--surface-3); border-bottom: 1px solid #cfd6df;
  color: var(--text-2); font-size: 11.5px; font-weight: 650; text-align: left; white-space: nowrap; letter-spacing: 0.01em;
}
.tbl td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.tbl tbody tr:nth-child(even) > td { background: #fafbfc; }
.tbl tbody tr:last-child > td { border-bottom: 0; }
.tbl tbody tr:hover > td { background: #f1f5fa; }
.tbl tr.clickable { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions-col { text-align: right; white-space: nowrap; width: 1%; }
.tbl .applied-col { min-width: 170px; }
.tbl .clip-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.cell-stack .ellipsis { max-width: 100%; }
.tbl .mode-cell { min-width: 170px; }
.tbl .scopes-cell { min-width: 140px; max-width: 260px; }
.tbl .sub-name { max-width: 300px; }
.tbl tr.empty-row > td, .tbl tr.empty-row:hover > td { padding: 0; background: var(--surface); }
.tbl tr.row-bad > td { background: #fff7f6; }
.tbl tr.row-muted > td { color: var(--muted); }
.tbl tr.row-open > td { background: var(--accent-soft); border-bottom-color: transparent; }
.tbl tr.detail-row > td, .tbl tr.detail-row:hover > td { background: var(--surface-2); padding: 12px 14px 14px; }
.tbl .expander-col { width: 34px; padding-right: 0; }
.tbl .expander { width: 22px; height: 22px; font-size: 12px; }
.tbl-sub { font-size: 12px; }
.tbl-sub td { padding: 5px 8px; }
.tbl-sub th { padding: 6px 8px; }
.feed-wrap { max-height: 420px; }
.tbl-feed { table-layout: fixed; font-size: 12px; }
.tbl-feed td { padding-top: 4px; padding-bottom: 4px; }
.tbl-feed .c-time { width: 76px; }
.tbl-feed .c-caller { width: 230px; }
.tbl-feed .c-method { width: 64px; }
.tbl-feed .c-status { width: 200px; }
.tbl-feed .c-notes { width: 140px; }
.tbl-feed .c-ms { width: 52px; }
.tbl-feed .tag { margin-left: 6px; }
.tbl-feed tr.fresh > td { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: #dceaf7; } to { background: transparent; } }
.status-code { margin-left: 6px; color: var(--red-tx); }
.failures { margin: 0; padding-left: 16px; color: var(--red-tx); font-size: 12px; }

/* ---------------------------------------------------------------- empty / loading */

.empty { padding: 26px 16px; text-align: center; }
.empty-title { font-weight: 600; color: var(--text-2); }
.empty-hint { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.empty .btn { margin-top: 12px; }
.empty-error .empty-title { color: var(--red-tx); }
.code-inline { padding: 1px 5px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red-tx); font-size: 11.5px; }
.loading { display: flex; align-items: center; gap: 8px; padding: 18px 4px; color: var(--muted); }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-right-color: var(--accent); animation: spin 700ms linear infinite; }

/* ---------------------------------------------------------------- dashboard */

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpis > .loading, .kpis > .empty { grid-column: 1 / -1; padding: 16px; background: var(--surface); border: 1px solid var(--border); }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 11px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--slate-bd); border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
a.kpi:hover { background: var(--surface-2); color: inherit; border-color: #b9c6d4; }
.kpi-label { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--navy); }
.kpi-hint { font-size: 11.5px; color: var(--muted); }
.kpi-amber { border-top-color: #d99a1e; }
.kpi-amber .kpi-value { color: var(--amber-tx); }
.kpi-blue { border-top-color: var(--accent); }
.kpi-red { border-top-color: #b8352a; }
.kpi-red .kpi-value { color: var(--red-tx); }
.kpi-orange { border-top-color: #d77a2e; }
.kpi-orange .kpi-value { color: var(--orange-tx); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.live[data-mode="live"] .live-dot { background: #2e8b57; animation: pulse 2s ease-in-out infinite; }
.live[data-mode="error"] { color: var(--red-tx); }
.live[data-mode="error"] .live-dot { background: #b8352a; }
@keyframes pulse { 50% { opacity: 0.35; } }
.inv-others { margin-top: 10px; color: var(--muted); }

/* ---------------------------------------------------------------- forms */

.input {
  width: 100%; height: 30px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: 12.5px var(--font);
}
textarea.input { height: auto; padding: 7px 9px; line-height: 1.45; resize: vertical; }
textarea.input.mono, .input.mono { font-family: var(--mono); font-size: 12px; }
select.input { padding-right: 26px; }
.input:focus-visible { outline: 2px solid #2f7bd0; outline-offset: 0; border-color: #2f7bd0; }
.input[aria-invalid="true"] { border-color: #b8352a; }
.input::placeholder { color: #848f9d; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field { gap: 8px; }
.field-label { font-size: 12px; font-weight: 650; color: var(--text-2); padding: 0; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--red-tx); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.check, .radio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }
.radio { align-items: flex-start; }
.radio input { margin-top: 3px; }
.check input, .radio input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.kv-rows { display: flex; flex-direction: column; gap: 6px; }
.kv-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; align-items: center; }
fieldset.field > .btn { align-self: flex-start; }
.preview { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.preview-bar { display: flex; gap: 8px; }
.preview-out:empty { display: none; }
.inject-result { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.inject-result:empty { display: none; }
.case-form { display: flex; align-items: flex-start; gap: 12px; }
.case-form .field { flex: 0 1 520px; }
.case-form-btn { padding-top: 21px; }
.case-stats { display: flex; gap: 32px; }
.case-stats > div { display: flex; flex-direction: column; }
.stat-value { font-size: 22px; font-weight: 650; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------------------------------------------------------------- JSON viewer */

.json {
  font: 12px/1.55 var(--mono); padding: 8px 10px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.j-kids { padding-left: 16px; border-left: 1px dotted var(--border-strong); margin-left: 3px; }
.j-node > summary { cursor: pointer; list-style: none; }
.j-node > summary::-webkit-details-marker { display: none; }
.j-node > summary::before { content: "▸"; display: inline-block; width: 12px; color: var(--muted); }
.j-node[open] > summary::before { content: "▾"; }
.j-row { padding-left: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.j-key { color: #1c4d86; }
.j-idx, .j-punct { color: var(--muted); }
.j-count { color: var(--muted); font-style: italic; padding: 0 4px; }
.j-str { color: #1d6537; }
.j-num { color: #8a4510; }
.j-bool { color: #52388f; }
.j-null { color: var(--muted); }
.pre {
  margin: 0; padding: 8px 10px; max-height: 320px; overflow: auto; font: 12px/1.5 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}

/* ---------------------------------------------------------------- dialogs: modal + record drawer */

dialog { color: var(--text); }
dialog::backdrop { background: rgba(11, 37, 69, 0.38); }
.modal { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-top: 3px solid var(--navy); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-wide { width: min(600px, calc(100vw - 32px)); }
.modal-inner { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.modal-title { font-size: 15px; font-weight: 650; color: var(--navy); }
.modal-msg { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal .notice { margin-bottom: 0; }
.facts { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.drawer {
  margin: 0 0 0 auto; padding: 0; width: min(840px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  border: 0; border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); background: var(--surface);
}
.drawer[open] { animation: drawer-in 160ms ease-out; }
@keyframes drawer-in { from { transform: translateX(20px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.drawer-inner { display: flex; flex-direction: column; height: 100%; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 20px 12px; border-bottom: 1px solid var(--border); border-top: 3px solid var(--navy); background: var(--surface-2);
}
.drawer-titles { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.drawer-title { font-size: 17px; font-weight: 650; font-family: var(--mono); color: var(--navy); overflow-wrap: anywhere; outline: none; font-variant-numeric: tabular-nums; }
.drawer-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.meta-item { display: inline-flex; align-items: baseline; gap: 5px; font-size: 12.5px; }
.meta-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.drawer-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.eyebrow { font-size: 10.5px; font-weight: 700; color: #6a7788; letter-spacing: 0.08em; text-transform: uppercase; }
.back-link { font-size: 12px; margin-bottom: 3px; }
.rec-body .tabs { margin-bottom: 14px; }
.rec-section { margin-bottom: 18px; }
.rec-section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); padding-bottom: 6px; margin-bottom: 4px; border-bottom: 2px solid var(--surface-3); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
.fg-item { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px dotted #dde2e8; min-width: 0; }
.fg-item dt { color: var(--muted); font-size: 12px; }
.fg-item dd { margin: 0; font-size: 12.5px; overflow-wrap: anywhere; min-width: 0; }
.sub-block { display: flex; flex-direction: column; gap: 6px; }
.sub-title { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

/* scanned-document viewer for long text (documentText, transcriptText) */
.doc-viewer { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.doc-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--surface-3); border-bottom: 1px solid var(--border); }
.doc-title { font-size: 12px; font-weight: 650; color: var(--text-2); }
.doc-meta { flex: 1; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-scroll { max-height: 440px; overflow: auto; padding: 18px; background: #d9dde2; outline: none; }
.doc-scroll:focus-visible { outline: 2px solid #2f7bd0; outline-offset: -2px; }
.doc-paper {
  position: relative; max-width: 680px; margin: 0 auto; padding: 30px 34px; overflow: hidden;
  background: #fdfcf7; border: 1px solid #d7d1c2; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.doc-paper::after {
  content: "DEMO / SYNTHETIC"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg);
  font: 700 42px/1 var(--font); letter-spacing: 0.08em; color: rgba(11, 37, 69, 0.06); white-space: nowrap; pointer-events: none;
}
.doc-text { position: relative; margin: 0; font: 12.5px/1.65 var(--mono); color: #2a2a2a; white-space: pre-wrap; overflow-wrap: anywhere; }
.cell-doc > summary { cursor: pointer; color: var(--accent-ink); font-size: 12px; }
.cell-doc .doc-viewer { margin-top: 6px; min-width: 420px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.tl-item:last-child { border-bottom: 0; }
.tl-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.tl-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; }
.tl-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tl-note { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.tl-json { margin-top: 4px; font-size: 12px; }
.tl-json > summary { cursor: pointer; color: var(--accent-ink); }
.tl-json .json { margin-top: 4px; }

/* ---------------------------------------------------------------- popover menu */

.menu-wrap { display: inline-block; }
.menu {
  position: fixed; inset: auto; margin: 0; padding: 4px; min-width: 280px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 7px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font: 12.5px var(--font); color: var(--text); cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-label { font-weight: 600; }
.menu-hint { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 8px; align-items: flex-start; padding: 9px 8px 9px 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 12.5px; animation: toast-in 150ms ease-out;
}
.toast-ok { border-left-color: #2e8b57; }
.toast-warn { border-left-color: #c98a12; }
.toast-error { border-left-color: #b8352a; }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.toast-title { font-weight: 600; overflow-wrap: anywhere; }
.toast-code { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red-tx); font-size: 11px; font-weight: 700; vertical-align: 1px; }
.toast-msg { color: var(--text-2); overflow-wrap: anywhere; }
.toast-lines { margin: 2px 0 0; padding-left: 16px; color: var(--text-2); font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.toast-details > summary { cursor: pointer; color: var(--accent-ink); font-size: 12px; margin-top: 2px; }
.toast-details .pre { margin-top: 6px; max-height: 220px; }
.toast-close { width: 22px; height: 22px; font-size: 15px; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- sign in */

.signin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.signin-shell .portal-header { min-height: 52px; }
.signin { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.signin-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 13px; padding: 24px 26px;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--navy); border-radius: var(--radius);
}
.signin-title { font-size: 18px; font-weight: 650; color: var(--navy); }
.signin-sub { margin-top: -8px; font-size: 12.5px; color: var(--muted); }
.signin-note { font-size: 12px; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* ---------------------------------------------------------------- keys */

.key-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.key-text { overflow-wrap: anywhere; }
.key-cell { min-width: 290px; }
.key-reveal { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.key-reveal code { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- scenarios */

.scenario-groups { display: flex; flex-direction: column; gap: 22px; }
.scn-expert { display: flex; flex-direction: column; gap: 12px; }
.scn-expert-title { font-size: 15px; font-weight: 650; color: var(--navy); padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.scn-skill { display: flex; flex-direction: column; gap: 10px; }
.scn-skill-title { font-size: 13px; font-weight: 650; color: var(--text-2); }
.scenario { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.scn-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scn-title { font-size: 14px; font-weight: 650; flex-basis: 100%; color: var(--text); }
.prompt { border: 1px solid #c3d4e8; border-radius: var(--radius); background: #f5f8fc; }
.prompt-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 0 10px; }
.prompt-label { font-size: 11px; font-weight: 650; color: var(--accent-ink); text-transform: uppercase; letter-spacing: 0.05em; }
.prompt-text { margin: 0; padding: 4px 10px 10px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.scn-records { display: flex; flex-direction: column; gap: 6px; }
.scn-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.scn-col-title { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.scn-list { margin: 0; padding-left: 18px; font-size: 12.5px; }
.scn-list li + li { margin-top: 3px; }
.scn-list.ref { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- checks, events */

.check-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.event-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.event-detail .sub-title { margin-bottom: 8px; }
.event-detail .section-bar .sub-title { margin-bottom: 0; }
.deliveries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.delivery { padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px; }
.delivery-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delivery-error { font-size: 12px; color: var(--red-tx); overflow-wrap: anywhere; }
.delivery details > summary { cursor: pointer; font-size: 12px; color: var(--accent-ink); }
.delivery details > .json, .delivery details > .pre { margin-top: 6px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1240px) {
  .secured-text { display: none; }
  .brand-name { font-size: 13px; }
}
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-detail { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .app-shell { height: auto; min-height: 100vh; }
  .portal-header { flex-wrap: wrap; }
  .gsearch { order: 10; flex: 1 1 100%; margin-left: 0; }
  .layout { display: block; }
  .rail { display: flex; overflow-x: auto; padding: 0 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-group { flex-direction: row; }
  .nav-group + .nav-group { margin-top: 0; border-top: 0; border-left: 1px solid var(--border-soft); }
  .nav-group-label { display: none; }
  .nav-link { white-space: nowrap; padding: 8px 12px; }
  .nav-link[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .main { overflow: visible; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .scn-cols { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-actions { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .page { padding: 14px 12px 28px; }
  .form-grid, .form-grid-4, .check-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-chip { border-left: 0; padding-left: 0; }
  .tl-item { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .case-form { flex-direction: column; }
  .case-form-btn { padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .btn[aria-busy="true"]::before, .spinner { animation: none; border-right-color: currentColor; opacity: 0.6; }
}
