:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --sidebar: #0d0f12;
  --surface: #111419;
  --surface-raised: #161a20;
  --surface-hover: #1a1f26;
  --border: #252a32;
  --border-strong: #343b46;
  --text: #f4f5f7;
  --muted: #969da8;
  --quiet: #656d79;
  --accent: #f07932;
  --accent-hover: #fb8a45;
  --accent-soft: rgba(240, 121, 50, 0.1);
  --success: #55c58a;
  --danger: #ef6b73;
  --warning: #e7b657;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { scrollbar-width: thin; scrollbar-color: #303640 transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg) !important;
  color: #d9dde3;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a, label[for], label:has(input[type="file"]) { -webkit-tap-highlight-color: transparent; }
button { transition: transform 140ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease; }
button:active:not(:disabled), a.nav-link:active, .logout-link:active { transform: scale(0.97); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid rgba(240, 121, 50, .75);
  outline-offset: 2px;
}

.app-sidebar {
  width: 244px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand-row { height: 72px; display: flex; align-items: center; gap: 11px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; color: #111; background: var(--accent); border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset; }
.brand-name { display: block; color: var(--text); font-weight: 650; font-size: 13px; letter-spacing: -.01em; line-height: 1.25; }
.brand-meta { display: block; color: var(--quiet); font-size: 10px; line-height: 1.35; letter-spacing: .02em; }
.sidebar-close { display: none; margin-left: auto; padding: 7px; color: var(--muted); border-radius: 7px; }
.sidebar-nav { padding: 17px 12px; }
.nav-section { padding: 0 10px 7px; margin: 0; color: #59616d; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.nav-section-spaced { margin-top: 20px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; color: #8c949f; border: 1px solid transparent; border-radius: 7px; font-size: 13px; font-weight: 500; transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 140ms var(--ease-out); }
.nav-link svg { color: #6f7783; }
.nav-link:hover { color: #d9dde3; background: #14171c; }
.nav-link.active { color: #fff; background: #191c21; border-color: #292e36; box-shadow: 0 1px 1px rgba(0,0,0,.2); }
.nav-link.active::before { content: ""; position: absolute; left: -13px; width: 2px; height: 18px; border-radius: 0 2px 2px 0; background: var(--accent); }
.nav-link.active svg { color: var(--accent); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.runtime-status { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px 9px; }
.runtime-status .status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(85,197,138,.1); }
.runtime-status strong, .runtime-status small { display: block; }
.runtime-status strong { color: #cfd3d9; font-size: 11px; font-weight: 600; }
.runtime-status small { margin-top: 1px; color: var(--quiet); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.logout-link { display: grid; place-items: center; width: 33px; height: 33px; color: #737b87; border-radius: 7px; transition: color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out); }
.logout-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.logout-link:hover { color: #e1e4e8; background: var(--surface-hover); }

.app-main { margin-left: 244px; min-width: 0; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 32px; background: rgba(11,13,16,.88); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; color: var(--text); font-size: 18px; line-height: 1.2; font-weight: 650; letter-spacing: -.025em; }
.topbar-kicker { margin: 0 0 3px; color: var(--quiet); font-size: 9px; line-height: 1; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; }
.mobile-menu { display: none; width: 34px; height: 34px; place-items: center; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.page-content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 28px 32px 48px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; color: #fff; font-size: 12px; font-weight: 600; line-height: 1; box-shadow: 0 1px 1px rgba(0,0,0,.18); }
.btn-primary { color: #15100c; background: var(--accent); border-color: rgba(255,255,255,.08); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #171a1f; border-color: var(--border-strong); color: #d8dce1; }
.btn-secondary:hover { background: #1e2229; color: #fff; }

/* Normalize legacy utility markup into the new visual system. */
body .bg-slate-950 { background-color: var(--bg) !important; }
body .bg-slate-900 { background-color: var(--surface) !important; }
body .bg-slate-800 { background-color: var(--surface-raised) !important; }
body .bg-slate-800\/50 { background-color: rgba(22,26,32,.65) !important; }
body .bg-slate-800\/30 { background-color: rgba(22,26,32,.4) !important; }
body .border-slate-800, body .border-slate-700, body .border-slate-700\/50, body .border-slate-600 { border-color: var(--border) !important; }
body .text-white { color: var(--text) !important; }
body .text-slate-200, body .text-slate-300 { color: #c8cdd4 !important; }
body .text-slate-400 { color: var(--muted) !important; }
body .text-slate-500 { color: var(--quiet) !important; }
body .text-slate-600 { color: #515965 !important; }
body .text-kiro { color: var(--accent) !important; }
body .bg-kiro { background-color: var(--accent) !important; }
body .hover\:bg-kiro-dark:hover { background-color: var(--accent-hover) !important; }
body .rounded-xl { border-radius: 10px !important; }
body .rounded-lg { border-radius: 7px !important; }
body .shadow-2xl { box-shadow: 0 24px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.02) !important; }

/* Cards, controls and data surfaces. */
.page-content > .grid > .bg-slate-900, .page-content > .bg-slate-900, .page-content .lg\:col-span-2.bg-slate-900 {
  box-shadow: 0 1px 0 rgba(255,255,255,.015) inset, 0 1px 2px rgba(0,0,0,.14);
}
input:not([type="file"]), select, textarea {
  min-height: 38px;
  background: #0e1115 !important;
  border-color: var(--border-strong) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 1px rgba(0,0,0,.2) inset;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}
input:hover, select:hover, textarea:hover { border-color: #454d59 !important; }
input:focus, select:focus, textarea:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(240,121,50,.12) !important; outline: none !important; }
input::placeholder, textarea::placeholder { color: #535b66 !important; }
select { cursor: pointer; }
label { letter-spacing: -.005em; }
code, pre, .font-mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace !important; font-variant-ligatures: none; }
table { border-collapse: collapse; }
thead { background: #0f1216 !important; }
th { color: #727b87 !important; font-size: 10px !important; font-weight: 700 !important; letter-spacing: .08em; }
tbody tr { border-color: var(--border) !important; }
tbody tr:hover { background: rgba(255,255,255,.018) !important; }
.progress-bar { transition: width 240ms var(--ease-out); }

.app-toast { max-width: min(380px, calc(100vw - 32px)); padding: 11px 14px 11px 38px; color: #e9ebee; background: #171a1f; border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: 0 18px 50px rgba(0,0,0,.42); font-size: 12px; font-weight: 550; opacity: 0; transform: translateY(12px) scale(.98); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.app-toast::before { content: ""; position: absolute; left: 14px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--success); transform: translateY(-50%); box-shadow: 0 0 0 3px rgba(85,197,138,.1); }
.app-toast.is-error::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,107,115,.1); }
.app-toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 35; padding: 0; border: 0; background: rgba(0,0,0,.58); backdrop-filter: blur(2px); opacity: 0; }

/* Dialogs share one crisp, restrained motion language. */
#addModal, #customAlert { transition: opacity 180ms var(--ease-out); }
#addModal > div, #customAlert > div { transform-origin: center; transition: transform 200ms var(--ease-out), opacity 180ms var(--ease-out); }
#addModal.hidden { display: flex !important; visibility: hidden; pointer-events: none; opacity: 0; }
#addModal.hidden > div { opacity: 0; transform: translateY(6px) scale(.98); }
#addModal:not(.hidden), #customAlert { opacity: 1; }
#addModal:not(.hidden) > div, #customAlert > div { opacity: 1; transform: translateY(0) scale(1); }
.tab-btn { transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 140ms var(--ease-out); }

@media (hover: hover) and (pointer: fine) {
  .page-content .group:hover { border-color: #363d47 !important; }
}

@media (max-width: 840px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0,0,0,.45); transition: transform 220ms var(--ease-out); }
  .sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; pointer-events: none; transition: opacity 180ms ease; }
  .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-close { display: inline-grid; place-items: center; }
  .app-main { margin-left: 0; }
  .topbar { height: 64px; padding: 0 18px; }
  .topbar-kicker { display: none; }
  .topbar h1 { font-size: 16px; }
  .mobile-menu { display: grid; }
  .page-content { padding: 20px 18px 36px; }
  .group .opacity-0 { opacity: 1; }
}

@media (max-width: 560px) {
  .topbar-actions .btn { width: 34px; padding: 0; }
  .topbar-actions .btn svg { margin: 0; }
  .topbar-actions .btn { font-size: 0; gap: 0; }
  .page-content > .grid.grid-cols-2 { grid-template-columns: 1fr; }
  #logStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #logsTable { overflow-x: auto; }
  #logsTable table { min-width: 720px; }
  #logStats + .flex { align-items: stretch; flex-wrap: wrap; }
  #logStats + .flex select { flex: 1 1 145px; }
  #logStats + .flex .flex-1 { display: none; }
  .app-toast { left: 16px; right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Purpose-built dashboard components. */
.metric-card { position: relative; min-height: 116px; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 1px; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .28; }
.metric-card > div:first-child, .metric-card > p:first-child { min-height: 20px; }
.metric-card > p.text-2xl, .metric-card > p.text-xl { margin-top: 8px; font-size: 25px !important; line-height: 1; font-weight: 620 !important; letter-spacing: -.035em; }
.panel-heading { min-height: 35px; margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h3 { margin: 2px 0 0; color: #dce0e5; font-size: 13px; font-weight: 600; letter-spacing: -.012em; }
.panel-kicker { margin: 0; color: #5d6570; font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.live-label { display: inline-flex; align-items: center; gap: 6px; color: #7d8590; font-size: 10px; }
.live-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.panel-link { display: inline-flex; align-items: center; gap: 4px; color: #79818c; font-size: 11px; transition: color 150ms ease; }
.panel-link:hover { color: #d8dce1; }

/* Shared page composition */
.page-lede { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 0 22px; }
.page-lede.compact { margin-top: 28px; margin-bottom: 12px; }
.page-lede h2 { margin: 0; color: #e6e8eb; font-size: 15px; font-weight: 620; letter-spacing: -.02em; }
.page-lede p { max-width: 680px; margin: 6px 0 0; color: #747c87; font-size: 12px; line-height: 1.55; }
.page-lede code { color: #a7adb6; font-size: 11px; }
.text-action, .freshness-note { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; min-height: 31px; padding: 0 9px; color: #8b939e; background: #111419; border: 1px solid var(--border); border-radius: 7px; font-size: 11px; }
.text-action { transition: color 150ms ease, background-color 150ms ease, transform 140ms var(--ease-out); }
.text-action:hover { color: #e4e7ea; background: var(--surface-raised); }
.resource-workspace { min-height: 180px; }
.resource-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; padding: 9px 10px 9px 14px; background: #0f1216; border: 1px solid var(--border); border-radius: 9px; }
.resource-count { display: flex; align-items: baseline; gap: 6px; }
.resource-count strong { color: #e8eaed; font-size: 15px; }
.resource-count span { color: #717984; font-size: 11px; }

/* Dashboard gateway command strip */
.gateway-banner { min-height: 64px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(300px, auto) auto; align-items: center; gap: 22px; margin-bottom: 16px; padding: 10px 12px 10px 16px; background: linear-gradient(90deg, rgba(85,197,138,.045), transparent 34%), #0f1215; border: 1px solid var(--border); border-radius: 9px; }
.gateway-banner-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gateway-pulse { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; background: rgba(85,197,138,.07); border: 1px solid rgba(85,197,138,.16); border-radius: 50%; }
.gateway-pulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(85,197,138,.09); }
.gateway-banner-main strong, .gateway-banner-main span { display: block; }
.gateway-banner-main strong { color: #dfe3e6; font-size: 12px; font-weight: 620; }
.gateway-banner-main span { margin-top: 2px; color: #68717c; font-size: 10px; }
.gateway-endpoint { display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 22px; border-left: 1px solid var(--border); }
.gateway-endpoint > span { color: #626a75; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gateway-endpoint code { overflow: hidden; color: #aeb4bc; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.icon-copy, .code-copy { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 28px; padding: 0 8px; color: #858d98; background: #171a1f; border: 1px solid #2a3038; border-radius: 6px; font-size: 10px; }
.icon-copy:hover, .code-copy:hover { color: #e1e4e8; background: #1d2127; }
.icon-copy.is-copied, .code-copy.is-copied, .copy-field button.is-copied { color: var(--success); }
.gateway-docs { display: flex; align-items: center; gap: 6px; padding: 8px 9px; color: #959ca6; font-size: 11px; border-radius: 6px; transition: color 150ms ease, background-color 150ms ease; }
.gateway-docs:hover { color: #f0f1f3; background: #191c21; }

/* Resource tables */
.resource-summary { display: grid; grid-template-columns: repeat(3, minmax(100px, 150px)) 1fr; min-height: 74px; margin-bottom: 12px; background: #0f1216; border: 1px solid var(--border); border-radius: 9px; }
.resource-summary > div { display: flex; flex-direction: column; justify-content: center; padding: 0 16px; border-right: 1px solid var(--border); }
.resource-summary span { color: #656d78; font-size: 10px; }
.resource-summary strong { margin-top: 3px; color: #e1e4e8; font-size: 17px; line-height: 1; font-weight: 620; }
.resource-summary .success-value { color: var(--success); }
.resource-summary .warning-value { color: var(--warning); }
.resource-summary .resource-summary-note { flex-direction: row; align-items: center; justify-content: flex-end; gap: 7px; color: #626a75; border-right: 0; font-size: 10px; }
.resource-list { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.resource-list-head { min-height: 36px; align-items: center; padding: 0 14px; color: #5f6772; background: #0f1216; border-bottom: 1px solid var(--border); font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.resource-row { position: relative; min-height: 68px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.resource-row:last-child { border-bottom: 0; }
.connection-columns { display: grid; grid-template-columns: minmax(240px, 1.35fr) minmax(170px, .85fr) minmax(120px, .55fr) 144px; gap: 20px; }
.key-columns { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(150px, .8fr) minmax(140px, .6fr) 42px; gap: 20px; }
.resource-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.resource-identity strong, .resource-auth strong { display: block; overflow: hidden; color: #dfe2e6; font-size: 12px; font-weight: 570; text-overflow: ellipsis; white-space: nowrap; }
.resource-identity small, .resource-auth small { display: block; margin-top: 3px; color: #68707b; font-size: 10px; }
.provider-avatar, .key-avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(240,121,50,.15); border-radius: 8px; }
.key-avatar { color: var(--warning); background: rgba(231,182,87,.07); border-color: rgba(231,182,87,.14); }
.status-badge { width: fit-content; display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 0 7px; border: 1px solid currentColor; border-radius: 99px; font-size: 10px; font-weight: 600; }
.row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.row-actions button { width: 31px; height: 31px; display: grid; place-items: center; color: #69717c; border-radius: 6px; }
.row-actions button:hover { color: #dce0e4; background: #1b1f25; }
.row-actions .danger-action:hover { color: var(--danger); background: rgba(239,107,115,.07); }
.resource-row-detail { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; padding: 8px 10px; color: #9d773b; background: rgba(231,182,87,.035); border: 1px solid rgba(231,182,87,.1); border-radius: 6px; }
.resource-row-detail code { min-width: 0; overflow: hidden; color: #a7696e; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.lock-chip { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; font-size: 9px; }
.key-list .resource-row > code { color: #9ca3ad; font-size: 11px; }
.key-list time { color: #747c87; font-size: 11px; }

.empty-state { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; background: radial-gradient(circle at 50% 35%, rgba(240,121,50,.035), transparent 28%), #0f1215; border: 1px dashed #2a3038; border-radius: 9px; text-align: center; }
.empty-state.compact { min-height: 220px; }
.empty-state-icon { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 14px; color: #7d858f; background: #171a1f; border: 1px solid #2d333c; border-radius: 10px; }
.empty-state h3 { margin: 0; color: #d9dde1; font-size: 13px; font-weight: 620; }
.empty-state p { max-width: 380px; margin: 6px 0 18px; color: #69717c; font-size: 11px; line-height: 1.5; }
.skeleton-list { display: grid; gap: 8px; }
.skeleton-list span { height: 66px; display: block; background: linear-gradient(90deg, #111419 20%, #171b21 50%, #111419 80%); background-size: 300% 100%; border: 1px solid var(--border); border-radius: 8px; animation: skeleton-shift 1.4s linear infinite; }
@keyframes skeleton-shift { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Model controls */
.model-lede { align-items: center; }
.search-control { position: relative; display: flex; align-items: center; }
.search-control svg { position: absolute; left: 11px; z-index: 1; color: #626a75; pointer-events: none; }
.search-control input { width: 230px; min-height: 34px; padding: 0 12px 0 35px; font-size: 11px; }
.model-groups { display: grid; gap: 14px; }
.model-group { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.model-group > header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 15px; background: #0f1216; border-bottom: 1px solid var(--border); }
.model-group h3 { margin: 0; color: #dde0e4; font-size: 12px; font-weight: 620; }
.model-group header p { margin: 3px 0 0; color: #626a75; font-size: 10px; }
.model-group header > span { color: #6f7782; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.model-row { min-height: 60px; display: grid; grid-template-columns: 1fr auto 46px; align-items: center; gap: 20px; padding: 8px 15px; border-bottom: 1px solid var(--border); }
.model-row:last-child { border-bottom: 0; }
.model-row.is-disabled { background: rgba(0,0,0,.06); }
.model-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-monogram { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; color: #a7adb5; background: #1a1e24; border: 1px solid #2c323a; border-radius: 7px; font-size: 10px; font-weight: 700; }
.model-identity strong, .model-identity code { display: block; }
.model-identity strong { color: #d8dce1; font-size: 11px; font-weight: 570; }
.model-identity code { margin-top: 3px; color: #5f6772; font-size: 9px; }
.is-disabled .model-identity strong { color: #737b86; }
.model-state { color: var(--success); font-size: 10px; }
.is-disabled .model-state { color: #626a75; }
.switch-control { position: relative; width: 34px; height: 19px; padding: 0; background: #282e36; border: 1px solid #343b45; border-radius: 99px; }
.switch-control span { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; background: #89919c; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.4); transition: transform 170ms var(--ease-out), background-color 150ms ease; }
.switch-control.is-on { background: var(--accent); border-color: var(--accent); }
.switch-control.is-on span { background: #19130f; transform: translateX(15px); }

/* Quota */
.quota-overview { min-height: 130px; display: grid; grid-template-columns: 92px minmax(200px, 1fr) minmax(150px, .45fr) auto; align-items: center; gap: 22px; margin-bottom: 14px; padding: 18px 20px; background: #0f1216; border: 1px solid var(--border); border-radius: 9px; }
.quota-dial { position: relative; width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--quota) * 1%), #242932 0); }
.quota-dial::before { content: ""; position: absolute; width: 60px; height: 60px; background: #0f1216; border-radius: 50%; }
.quota-dial span { position: relative; text-align: center; }
.quota-dial strong, .quota-dial small { display: block; }
.quota-dial strong { color: #e6e8eb; font-size: 15px; line-height: 1; }
.quota-dial small { margin-top: 3px; color: #626a75; font-size: 8px; text-transform: uppercase; }
.quota-total > span, .quota-health > span { color: #656d78; font-size: 10px; }
.quota-total > strong { display: block; margin-top: 3px; color: #e4e7ea; font-size: 24px; font-weight: 620; letter-spacing: -.035em; }
.quota-total > strong small { color: #686f7a; font-size: 13px; font-weight: 500; }
.quota-total p { margin: 4px 0 0; color: #626a75; font-size: 10px; }
.quota-health { padding-left: 22px; border-left: 1px solid var(--border); }
.quota-health strong, .quota-health small { display: block; }
.quota-health strong { margin-top: 3px; color: #dfe2e5; font-size: 17px; }
.quota-health small { margin-top: 4px; color: #68717c; font-size: 9px; }
.quota-accounts { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.quota-accounts-heading { min-height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; color: #666e79; background: #0f1216; border-bottom: 1px solid var(--border); font-size: 10px; font-weight: 620; text-transform: uppercase; letter-spacing: .07em; }
.quota-accounts-heading small { font-weight: 500; text-transform: none; letter-spacing: 0; }
.quota-account { padding: 15px; border-bottom: 1px solid var(--border); }
.quota-account:last-child { border-bottom: 0; }
.quota-account > header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.quota-account > header time { color: #5f6772; font-size: 9px; }
.quota-lines { display: grid; gap: 6px; padding-left: 43px; }
.quota-line { min-height: 44px; display: grid; grid-template-columns: minmax(160px, .75fr) minmax(160px, 1.5fr) 100px; align-items: center; gap: 18px; }
.quota-line > div:first-child strong, .quota-line > div:first-child small { display: block; }
.quota-line > div:first-child strong { color: #bfc4ca; font-size: 10px; font-weight: 560; }
.quota-line > div:first-child small { margin-top: 2px; color: #59616c; font-size: 9px; }
.quota-track { height: 5px; overflow: hidden; background: #252a31; border-radius: 99px; }
.quota-track span { display: block; width: var(--usage); height: 100%; background: var(--success); border-radius: inherit; }
.quota-track span.is-warning { background: var(--warning); }
.quota-track span.is-critical { background: var(--danger); }
.quota-values { text-align: right; }
.quota-values strong, .quota-values small { display: block; }
.quota-values strong { color: #dce0e4; font-size: 11px; }
.quota-values small { margin-top: 2px; color: #5f6772; font-size: 9px; }
.inline-error { display: flex; align-items: center; gap: 7px; padding: 9px 10px; color: #c4777d; background: rgba(239,107,115,.05); border: 1px solid rgba(239,107,115,.13); border-radius: 6px; font-size: 10px; }
.quiet-message { color: #68707b; font-size: 10px; }
.load-error { min-height: 92px; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; padding: 15px; background: rgba(239,107,115,.025); border: 1px solid rgba(239,107,115,.13); border-radius: 8px; }
.load-error > span { width: 31px; height: 31px; display: grid; place-items: center; color: #c4777d; background: rgba(239,107,115,.06); border-radius: 7px; }
.load-error strong { color: #d8dce1; font-size: 11px; font-weight: 620; }
.load-error p { margin: 3px 0 0; color: #8a6a6d; font-size: 9px; }

/* API key security context */
.security-notice { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 13px; padding: 14px 15px; background: linear-gradient(90deg, rgba(231,182,87,.04), transparent 45%), #0f1216; border: 1px solid var(--border); border-radius: 9px; }
.security-icon { width: 32px; height: 32px; display: grid; place-items: center; color: var(--warning); background: rgba(231,182,87,.07); border: 1px solid rgba(231,182,87,.14); border-radius: 8px; }
.security-notice strong { display: block; color: #d9dde1; font-size: 11px; font-weight: 620; }
.security-notice p { margin: 3px 0 0; color: #68707b; font-size: 10px; }
.security-notice > code { padding: 7px 9px; color: #9da4ae; background: #0b0d10; border: 1px solid #252a31; border-radius: 6px; font-size: 9px; }

/* Endpoint reference */
.endpoint-layout { display: grid; grid-template-columns: 190px minmax(0, 840px); gap: 42px; align-items: start; }
.endpoint-index { position: sticky; top: 100px; display: flex; flex-direction: column; padding-right: 20px; border-right: 1px solid var(--border); }
.endpoint-index .nav-section { padding-left: 8px; }
.endpoint-index > a { padding: 7px 8px; color: #6f7782; border-radius: 6px; font-size: 11px; transition: color 150ms ease, background-color 150ms ease; }
.endpoint-index > a:hover { color: #d9dde2; }
.endpoint-index > a.active { color: #e8eaed; background: #15181d; }
.endpoint-version { margin-top: 26px; padding: 12px 9px; border-top: 1px solid var(--border); }
.endpoint-version span, .endpoint-version strong, .endpoint-version small { display: block; }
.endpoint-version span { color: #59616c; font-size: 8px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.endpoint-version strong { margin-top: 5px; color: #b8bec6; font-size: 10px; font-weight: 580; }
.endpoint-version small { margin-top: 3px; color: #5e6671; font-size: 9px; }
.endpoint-content { min-width: 0; }
.doc-section { padding: 4px 0 32px; margin-bottom: 31px; border-bottom: 1px solid var(--border); scroll-margin-top: 100px; }
.doc-section:last-child { border-bottom: 0; }
.doc-section h2 { margin: 7px 0 0; color: #ebedef; font-size: 23px; font-weight: 580; letter-spacing: -.035em; }
.doc-copy { max-width: 650px; margin: 12px 0 20px; color: #7b838e; font-size: 12px; line-height: 1.65; }
.copy-field { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 62px; padding: 10px 10px 10px 14px; background: #0f1216; border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.copy-field span, .copy-field code { display: block; }
.copy-field div > span { margin-bottom: 4px; color: #5c6470; font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.copy-field code { color: #d1d5da; font-size: 12px; }
.copy-field button { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; color: #939ba5; background: #1b1f25; border: 1px solid #303741; border-radius: 6px; font-size: 10px; }
.compatibility-row { display: flex; align-items: center; gap: 15px; margin-top: 14px; }
.compatibility-row > span { color: #5d6570; font-size: 9px; }
.compatibility-row > div { display: flex; flex-wrap: wrap; gap: 5px; }
.compatibility-row b { padding: 4px 7px; color: #7d8590; background: #12151a; border: 1px solid #252a31; border-radius: 4px; font-size: 8px; font-weight: 600; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { font-size: 16px; }
.section-heading > span { color: #5f6772; font-size: 9px; }
.route-list { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; }
.route-row { min-height: 61px; display: grid; grid-template-columns: 48px minmax(190px, .8fr) 1fr 20px; align-items: center; gap: 14px; padding: 10px 13px; background: var(--surface); border-bottom: 1px solid var(--border); }
.route-row:last-child { border-bottom: 0; }
.route-row code { color: #c7ccd2; font-size: 10px; }
.route-row p { margin: 0; color: #6b737e; font-size: 10px; }
.route-row > svg { color: #59616c; }
.method { width: fit-content; padding: 3px 5px; border-radius: 4px; font: 8px ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; }
.method-post { color: #d58b5e; background: rgba(240,121,50,.08); }
.method-get { color: #66afcb; background: rgba(74,169,207,.08); }
.code-window { margin: 0; padding: 0 17px 17px; overflow: auto; color: #b8bec6; background: #0c0e11; border: 1px solid var(--border); border-radius: 8px; font-size: 10px; line-height: 1.7; }
.code-window-bar { height: 36px; display: flex; align-items: center; gap: 5px; margin: 0 -17px 14px; padding: 0 13px; background: #12151a; border-bottom: 1px solid var(--border); }
.code-window-bar i { width: 6px; height: 6px; background: #3b414a; border-radius: 50%; }
.code-window-bar em { margin-left: 6px; color: #5e6671; font-size: 8px; font-style: normal; }

/* Settings are a navigable form, not a stack of cards. */
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 720px); gap: 40px; align-items: start; }
.settings-index { position: sticky; top: 96px; display: flex; flex-direction: column; }
.settings-index .nav-section { padding-left: 8px; }
.settings-index a { display: flex; align-items: center; gap: 8px; padding: 7px 8px; color: #707884; border-radius: 6px; font-size: 10px; transition: color 150ms ease, background-color 150ms ease; }
.settings-index a:hover { color: #d8dce1; background: #14171b; }
.settings-sections { display: grid; gap: 12px; }
.settings-section { scroll-margin-top: 94px; }
.settings-section > .flex:first-child { margin-bottom: 19px; }
.settings-section > .flex:first-child svg { color: #7c848f !important; }
.settings-section h3 { font-size: 13px !important; font-weight: 620 !important; letter-spacing: -.015em; }
.settings-section .space-y-4 > div + div { padding-top: 14px; border-top: 1px solid var(--border); }
.settings-section .space-y-4 > div { transition: opacity 160ms ease; }
.settings-section .space-y-4 > div.is-disabled { opacity: .42; }
.settings-section label { font-size: 11px !important; }
.danger-section { border-color: rgba(239,107,115,.16) !important; }
.danger-section > .flex:first-child svg { color: var(--danger) !important; }

.log-toolbar { min-height: 48px; padding: 7px 8px; background: #0f1216; border: 1px solid var(--border); border-radius: 8px; }
.log-toolbar select { min-height: 32px; font-size: 10px; }
.toolbar-label { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; color: #656d78; font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.btn-danger-subtle { color: #ca7379; background: rgba(239,107,115,.045); border-color: rgba(239,107,115,.16); }
.btn-danger-subtle:hover { color: #ef8a91; background: rgba(239,107,115,.08); }
.analytics-panel { min-height: 290px; }

@media (max-width: 1080px) {
  .gateway-banner { grid-template-columns: 1fr auto; }
  .gateway-endpoint { display: none; }
  .connection-columns { grid-template-columns: minmax(220px, 1.2fr) minmax(150px, .75fr) minmax(110px, .5fr) 140px; gap: 14px; }
}

@media (max-width: 840px) {
  .page-lede { align-items: flex-start; }
  .endpoint-layout, .settings-layout { grid-template-columns: 1fr; gap: 20px; }
  .endpoint-index, .settings-index { position: static; flex-direction: row; gap: 3px; overflow-x: auto; padding: 0 0 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .endpoint-index .nav-section, .endpoint-version, .settings-index .nav-section { display: none; }
  .endpoint-index > a, .settings-index a { flex: 0 0 auto; }
  .resource-list-head { display: none; }
  .connection-columns { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .resource-row .resource-auth { grid-column: 1; padding-left: 43px; }
  .resource-row > div:nth-child(3) { grid-column: 2; grid-row: 1; }
  .resource-row .row-actions { grid-column: 2; grid-row: 2; }
  .resource-row-detail { grid-row: 3; }
  .quota-overview { grid-template-columns: 80px 1fr auto; }
  .quota-health { display: none; }
}

@media (max-width: 620px) {
  .page-lede { display: block; }
  .page-lede > :last-child { margin-top: 12px; }
  .model-lede .search-control input { width: 100%; }
  .model-lede .search-control { width: 100%; }
  .gateway-banner { grid-template-columns: 1fr; }
  .gateway-docs { display: none; }
  .resource-summary { grid-template-columns: repeat(3, 1fr); }
  .resource-summary > div { padding: 0 10px; }
  .resource-summary .resource-summary-note { display: none; }
  .connection-columns { grid-template-columns: 1fr; }
  .resource-row > div:nth-child(3), .resource-row .resource-auth, .resource-row .row-actions { grid-column: 1; grid-row: auto; padding-left: 0; }
  .resource-row .row-actions { justify-content: flex-start; padding-top: 5px; border-top: 1px solid var(--border); }
  .key-columns { grid-template-columns: 1fr auto; }
  .key-list .resource-row > code, .key-list .resource-row > time { grid-column: 1; }
  .key-list .resource-row .row-actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; border: 0; }
  .security-notice { grid-template-columns: 34px 1fr; }
  .security-notice > code { grid-column: 1 / -1; }
  .quota-overview { grid-template-columns: 68px 1fr; padding: 15px; }
  .quota-overview > button { grid-column: 1 / -1; }
  .quota-dial { width: 60px; height: 60px; }
  .quota-dial::before { width: 50px; height: 50px; }
  .quota-line { grid-template-columns: 1fr 70px; gap: 10px; }
  .quota-track { grid-column: 1 / -1; grid-row: 2; }
  .quota-values { grid-column: 2; grid-row: 1; }
  .quota-lines { padding-left: 0; }
  .route-row { grid-template-columns: 46px 1fr 18px; }
  .route-row p { grid-column: 2 / -1; }
  .compatibility-row { align-items: flex-start; flex-direction: column; gap: 8px; }
}

/* Login deliberately avoids the generic centered-card treatment. */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr); }
.login-context { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 42px 48px; overflow: hidden; background: #0e1013; border-right: 1px solid var(--border); }
.login-context::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px); background-size: 52px 52px; mask-image: linear-gradient(to bottom right, #000, transparent 68%); }
.login-context::after { content: ""; position: absolute; width: 420px; height: 420px; left: 18%; top: 24%; border: 1px solid rgba(240,121,50,.13); border-radius: 50%; box-shadow: 0 0 100px rgba(240,121,50,.04), 0 0 0 74px rgba(240,121,50,.015), 0 0 0 148px rgba(240,121,50,.01); }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; color: var(--text); font-size: 13px; font-weight: 650; }
.login-copy { position: relative; z-index: 1; max-width: 570px; }
.eyebrow { margin: 0 0 16px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.login-copy h1 { margin: 0; color: #f3f4f6; font-size: clamp(42px, 5.2vw, 72px); line-height: .98; font-weight: 560; letter-spacing: -.055em; }
.login-copy > p:last-child { max-width: 490px; margin: 28px 0 0; color: #7f8792; font-size: 14px; line-height: 1.65; }
.login-status { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; color: #686f79; font-size: 11px; }
.login-status .status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(85,197,138,.09); }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.login-form-wrap { width: 100%; max-width: 390px; }
.login-heading { margin-bottom: 25px; }
.login-heading .eyebrow { margin-bottom: 11px; color: #6d7580; }
.login-heading h2 { margin: 0; color: var(--text); font-size: 24px; line-height: 1.2; font-weight: 620; letter-spacing: -.035em; }
.login-heading > p:last-child { margin: 8px 0 0; color: var(--quiet); font-size: 13px; }
.login-card { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 16px 50px rgba(0,0,0,.18); }
.login-card .btn { min-height: 40px; }
.login-hint { margin: 17px 0 0; color: #5c646f; font-size: 11px; text-align: center; }
.login-hint code { color: #979faa; }

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-context { min-height: auto; padding: 24px; border-right: 0; border-bottom: 1px solid var(--border); }
  .login-copy, .login-status { display: none; }
  .login-panel { min-height: calc(100vh - 80px); padding: 32px 20px; align-items: start; padding-top: 13vh; }
}
