:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11151d;
  --panel-2: #151b25;
  --line: #26303e;
  --text: #ecf2ff;
  --muted: #8b98ad;
  --accent: #83a9ff;
  --green: #64d39a;
  --red: #ff7e8b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 15% 0%, #18243b 0, var(--bg) 42%); color: var(--text); }
.shell { max-width: 1280px; margin: 0 auto; padding: 34px 22px 60px; }
.topbar { display: flex; gap: 28px; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { color: var(--accent); letter-spacing: .18em; font-size: 11px; font-weight: 700; }
h1, h2, p { margin: 0; }
h1 { margin-top: 8px; font-size: clamp(28px, 5vw, 46px); letter-spacing: -.04em; }
h2 { font-size: 18px; }
.muted { color: var(--muted); line-height: 1.5; }
.endpoint { min-width: 270px; padding: 13px 16px; background: rgba(13,17,24,.86); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.12); }
.endpoint span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
code { color: #b9d0ff; word-break: break-all; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .value { display: block; font-size: 25px; font-weight: 700; margin-bottom: 4px; }
.stat .label { color: var(--muted); font-size: 12px; }
.panel { background: rgba(17, 21, 29, .92); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 18px; box-shadow: 0 18px 60px rgba(0,0,0,.13); }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; min-width: 0; }
.panel-head .muted { margin-top: 6px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.overview-grid { grid-template-columns: minmax(0, 1.2fr) minmax(420px, .95fr); align-items: stretch; }
.overview-grid > .panel { min-width: 0; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 8px; min-width: 0; }
.mini-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 290px; }
.mini-stat { display: inline-flex; align-items: baseline; gap: 4px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.mini-stat strong { color: var(--text); font-size: 14px; }
.mini-stat.success, .mini-stat.done { border-color: rgba(100,211,154,.42); }
.mini-stat.failed, .mini-stat.error { border-color: rgba(255,126,139,.42); }
.mini-stat.available { border-color: rgba(131,169,255,.42); }
.mini-stat.running, .mini-stat.in_use { border-color: rgba(255,203,125,.42); }
.panel-head > div:first-child { min-width: 0; }
.panel-head > div:first-child > .muted { max-height: 3.2em; overflow: hidden; text-overflow: ellipsis; }
.overview-grid .table-wrap { max-height: 488px; overflow: auto; border: 1px solid rgba(38,48,62,.72); border-radius: 11px; background: rgba(8,11,16,.22); }
.overview-grid thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.table-wrap { overflow-x: auto; }
.accounts-table-wrap { max-height: 430px; overflow: auto; border: 1px solid rgba(38,48,62,.72); border-radius: 11px; background: rgba(8,11,16,.22); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td code { display: block; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.truncate { max-width: 300px; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: rgba(131,169,255,.055); }
.overview-grid table { min-width: 650px; }
.overview-grid .panel:nth-child(2) table { min-width: 0; table-layout: fixed; }
.overview-grid .panel:nth-child(2) th:nth-child(1), .overview-grid .panel:nth-child(2) td:nth-child(1) { width: 38%; }
.overview-grid .panel:nth-child(2) th:nth-child(2), .overview-grid .panel:nth-child(2) td:nth-child(2) { width: 13%; }
.overview-grid .panel:nth-child(2) th:nth-child(3), .overview-grid .panel:nth-child(2) td:nth-child(3) { width: 19%; }
.overview-grid .panel:nth-child(2) th:nth-child(4), .overview-grid .panel:nth-child(2) td:nth-child(4) { width: 20%; }
.overview-grid .panel:nth-child(2) th:nth-child(5), .overview-grid .panel:nth-child(2) td:nth-child(5) { width: 10%; }
.overview-grid .panel:nth-child(2) td { overflow: hidden; }
.overview-grid .panel:nth-child(2) td code { max-width: 100%; }
.overview-grid .panel:nth-child(2) td:first-child strong,
.overview-grid .panel:nth-child(2) td:last-child span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-controls { display: grid; grid-template-columns: minmax(220px, 1.55fr) minmax(135px, .72fr) auto; align-items: end; gap: 10px; margin: 0 0 12px; padding: 10px; border: 1px solid rgba(38,48,62,.78); border-radius: 11px; background: rgba(9,12,18,.56); }
.pool-controls label { min-width: 0; }
.pool-controls input, .pool-controls select { padding: 9px 10px; }
.search-field input { min-width: 0; }
.filter-check { align-self: center; padding: 0 4px; white-space: nowrap; }
.filter-check input { accent-color: var(--accent); }
.toolbar-note { align-self: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px 0; }
.pager { display: inline-flex; align-items: center; gap: 8px; }
.pager .small { margin-right: 0; }
.page-indicator { min-width: 70px; color: var(--muted); font-size: 12px; text-align: center; }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: #bdc7d8; font-size: 13px; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #0b0f15; color: var(--text); padding: 11px 12px; outline: none; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 9px; background: #0b0f15; color: var(--text); padding: 11px 12px; outline: none; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(131,169,255,.12); }
input::placeholder, textarea::placeholder { color: #657287; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(131,169,255,.12); }
.inline { display: flex; align-items: center; grid-template-columns: none; gap: 8px; }
.inline input { width: auto; }
.subform { display: grid; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11,15,21,.55); }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.hidden { display: none; }
button { border: 0; border-radius: 9px; padding: 10px 14px; color: var(--text); cursor: pointer; font-weight: 650; }
button:disabled { opacity: .45; cursor: wait; }
button:not(:disabled):hover { filter: brightness(1.1); transform: translateY(-1px); }
button { transition: filter .16s ease, transform .16s ease, border-color .16s ease; }
.primary { background: linear-gradient(135deg, #6f95ef, #8c72e7); }
.secondary, .small { background: var(--panel-2); border: 1px solid var(--line); }
.small { padding: 6px 9px; font-size: 12px; margin-right: 5px; }
.danger { color: var(--red); }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.healthy { color: #0b271a; background: var(--green); }
.cooldown, .degraded { color: #321d05; background: #ffcb7d; }
.exhausted, .payment_required { color: #3b1016; background: #ff8792; }
.disabled { color: #2b2d33; background: #a7adb9; }
.status-available, .status-done, .status-success { color: #0b271a; background: var(--green); }
.status-running, .status-in_use, .status-queued, .status-waiting_credentials { color: #321d05; background: #ffcb7d; }
.status-error, .status-failed { color: #3b1016; background: #ff8792; }
.status-skipped, .status-used, .status-denied, .status-exists, .status-unknown { color: #2b2d33; background: #a7adb9; }
.log { min-height: 110px; margin-top: 14px; background: #0a0e14; border: 1px solid var(--line); border-radius: 10px; padding: 11px; white-space: pre-wrap; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; color: #b7c7df; }
.credentials-form { margin-top: 12px; }
.log.empty { color: var(--muted); }
.compat-details { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(11,15,21,.38); }
.compat-details summary { padding: 11px 13px; color: #bdc7d8; cursor: pointer; font-size: 13px; list-style-position: inside; }
.compat-details summary span { color: var(--muted); font-size: 12px; }
.compat-details[open] summary { border-bottom: 1px solid var(--line); }
.compat-details .credentials-form { margin: 12px; }
.footer { padding: 10px 2px; font-size: 12px; }
.connection-pill { display: inline-flex !important; align-items: center; gap: 5px; width: fit-content; margin-top: 10px; margin-bottom: 0 !important; color: var(--green) !important; font-weight: 700; }
.connection-pill.offline { color: var(--red) !important; }
.egress-pill.egress-active { color: #ffcb7d !important; }
.egress-pill.egress-off { color: var(--muted) !important; }
.egress-pill.egress-error { color: var(--red) !important; }
@media (max-width: 1040px) { .overview-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .topbar, .grid-2 { display: grid; grid-template-columns: 1fr; }
  .endpoint { min-width: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .mini-stats { justify-content: flex-start; max-width: none; }
  .panel-actions { justify-content: flex-start; }
  .pool-controls { grid-template-columns: 1fr 1fr; }
  .toolbar-note { justify-self: start; }
}
@media (max-width: 520px) {
  .shell { padding: 24px 12px 40px; }
  .panel { padding: 15px; border-radius: 13px; }
  .panel-head { display: grid; grid-template-columns: 1fr; }
  .panel-actions { align-items: center; }
  .pool-controls { grid-template-columns: 1fr; }
  .filter-check { justify-self: start; }
  .toolbar-note { justify-self: start; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .stats { gap: 8px; }
  .stat { padding: 13px; }
  .stat .value { font-size: 22px; }
}

/* Auth and operations settings */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; }
.auth-card { width: min(100%, 470px); padding: 30px; box-shadow: 0 20px 80px #0004; }
.auth-card h1 { margin: 12px 0 28px; }
.auth-card h2 { font-size: 21px; margin-bottom: 8px; }
.auth-card .form { margin-top: 22px; }
.auth-card #auth-error { min-height: 20px; font-size: 13px; }
.session-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.system-settings summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.system-settings summary span { font-size: 12px; }
.settings-grid { margin-top: 22px; align-items: start; }
.settings-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #0b0f1540; }
.settings-card-wide { grid-column: 1 / -1; }
.settings-card h2 { margin: 0 0 8px; }
.settings-status { background: #121c2d; border: 1px solid var(--line); padding: 12px; margin: 14px 0; border-radius: 10px; font-size: 12px; line-height: 1.7; white-space: pre-line; }
.proxy-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.proxy-actions button { margin-right: 0; }
.form-message { margin: 0; font-size: 12px; color: var(--green); min-height: 16px; }
.form-message.danger { color: var(--red); }
.headless-note { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; font-size: 13px; }
.secret-once { border-color: var(--accent); }
.key-display { display: flex; gap: 8px; flex-wrap: wrap; }
.key-display input { flex: 1 1 250px; min-width: 0; font-family: ui-monospace, monospace; }
.hidden { display: none !important; }
@media (max-width: 820px) { .settings-grid { grid-template-columns: 1fr; } .system-settings summary { align-items: flex-start; flex-direction: column; } }
