:root {
  --bg: #0f1419;
  --panel: #171d25;
  --panel-2: #1e2630;
  --border: #2a3441;
  --text: #e8eef6;
  --muted: #93a1b3;
  --primary: #4f8cff;
  --primary-2: #3a6fd8;
  --danger: #ff6b6b;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font: "Inter", "SF Pro Text", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2a44 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a3328 0%, transparent 45%),
    var(--bg);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

.hidden { display: none !important; }
.mobile-only, .icon-btn.mobile-only { display: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0.4rem 0 0; }
.ok { color: var(--ok); }
.status-text { color: var(--muted); min-height: 1.2em; margin: 0; font-size: 13px; }
a { color: #8eb5ff; }
a:hover { color: #b5ceff; }
.skip-link {
  position: fixed;
  z-index: 1000;
  left: 12px;
  top: 12px;
  transform: translateY(-160%);
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
}
.skip-link:focus { transform: translateY(0); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 16px;
}
.login-mount { width: min(400px, 100%); }
.login-mount .login-card { width: 100%; }
.login-trap {
  position: fixed;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-right: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 4px 38px 8px;
}
.brand-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(142, 181, 255, 0.4);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(79, 140, 255, 0.32), rgba(118, 87, 255, 0.16));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(42, 93, 190, 0.28);
}
.brand-logo svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: #a9c7ff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(79, 140, 255, 0.6));
}
.brand-title {
  width: 100%;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.025em;
}
#sidebar-close { position: absolute; top: 0; right: 0; }
.title-row { display: flex; align-items: center; gap: 10px; }
.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}
.nav-btn::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #77a8ff;
  box-shadow: 0 0 8px rgba(79, 140, 255, 0.9), 6px 0 18px rgba(79, 140, 255, 0.45);
  opacity: 0;
  transform: scaleY(0.35);
  transition: opacity 160ms ease, transform 160ms ease;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
  transition: color 160ms ease, filter 160ms ease;
}
.nav-btn:hover { background: rgba(79, 140, 255, 0.08); }
.nav-btn:hover .nav-icon { color: #b5ceff; }
.nav-btn.active {
  color: #f4f7ff;
  background: linear-gradient(90deg, rgba(79, 140, 255, 0.22), rgba(79, 140, 255, 0.08));
  border-color: rgba(79, 140, 255, 0.35);
}
.nav-btn.active::before { opacity: 1; transform: scaleY(1); }
.nav-btn.active .nav-icon {
  color: #8eb5ff;
  filter: drop-shadow(0 0 5px rgba(79, 140, 255, 0.7));
}
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.admin-identity {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(147, 161, 179, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}
.admin-identity svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#admin-email {
  min-width: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.app-version {
  font-variant-numeric: tabular-nums;
}
.main { padding: 20px 24px 40px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h2 { margin: 0; font-size: 1.35rem; }

.content { display: grid; gap: 16px; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible, .nav-btn:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid rgba(79, 140, 255, 0.45);
  outline-offset: 2px;
}
.btn:disabled, .nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  filter: none;
}
.btn[aria-busy="true"] { cursor: wait; }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: white;
  font-weight: 600;
}
.btn.danger { background: rgba(255, 107, 107, 0.15); border-color: rgba(255, 107, 107, 0.4); color: #ffc9c9; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 8px; font-size: 12px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  background: #0d1218;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
  accent-color: var(--primary);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  opacity: 0.75;
  cursor: not-allowed;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(79, 140, 255, 0.35);
  border-color: var(--primary);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(23, 29, 37, 0.9);
}
.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.table-toolbar label { min-width: min(320px, 100%); }
.table-count { margin: 0 0 10px; white-space: nowrap; }
.table-tools { display: flex; align-items: center; gap: 12px; }
.sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.sort-button:hover { color: var(--text); }
th[aria-sort="ascending"] .sort-button::after { content: " ↑"; }
th[aria-sort="descending"] .sort-button::after { content: " ↓"; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
tbody tr:hover { background: rgba(79, 140, 255, 0.045); }
tbody tr[hidden] { display: none; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.stat {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1b2430, #151b23);
}
.stat .v { font-size: 1.4rem; font-weight: 700; margin-top: 6px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
}
.badge.on { color: #b8f5d4; border-color: rgba(62, 207, 142, 0.4); background: rgba(62, 207, 142, 0.12); }
.badge.off { color: #ffc9c9; border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.1); }
.badge.warning { color: #f8d98b; border-color: rgba(240, 180, 41, 0.4); background: rgba(240, 180, 41, 0.1); }
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.flash.ok { background: rgba(62, 207, 142, 0.12); border-color: rgba(62, 207, 142, 0.35); }
.flash.err { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.35); }

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #141a22;
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.modal-body {
  max-height: calc(100dvh - 26px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}
.modal-body h3 { margin: 0; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-description { margin: 6px 0 0; line-height: 1.45; }
.modal-fields {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-body > .error { padding: 0 18px; }
.connection-result {
  margin: 0 18px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}
.connection-result.ok { color: #b8f5d4; border-color: rgba(62, 207, 142, 0.4); background: rgba(62, 207, 142, 0.1); }
.connection-result.fail { color: #ffc9c9; border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.provider-check { display: grid; gap: 4px; min-width: 150px; }
.provider-check .check-message { max-width: 320px; white-space: normal; line-height: 1.35; }
.provider-balance { display: grid; gap: 4px; min-width: 130px; }
.provider-balance strong { color: #b8f5d4; font-size: 15px; white-space: nowrap; }
.provider-balance .badge { width: fit-content; }
.empty-balance { min-width: 150px; }
.integration-section,
.provider-instances-section { display: grid; gap: 12px; margin-top: 24px; }
.integration-section:first-child { margin-top: 0; }
.integration-section .card-heading,
.provider-instances-section .card-heading { margin-bottom: 0; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: #141a22;
}
.field-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.checkbox-field {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  column-gap: 10px;
  color: var(--text);
}
.checkbox-field .field-help { grid-column: 2; }
.secret-value { min-height: 92px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.filters > * { min-width: 160px; }
.filters-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(23, 29, 37, 0.75);
}
.filters-card.compact { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.filter-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }
.filter-actions .btn { flex: 1 1 0; min-width: 0; padding-inline: 8px; }
.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(23, 29, 37, 0.75);
}
.summary-line strong { font-size: 1.25rem; }
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
details summary { color: #a9c7ff; cursor: pointer; }
details pre {
  max-width: 460px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1218;
  color: var(--text);
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.inline-note {
  padding: 12px 14px;
  border: 1px solid rgba(240, 180, 41, 0.35);
  border-radius: 10px;
  background: rgba(240, 180, 41, 0.08);
  color: #f8d98b;
  font-size: 13px;
}

/* LLM monitoring dashboard */
.monitoring-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px;
}
.monitoring-toolbar h3,
.monitoring-card h3,
.quick-actions-card h3 { margin: 0; }
.monitoring-toolbar p,
.card-heading p { margin: 5px 0 0; }
.monitoring-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}
.monitoring-period {
  display: inline-flex;
  align-self: stretch;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 20, 25, 0.72);
}
.period-btn {
  min-height: 34px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.period-btn:hover { color: var(--text); }
.period-btn.active {
  border-color: rgba(79, 140, 255, 0.5);
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.28), rgba(58, 111, 216, 0.2));
  color: #f4f7ff;
  box-shadow: 0 0 14px rgba(79, 140, 255, 0.16);
}
.monitoring-kpis { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-note { margin-top: 5px; color: var(--muted); font-size: 12px; }
.stat.healthy { border-color: rgba(62, 207, 142, 0.3); }
.stat.warning { border-color: rgba(240, 180, 41, 0.45); }
.stat.danger { border-color: rgba(255, 107, 107, 0.5); }
.danger-text { color: #ff9191; }
.warning-text { color: #f5cb64; }
.monitoring-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.monitoring-grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.ranking-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.details-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.monitoring-card { min-width: 0; }
.provider-balances-card { grid-column: 1 / -1; }
.provider-balance-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.provider-balance-row { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: rgba(15, 20, 25, 0.72); }
.provider-balance-row > div:first-child { display: grid; gap: 4px; min-width: 0; }
.provider-balance-row .provider-balance { text-align: right; justify-items: end; }
.card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.load-chart {
  display: flex;
  align-items: end;
  gap: 5px;
  min-height: 212px;
  padding-top: 10px;
  overflow-x: auto;
}
.load-column {
  display: grid;
  grid-template-rows: 22px 160px 20px;
  flex: 1 0 18px;
  min-width: 18px;
  text-align: center;
}
.load-value {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.load-track {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 0;
  border-bottom: 1px solid rgba(147, 161, 179, 0.2);
}
.load-bar {
  position: relative;
  width: 100%;
  min-height: 0;
  border-radius: 4px 4px 1px 1px;
  overflow: hidden;
  background: linear-gradient(180deg, #6da2ff, #3a6fd8);
  box-shadow: 0 0 12px rgba(79, 140, 255, 0.18);
}
.load-errors {
  position: absolute;
  inset: auto 0 0;
  min-height: 0;
  background: #ff6b6b;
}
.load-label {
  padding-top: 6px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}
.realtime-metrics,
.platform-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}
.realtime-metrics > div,
.platform-metrics > div {
  display: grid;
  gap: 5px;
  padding: 13px;
  background: rgba(15, 20, 25, 0.88);
}
.realtime-metrics span,
.platform-metrics span { color: var(--muted); font-size: 12px; }
.realtime-metrics strong,
.platform-metrics strong { font-size: 15px; overflow-wrap: anywhere; }
.ranking-list { display: grid; gap: 18px; }
.ranking-item { min-width: 0; }
.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ranking-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ranking-position {
  display: inline-grid;
  place-items: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(79, 140, 255, 0.15);
  color: #a9c7ff;
  font-size: 11px;
  font-weight: 700;
}
.ranking-track,
.mix-track {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(147, 161, 179, 0.13);
}
.ranking-track span,
.mix-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-2), #7657ff);
}
.ranking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 13px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.mix-list,
.error-breakdown { display: grid; gap: 11px; }
.mix-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(70px, 1.3fr) 46px;
  align-items: center;
  gap: 10px;
}
.mix-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.mix-row strong { text-align: right; font-size: 12px; }
.error-breakdown > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.error-breakdown > div:last-child { padding-bottom: 0; border-bottom: 0; }
.error-breakdown span { min-width: 0; overflow-wrap: anywhere; }
.error-breakdown span:nth-child(2) { color: var(--muted); font-size: 12px; }
.monitoring-empty {
  display: grid;
  min-height: 202px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}
.monitoring-empty.compact { min-height: 90px; }
.quick-actions-card .row { margin-top: 14px; }

@media (max-width: 1150px) {
  .monitoring-kpis { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .monitoring-grid-main { grid-template-columns: 1fr; }
  .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-card { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .mobile-only, .icon-btn.mobile-only { display: inline-grid; }
  .shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.58);
  }
  .main { padding: 16px 16px 32px; }
  .topbar { align-items: flex-start; }
  .ranking-grid, .details-grid { grid-template-columns: 1fr; }
  .platform-card { grid-column: auto; }
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  #topbar-actions { width: 100%; }
  #topbar-actions .btn { width: 100%; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .v { font-size: 1.15rem; overflow-wrap: anywhere; }
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(23, 29, 37, 0.92);
  }
  td {
    display: grid;
    grid-template-columns: minmax(90px, 36%) minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    overflow-wrap: anywhere;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
  }
  td.actions { display: flex; padding-top: 12px; }
  td.actions::before { display: none; }
  td.empty { display: block; }
  td.empty::before { display: none; }
  .table-toolbar label { width: 100%; min-width: 0; }
  .table-tools { width: 100%; justify-content: space-between; }
  .filters-card, .filters-card.compact { grid-template-columns: 1fr; }
  .filter-actions .btn { flex: 1; }
  .summary-line { align-items: flex-start; flex-direction: column; }
  .modal-footer .btn { flex: 1; }
  .monitoring-toolbar { align-items: stretch; flex-direction: column; }
  .monitoring-controls { align-items: stretch; flex-wrap: wrap; }
  .monitoring-period { flex: 1 1 100%; }
  .period-btn { flex: 1; }
  .load-column { flex-basis: 22px; }
  .load-value { visibility: hidden; }
}

@media (max-width: 420px) {
  .grid-stats { grid-template-columns: 1fr; }
  .main { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
