/* ============================================================
   ZZZ Relay · 管理控制台
   Pure static, no external assets. Dark theme, orange accent.
   ============================================================ */

:root {
  --bg: #0b0c0e;
  --bg-soft: #0e1013;
  --card: #15171b;
  --card-2: #1a1d22;
  --card-3: #1e2229;
  --line: #262a31;
  --line-soft: #1f232a;
  --text: #e6e8ec;
  --muted: #949aa6;
  --muted-2: #6f7683;
  --accent: #ff7500;
  --accent-hover: #ff8a26;
  --accent-soft: rgba(255, 117, 0, 0.12);
  --accent-line: rgba(255, 117, 0, 0.38);
  --green: #3ecf8e;
  --green-soft: rgba(62, 207, 142, 0.12);
  --red: #ff5d5d;
  --red-soft: rgba(255, 93, 93, 0.12);
  --yellow: #f5b544;
  --yellow-soft: rgba(245, 181, 68, 0.12);
  --blue: #5aa9ff;
  --blue-soft: rgba(90, 169, 255, 0.12);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; color-scheme: dark; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, p, dl, dd { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

code, pre, .mono { font-family: var(--mono); }

::selection { background: rgba(255, 117, 0, 0.32); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3038; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a414c; }

:focus-visible { outline: 2px solid rgba(255, 117, 0, 0.72); outline-offset: 2px; }

body.modal-open { overflow: hidden; }

/* ------------------------------- layout ------------------------------- */

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px;
  background: linear-gradient(180deg, #101216 0%, #0c0e11 100%);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 3px 8px 20px; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ff9633 0%, #ff5c00 100%);
  color: #1c0d02;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  box-shadow: 0 5px 18px rgba(255, 117, 0, 0.28);
}

.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text span { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item:hover { background: #171a1f; color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(255, 117, 0, 0.18);
  color: #ffb273;
  font-weight: 600;
}
.nav-item.active svg { color: var(--accent); opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 14px 9px 2px; border-top: 1px solid var(--line-soft); }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); }
.side-version { margin-top: 4px; color: var(--muted-2); font-size: 10.5px; font-family: var(--mono); }

.dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.1);
}
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 93, 93, 0.1); }
.dot.pending { background: var(--yellow); box-shadow: 0 0 0 3px rgba(245, 181, 68, 0.12); animation: pulse 1.3s ease infinite; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 14, 0.9);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.page-heading { min-width: 0; }
.page-heading h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.1px; }
.page-heading p { margin-top: 2px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.conn-pill[data-tone="pending"] .dot { background: var(--yellow); }
.conn-pill[data-tone="off"] .dot { background: var(--red); }

.user-chip { display: flex; align-items: center; gap: 7px; max-width: 190px; padding: 3px 8px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.user-avatar { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: #ffb273; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.user-meta strong { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.user-meta span { font-size: 9.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

.content { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px 44px; }
.content:focus { outline: none; }

.stack { display: flex; flex-direction: column; gap: 14px; }

/* ------------------------------ buttons ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease, opacity 0.14s ease;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover:not(:disabled) { background: #242830; border-color: #343a45; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b0c02; font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger { background: rgba(255, 93, 93, 0.08); border-color: rgba(255, 93, 93, 0.34); color: #ffb4b4; }
.btn.danger:hover:not(:disabled) { background: rgba(255, 93, 93, 0.16); border-color: rgba(255, 93, 93, 0.55); }

.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--card-2); border-color: var(--line); }

.btn.sm { height: 28px; padding: 0 10px; font-size: 11.5px; }
.btn.sm svg { width: 13px; height: 13px; }
.btn.xs { height: 25px; padding: 0 8px; font-size: 11px; border-radius: 8px; }
.btn.icon { width: 30px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.icon.xs { width: 25px; }
.btn.block { width: 100%; }

.btn .btn-spin {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0.8;
}

/* ------------------------------- inputs ------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 11.5px; font-weight: 500; color: #b3b9c4; }
.field .hint { font-size: 10.5px; line-height: 1.45; color: var(--muted-2); }
.field .required { color: var(--accent); }

.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0e1014;
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.textarea { height: auto; min-height: 82px; padding: 8px 10px; line-height: 1.55; resize: vertical; }

.input::placeholder, .textarea::placeholder { color: #5d6470; }

.input:hover, .select:hover, .textarea:hover { border-color: #333944; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(255, 117, 0, 0.1);
  background: #0d0f13;
}

.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option, select optgroup { background: #15171b; color: var(--text); }

.input.num, .select.num { font-variant-numeric: tabular-nums; }
.input.mono { font-family: var(--mono); font-size: 11.5px; }

input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.5; }

.check-row { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.check-row label { font-size: 12px; color: var(--text); cursor: pointer; }

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { margin-bottom: 18px; }
.form-section:last-child { margin-bottom: 0; }
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 12px; font-weight: 600; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.section-title .section-hint { font-size: 10.5px; font-weight: 400; color: var(--muted-2); }

.form-error { min-height: 18px; margin-top: 6px; color: #ff8585; font-size: 11.5px; line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }

/* ------------------------------- switch ------------------------------- */

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none; cursor: pointer; user-select: none; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  flex: none;
  border: 1px solid #363c46;
  border-radius: 999px;
  background: #2a2f37;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #9aa1ad;
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-track { background: rgba(255, 117, 0, 0.24); border-color: rgba(255, 117, 0, 0.58); }
.switch input:checked + .switch-track::after { transform: translateX(15px); background: var(--accent); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(255, 117, 0, 0.18); }
.switch input:disabled + .switch-track { opacity: 0.45; cursor: not-allowed; }
.switch-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* -------------------------------- cards ------------------------------- */

.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-soft);
}
.card-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.card-title svg { width: 15px; height: 15px; color: var(--muted); }
.card-sub { margin-top: 2px; font-size: 11px; color: var(--muted); }
.card-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.card-body { padding: 15px; }
.card-body.flush { padding: 0; }
.card-body.pad-sm { padding: 10px; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 11px 15px; border-top: 1px solid var(--line-soft); }
.card-foot .spacer { margin-right: auto; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.muted { color: var(--muted); }

/* ------------------------------- metrics ------------------------------ */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }

.metric {
  position: relative;
  min-width: 0;
  padding: 13px 15px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  --tone: var(--accent);
  --tone-soft: var(--accent-soft);
}
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--tone); opacity: 0.85; }
.metric.tone-blue { --tone: var(--blue); --tone-soft: var(--blue-soft); }
.metric.tone-green { --tone: var(--green); --tone-soft: var(--green-soft); }
.metric.tone-yellow { --tone: var(--yellow); --tone-soft: var(--yellow-soft); }

.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11.5px; }
.metric-icon { width: 27px; height: 27px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--tone-soft); color: var(--tone); }
.metric-icon svg { width: 14px; height: 14px; }
.metric-value {
  margin: 7px 0 1px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric-sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sys-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 20px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 117, 0, 0.055), transparent 46%), var(--card);
}
.sys-item { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11px; color: var(--muted); }
.sys-item strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sys-item .mono { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b8bec9; }

/* -------------------------------- chart ------------------------------- */

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.9fr); gap: 14px; align-items: stretch; }
.chart-wrap { padding: 8px 10px 3px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { fill: var(--muted); font-family: var(--font); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-svg .chart-axis { stroke: #2a2f37; stroke-width: 1; }
.chart-svg .chart-grid { stroke: #20242b; stroke-width: 1; stroke-dasharray: 3 4; }
.chart-svg .chart-bar { transition: opacity 0.14s ease; }
.chart-svg .chart-bar:hover { opacity: 0.82; }
.chart-empty { fill: var(--muted-2); font-size: 11.5px; }

/* -------------------------------- health ------------------------------ */

.health-list { max-height: 298px; overflow-y: auto; }
.health-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 15px; border-bottom: 1px solid var(--line-soft); }
.health-row:last-child { border-bottom: none; }
.health-main { min-width: 0; }
.health-name { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 550; min-width: 0; }
.health-name .health-id { font-family: var(--mono); font-size: 10.5px; font-weight: 400; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.health-meta .err { color: #ff8d8d; }
.health-actions { display: flex; align-items: flex-start; gap: 5px; }
.health-result { margin-top: 5px; font-size: 10.5px; line-height: 1.4; word-break: break-word; }
.health-result.success { color: #61dba5; }
.health-result.error { color: #ff8d8d; }

/* -------------------------------- tables ------------------------------ */

.table-wrap { width: 100%; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #121419;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #191c21; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:focus-visible { outline: 1px solid var(--accent-line); outline-offset: -1px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table .cell-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.table .cell-sub { margin-top: 2px; font-size: 10.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.table .cell-code { font-family: var(--mono); font-size: 11px; color: #c9cfda; }
.table .actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.table .row-arrow { display: inline-flex; color: var(--muted-2); transition: transform 0.14s ease; }
.table tr.expanded .row-arrow { transform: rotate(90deg); color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge .bdot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge.success { color: #61dba5; background: var(--green-soft); border-color: rgba(62, 207, 142, 0.18); }
.badge.danger { color: #ff8d8d; background: var(--red-soft); border-color: rgba(255, 93, 93, 0.2); }
.badge.warn { color: #f7c66b; background: var(--yellow-soft); border-color: rgba(245, 181, 68, 0.2); }
.badge.accent { color: #ffa45c; background: var(--accent-soft); border-color: rgba(255, 117, 0, 0.2); }
.badge.blue { color: #8dc0ff; background: var(--blue-soft); border-color: rgba(90, 169, 255, 0.2); }
.badge.neutral { color: #aab1bd; background: #1d2127; border-color: #2b3039; }

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101216;
  color: #b8bec9;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.accent { border-color: rgba(255, 117, 0, 0.22); color: #ffb273; background: rgba(255, 117, 0, 0.07); }

/* ------------------------------ empty/load ---------------------------- */

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); color: var(--muted); }
.empty-icon svg { width: 20px; height: 20px; }
.empty-title { color: var(--text); font-size: 13px; font-weight: 600; }
.empty-hint { max-width: 430px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.empty .btn { margin-top: 4px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 52px 20px; color: var(--muted); font-size: 12px; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.75s linear infinite; }

.page-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 52px 20px; text-align: center; }
.page-error .empty-icon { color: var(--red); border-color: rgba(255, 93, 93, 0.25); background: var(--red-soft); }
.page-error-msg { max-width: 560px; color: var(--muted); font-size: 12px; line-height: 1.6; word-break: break-word; }

/* ------------------------------- toolbar ------------------------------ */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-meta { font-size: 11.5px; color: var(--muted); }
.toolbar-meta strong { color: var(--text); font-weight: 600; }
.toolbar-actions { display: flex; align-items: center; gap: 7px; }

/* ------------------------------ providers ----------------------------- */

.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.provider-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); transition: border-color 0.14s ease; }
.provider-card:hover { border-color: #303641; }
.provider-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 14px 9px; }
.provider-title { min-width: 0; }
.provider-name { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; min-width: 0; }
.provider-name .provider-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.provider-id { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }
.provider-url {
  margin: 0 14px 9px;
  padding: 5px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0e1014;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.provider-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: var(--line-soft); gap: 1px; }
.provider-stat { min-width: 0; padding: 7px 10px; background: var(--card); }
.provider-stat span { display: block; font-size: 9.5px; color: var(--muted-2); }
.provider-stat strong { display: block; margin-top: 1px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.provider-models { display: flex; flex-wrap: wrap; gap: 4px; padding: 9px 14px 7px; min-height: 34px; }
.provider-result { padding: 0 14px 8px; font-size: 10.5px; line-height: 1.4; word-break: break-word; }
.provider-result.success { color: #61dba5; }
.provider-result.error { color: #ff8d8d; }
.provider-actions { display: flex; align-items: center; gap: 5px; margin-top: auto; padding: 9px 14px 11px; border-top: 1px solid var(--line-soft); }
.provider-actions .spacer { flex: 1; }

/* ------------------------------ presets ------------------------------- */

.preset-search { margin-bottom: 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 8px; }
.preset-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-2);
  color: var(--text);
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
  min-width: 0;
}
.preset-card:hover { border-color: var(--accent-line); background: #1c2026; }
.preset-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preset-card-head strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-url { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 10px; color: var(--muted); }
.preset-note { margin-top: 2px; font-size: 10px; line-height: 1.4; color: #e8b45f; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ------------------------------- models ------------------------------- */

.model-editor { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.model-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: #121419; border-bottom: 1px solid var(--line); }
.model-editor-title { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); }
.model-editor-title strong { color: var(--text); font-weight: 600; }
.model-editor-actions { display: flex; align-items: center; gap: 5px; }
.model-table-wrap { max-height: 330px; overflow: auto; }
.model-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.model-table th { position: sticky; top: 0; z-index: 1; padding: 6px; border-bottom: 1px solid var(--line); background: #121419; color: var(--muted); font-size: 9.5px; font-weight: 500; text-align: left; white-space: nowrap; }
.model-table td { padding: 5px 6px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.model-table tr:first-child td { border-top: none; }
.model-table .input { height: 27px; padding: 0 7px; font-size: 11px; border-radius: 7px; }
.model-table .input.mono { font-size: 10.5px; }
.model-table .w-id { min-width: 168px; }
.model-table .w-name { min-width: 138px; }
.model-table .w-num { width: 84px; }
.model-table .w-price { width: 82px; }
.model-table .c { text-align: center; }
.model-table .btn.icon { width: 26px; height: 26px; }
.model-table .btn.icon svg { width: 12px; height: 12px; }
.model-table .cell-check { display: flex; justify-content: center; }
.bulk-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: #111318; }
.bulk-panel .textarea { min-height: 76px; font-family: var(--mono); font-size: 11px; }
.bulk-panel .bulk-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bulk-panel .hint { font-size: 10px; color: var(--muted-2); }

/* ------------------------------- aliases ------------------------------ */

.alias-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 117, 0, 0.05), transparent 42%), var(--card);
}
.alias-summary-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.alias-summary-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }
.alias-summary-icon svg { width: 17px; height: 17px; }
.alias-summary-text { min-width: 0; }
.alias-summary-text .line1 { font-size: 11.5px; color: var(--muted); }
.alias-summary-text .line1 strong { color: var(--text); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.alias-summary-text .line2 { margin-top: 3px; }
.model-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.model-chips .more { font-size: 10px; color: var(--muted-2); }

/* -------------------------------- keys -------------------------------- */

.quota-cell { min-width: 120px; }
.quota-line { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.quota-line .used { color: var(--text); }
.quota-line .sep { color: var(--muted-2); }
.quota-line .limit { color: var(--muted); }
.quota-bar { width: 100%; height: 3px; margin-top: 5px; border-radius: 999px; background: #242930; overflow: hidden; }
.quota-bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.quota-bar span.over { background: var(--red); }

.one-time { border: 1px solid rgba(255, 117, 0, 0.34); border-radius: var(--radius); background: linear-gradient(180deg, rgba(255, 117, 0, 0.075), rgba(255, 117, 0, 0.015)); padding: 13px; }
.one-time-label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: #ffb273; font-size: 11px; font-weight: 650; letter-spacing: 0.2px; }
.one-time-label svg { width: 14px; height: 14px; }
.secret-box { display: flex; align-items: stretch; gap: 7px; }
.secret-value {
  flex: 1;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #343a44;
  border-radius: 8px;
  background: #090a0c;
  color: #ffd0a4;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-all;
  user-select: all;
}
.code-block {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090a0c;
  color: #c7cdd8;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}

/* ------------------------------- balances ------------------------------ */

.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); gap: 12px; }
.balance-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.balance-card.ok { border-color: rgba(62, 207, 142, 0.28); }
.balance-card.failed { border-color: rgba(255, 93, 93, 0.34); background: linear-gradient(180deg, rgba(255, 93, 93, 0.03), transparent 52%), var(--card); }
.balance-card.unsupported { border-color: rgba(245, 181, 68, 0.24); }
.balance-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 13px 8px; }
.balance-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance-kind { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 5px; }
.balance-amount { padding: 2px 13px 10px; font-size: 25px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance-amount .currency { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 5px; letter-spacing: 0; }
.balance-card.failed .balance-amount { color: #ff9d9d; }
.balance-details { display: flex; flex-direction: column; margin: 0 13px 10px; border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
.balance-detail-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 9px; border-top: 1px solid var(--line-soft); background: #111318; font-size: 11px; }
.balance-detail-row:first-child { border-top: none; }
.balance-detail-row span { color: var(--muted); }
.balance-detail-row strong { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-error { margin: 0 13px 10px; padding: 8px 9px; border: 1px solid rgba(255, 93, 93, 0.24); border-radius: 8px; background: rgba(255, 93, 93, 0.055); color: #ffb3b3; font-size: 10.5px; line-height: 1.55; word-break: break-word; }
.balance-hint { margin: 0 13px 10px; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.balance-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 8px 13px 10px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: 9.5px; }
.balance-foot .left { display: flex; align-items: center; gap: 5px; min-width: 0; }

/* ------------------------------- accounts ------------------------------ */

.account-line { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.account-sub { margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.password-form { display: flex; flex-direction: column; gap: 10px; }
.password-form .form-actions { margin-top: 2px; justify-content: flex-start; }

/* -------------------------------- logs -------------------------------- */

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 11px 13px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 118px; flex: 0 1 150px; }
.filter-field.wide { flex: 1 1 190px; }
.filter-field label { font-size: 9.5px; color: var(--muted-2); }
.filter-field .input, .filter-field .select { height: 30px; font-size: 11.5px; }
.filter-bar .spacer { flex: 1; }
.filter-actions { display: flex; align-items: center; gap: 6px; }
.auto-refresh { display: inline-flex; align-items: center; gap: 6px; padding-bottom: 7px; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.auto-refresh .switch-track { width: 30px; height: 17px; }
.auto-refresh .switch-track::after { width: 11px; height: 11px; }
.auto-refresh .switch input:checked + .switch-track::after { transform: translateX(13px); }

.log-detail-row td { padding: 0 !important; background: #101216; border-bottom: 1px solid var(--line) !important; }
.log-detail-row:hover { background: transparent !important; }
.log-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 11px 16px; padding: 13px 15px; }
.detail-item { min-width: 0; }
.detail-item dt { margin-bottom: 2px; color: var(--muted-2); font-size: 9.5px; }
.detail-item dd { margin: 0; font-size: 11.5px; line-height: 1.45; word-break: break-word; }
.detail-item dd.mono { font-family: var(--mono); font-size: 10.5px; }
.detail-error { grid-column: 1 / -1; padding: 9px 11px; border: 1px solid rgba(255, 93, 93, 0.26); border-radius: 8px; background: rgba(255, 93, 93, 0.06); color: #ffb3b3; font-family: var(--mono); font-size: 10.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.detail-error strong { color: #ff8d8d; }
.detail-json { grid-column: 1 / -1; }
.detail-json summary { cursor: pointer; color: var(--muted); font-size: 10.5px; user-select: none; }
.detail-json summary:hover { color: var(--text); }
.detail-json pre { margin: 7px 0 0; padding: 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: #090a0c; color: #b8bec9; font-family: var(--mono); font-size: 10px; line-height: 1.55; max-height: 310px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 2px 0; font-size: 10.5px; color: var(--muted); }
.pager-info { font-variant-numeric: tabular-nums; }
.pager-actions { display: flex; align-items: center; gap: 6px; }

/* ------------------------------ settings ------------------------------ */

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr); gap: 14px; align-items: start; }
.info-list { display: flex; flex-direction: column; }
.info-row { display: grid; grid-template-columns: 102px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
.info-row:last-child { border-bottom: none; }
.info-row dt { color: var(--muted); }
.info-row dd { min-width: 0; margin: 0; color: #cbd1db; word-break: break-all; }
.info-row dd.mono { font-family: var(--mono); font-size: 10.5px; }
.info-copy-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.info-copy-row .mono { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone { border-color: rgba(255, 93, 93, 0.28); background: linear-gradient(180deg, rgba(255, 93, 93, 0.045), transparent 55%), var(--card); }
.danger-zone .card-title { color: #ff9a9a; }
.danger-zone .card-title svg { color: var(--red); }
.danger-text { font-size: 11.5px; line-height: 1.65; color: var(--muted); }
.danger-text strong { color: #ffb4b4; font-weight: 550; }

/* ----------------------------- playground ----------------------------- */

.playground-grid { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 14px; align-items: start; }
.pg-model-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; min-height: 19px; font-size: 10.5px; color: var(--muted); }
.message-list { display: flex; flex-direction: column; gap: 9px; }
.message-item { border: 1px solid var(--line); border-radius: var(--radius); background: #111318; overflow: hidden; }
.message-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 7px; border-bottom: 1px solid var(--line-soft); background: #13161b; }
.message-head .select { width: 112px; height: 25px; padding: 0 24px 0 8px; font-size: 11px; border-radius: 7px; background-position: calc(100% - 13px) 10px, calc(100% - 8px) 10px; }
.message-item textarea { display: block; width: 100%; min-height: 62px; padding: 9px 10px; border: 0; background: transparent; color: var(--text); font-size: 12.5px; line-height: 1.55; resize: vertical; outline: none; }
.message-item textarea::placeholder { color: #5d6470; }
.message-add { display: flex; align-items: center; gap: 6px; margin-top: 9px; }
.pg-params { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.pg-send-row { display: flex; align-items: center; gap: 7px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.pg-send-row .spacer { flex: 1; }

.result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 11px; }
.result-text { padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--radius); background: #0e1014; font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; max-height: 430px; overflow: auto; }
.result-text.empty-text { color: var(--muted-2); font-style: normal; }
.result-block { margin-top: 12px; }
.result-block > h4 { margin: 0 0 6px; color: var(--muted); font-size: 10.5px; font-weight: 500; }
details.reasoning { border: 1px solid var(--line); border-radius: var(--radius); background: #111318; overflow: hidden; }
details.reasoning summary { display: flex; align-items: center; gap: 6px; padding: 9px 11px; color: var(--muted); font-size: 11px; cursor: pointer; list-style: none; user-select: none; }
details.reasoning summary::-webkit-details-marker { display: none; }
details.reasoning summary::before { content: "▸"; color: var(--accent); transition: transform 0.14s ease; }
details.reasoning[open] summary::before { transform: rotate(90deg); }
details.reasoning pre { margin: 0; padding: 0 11px 11px; color: #b8bec9; font-family: var(--mono); font-size: 10.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; }
.tool-call { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #101216; }
.tool-call + .tool-call { margin-top: 6px; }
.tool-call-name { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-family: var(--mono); font-size: 11px; color: #ffb273; }
.tool-call pre { margin: 0; color: #b8bec9; font-family: var(--mono); font-size: 10px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(94px, 1fr)); gap: 7px; }
.usage-item { min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #101216; }
.usage-item span { display: block; color: var(--muted-2); font-size: 9.5px; }
.usage-item strong { display: block; margin-top: 1px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-error { padding: 11px 12px; border: 1px solid rgba(255, 93, 93, 0.28); border-radius: var(--radius); background: rgba(255, 93, 93, 0.06); color: #ffb3b3; font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

/* -------------------------------- modal ------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 5, 7, 0.72);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.12s ease;
}
.modal {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  border: 1px solid #2d323b;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58);
  animation: modalIn 0.15s ease;
  overflow: hidden;
}
.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(470px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex: none; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); }
.modal-title { font-size: 14.5px; font-weight: 650; }
.modal-sub { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.modal-close { flex: none; }
.modal-body { flex: 1; min-height: 0; padding: 17px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: none; padding: 11px 17px; border-top: 1px solid var(--line-soft); background: #131519; }
.modal-foot .spacer { margin-right: auto; }

.confirm-message { font-size: 13px; line-height: 1.6; color: var(--text); }
.confirm-detail { margin-top: 7px; font-size: 11.5px; line-height: 1.65; color: var(--muted); }

/* -------------------------------- toast ------------------------------- */

.toasts { position: fixed; top: 15px; right: 15px; z-index: 4000; display: flex; flex-direction: column; gap: 8px; width: min(370px, calc(100vw - 30px)); pointer-events: none; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1a1d22;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.55;
  pointer-events: auto;
  animation: toastIn 0.18s ease;
}
.toast.out { animation: toastOut 0.16s ease forwards; }
.toast .toast-icon { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.toast .toast-icon svg { width: 16px; height: 16px; }
.toast.success { border-color: rgba(62, 207, 142, 0.34); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-color: rgba(255, 93, 93, 0.4); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--blue); }
.toast .toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast .toast-close { flex: none; display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted-2); }
.toast .toast-close:hover { background: #262b33; color: var(--text); }
.toast .toast-close svg { width: 12px; height: 12px; }

/* -------------------------------- login ------------------------------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg);
}
.login-glow {
  position: fixed;
  top: -180px;
  left: 50%;
  width: 680px;
  height: 680px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 117, 0, 0.15), transparent 66%);
  filter: blur(18px);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 27px 23px;
  border: 1px solid #2b3038;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #171a1f 0%, #121419 100%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 21px; }
.login-card h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.login-sub { margin: 6px 0 19px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.login-sub code, .login-foot code { padding: 1px 4px; border-radius: 4px; background: #0e1014; color: #cfd5df; font-size: 10px; }
.input-with-action { position: relative; display: flex; }
.input-with-action .input { height: 38px; padding-right: 43px; font-size: 13px; }
.input-with-action .btn { position: absolute; top: 3px; right: 3px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); }
.input-with-action .btn:hover:not(:disabled) { background: #1c2026; border: 0; color: var(--text); }
.login-submit { width: 100%; height: 38px; margin-top: 3px; font-size: 13px; }
.login-alt { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.login-alt summary { color: var(--muted); font-size: 11px; cursor: pointer; user-select: none; list-style: none; display: flex; align-items: center; gap: 6px; }
.login-alt summary::-webkit-details-marker { display: none; }
.login-alt summary::before { content: "▸"; color: var(--accent); transition: transform 0.14s ease; }
.login-alt[open] summary::before { transform: rotate(90deg); }
.login-alt form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.login-alt .form-error { min-height: 0; margin: 0; }
.login-alt .login-submit { height: 34px; font-size: 12px; background: var(--card-2); border-color: var(--line); color: var(--text); font-weight: 550; }
.login-alt .login-submit:hover:not(:disabled) { background: #242830; }
.login-foot { margin-top: 17px; color: var(--muted-2); font-size: 10px; line-height: 1.7; text-align: center; }

/* ------------------------------ animations ---------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(12px); } }

/* ------------------------------ responsive ---------------------------- */

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .settings-grid, .playground-grid { grid-template-columns: minmax(0, 1fr); }
  .health-list { max-height: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: auto; min-height: 100vh; min-height: 100dvh; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .brand { padding: 0; flex: none; gap: 8px; }
  .brand-mark { width: 30px; height: 30px; font-size: 16px; }
  .brand-text span { display: none; }
  .brand-text strong { font-size: 12.5px; white-space: nowrap; }
  .nav { flex-direction: row; align-items: center; gap: 2px; flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; padding: 1px; }
  .nav-item { width: auto; flex: none; padding: 7px 9px; }
  .nav-item span { font-size: 11.5px; }
  .sidebar-foot { display: none; }
  .main { min-height: 0; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
  .page-heading h1 { font-size: 16px; }
  .page-heading p { white-space: normal; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .content { overflow: visible; padding: 14px 14px 36px; }
  .metrics { gap: 10px; }
  .overview-grid, .settings-grid, .playground-grid { gap: 12px; }
  .provider-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .modal-overlay { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
  .modal-body { padding: 14px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .chart-svg text { font-size: 19px; }
  .chart-svg .chart-empty { font-size: 21px; }
  .filter-field { flex: 1 1 140px; }
  .filter-field.wide { flex: 1 1 100%; }
  .filter-bar .spacer { display: none; }
  .info-row { grid-template-columns: 88px minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 20px; }
  .topbar-actions { gap: 6px; }
  .conn-pill { display: none; }
  .toolbar { align-items: flex-start; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .pg-params { grid-template-columns: minmax(0, 1fr); }
  .secret-box { flex-direction: column; }
  .secret-box .btn { height: 32px; }
  .health-row { padding-left: 12px; padding-right: 12px; }
  .card-head, .card-body { padding-left: 12px; padding-right: 12px; }
  .pager { flex-wrap: wrap; }
}

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