:root {
  --bg: #0b0f14;
  --bg-elevated: #121821;
  --bg-soft: #18212d;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --primary: #4d7cff;
  --primary-2: #6aa1ff;
  --success: #3ecf8e;
  --danger: #ff6b7a;
  --radius: 12px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --control-h: 36px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 520px at 8% -8%, rgba(77, 124, 255, 0.14), transparent 50%),
    radial-gradient(800px 420px at 100% 0%, rgba(62, 207, 142, 0.06), transparent 45%),
    var(--bg);
}

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

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(255,255,255,0.04);
  padding: 1px 5px;
  border-radius: 4px;
}

.hidden { display: none !important; }

/* Login */
#login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: linear-gradient(180deg, rgba(24, 33, 45, 0.95), rgba(18, 24, 33, 0.98));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4d7cff, #7aa2ff);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.login-card h1 { margin: 0; font-size: 1.25rem; }
.login-card p {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Form controls */
.field { margin-bottom: 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}
.field input,
.field select,
.field textarea,
.input,
.textarea,
.select {
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: var(--control-h);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
/* select 默认不占满整行 */
.field select,
.select {
  width: auto;
  min-width: 160px;
  max-width: 100%;
  padding-right: 28px;
  cursor: pointer;
}
.field select.full,
.select.full,
.field input.full,
.input.full {
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(77, 124, 255, 0.16);
}
.textarea, textarea {
  min-height: 88px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.45;
  min-height: auto;
}

/* 表单行：多列紧凑 */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.form-row > .field {
  margin-bottom: 0;
  flex: 1 1 180px;
}
.form-row > .field.fixed {
  flex: 0 0 auto;
}
.form-row > .field.grow {
  flex: 1 1 240px;
}
.form-row > .field.w-sm {
  flex: 0 1 140px;
  min-width: 120px;
}
.form-row > .field.w-md {
  flex: 0 1 220px;
  min-width: 160px;
}
.form-row > .field.w-lg {
  flex: 1 1 280px;
}
.form-row.tight { gap: 10px; }

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  user-select: none;
  white-space: nowrap;
}
.check-inline input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  min-height: var(--control-h);
  cursor: pointer;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  transition: transform .08s ease, background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { border-color: #355070; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, #4d7cff, #3b6af0);
  border-color: transparent;
  color: white;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn-danger {
  background: rgba(255, 107, 122, 0.12);
  border-color: rgba(255, 107, 122, 0.35);
  color: #ff9aa5;
}
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm {
  padding: 5px 9px;
  font-size: 0.82rem;
  min-height: 30px;
}
.error-text { color: var(--danger); min-height: 1.1em; margin: 8px 0 0; font-size: 0.86rem; }
.hint { color: var(--muted); font-size: 0.8rem; line-height: 1.45; }

/* Dashboard */
.stack.dash {
  gap: 12px;
  max-width: 100%;
}
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.kpi {
  background: linear-gradient(180deg, rgba(24,33,45,0.95), rgba(18,24,33,0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  height: 96px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  min-width: 0;
}
.kpi .kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .kpi-sub {
  margin-top: 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi.accent { border-color: rgba(77,124,255,0.45); box-shadow: 0 0 0 1px rgba(77,124,255,0.08) inset; }

/* Single 4-col grid: row1 = span2 + 1 + 1, row2 = 1+1+1+1 → edges align */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: 280px 260px;
  gap: 12px;
  align-items: stretch;
  justify-items: stretch;
  width: 100%;
}
.dash-grid > .dash-span-2 {
  grid-column: span 2;
}
/* Override global `.card + .card { margin-top }` which breaks grid alignment */
.dash-grid > .card,
.dash-grid > .card + .card {
  margin-top: 0;
  margin-bottom: 0;
}

/* Equal-height cards: header fixed, body scrolls */
.dash-card {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  align-self: stretch;
  justify-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0;
}
.dash-card > .card-title {
  flex: 0 0 auto;
  margin-bottom: 8px;
  min-height: 28px;
  align-items: center;
}
.dash-card .card-title h3 {
  font-size: 0.95rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dash-body.dash-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
.dash-body.dash-scroll::-webkit-scrollbar { width: 6px; }
.dash-body.dash-scroll::-webkit-scrollbar-thumb {
  background: #2a384c;
  border-radius: 99px;
}
.dash-body.dash-scroll::-webkit-scrollbar-track { background: transparent; }
.dash-body-chart {
  justify-content: center;
}
.dash-body-hint {
  flex: 0 0 auto;
  margin: 0 0 8px !important;
}
#dash-trend {
  width: 100%;
  height: 100%;
  max-height: 200px;
  display: block;
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: middle;
}
.dot.blue { background: #4d7cff; }
.dot.green { background: #3ecf8e; }
.dot.yellow { background: #f0c14b; }
.dot.red { background: #ff6b7a; }
.dot.gray { background: #3a4658; }

.health-grid {
  display: grid;
  grid-template-columns: 28px repeat(24, minmax(0, 1fr));
  gap: 2px;
  font-size: 0.65rem;
  color: var(--muted);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}
.health-grid .hh {
  display: grid;
  grid-template-rows: repeat(6, 12px);
  gap: 2px;
  min-width: 0;
}
.health-grid .ylabels {
  display: grid;
  grid-template-rows: repeat(6, 12px);
  gap: 2px;
  padding-right: 4px;
  text-align: right;
  flex-shrink: 0;
}
.health-cell {
  width: 100%;
  min-width: 6px;
  height: 12px;
  border-radius: 2px;
  background: #1a2330;
}
.health-cell.ok { background: #2fbf7a; }
.health-cell.warn { background: #d4a017; }
.health-cell.fail { background: #e85d6c; }
.health-cell.none { background: #1a2330; }

.token-total {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.token-bars {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.token-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 78px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  min-width: 0;
}
.token-row .bar {
  height: 8px;
  background: #1a2330;
  border-radius: 99px;
  overflow: hidden;
  min-width: 0;
}
.token-row .bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
}
.token-row .val {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.75rem;
}

.rank-list, .fail-list, .kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.rank-item, .fail-item, .kv-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 0.84rem;
  min-width: 0;
}
.rank-item .left, .fail-item .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.rank-item .name, .fail-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: none;
  flex: 1 1 auto;
}
.rank-item > .hint,
.rank-item > .rank-bar + span {
  flex: 0 0 auto;
  white-space: nowrap;
}
.rank-num {
  width: 20px; height: 20px;
  border-radius: 6px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}
.rank-bar {
  flex: 0 0 48px;
  height: 6px;
  background: #1a2330;
  border-radius: 99px;
  overflow: hidden;
  min-width: 36px;
  max-width: 64px;
}
.rank-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #4d7cff, #6aa1ff); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.on { background: var(--success); }
.status-dot.off { background: var(--danger); }
.status-dot.warn { background: #f0c14b; }
.fail-item {
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(36,48,65,0.7);
}
.fail-item:last-child { border-bottom: none; }
.fail-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  min-width: 0;
}
.fail-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kv-item .k { color: var(--muted); flex: 0 0 auto; }
.kv-item .v {
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  min-width: 0;
}

@media (max-width: 1280px) {
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 260px 240px 240px 240px;
  }
  .dash-grid > .dash-span-2 {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: 240px;
  }
  .dash-grid > .dash-span-2 {
    grid-column: auto;
  }
  #app-view { grid-template-columns: 1fr; }
}

/* Request monitor */
.mon-toolbar { gap: 8px; flex-wrap: wrap; }
.mon-search {
  min-width: 220px;
  width: min(320px, 40vw);
  height: var(--control-h);
}
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  min-height: 30px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: linear-gradient(135deg, #4d7cff, #3b6af0);
  color: #fff;
  font-weight: 600;
}
.mon-filters {
  margin-bottom: 0;
  gap: 12px 20px;
  align-items: flex-end;
}
.mon-filters > .field.w-sm {
  flex: 0 0 160px;
  min-width: 150px;
}
.mon-filters > .field.fixed {
  flex: 0 0 auto;
  margin-left: 8px;
  padding-left: 4px;
}
.mon-filters > .field.fixed .btn {
  white-space: nowrap;
  min-height: var(--control-h, 36px);
}
.mon-kpis {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.mon-kpis .kpi { height: 90px; }
.mon-table-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
  min-height: 320px;
}
.mon-table-card > .card-title { flex: 0 0 auto; }
.mon-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}
.mon-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.mon-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #121821;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mon-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(36, 48, 65, 0.65);
  vertical-align: middle;
  white-space: nowrap;
}
.mon-table tr.mon-row { cursor: pointer; }
.mon-table tr.mon-row:hover { background: rgba(77, 124, 255, 0.06); }
.mon-table tr.mon-row.open { background: rgba(77, 124, 255, 0.08); }
.mon-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.mon-table .muted { color: var(--muted); }
.mon-table .ok { color: var(--success); }
.mon-table .fail { color: var(--danger); }
.mon-acc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 220px;
}
.mon-acc .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mon-acc .sub {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.mon-expand {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  cursor: pointer;
}
.mon-detail-row td {
  background: rgba(12, 16, 22, 0.65);
  padding: 0 8px 12px 36px;
  white-space: normal;
  border-bottom: 1px solid var(--border);
}
.mon-detail {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 12px;
  padding-top: 8px;
}
.mon-detail-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(18, 24, 33, 0.9);
  padding: 10px 12px;
  min-width: 0;
}
.mon-detail-box h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
}
.mon-token-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 0 6px 6px 0;
  font-size: 0.8rem;
  background: rgba(77, 124, 255, 0.08);
  border: 1px solid rgba(77, 124, 255, 0.18);
}
.mon-token-chip.out {
  background: rgba(240, 162, 2, 0.1);
  border-color: rgba(240, 162, 2, 0.25);
}
.mon-token-chip.in {
  background: rgba(62, 207, 142, 0.1);
  border-color: rgba(62, 207, 142, 0.22);
}
.mon-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.mon-mini-table th,
.mon-mini-table td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(36, 48, 65, 0.55);
  text-align: left;
}
.mon-mini-table th { color: var(--muted); font-weight: 500; }
.mon-mini-table .num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 1280px) {
  .mon-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mon-detail { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .mon-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mon-search { width: 100%; }
}

/* App shell */
#app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 200px 1fr;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(12, 16, 22, 0.92);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { margin: 2px 6px 14px; }
.sidebar .brand strong { font-size: 0.92rem; }
.nav-btn {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.nav-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-btn.active {
  background: rgba(77, 124, 255, 0.12);
  border-color: rgba(77, 124, 255, 0.35);
  color: var(--text);
}
.sidebar-foot {
  margin-top: auto;
  padding: 6px;
  display: grid;
  gap: 6px;
}
.main {
  padding: 18px 22px 32px;
  min-width: 0;
  width: 100%;
  max-width: none; /* 内容区铺满侧栏右侧，不再限宽 1200px */
  box-sizing: border-box;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.topbar h2 { margin: 0 0 3px; font-size: 1.2rem; }
.topbar p { margin: 0; color: var(--muted); font-size: 0.86rem; max-width: 720px; }

.card {
  background: rgba(18, 24, 33, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.stack { display: grid; gap: 12px; }
.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.card-title h3 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.card-title .hint { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat .label { color: var(--muted); font-size: 0.78rem; }
.stat .value { margin-top: 4px; font-size: 1.1rem; font-weight: 650; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th, td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
td .hint { margin-top: 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.warn {
  background: rgba(255, 176, 32, 0.15);
  color: #ffc24d;
  border: 1px solid rgba(255, 176, 32, 0.35);
}
.badge.on {
  color: #8dffc4;
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(62, 207, 142, 0.1);
}
.badge.off {
  color: #ffb3bb;
  border-color: rgba(255, 107, 122, 0.35);
  background: rgba(255, 107, 122, 0.08);
}

.tabs {
  display: inline-flex;
  gap: 6px;
  margin: 0;
  flex-wrap: wrap;
}
.tab {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  min-height: 30px;
}
.tab.active {
  color: white;
  background: rgba(77, 124, 255, 0.2);
  border-color: rgba(77, 124, 255, 0.45);
}
.acc-tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.tab.active .tab-count {
  background: rgba(77, 124, 255, 0.35);
  color: #fff;
}

/* Account list row expand (inline under selected row) */
tr.acc-row { cursor: pointer; }
tr.acc-row:hover { background: rgba(77, 124, 255, 0.06); }
tr.acc-row.open { background: rgba(77, 124, 255, 0.08); }
tr.acc-row .acc-exp {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft, rgba(18, 24, 33, 0.9));
  color: var(--muted);
  font-size: 0.75rem;
  vertical-align: middle;
}
tr.acc-detail-row > td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.72);
  white-space: normal;
  vertical-align: top;
}
.acc-inline-detail {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: acc-expand-in 0.18s ease-out;
}
@keyframes acc-expand-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.acc-inline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.acc-inline-head h4 {
  margin: 0;
  font-size: 0.92rem;
}
.acc-inline-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.acc-inline-kpis .kpi {
  height: 78px;
  padding: 10px 12px;
}
.acc-inline-kpis .kpi-value { font-size: 1.15rem; }
.acc-inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 10px;
  align-items: stretch;
}
.acc-inline-grid > .card {
  margin: 0;
  min-height: 0;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.acc-inline-grid > .card > .card-title {
  flex: 0 0 auto;
  margin-bottom: 6px;
}
.acc-inline-grid > .card > .dash-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.acc-inline-grid .health-grid {
  transform: scale(0.92);
  transform-origin: top left;
}
.acc-inline-grid canvas {
  max-height: 160px !important;
}

@media (max-width: 1100px) {
  .acc-inline-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .acc-inline-grid { grid-template-columns: 1fr; }
  .acc-inline-grid > .card { max-height: 240px; }
}
@media (max-width: 720px) {
  .acc-inline-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-box {
  background: #0a0e13;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 140px;
  max-height: 360px;
  overflow: auto;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.grow { flex: 1; min-width: 120px; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.toolbar .spacer { flex: 1; min-width: 8px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  width: min(480px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 12px; font-size: 1rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #152033;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  z-index: 80;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: .2s ease;
  pointer-events: none;
  font-size: 0.88rem;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.endpoint-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  background: rgba(77, 124, 255, 0.1);
  border: 1px solid rgba(77, 124, 255, 0.25);
  padding: 2px 7px;
  border-radius: 6px;
  margin: 0 4px 0 0;
}
.endpoint-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 12px;
}

@media (max-width: 960px) {
  #app-view { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 14px; width: 100%; max-width: none; }
  .field select, .select { width: 100%; min-width: 0; }
  .form-row > .field,
  .form-row > .field.w-sm,
  .form-row > .field.w-md,
  .form-row > .field.w-lg { flex: 1 1 100%; }
}
