/* AI Gateway admin — premium dark UI (Linear / Vercel inspired). No external assets (CSP: self only). */
:root {
  color-scheme: dark;
  --bg: #08090a; --bg2: #0b0c0e; --panel: #0e0f12; --card: #111216; --card2: #16171c; --card3: #1c1d23;
  --line: rgba(255, 255, 255, .07); --line2: rgba(255, 255, 255, .11); --line3: rgba(255, 255, 255, .16);
  --text: #f1f2f4; --text2: #d0d3d9; --muted: #8b9099; --faint: #5d626b;
  --accent: #7170ff; --accent-2: #5e6ad2; --accent-hi: #8d8cff; --accent-soft: rgba(113, 112, 255, .13); --accent-ring: rgba(113, 112, 255, .32);
  --green: #4cc38a; --amber: #e5a65b; --red: #eb5757; --sky: #6cb6f2; --blue: #7170ff;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 16px 48px -8px rgba(0, 0, 0, .7), 0 6px 18px -6px rgba(0, 0, 0, .5);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .04);
  --font: "Inter", "Inter Variable", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, .8, .24, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 400 14px/1.55 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01", "ss03";
}
::selection { background: rgba(113, 112, 255, .35); color: #fff; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .r { text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.mono-sm { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 13px; }
.hint { color: var(--faint); font-size: 12px; margin: 10px 0 0; line-height: 1.5; }
a { color: var(--accent-hi); text-decoration: none; transition: color .12s; } a:hover { color: #b3b2ff; }
b, strong { font-weight: 600; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.018em; color: var(--text); }
h1 { font-size: 20px; letter-spacing: -.022em; } h2 { font-size: 16px; } h3 { font-size: 13.5px; letter-spacing: -.01em; }
i[data-icon] { display: inline-flex; width: 16px; height: 16px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; stroke-width: 1.75; }
code { font-family: var(--mono); font-size: 12px; background: var(--card2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--text2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .16); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Controls ---------- */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  background-color: var(--card2); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius-sm);
  padding: 0 11px; height: 36px; font: inherit; font-size: 13.5px; outline: none;
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s, background .12s;
}
textarea { height: auto; padding: 10px 11px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: var(--line3); }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background-color: #18191f; }
input[readonly] { color: var(--text2); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9099' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select option, select optgroup { background: #16171c; color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius-sm);
  padding: 0 13px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; letter-spacing: -.005em;
  box-shadow: var(--shadow-sm), var(--hl); transition: background .12s, border-color .12s, box-shadow .12s, transform .06s, filter .12s;
}
.btn:hover { background: var(--card3); border-color: var(--line3); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn i[data-icon] { width: 15px; height: 15px; }
.btn.primary {
  background: linear-gradient(180deg, #8382ff 0%, #6766ee 100%); border-color: rgba(140, 139, 255, .6); color: #fff; font-weight: 550;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .22), 0 0 0 0 rgba(113, 112, 255, 0);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 18px -4px rgba(113, 112, 255, .55); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; height: 38px; }
.btn.danger { color: var(--red); }
.btn.danger-solid { background: linear-gradient(180deg, #f06464, #d94848); border-color: rgba(240, 100, 100, .6); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.danger-solid:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; filter: none; transform: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .05); color: var(--text); border-color: var(--line); }
.link-sm { font-size: 12px; font-weight: 500; color: var(--muted); } .link-sm:hover { color: var(--text); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(113, 112, 255, .22), transparent 62%),
    radial-gradient(600px 400px at 85% 110%, rgba(76, 195, 138, .07), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .01)), var(--card);
  border: 1px solid var(--line2); border-radius: 16px; padding: 30px; box-shadow: var(--shadow), var(--hl);
  animation: rise .35s var(--ease);
}
.login-card label { display: flex; flex-direction: column; gap: 7px; color: var(--text2); font-size: 12.5px; font-weight: 500; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--bg2); border-right: 1px solid var(--line); padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand b { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -.012em; line-height: 1.25; }
.brand small { color: var(--faint); font-size: 11.5px; }
.brand.big { padding: 0 0 6px; } .brand.big b { font-size: 15px; } .brand.big .logo { width: 36px; height: 36px; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 11px; letter-spacing: -.02em; color: #fff;
  background: linear-gradient(140deg, #8d8cff 0%, #5e6ad2 55%, #3d3fb0 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 0 1px rgba(113, 112, 255, .45), 0 4px 14px -4px rgba(113, 112, 255, .6);
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 7px;
  color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; letter-spacing: -.005em;
  transition: background .12s, color .12s;
}
.nav a i[data-icon] { width: 15px; height: 15px; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a.active { background: rgba(255, 255, 255, .06); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.nav a.active i { color: var(--accent-hi); opacity: 1; }
.nav a em {
  margin-left: auto; font-style: normal; font-size: 10.5px; font-weight: 600; color: var(--muted);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; line-height: 17px;
  font-variant-numeric: tabular-nums;
}
.nav a.active em { color: var(--text2); }
.nav a em:empty { display: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.health { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); padding: 0 10px; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(76, 195, 138, .15), 0 0 10px rgba(76, 195, 138, .6); flex: none; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(76, 195, 138, .05), 0 0 12px rgba(76, 195, 138, .8); } }
.me { display: flex; align-items: center; gap: 9px; padding: 4px 4px 0 8px; }
.me #me-name { flex: 1; font-weight: 500; font-size: 13px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff;
  background: linear-gradient(140deg, #6c6bf0, #3b3d9e); box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}

.main { min-width: 0; background: radial-gradient(1200px 400px at 60% -200px, rgba(113, 112, 255, .055), transparent 70%); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 32px; min-height: 68px; background: rgba(8, 9, 10, .72); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input:not([type=checkbox]) { height: 32px; font-size: 12.5px; }
.page { padding: 24px 32px 48px; max-width: 1760px; animation: fade .22s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Cards & grids ---------- */
.card {
  position: relative; background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0) 120px), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, .3);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 13px; font-weight: 600; color: var(--text2); }
.card-head .muted { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; } .grid-3-1 > .card { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  position: relative; overflow: hidden; background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0)), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 13px; box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, .3);
  transition: border-color .15s, transform .15s;
}
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(141, 140, 255, .45), transparent); opacity: .55; }
.kpi:hover { border-color: var(--line2); }
.kpi .l { color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.kpi .v { font-size: 25px; font-weight: 600; margin-top: 6px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .s { color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar p { margin: 0; max-width: 760px; font-size: 13px; line-height: 1.55; }
.page > p.muted { font-size: 13px; margin: 0 0 12px; max-width: 860px; line-height: 1.55; }
.spacer { flex: 1; }
.search { min-width: 260px; padding-left: 32px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235d626b' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 220px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: rgba(255, 255, 255, .05); stroke-width: 1; stroke-dasharray: 2 4; }
.chart rect { transition: opacity .15s; } .chart rect:hover { opacity: .78; }
#c-cost rect { fill: #4cc38a; } #c-tokens rect { fill: #6cb6f2; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 11.5px; margin-top: 8px; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.sw.cached { background: #7b8cff; } .sw.uncached { background: #f3b679; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th {
  color: var(--faint); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  background: rgba(14, 15, 18, .96); white-space: nowrap; position: sticky; top: 0; z-index: 1; padding-top: 9px; padding-bottom: 9px;
}
.table td { color: var(--text2); white-space: nowrap; }
.table td b { color: var(--text); font-weight: 550; }
.table td.r, .table th.r { text-align: right; }
.table td.r { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; }
.table tbody tr { transition: background .1s; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.table td.clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.table td.name b, .table td.name .sub { display: block; overflow: hidden; text-overflow: ellipsis; }
.table .sub { color: var(--faint); font-size: 11.5px; margin-top: 1px; }
.empty { text-align: center; color: var(--muted); padding: 44px 14px !important; white-space: normal !important; }
.card:not(.flush) .table th { background: transparent; }

/* ---------- Badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 21px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; border: 1px solid var(--line2); white-space: nowrap; color: var(--text2); background: rgba(255, 255, 255, .04);
  vertical-align: middle; letter-spacing: -.005em;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill:not(.ok):not(.err):not(.warn):not(.off):not(.backup)::before { display: none; }
.pill.ok { color: var(--green); border-color: rgba(76, 195, 138, .28); background: rgba(76, 195, 138, .09); }
.pill.ok::before { box-shadow: 0 0 6px var(--green); }
.pill.err { color: #f27474; border-color: rgba(235, 87, 87, .3); background: rgba(235, 87, 87, .09); }
.pill.warn { color: var(--amber); border-color: rgba(229, 166, 91, .3); background: rgba(229, 166, 91, .09); }
.pill.off { color: var(--muted); background: rgba(255, 255, 255, .03); }
.pill.backup { color: var(--sky); border-color: rgba(108, 182, 242, .3); background: rgba(108, 182, 242, .09); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; height: 20px; padding: 0 7px; margin: 1px 4px 1px 0; border-radius: 6px;
  background: var(--accent-soft); color: #c4c3ff; border: 1px solid rgba(113, 112, 255, .2); white-space: nowrap; font-weight: 500;
}
.chip.more { background: rgba(255, 255, 255, .05); color: var(--muted); border-color: var(--line); }
.chip.map { background: rgba(76, 195, 138, .09); color: #a5e6c6; border-color: rgba(76, 195, 138, .2); }
.chip.map em { font-style: normal; color: var(--muted); }

/* ---------- Account / provider cards ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.acc {
  position: relative; background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0) 140px), var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, .3); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.acc:hover { border-color: var(--line2); box-shadow: var(--hl), 0 10px 30px -12px rgba(0, 0, 0, .7); }
.acc.is-backup { border-color: rgba(108, 182, 242, .28); }
.acc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.acc-top h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.015em; }
.acc-top .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.acc-top > div:first-child { min-width: 0; }
.acc-right { display: flex; align-items: center; gap: 4px; }
.acc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.acc-stats div { background: var(--panel); padding: 10px 12px; min-width: 0; }
.acc-stats b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.acc-stats span { display: block; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.acc .kv { font-size: 13px; }
.acc-note { font-size: 12.5px; color: #eebf86; background: rgba(229, 166, 91, .07); border: 1px solid rgba(229, 166, 91, .22); border-radius: 9px; padding: 9px 11px; line-height: 1.5; }
.acc-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.acc-empty {
  grid-column: 1 / -1; border: 1px dashed var(--line2); border-radius: 14px; padding: 48px 24px; text-align: center; color: var(--muted);
  background: radial-gradient(400px 160px at 50% 0, rgba(113, 112, 255, .06), transparent 70%);
}
.acc-empty h3 { color: var(--text); font-size: 15px; margin-bottom: 6px; } .acc-empty p { margin: 0; font-size: 13px; }

/* ---------- Mini list ---------- */
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; transition: border-color .12s; }
.mini-row:hover { border-color: var(--line2); }
.mini-row b { font-weight: 600; font-size: 13px; } .mini-row .sub { color: var(--faint); font-size: 11.5px; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(4, 5, 7, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 30; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 8px; right: 8px; bottom: 8px; width: min(620px, calc(100vw - 16px));
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0) 160px), #0f1014;
  border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); z-index: 31; display: flex; flex-direction: column;
  overflow: hidden; animation: slide .28s var(--ease);
}
.drawer.wide { width: min(980px, calc(100vw - 16px)); }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, .2); }
.drawer-foot:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field > span { color: var(--text2); font-size: 12.5px; font-weight: 500; letter-spacing: -.005em; }
.field > span .muted { font-weight: 400; }
.field .help { color: var(--faint); font-size: 12px; line-height: 1.5; font-weight: 400; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.drawer .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  background: var(--card); transition: border-color .12s, background .12s; font-size: 13px;
}
.check:hover { border-color: var(--line2); background: var(--card2); }
.check:has(> input:checked) { border-color: rgba(113, 112, 255, .4); background: linear-gradient(180deg, rgba(113, 112, 255, .07), rgba(113, 112, 255, .02)); }
.check input { margin-top: 2px; flex: none; }
.check b { font-weight: 550; }
.check .sub { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; line-height: 1.45; }
.check-actions { display: flex; gap: 8px; margin-top: 8px; }
/* provider model checklist */
.drawer .checks:has(.model-row) { grid-template-columns: 1fr; }
.model-row { align-items: center !important; padding: 9px 12px !important; }
.model-row .mono { font-size: 12.5px; color: var(--text); }
.model-row .to { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 2px 8px 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); white-space: nowrap; }
.model-row .to input { width: 13px; height: 13px; margin: 0; }
.add-model { display: flex; gap: 8px; margin-top: 8px; }
.add-model input:not([type=checkbox]) { flex: 1; min-width: 0; }
.add-model .btn { height: 36px; }
.callout { border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; line-height: 1.5; border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); }
.callout.success { background: rgba(76, 195, 138, .07); border-color: rgba(76, 195, 138, .26); color: #cdeedd; }
.callout.warn { background: rgba(229, 166, 91, .07); border-color: rgba(229, 166, 91, .26); color: #f1d6b3; }
.callout b { color: var(--text); }
.keybox { display: flex; gap: 8px; } .keybox input { flex: 1; font-family: var(--mono); font-size: 12.5px !important; }
textarea.json { width: 100%; min-height: 280px; font-family: var(--mono); font-size: 12px; resize: vertical; background-color: #0b0c0f; }
.device-code {
  font: 600 30px/1.2 var(--mono); letter-spacing: 6px; color: #fff; display: inline-block; padding: 14px 22px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(113, 112, 255, .14), rgba(113, 112, 255, .05)); border: 1px solid rgba(113, 112, 255, .35);
  box-shadow: 0 0 30px -10px rgba(113, 112, 255, .6);
}
.steps { padding-left: 20px; margin: 0 0 16px; color: var(--text2); } .steps li { margin: 12px 0; padding-left: 4px; } .steps li::marker { color: var(--accent-hi); font-weight: 600; }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 9px 14px; margin: 0; font-size: 13px; align-items: baseline; }
.kv dt { color: var(--faint); font-size: 12.5px; } .kv dd { margin: 0; overflow-wrap: anywhere; color: var(--text2); min-width: 0; }
.kv dd.mono, .kv dd.mono-sm { word-break: break-all; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.meta > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; font-variant-numeric: tabular-nums; }
.meta > div > span:first-child { display: block; color: var(--faint); font-size: 10.5px; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.msg { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; background: var(--card); }
.msg-head { padding: 7px 12px; background: rgba(255, 255, 255, .025); border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.msg-body { padding: 11px 12px; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; font-size: 13px; color: var(--text2); line-height: 1.6; }
.msg.role-user .msg-head { color: var(--sky); } .msg.role-assistant .msg-head { color: var(--green); } .msg.role-tool .msg-head { color: var(--amber); } .msg.role-system .msg-head { color: var(--accent-hi); }
details summary { cursor: pointer; color: var(--muted); margin: 8px 0; font-size: 13px; } details summary:hover { color: var(--text); }
pre.raw { white-space: pre-wrap; word-break: break-word; background: #0b0c0f; border: 1px solid var(--line); padding: 12px; border-radius: 10px; max-height: 400px; overflow: auto; font: 12px/1.55 var(--mono); color: var(--text2); }
.section-title { margin: 22px 0 10px; font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

/* ---------- Menu, confirm, toasts ---------- */
.menu { position: fixed; z-index: 40; min-width: 190px; background: rgba(22, 23, 28, .96); backdrop-filter: blur(12px); border: 1px solid var(--line2); border-radius: 11px; padding: 5px; box-shadow: var(--shadow); animation: pop .14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-3px); } to { opacity: 1; transform: none; } }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: var(--text2); padding: 7px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; }
.menu button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.menu button.danger { color: #f27474; } .menu button.danger:hover { background: rgba(235, 87, 87, .1); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }
.confirm { position: fixed; inset: 0; z-index: 50; background: rgba(4, 5, 7, .6); backdrop-filter: blur(4px); display: grid; place-items: center; animation: fadein .15s ease; }
.confirm-box { width: min(420px, 92vw); background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0)), #111216; border: 1px solid var(--line2); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); animation: rise .2s var(--ease); }
.confirm-box h3 { font-size: 15px; } .confirm-box p { margin: 8px 0 20px; font-size: 13px; line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; background: rgba(22, 23, 28, .96); backdrop-filter: blur(12px); border: 1px solid var(--line2);
  border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 400px; font-size: 13px; animation: slide .22s var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex: none; }
.toast.err::before { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ---------- Pager / combo / prices ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.pager b { color: var(--text2); font-weight: 550; }
.pager:empty { display: none; }
.pager .pages { display: flex; gap: 4px; align-items: center; }
.pager .pg { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--text2); cursor: pointer; font: inherit; font-size: 12px; transition: background .12s, border-color .12s; }
.pager .pg:hover { background: rgba(255, 255, 255, .05); border-color: var(--line2); }
.pager .pg.on { background: var(--accent-soft); border-color: rgba(113, 112, 255, .45); color: #fff; font-weight: 600; }
.pager .pg:disabled { opacity: .35; cursor: default; }
.pager select { height: 28px; padding: 0 28px 0 8px; font-size: 12px; background-position: right 8px center; }
.pager label { display: inline-flex; align-items: center; gap: 6px; }
.combo { position: relative; }
.combo input { width: 200px; padding-right: 26px !important; }
.combo-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 5px; }
.combo-clear:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.price-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.price-row:last-child { border-bottom: 0; }
.price-row label { display: flex; flex-direction: column; font-size: 10.5px; color: var(--faint); gap: 5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.price-row input { width: 100%; font-variant-numeric: tabular-nums; }
.price-row .btn.sm { height: 36px; padding: 0 14px; }
.price-row > div:first-child, .price-row > b { font-size: 13px; }

/* ---------- Name mapping ---------- */
.map-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin-bottom: 8px; transition: border-color .12s, opacity .12s, background .12s;
}
.map-row:has(> input:checked) { border-color: rgba(113, 112, 255, .35); background: linear-gradient(180deg, rgba(113, 112, 255, .06), rgba(113, 112, 255, .015)); }
.map-row.off { opacity: .5; }
.map-row.off:hover { opacity: .75; }
.map-row select { width: 100%; }
.map-row b { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.map-row .sub { display: block; color: var(--faint); font-size: 12px; font-weight: 400; }
.switch { position: relative; display: inline-block; width: 32px; height: 18px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: rgba(255, 255, 255, .12); border-radius: 999px; cursor: pointer; transition: background .18s; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .18s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .grid2, .grid-3-1 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 4px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav a.active::before { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; flex-direction: row; align-items: center; }
  .health { display: none; }
  .topbar { padding: 14px 18px; } .page { padding: 18px 18px 40px; }
  .account-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; flex: 1; }
}
@media (max-width: 640px) { .drawer .checks { grid-template-columns: 1fr; } .meta { grid-template-columns: 1fr 1fr; } .kv { grid-template-columns: 1fr; } .acc-stats { grid-template-columns: repeat(2, 1fr); } .price-row { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Density: let chip cells wrap so wide tables fit without horizontal scroll */
.table td:not(.clip):has(> .chip) { white-space: normal; min-width: 250px; max-width: 400px; line-height: 1.9; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
@media (max-width: 1500px) { .table th, .table td { padding-left: 12px; padding-right: 12px; } }
#log td.clip { max-width: 190px; }
#log td.clip .chip { margin-right: 6px; }
.login-card .error:empty { display: none; }
.login-card .btn.block { margin-top: 4px; }
