/* NLD Relay — layout and tokens modelled on the Kaliper UI (with permission). */
:root {
  --gray-10:#f8f8f8; --gray-20:#f0f0f0; --gray-30:#e8e8e8; --gray-40:#d4d4d4; --gray-60:#a4a4a4; --gray-70:#909090;
  --gray-90:#6d6d6d; --gray-110:#3d3d3d; --gray-black:#0b0b0b;
  --indigo-10:#f5f6ff; --indigo-20:#ebedff; --indigo-30:#e3e6ff; --indigo-40:#cbd0fe; --indigo-60:#9098fe;
  --indigo-80:#625dde; --indigo-90:#5d60c2; --indigo-100:#453fa6;
  --red-20:#ffe9e5; --red-30:#ffe0da; --red-70:#ea6452; --red-80:#c93627; --red-100:#951c11;
  --green-20:#e7f3dd; --green-30:#ddefcd; --green-70:#6da31a; --green-80:#558300; --green-100:#3b5d00;
  --orange-10:#fff4ef; --orange-20:#ffeade; --orange-70:#e16e18; --orange-80:#b45300; --orange-100:#813a00;
  --blue-20:#e5efff; --blue-80:#006de3; --cyan-20:#d7f5fc; --cyan-80:#008197; --violet-20:#f1ebff; --violet-80:#884ad7;
  --steel-20:#e4f1f7; --steel-80:#5b7886;
  --ink-0:var(--gray-black); --ink-1:var(--gray-110); --ink-2:var(--gray-90); --ink-ph:var(--gray-60);
  --line-1:#00000042; --line-2:#0000001f; --line-3:#0000000f;
  --surface-l1:var(--gray-10); --surface-l2:var(--gray-20);
  --ui1:var(--indigo-80); --ui1-ink:var(--indigo-100);
  --danger:var(--red-70); --success:var(--green-70); --warning:var(--orange-70);
  --r-sm:6px; --r-md:8px; --r-lg:12px;
  --shadow-pop:0 0 2px 0 #00000042, 0 6px 16px 0 #00000026;
  --side-w:224px;
}
* { box-sizing:border-box; }
html, body { margin:0; height:100%; }
body { font:13px/1.45 "DM Sans", ui-sans-serif, system-ui, sans-serif; color:var(--ink-0); background:#fff;
  -webkit-font-smoothing:antialiased; }
button, input, select, textarea { font:inherit; color:inherit; }
a { color:var(--ui1-ink); text-decoration:none; }
.num, td.n, .tab-num { font-variant-numeric:tabular-nums; }
.muted { color:var(--ink-2); } .faint { color:var(--ink-ph); }
.hidden { display:none !important; }

/* ---------- shell ---------- */
.app { display:flex; height:100vh; }
.side { width:var(--side-w); flex:none; display:flex; flex-direction:column; padding:14px 12px 10px; background:#fff;
  border-right:1px solid var(--line-3); }
.brand { display:flex; align-items:center; gap:10px; padding:4px 10px 18px; margin-bottom:6px; border-bottom:1px solid var(--line-3); text-decoration:none; }
.brand .bm { height:34px; width:auto; display:block; }
.brand .bw { height:30px; width:auto; display:block; }
.login .login-logo { text-align:center; margin:4px 0 10px; }
.login .login-logo img { width:150px; height:auto; display:inline-block; }
.login .login-title { text-align:center; font-weight:600; font-size:15px; letter-spacing:.3px; margin:0 0 16px; color:var(--ink-2); }
.brand .mark { width:22px; height:22px; border-radius:6px; background:var(--ui1); color:#fff; display:grid; place-items:center;
  font-size:12px; font-weight:700; }
.org { display:flex; align-items:center; gap:10px; padding:9px 10px; border:1px solid var(--line-3); border-radius:var(--r-md);
  margin-bottom:16px; }
.org .av { width:28px; height:28px; border-radius:6px; background:var(--violet-20); color:var(--violet-80); display:grid;
  place-items:center; font-size:11px; font-weight:600; }
.org .nm { flex:1; font-weight:500; }
.nav a { display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:var(--r-md); color:var(--ink-1);
  font-weight:500; margin-bottom:1px; }
.nav a:hover { background:var(--gray-10); }
.nav a.on { background:var(--gray-20); color:var(--ui1-ink); }
.nav a .ic { width:16px; height:16px; flex:none; opacity:.75; }
.nav a.sub { padding-left:22px; font-weight:400; }
.nav a.sub::before { content:""; width:9px; height:12px; border-left:1px solid var(--gray-40); border-bottom:1px solid var(--gray-40);
  margin:-8px -2px 0 0; border-bottom-left-radius:3px; }
.nav .badge { margin-left:auto; font-size:10px; padding:1px 6px; border-radius:4px; background:var(--gray-20); color:var(--ink-2); }
.side .foot { margin-top:auto; padding:10px; border-radius:var(--r-md); background:var(--gray-10); font-size:12px; }
.side .foot .bar { height:4px; border-radius:2px; margin-top:6px; background:linear-gradient(90deg, var(--indigo-80), var(--violet-80), var(--red-70)); }
.main { flex:1; min-width:0; display:flex; flex-direction:column; }
.topbar { height:42px; flex:none; display:flex; align-items:center; padding:0 18px; gap:8px; border-bottom:1px solid var(--line-3);
  color:var(--ink-2); font-size:12.5px; }
.topbar .crumb { color:var(--ink-1); }
.topbar .sp { flex:1; }
.topbar .user { width:26px; height:26px; border-radius:50%; border:1px solid var(--line-2); display:grid; place-items:center; cursor:pointer; }
.page { flex:1; overflow:auto; padding:22px 28px 40px; }
h1.title { font-size:24px; font-weight:500; margin:0 0 14px; letter-spacing:-.3px; padding-bottom:14px; border-bottom:1px solid var(--line-3); }
h3 { font-size:14px; font-weight:600; margin:22px 0 10px; }

/* ---------- controls ---------- */
.row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.row.sb { justify-content:space-between; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip { border:1px solid var(--line-2); background:#fff; border-radius:999px; padding:5px 13px; cursor:pointer; white-space:nowrap; }
.chip:hover { background:var(--gray-10); }
.chip.on { background:var(--indigo-20); border-color:var(--indigo-30); color:var(--ui1-ink); }
.btn { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--line-2); background:#fff; border-radius:var(--r-sm);
  padding:5px 11px; cursor:pointer; white-space:nowrap; }
.btn:hover { background:var(--gray-10); }
.btn.pri { background:var(--ui1); border-color:var(--ui1); color:#fff; }
.btn.pri:hover { background:var(--indigo-90); }
.btn.ghost { border-color:transparent; background:var(--gray-20); }
.btn.danger { color:var(--red-80); }
.btn.sm { padding:3px 8px; font-size:12px; }
.btn.icon { padding:5px 7px; }
.btn[disabled] { opacity:.5; cursor:default; }
.filterbar { display:flex; align-items:center; gap:6px; background:var(--gray-10); border-radius:var(--r-md); padding:7px 8px; margin:12px 0 14px; flex-wrap:wrap; }
.filterbar .div { width:1px; height:20px; background:var(--line-2); margin:0 4px; }
.filterbar .fbtn { border:1px solid var(--line-2); background:#fff; border-radius:var(--r-sm); padding:3px 9px; cursor:pointer; }
.filterbar .fbtn.act { background:var(--indigo-20); border-color:var(--indigo-40); color:var(--ui1-ink); }
.filterbar .clear { margin-left:auto; color:var(--ink-2); cursor:pointer; padding:2px 6px; }
input.in, select.in, textarea.in { border:1px solid var(--line-2); border-radius:var(--r-sm); padding:6px 9px; background:#fff; width:100%; }
input.in:focus, select.in:focus, textarea.in:focus { outline:none; border-color:var(--indigo-60); box-shadow:0 0 0 3px var(--indigo-20); }
textarea.in { min-height:70px; resize:vertical; }
label.fl { display:block; font-size:12px; color:var(--ink-2); margin:10px 0 4px; }
.lab { display:flex; align-items:center; border:1px solid var(--line-2); border-radius:var(--r-sm); background:#fff; padding:0 0 0 9px; }
.lab > span { color:var(--ink-2); white-space:nowrap; font-size:12.5px; }
.lab input, .lab select { border:0; padding:6px 9px; width:100%; background:transparent; outline:none; }
.toggle { position:relative; width:30px; height:17px; border-radius:9px; background:var(--gray-40); cursor:pointer; flex:none; transition:.15s; }
.toggle::after { content:""; position:absolute; top:2px; left:2px; width:13px; height:13px; border-radius:50%; background:#fff; transition:.15s; }
.toggle.on { background:var(--ui1); } .toggle.on::after { left:15px; }
.tgl-row { display:flex; align-items:center; justify-content:space-between; border:1px solid var(--line-2); border-radius:var(--r-sm);
  padding:6px 10px; background:#fff; }

/* ---------- cards ---------- */
.grid { display:grid; gap:10px; }
.g3 { grid-template-columns:repeat(3, 1fr); } .g4 { grid-template-columns:repeat(4, 1fr); } .g2 { grid-template-columns:repeat(2, 1fr); }
@media (max-width:1100px) { .g3, .g4 { grid-template-columns:repeat(2, 1fr); } }
.card { background:var(--surface-l2); border-radius:var(--r-lg); padding:12px 14px; min-height:92px; }
.card .lbl { color:var(--ink-1); font-size:12.5px; }
.card .big { font-size:22px; font-weight:500; letter-spacing:-.3px; margin-top:6px; }
.card .sub { color:var(--ink-2); font-size:12px; }
.card .trio { display:flex; gap:10px; margin-top:22px; } .card .trio > div { flex:1; }
.card .trio .v { font-size:19px; font-weight:500; } .card .trio .k { color:var(--ink-2); font-size:12px; }
.card.chart { padding-bottom:6px; }
.delta { font-size:12px; margin-left:6px; } .delta.up { color:var(--green-80); } .delta.down { color:var(--red-80); }
.vol { display:flex; gap:14px; align-items:stretch; }
.vol .spark { flex:1; background:#fff; border:1px solid var(--line-3); border-radius:var(--r-sm); min-height:70px; }
.panel-white { background:#fff; border:1px solid var(--line-3); border-radius:var(--r-lg); padding:14px; }

/* ---------- tables ---------- */
.tbar { display:flex; align-items:center; gap:6px; margin:18px 0 8px; }
.tbar .tabs { display:flex; gap:2px; }
.tbar .tab { padding:5px 12px; border-radius:999px; cursor:pointer; color:var(--ink-1); }
.tbar .tab.on { background:var(--indigo-20); color:var(--ui1-ink); }
.tbar .sep { width:1px; height:18px; background:var(--line-2); margin:0 6px; }
.tbar .sp { flex:1; }
.tbl-wrap { border:1px solid var(--line-3); border-radius:var(--r-md); overflow:auto; max-height:calc(100vh - 230px); }
table.t { border-collapse:separate; border-spacing:0; width:100%; font-variant-numeric:tabular-nums; }
table.t th { position:sticky; top:0; z-index:2; background:#fff; text-align:left; font-weight:400; color:var(--ink-1); font-size:12.5px;
  padding:7px 10px; border-bottom:1px solid var(--line-2); border-right:1px solid var(--line-3); white-space:nowrap; cursor:default; }
table.t th.sort { cursor:pointer; } table.t th .arr { color:var(--ink-2); margin-left:4px; }
table.t td { padding:7px 10px; border-bottom:1px solid var(--line-3); white-space:nowrap; max-width:340px; overflow:hidden; text-overflow:ellipsis; }
table.t td.n, table.t th.n { text-align:right; }
table.t tr:hover td { background:var(--gray-10); }
table.t tr.sel td { background:var(--indigo-10); }
table.t tr.click { cursor:pointer; }
table.t td:first-child, table.t th:first-child { position:sticky; left:0; z-index:1; background:#fff; border-right:1px solid var(--line-2); }
table.t th:first-child { z-index:3; }
table.t tr:hover td:first-child { background:var(--gray-10); } table.t tr.sel td:first-child { background:var(--indigo-10); }
.prev { display:block; font-size:11px; color:var(--ink-2); }
.pager { display:flex; justify-content:space-between; align-items:center; padding:10px 2px; color:var(--ink-2); }
.empty { padding:40px; text-align:center; color:var(--ink-2); }

/* ---------- pills / status ---------- */
.pill { display:inline-flex; align-items:center; gap:4px; padding:1px 8px; border-radius:5px; font-size:12px; line-height:19px; }
.pill.red { background:var(--red-20); color:var(--red-80); } .pill.green { background:var(--green-20); color:var(--green-80); }
.pill.orange { background:var(--orange-20); color:var(--orange-80); } .pill.gray { background:var(--gray-20); color:var(--ink-2); }
.pill.indigo { background:var(--indigo-20); color:var(--ui1-ink); } .pill.blue { background:var(--blue-20); color:var(--blue-80); }
.pill.cyan { background:var(--cyan-20); color:var(--cyan-80); } .pill.violet { background:var(--violet-20); color:var(--violet-80); }
.dot { display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:6px; vertical-align:1px; }
.dot.red { background:var(--danger); } .dot.green { background:var(--success); } .dot.orange { background:var(--warning); }
.dot.gray { background:var(--gray-60); } .dot.indigo { background:var(--ui1); }
.distbar { display:flex; height:8px; border-radius:4px; overflow:hidden; background:var(--gray-20); min-width:110px; }
.distbar > i { display:block; height:100%; }

/* ---------- drawer ---------- */
.drawer { position:fixed; top:0; right:0; bottom:0; width:min(640px, 96vw); background:#fff; box-shadow:var(--shadow-pop); z-index:50;
  display:flex; flex-direction:column; border-top-left-radius:var(--r-lg); border-bottom-left-radius:var(--r-lg); }
.drawer .hd { display:flex; align-items:center; gap:8px; padding:14px 16px; border-bottom:1px solid var(--line-3); }
.drawer .hd .ttl { font-weight:500; font-size:14.5px; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.drawer .bd { flex:1; overflow:auto; padding:14px 16px 24px; }
.drawer .ft { padding:10px 16px; border-top:1px solid var(--line-3); display:flex; justify-content:flex-end; gap:8px; }
.seg { display:flex; background:var(--gray-20); border-radius:var(--r-md); padding:3px; gap:3px; margin-bottom:14px; }
.seg > div { flex:1; text-align:center; padding:5px; border-radius:6px; cursor:pointer; color:var(--ink-1); }
.seg > div.on { background:#fff; box-shadow:0 1px 3px #0000001f; }
.sec { border-bottom:1px solid var(--line-3); padding:12px 0; }
.sec > .sh { display:flex; align-items:center; gap:8px; cursor:pointer; font-weight:500; }
.sec > .sh .chev { width:20px; height:20px; border-radius:50%; background:var(--gray-20); display:grid; place-items:center; font-size:10px; transition:.15s; }
.sec.closed > .sh .chev { transform:rotate(180deg); }
.sec.closed > .sb { display:none; }
.sec > .sb { margin-top:10px; }
.box { background:var(--gray-10); border-radius:var(--r-lg); padding:12px; }
.box h4 { margin:2px 0 10px; font-size:13px; font-weight:500; display:flex; align-items:center; gap:6px; }
.box hr { border:0; border-top:1px solid var(--line-2); margin:14px 0; }
.kv { display:grid; grid-template-columns:150px 1fr; gap:8px 12px; }
.kv .k { color:var(--ink-2); }
.kv .v { word-break:break-all; }
.scorebox { display:grid; grid-template-columns:repeat(5, 1fr); gap:6px; margin:8px 0 10px; }
.scorebox > div { background:var(--gray-20); border-radius:var(--r-md); padding:8px 10px; }
.scorebox .k { font-size:12px; color:var(--ink-1); } .scorebox .v { font-size:18px; margin-top:8px; }
.qcbox { display:grid; grid-template-columns:1fr 1fr 2fr; gap:6px; }
.qcbox > div { border-radius:var(--r-md); padding:10px; background:var(--gray-20); }
.qcbox > div.bad { background:var(--red-20); color:var(--red-100); } .qcbox > div.good { background:var(--green-20); color:var(--green-100); }
.summary { background:var(--gray-20); border-radius:var(--r-md); padding:12px; margin:8px 0; white-space:pre-wrap; }
.transcript { white-space:pre-wrap; background:var(--gray-10); border-radius:var(--r-md); padding:12px; max-height:60vh; overflow:auto; font-size:12.5px; }
.det-row { display:grid; grid-template-columns:1.4fr 1fr 50px; gap:8px; padding:6px 8px; border-bottom:1px solid var(--line-3); align-items:center; }
.det-row.conv { background:var(--green-20); }
.det-row.fail { background:var(--red-20); }
.thumbs span { cursor:pointer; opacity:.45; margin-left:4px; } .thumbs span.on { opacity:1; }
.tag { display:inline-flex; align-items:center; gap:4px; background:var(--steel-20); color:var(--steel-80); padding:2px 8px; border-radius:5px; margin:2px 4px 2px 0; font-size:12px; }
.tag b { cursor:pointer; font-weight:400; opacity:.7; }
.overlay { position:fixed; inset:0; background:#0000001a; z-index:40; }
.modal { position:fixed; top:20%; left:50%; transform:translateX(-50%); width:min(420px, 92vw); background:#fff; border-radius:var(--r-lg);
  box-shadow:var(--shadow-pop); z-index:60; padding:16px; }
.menu { position:absolute; background:#fff; border-radius:var(--r-md); box-shadow:var(--shadow-pop); z-index:70; padding:6px; min-width:220px;
  max-height:340px; overflow:auto; }
.menu .it { padding:6px 9px; border-radius:6px; cursor:pointer; display:flex; align-items:center; gap:8px; }
.menu .it:hover { background:var(--gray-10); }
.menu .it.on { background:var(--indigo-20); color:var(--ui1-ink); }
.menu input.in { margin-bottom:6px; }
.banner { display:flex; gap:14px; border-radius:var(--r-lg); padding:16px 20px; background:linear-gradient(100deg, var(--orange-10), #fff6f1 60%, var(--orange-20));
  border:1px solid var(--orange-20); margin-bottom:12px; }
.banner b { color:var(--orange-100); } .banner .t { color:var(--orange-100); }
.toast { position:fixed; bottom:18px; left:50%; transform:translateX(-50%); background:var(--gray-110); color:#fff; padding:8px 14px; border-radius:var(--r-md); z-index:100; }
.insight { border:1px solid var(--line-3); border-radius:var(--r-lg); padding:14px 16px; margin-bottom:10px; display:flex; gap:12px; }
.insight .ic { width:28px; height:28px; border-radius:8px; display:grid; place-items:center; flex:none; font-weight:700; }
.insight.danger .ic { background:var(--red-20); color:var(--red-80); } .insight.warning .ic { background:var(--orange-20); color:var(--orange-80); }
.insight.info .ic { background:var(--blue-20); color:var(--blue-80); }
.insight .tt { font-weight:500; font-size:14px; } .insight .cat { font-size:11px; color:var(--ink-2); text-transform:uppercase; letter-spacing:.4px; }
.login { max-width:360px; margin:14vh auto; padding:24px; border:1px solid var(--line-3); border-radius:var(--r-lg); }
svg.chart text { font-size:10px; fill:var(--ink-2); }
code.k { background:var(--gray-20); padding:2px 6px; border-radius:4px; font-size:12px; word-break:break-all; }

/* --- Ringba relay additions --- */
.modal-bg { position:fixed; inset:0; background:#00000038; z-index:60; display:flex; align-items:flex-start; justify-content:center; padding-top:8vh; }
.modal-bg .modal { position:static; transform:none; width:min(460px, 92vw); max-height:84vh; overflow:auto; padding:18px 20px; box-shadow:0 12px 40px #0000002e; }
.modal-bg .modal.wide { width:min(880px, 94vw); }
.modal .fl { display:block; margin:10px 0 4px; color:var(--ink-2); font-size:12.5px; }
textarea.in.code, pre.code { font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12px; }
textarea.in { width:100%; resize:vertical; }
pre.code { margin:0; white-space:pre-wrap; word-break:break-all; background:var(--gray-10); border-radius:6px; padding:6px 8px; max-height:220px; overflow:auto; }
table.diff td { vertical-align:top; width:42%; } table.diff td:first-child { width:16%; white-space:nowrap; }
.box.err { background:var(--red-20); color:var(--red-80); }
.box.warnbox { background:var(--orange-20); color:var(--orange-80); }
.twist { display:inline-block; width:16px; color:var(--ink-2); cursor:pointer; user-select:none; }
tr.lvl td:first-child { color:var(--ink-1); }
.warn { color:var(--orange-70); margin-left:4px; }
.rowcb { cursor:pointer; }
.tag.click { cursor:pointer; }
.menu .mi { display:flex; align-items:center; gap:8px; padding:6px 10px; cursor:pointer; border-radius:6px; }
.menu .mi:hover { background:var(--gray-20); }
.menu .mi .num { width:18px; height:18px; border-radius:9px; background:var(--indigo-20); color:var(--ui1-ink); font-size:11px; display:inline-flex; align-items:center; justify-content:center; }
.menu .mi .num:empty { background:var(--gray-20); }
.btn.sm.danger, .btn.danger { color:var(--red-80); }
.steps { counter-reset:st; padding-left:0; list-style:none; } .steps li { counter-increment:st; margin:6px 0; padding-left:26px; position:relative; }
.steps li::before { content:counter(st); position:absolute; left:0; top:0; width:18px; height:18px; border-radius:9px; background:var(--indigo-20); color:var(--ui1-ink); font-size:11px; display:flex; align-items:center; justify-content:center; }

table.diff code.k, .kv code.k { white-space:normal; word-break:break-all; }
