/* Shravelle client panel — clean, bright SaaS design (light) with a matching dark mode. */
:root, :root[data-theme="light"] {
  --bg: #F7F8FA; --panel: #FFFFFF; --panel2: #F4F5F8; --hover: #F6F7FB; --border: #E7E9EE; --border2: #EFF1F4;
  --text: #0F172A; --text2: #334155; --muted: #64748B; --faint: #94A3B8;
  --accent: #635BFF; --accent-ink: #FFFFFF; --accent-soft: #F0EFFF; --accent-text: #4B44E0; --accent2: #0EA5E9; --link: #5048E5;
  --ok: #059669; --ok-bg: #ECFDF5; --ok-ink: #047857; --warn: #D97706; --warn-bg: #FFFBEB; --warn-ink: #B45309;
  --bad: #DC2626; --bad-bg: #FEF2F2; --bad-ink: #B91C1C; --info-bg: #EFF6FF; --info-ink: #1D4ED8; --purple: #8B5CF6;
  --side: #FBFBFD; --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .02);
  --shadow-lg: 0 12px 32px -12px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .04);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --num: Inter, -apple-system, sans-serif; --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --grid: #EEF0F4; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A0B10; --panel: #111218; --panel2: #171922; --hover: #161822; --border: #22252F; --border2: #1A1C24;
  --text: #EDEEF3; --text2: #C6C9D4; --muted: #8C91A2; --faint: #6B7083;
  --accent: #7C74FF; --accent-ink: #FFFFFF; --accent-soft: #1E1C3A; --accent-text: #C9C5FF; --accent2: #38BDF8; --link: #A5A0FF;
  --ok: #34D399; --ok-bg: rgba(52, 211, 153, .12); --ok-ink: #6EE7B7; --warn: #FBBF24; --warn-bg: rgba(251, 191, 36, .12); --warn-ink: #FCD34D;
  --bad: #F87171; --bad-bg: rgba(248, 113, 113, .13); --bad-ink: #FCA5A5; --info-bg: rgba(56, 189, 248, .12); --info-ink: #7DD3FC; --purple: #A78BFA;
  --side: #0D0E14; --shadow: none; --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .6); --grid: #1C1F28; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 14px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
h1, h2, h3 { letter-spacing: -0.015em; }
::selection { background: var(--accent-soft); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--border); padding: 14px 10px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15.5px; padding: 6px 10px 14px; letter-spacing: -0.01em; }
.brand i { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #8B7CFF, #635BFF 55%, #3B82F6); display: inline-grid; place-items: center; box-shadow: 0 2px 6px rgba(99, 91, 255, .35); }
.brand i::after { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 2.5px solid #fff; }
.ws { display: flex; align-items: center; gap: 10px; margin: 0 2px 10px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); position: relative; }
.ws .av { width: 26px; height: 26px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.ws .t { min-width: 0; flex: 1; line-height: 1.25; } .ws .t b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ws .t span { font-size: 11.5px; color: var(--muted); }
.ws > svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.ws select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; color: var(--text2); font-size: 13.5px; font-weight: 500; }
.nav a svg { width: 16px; height: 16px; flex: none; color: var(--faint); }
.nav a:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.nav a:hover svg { color: var(--text2); }
.nav a.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--border), var(--shadow); font-weight: 600; }
.nav a.on svg { color: var(--accent); }
:root[data-theme="dark"] .nav a.on { background: var(--panel2); box-shadow: 0 0 0 1px var(--border); }
.nav a .badge { margin-left: auto; }
.nav .sec { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--faint); padding: 14px 10px 4px; }
.side .foot { margin-top: auto; padding: 10px 4px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.side .foot a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; color: var(--text2); font-size: 13px; }
.side .foot a:hover { background: var(--hover); text-decoration: none; }
.side .foot svg { width: 16px; height: 16px; color: var(--faint); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; }
.me .av { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #C7D2FE, #A5B4FC); color: #312E81; font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.me .t { min-width: 0; line-height: 1.25; } .me .t b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .me .t span { font-size: 11.5px; color: var(--muted); }

.mainwrap { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-right: auto; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; flex: 0 1 300px; }
.search input { width: 100%; padding: 7px 46px 7px 32px; background: var(--panel); font-size: 13px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 500 11px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--panel2); }
.main { padding: 24px 28px 56px; max-width: 1480px; width: 100%; }
.top { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { font-size: 22px; font-weight: 650; margin: 0 auto 0 0; letter-spacing: -0.02em; }
.seg { display: inline-flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: 12.5px; color: var(--muted); border-radius: 7px; font-weight: 500; box-shadow: none; }
.seg button:hover { color: var(--text); background: transparent; }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.iconbtn { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; color: var(--text2); }
.iconbtn svg { width: 16px; height: 16px; }

/* ---------- controls */
select, input, textarea, button { font: inherit; font-size: 13.5px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 7px 11px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { width: 100%; font-family: var(--mono); }
button { cursor: pointer; font-weight: 500; box-shadow: var(--shadow); transition: background .12s, border-color .12s; }
button:hover { background: var(--hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(99, 91, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .15); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
button.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); color: var(--bad); }
button.small, .small button { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }

/* ---------- cards & grids */
.grid { display: grid; gap: 16px; }
.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)); }
@media (max-width: 1180px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .main, .topbar { padding-left: 16px; padding-right: 16px; } .search { display: none; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 14px; color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat { position: relative; padding: 16px 18px; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -0.025em; margin: 6px 0 2px; font-family: var(--num); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .v a { color: inherit; } .stat .v .badge { font-size: 15px; padding: 3px 10px; }
.stat .l + .v + .l { font-size: 12px; color: var(--faint); }

/* ---------- tables */
.tblwrap { overflow-x: auto; margin: 0 -20px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-top: 1px solid var(--border2); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--panel2); letter-spacing: .01em; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; } .tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border2); vertical-align: middle; font-size: 13.5px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--num); }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--text2); white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge:empty::before, .badge.nodot::before { display: none; }
.b-ok { background: var(--ok-bg); color: var(--ok-ink); } .b-warn { background: var(--warn-bg); color: var(--warn-ink); }
.b-bad { background: var(--bad-bg); color: var(--bad-ink); } .b-info { background: var(--info-bg); color: var(--info-ink); }

.muted { color: var(--muted); } .small { font-size: 12.5px; } .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .sp { flex: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 20px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: 13.5px; }
.tabs a.on { color: var(--text); border-color: var(--accent); text-decoration: none; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }

/* ---------- charts */
.chart { position: relative; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 8px; }
.chart .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart .tip { position: absolute; pointer-events: none; z-index: 3; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; min-width: 150px; display: none; white-space: nowrap; }
.chart .tip b { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.chart .tip div { display: flex; align-items: center; gap: 8px; } .chart .tip div span { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.chart .tip i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.wf { position: relative; height: 18px; background: var(--panel2); border-radius: 4px; }
.wf span { position: absolute; top: 3px; height: 12px; border-radius: 3px; min-width: 2px; }

.log { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.sev-ERROR, .sev-FATAL { color: var(--bad); } .sev-WARN { color: var(--warn); } .sev-INFO { color: var(--accent2); } .sev-DEBUG, .sev-TRACE { color: var(--muted); }

/* ---------- auth (split screen) */
.authwrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
@media (max-width: 900px) { .authwrap { grid-template-columns: 1fr; } .authart { display: none; } }
.authform { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 96px); background: var(--panel); }
.authform .brand { padding: 0 0 28px; }
.authform h2 { font-size: 26px; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.025em; }
.authform p.sub { color: var(--muted); margin: 0 0 24px; }
.authform form { display: flex; flex-direction: column; gap: 12px; max-width: 380px; }
.authform label { font-size: 13px; font-weight: 500; color: var(--text2); display: flex; flex-direction: column; gap: 6px; }
.authform input { padding: 10px 12px; font-size: 14px; }
.authform button.primary { padding: 10px; font-size: 14px; margin-top: 6px; }
.authart { position: relative; overflow: hidden; background: radial-gradient(60% 50% at 20% 20%, #E0E7FF 0%, transparent 60%), radial-gradient(50% 50% at 85% 30%, #FCE7F3 0%, transparent 60%), radial-gradient(60% 60% at 60% 90%, #CFFAFE 0%, transparent 60%), #F5F6FF; display: flex; align-items: center; justify-content: center; padding: 48px; }
.authart .q { max-width: 460px; }
.authart .q h3 { font-size: 30px; line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 14px; color: #0F172A; font-weight: 650; }
.authart .q p { color: #475569; font-size: 15px; margin: 0 0 22px; }
.authart .mini { background: #fff; border: 1px solid #E7E9EE; border-radius: 14px; box-shadow: 0 24px 48px -20px rgba(15, 23, 42, .25); padding: 16px 18px; color: #0F172A; }
.authart .mini .k { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 10px; }
.authart .mini .k div { font-size: 11.5px; color: #64748B; } .authart .mini .k b { display: block; font-size: 18px; color: #0F172A; letter-spacing: -0.02em; }
.form label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; font-weight: 500; } .form input, .form select { width: 100%; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 20; font-weight: 500; font-size: 13.5px; }
.md h3 { color: var(--text); font-size: 15px; margin: 14px 0 6px; } .md p { margin: 6px 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty::before { content: ""; display: block; width: 36px; height: 36px; margin: 0 auto 10px; border-radius: 10px; background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 12h4l3-8 4 16 3-8h4'/%3E%3C/svg%3E") center / 18px no-repeat; }
.statusbar { display: flex; gap: 2px; } .statusbar i { flex: 1; height: 26px; border-radius: 2px; background: var(--ok); }
details.card summary { color: var(--text); font-weight: 600; }

.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-radius: 10px; padding: 9px 14px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--accent2) 40%, transparent); }

/* ---------- flame graph */
.flame { position: relative; width: 100%; overflow: hidden; font: 11px/18px var(--mono); }
.flame .fr { position: absolute; height: 18px; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; border-radius: 3px; cursor: pointer; box-sizing: border-box; }
.flame .fr:hover { filter: brightness(1.08); outline: 1px solid var(--text); }
.flame .fr.hit { color: #fff; outline: 2px solid #f0f; }
