:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel2: #f0f2f5; --text: #18202b; --muted: #5d6878; --line: #e1e5eb;
  --accent: #2f6fed; --accent-weak: #e7efff; --ok: #1f8f4e; --ok-weak: #e3f5ea; --warn: #b26a00; --warn-weak: #fff3dc;
  --err: #c9372c; --err-weak: #fde8e6; --code: #f3f4f7; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0f141b; --panel: #161d27; --panel2: #1d2632; --text: #e6ebf2; --muted: #95a1b2; --line: #2a3442;
  --accent: #6c9cff; --accent-weak: #1d2b47; --ok: #4cc27f; --ok-weak: #15301f; --warn: #f0b44c; --warn-weak: #33280f;
  --err: #ff7a6e; --err-weak: #3a1a18; --code: #1b2330; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code); padding: 12px; border-radius: 8px; overflow: auto; max-height: 420px; margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.layout { display: grid; grid-template-columns: 232px 1fr auto; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 22px; padding: 0 0 8px; }
.logo { color: var(--accent); } .ver { font-weight: 400; font-size: 11px; color: var(--muted); }
nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
nav a:hover { background: var(--panel2); text-decoration: none; }
nav a.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; gap: 6px; padding: 10px; }
main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
#menu-btn { display: none; }
.crumbs { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); font-weight: 400; }
.search input { width: 260px; }
.view { padding: 22px 24px 60px; overflow-y: auto; flex: 1; }
.help { width: 360px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.help-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.help-body { padding: 6px 18px 30px; overflow-y: auto; }
.help-body h4 { margin: 18px 0 6px; }
.help-body .note-box { background: var(--accent-weak); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 820px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.tight { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.stat .num { font-size: 26px; font-weight: 700; } .stat .lbl { color: var(--muted); font-size: 12px; }
.stat .sub { font-size: 12px; margin-top: 2px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--panel2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel2); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-weak); color: var(--ok); } .pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.err, .pill.error { background: var(--err-weak); color: var(--err); } .pill.info { background: var(--accent-weak); color: var(--accent); }
.pill.gray { background: var(--panel2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.gray { background: var(--muted); } .dot.warn { background: var(--warn); }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--panel2); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; text-decoration: none; }
.check { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: none; }
.check .ic { font-size: 16px; line-height: 1.3; }
.check .fix { margin-top: 4px; font-size: 13px; background: var(--panel2); padding: 6px 10px; border-radius: 6px; }
.score { width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; font-weight: 800; border: 6px solid var(--line); }
.score.ok { border-color: var(--ok); color: var(--ok); } .score.warn { border-color: var(--warn); color: var(--warn); } .score.error { border-color: var(--err); color: var(--err); }
.steps { counter-reset: s; display: grid; gap: 12px; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.step .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); font-weight: 700; color: var(--muted); }
.step.done .n { background: var(--ok); color: #fff; } .step.current .n { background: var(--accent); color: #fff; }
.choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice button { text-align: left; padding: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--text); font: inherit; }
.choice button.sel { border-color: var(--accent); background: var(--accent-weak); }
.choice b { display: block; margin-bottom: 4px; }
.timeline { position: relative; }
.ev { display: grid; grid-template-columns: 150px 22px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.ev .t { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty .big { font-size: 30px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: 80vw; }
.toast.err { background: var(--err); color: #fff; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-weak); padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-weak); }
.callout.ok { border-color: var(--ok); background: var(--ok-weak); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.login { display: grid; place-items: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); padding: 30px; border-radius: 14px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); }
.login-card .btn { margin-top: 14px; width: 100%; }
svg.chart { width: 100%; height: 180px; display: block; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .area { fill: var(--accent-weak); }
svg.chart text { fill: var(--muted); font-size: 10px; }
svg.chart .grid { stroke: var(--line); }
.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  #menu-btn { display: inline-block; }
  .help { position: fixed; inset: 0 0 0 auto; width: 100%; z-index: 30; }
  .g2, .g4, .choice { grid-template-columns: 1fr; }
  .search input { width: 140px; }
  .view { padding: 16px; }
  .ev { grid-template-columns: 1fr; }
}
.who { padding: 8px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.who b { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-card details { margin-top: 10px; }
.login-card .callout { margin-top: 10px; }
/* metrics charts */
.chart-box .chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chart-box .lg { font-size: 11px; color: var(--muted); margin-left: 10px; white-space: nowrap; }
.chart-box .lg::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; background: var(--accent); }
svg.chart .line.s2, .lg.s2::before { stroke: var(--ok); background: var(--ok) !important; }
svg.chart .line.s3, .lg.s3::before { stroke: var(--err); background: var(--err) !important; }
svg.chart .line.s4, .lg.s4::before { stroke: var(--warn); background: var(--warn) !important; }
.stat .num.bad { color: var(--err); }
td.num { text-align: right; } .trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--accent-weak); }
/* trace waterfall */
.wf-row { display: grid; grid-template-columns: minmax(200px, 2fr) 150px 3fr; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.wf-label { font-size: 13px; } .wf-label .mono { word-break: break-all; }
.wf-track { position: relative; height: 12px; background: var(--panel2); border-radius: 6px; }
.wf-bar { position: absolute; top: 0; height: 100%; min-width: 3px; border-radius: 6px; background: var(--accent); }
.wf-bar.q { background: var(--warn); } .wf-bar.bad { background: var(--err); }
#acct-badge { margin-left: 8px; }
@media (max-width: 760px) { .wf-row { grid-template-columns: 1fr; } }
/* Settings and Roles */
.setting { margin-bottom: 10px; }
table.roles td, table.roles th { white-space: nowrap; vertical-align: top; }
table.roles td:first-child { white-space: normal; min-width: 260px; }
table.roles select.scope { width: auto; min-width: 110px; }
table.roles select.scope.on { border-color: var(--accent, #3b82f6); font-weight: 600; }
#sso-box .btn { display: block; text-align: center; }
.setting input:disabled, .setting select:disabled { opacity: .6; cursor: not-allowed; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.login-card h2 { margin: 6px 0 4px; }
