/* ===== Reset & Tokens ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0f14;
  --surface: #141922;
  --surface-2: #1b222d;
  --surface-3: #232b37;
  --border: #303947;
  --border-strong: #465469;
  --text: #edf2f7;
  --text-muted: #95a1b2;
  --text-subtle: #6f7a8a;
  --success: #38b46b;
  --info: #5aa2f7;
  --warning: #d19a2a;
  --danger: #ef5b5b;
  --focus: #8ec5ff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 228px;
  --header-h: 56px;
  --page-pad-x: clamp(24px, 2.2vw, 40px);
  --page-pad-y: 28px;
  --page-pad-bottom: 44px;
  --section-gap: 20px;
  --grid-gap: 12px;
  --touch-target: 44px;
  --content-max: 1360px;
  --content-wide-max: 1760px;
}

html { color-scheme: dark; }

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { flex: 0 0 auto; }

/* ===== Typography & Utilities ===== */
h1, h2, h3 { color: var(--text); font-weight: 700; line-height: 1.2; }
h1 { font-size: 21px; }
h2, .card-title, .log-title { font-size: 15px; }
p { color: var(--text-muted); }

.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.section-note { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.accent-green { color: var(--success); }
.accent-blue { color: var(--info); }
.accent-yellow { color: var(--warning); }
.accent-red { color: var(--danger); }
.min-w-0 { min-width: 0; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-5 { margin-top: 20px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.no-margin { margin: 0 !important; }
.truncate { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #5a687c; }

/* ===== Layout ===== */
.layout {
  display: block;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-logo,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.sidebar-logo {
  padding: 4px 4px 16px;
  border-bottom: 1px solid var(--border);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar > .admin-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(90, 162, 247, 0.12);
  border-color: rgba(90, 162, 247, 0.28);
  color: var(--info);
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mobile-topbar { display: none; }

.main-content {
  width: min(calc(100% - var(--sidebar-w)), var(--content-max));
  margin-left: calc(var(--sidebar-w) + max(0px, (100vw - var(--sidebar-w) - var(--content-max)) / 2));
  padding: var(--page-pad-y) var(--page-pad-x) var(--page-pad-bottom);
  min-width: 0;
}

.main-content.wide {
  width: min(calc(100% - var(--sidebar-w)), var(--content-wide-max));
  margin-left: calc(var(--sidebar-w) + max(0px, (100vw - var(--sidebar-w) - var(--content-wide-max)) / 2));
}
.page-id { font-size: 14px; color: var(--text-muted); font-weight: 600; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--section-gap);
  min-width: 0;
}

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

/* ===== Components ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--grid-gap);
  margin-bottom: var(--section-gap);
}

.stats-six { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat-card {
  min-width: 0;
  min-height: 82px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.stat-value {
  font-size: 24px;
  line-height: 1.15;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stat-value.small-value {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card,
.control-panel,
.log-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card { overflow: hidden; }
.form-card { max-width: 980px; }

.card-header-basic {
  min-height: 52px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.card-body { padding: 16px; }

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 306px), 1fr));
  gap: 14px;
}

.cluster-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  min-width: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
}

.cluster-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.cluster-card.card-attention { border-color: rgba(209, 154, 42, 0.75); }

.cluster-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.card-title { margin: 0; }
.card-id { color: var(--text-subtle); font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; margin-top: 3px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.metric-grid div { min-width: 0; }
.metric-grid dt { color: var(--text-subtle); }
.metric-grid dd { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.metric-grid dd { min-width: 0; overflow-wrap: anywhere; }

.card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.action-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

/* ===== Forms & Controls ===== */
.control-panel {
  padding: 14px;
  margin-bottom: var(--section-gap);
  min-width: 0;
}

.cluster-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cluster-controls .compact-status {
  margin-left: auto;
}

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

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-field { gap: 4px; }

.form-label,
.info-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.form-input,
.filter-grid input,
.filter-grid select,
.summary-form input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 36px;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-input:focus,
.filter-grid input:focus,
.filter-grid select:focus,
.summary-form input:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(90, 162, 247, 0.16);
}

.form-textarea {
  resize: vertical;
  min-height: clamp(220px, 34vh, 420px);
  line-height: 1.45;
}

.compact-input { max-width: 340px; }
.form-help { color: var(--text-subtle); font-size: 12px; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 180px) minmax(150px, 180px) minmax(118px, auto) auto;
  align-items: end;
  gap: 10px;
}

.check-filter,
.select-all-wrap {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.check-filter input,
.select-all-wrap input,
.proxy-select {
  width: 16px;
  height: 16px;
  accent-color: var(--info);
}

.bulk-toolbar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.bulk-toolbar.is-active {
  border-top-color: rgba(90, 162, 247, 0.36);
}

.compact-status {
  font-size: 12px;
  white-space: nowrap;
  min-width: 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  max-width: 100%;
}

.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--info); color: #07111f; border-color: rgba(255, 255, 255, 0.08); }
.btn-primary:hover { background: #78b6ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff6b6b; }
.btn-danger-soft { color: #ff9b9b; background: rgba(239, 91, 91, 0.1); border-color: rgba(239, 91, 91, 0.28); }
.btn-danger-soft:hover { background: rgba(239, 91, 91, 0.16); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-full { width: 100%; }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 12px; }

/* ===== Badges & Alerts ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}

.badge-success,
.badge-healthy {
  background: rgba(56, 180, 107, 0.14);
  color: #6fe09d;
  border-color: rgba(56, 180, 107, 0.32);
}

.badge-info,
.badge-running {
  background: rgba(90, 162, 247, 0.14);
  color: #9ac9ff;
  border-color: rgba(90, 162, 247, 0.32);
}

.badge-warning,
.badge-stopped {
  background: rgba(209, 154, 42, 0.14);
  color: #f0c36b;
  border-color: rgba(209, 154, 42, 0.32);
}

.badge-error {
  background: rgba(239, 91, 91, 0.14);
  color: #ff9797;
  border-color: rgba(239, 91, 91, 0.34);
}

.badge-neutral,
.badge-disabled {
  background: rgba(149, 161, 178, 0.12);
  color: var(--text-muted);
  border-color: rgba(149, 161, 178, 0.24);
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.alert-error {
  background: rgba(239, 91, 91, 0.12);
  color: #ffb0b0;
  border: 1px solid rgba(239, 91, 91, 0.32);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #143322; color: #b8f2cd; border-color: rgba(56, 180, 107, 0.4); }
.toast.error { background: #3b1818; color: #ffc4c4; border-color: rgba(239, 91, 91, 0.42); }

/* ===== Tables ===== */
.table-container {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 100%;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table-container-flat {
  border: 0;
  border-radius: 0;
}

.table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.ops-table { min-width: 1120px; table-layout: fixed; }
.monitor-table { min-width: 980px; table-layout: fixed; }
.login-error-table { min-width: 820px; table-layout: fixed; }
.like-error-table { min-width: 720px; table-layout: fixed; }
.failed-rotation-table { min-width: 920px; table-layout: fixed; }
.summary-main-table { min-width: 520px; table-layout: fixed; }
.summary-rate-table { min-width: 0; table-layout: fixed; }
.summary-snapshot-table { min-width: 600px; table-layout: fixed; }
.table-compact { table-layout: fixed; }

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  min-width: 0;
}

.table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.col-select { width: 42px; }
.ops-table th:nth-child(1),
.ops-table td:nth-child(1) { width: 46px; }
.ops-table th:nth-child(2),
.ops-table td:nth-child(2) { width: 104px; }
.ops-table th:nth-child(3),
.ops-table td:nth-child(3) { width: 260px; }
.ops-table th:nth-child(4),
.ops-table td:nth-child(4) { width: 300px; }
.ops-table th:nth-child(5),
.ops-table td:nth-child(5) { width: 98px; }
.ops-table th:nth-child(6),
.ops-table td:nth-child(6),
.ops-table th:nth-child(7),
.ops-table td:nth-child(7) { width: 150px; }
.ops-table th:nth-child(8),
.ops-table td:nth-child(8) { width: 70px; }
.ops-table th:nth-child(9),
.ops-table td:nth-child(9) { width: 92px; }

.monitor-table th:nth-child(1),
.monitor-table td:nth-child(1) { width: 300px; }
.monitor-table th:nth-child(2),
.monitor-table td:nth-child(2) { width: 106px; }
.monitor-table th:nth-child(3),
.monitor-table td:nth-child(3),
.monitor-table th:nth-child(4),
.monitor-table td:nth-child(4),
.monitor-table th:nth-child(5),
.monitor-table td:nth-child(5) { width: 104px; }
.monitor-table th:nth-child(6),
.monitor-table td:nth-child(6) { width: 160px; }
.monitor-table th:nth-child(7),
.monitor-table td:nth-child(7) { width: 206px; }

.failed-rotation-table th:nth-child(1),
.failed-rotation-table td:nth-child(1) { width: 170px; }
.failed-rotation-table th:nth-child(2),
.failed-rotation-table td:nth-child(2) { width: 110px; }
.failed-rotation-table th:nth-child(3),
.failed-rotation-table td:nth-child(3) { width: 140px; }
.failed-rotation-table th:nth-child(4),
.failed-rotation-table td:nth-child(4) { width: 260px; }
.failed-rotation-table th:nth-child(5),
.failed-rotation-table td:nth-child(5) { width: 200px; }
.failed-rotation-table th:nth-child(6),
.failed-rotation-table td:nth-child(6) { width: 96px; }

.login-error-table th:nth-child(1),
.login-error-table td:nth-child(1) { width: 300px; }
.login-error-table th:nth-child(2),
.login-error-table td:nth-child(2),
.login-error-table th:nth-child(3),
.login-error-table td:nth-child(3) { width: 92px; }
.login-error-table th:nth-child(4),
.login-error-table td:nth-child(4),
.login-error-table th:nth-child(5),
.login-error-table td:nth-child(5) { width: 150px; }
.login-error-table th:nth-child(6),
.login-error-table td:nth-child(6) { width: 190px; }

.like-error-table th:nth-child(1),
.like-error-table td:nth-child(1) { width: 500px; }
.like-error-table th:nth-child(2),
.like-error-table td:nth-child(2),
.like-error-table th:nth-child(3),
.like-error-table td:nth-child(3) { width: 110px; }

.ops-table td,
.monitor-table td { font-size: 13px; }
.proxy-row.row-warning { background: rgba(209, 154, 42, 0.055); }
.proxy-row.row-selected { background: rgba(90, 162, 247, 0.1); }
.asset-cell,
.error-cell {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-cell { max-width: 420px; }

.table-empty { border: 1px dashed var(--border); border-radius: var(--radius); margin-top: 10px; }
.empty-state {
  grid-column: 1/-1;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

.empty-inline {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

/* ===== Info & Logs ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.info-card {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.log-section { overflow: hidden; }

.log-header {
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-title { margin-bottom: 5px; }

.log-box {
  height: min(460px, 54vh);
  min-height: 260px;
  overflow: auto;
  background: #05080d;
  color: #c7d0dd;
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.log-line-ok { color: #71df9b; }
.log-line-error { color: #ff8c8c; }
.log-line-muted { color: #8c98a9; }

/* ===== Monitor ===== */
.rotation-list {
  max-height: min(420px, 52vh);
  overflow: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  -webkit-overflow-scrolling: touch;
}

.rotation-row {
  display: grid;
  grid-template-columns: minmax(140px, 22%) minmax(190px, 1fr) 88px;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  font-size: 12px;
  min-width: 0;
}

.rotation-label {
  color: var(--text-muted);
  text-align: right;
  min-width: 0;
}

.rotation-track {
  height: 14px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.rotation-stack {
  display: flex;
  height: 100%;
  min-width: 0;
  transition: width 0.2s;
}

.rotation-success { background: var(--success); }
.rotation-fail { background: var(--danger); }
.rotation-counts { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Summary Monitor ===== */
.summary-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.summary-form .form-field { min-width: 0; }

.summary-form > .btn {
  min-width: 132px;
}

.summary-form.is-loading {
  opacity: 0.86;
}

.summary-range-buttons {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.summary-range-buttons .btn {
  flex: 0 0 auto;
  min-width: 54px;
}

.summary-range-buttons .is-active {
  border-color: rgba(90, 162, 247, 0.5);
  background: rgba(90, 162, 247, 0.16);
  color: #b8d9ff;
}

.summary-hint {
  margin-top: 10px;
  color: var(--text-subtle);
  font-size: 12px;
}

.compact-hint { margin-top: 2px; }
.summary-alert { margin-top: 12px; }

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 20px;
}

.summary-rate-good { color: var(--success); }
.summary-rate-bad { color: var(--danger); }
.card-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.reason-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--text-subtle);
  font-size: 12px;
}
.reason-summary-strip span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(20, 25, 34, 0.52);
}
.reason-summary-strip strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.login-error-row { cursor: pointer; }
.login-error-row.is-open { background: rgba(90, 162, 247, 0.08); }
.login-error-detail { background: rgba(5, 8, 13, 0.5); }
.login-error-detail > td { padding: 0; }
.login-error-detail-header {
  padding: 12px;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.login-error-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.login-error-summary-card {
  min-width: 0;
  padding: 10px;
  background: rgba(20, 25, 34, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.login-error-summary-card dt {
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 1.25;
}
.login-error-summary-card dd {
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.login-error-preview {
  max-height: 360px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.login-error-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.table-compact { min-width: 680px; }
.table-compact th,
.table-compact td {
  padding: 8px 10px;
  font-size: 12px;
}

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 750;
}

/* ===== Responsive ===== */
@media (max-width: 1280px) {
  :root {
    --page-pad-x: 28px;
    --page-pad-y: 24px;
  }
  .filter-grid { grid-template-columns: minmax(260px, 1fr) repeat(2, minmax(148px, 170px)); }
  .filter-grid .check-filter,
  .filter-grid .compact-status { align-self: center; }
  .summary-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 1024px) {
  .stats-bar { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .stats-six { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .form-grid.two-col { grid-template-columns: 1fr; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-actions { justify-content: flex-start; }
}

@media (max-width: 820px) {
  :root {
    --page-pad-x: 16px;
    --page-pad-y: 16px;
    --page-pad-bottom: 28px;
    --grid-gap: 10px;
  }
  .layout { display: block; }
  .sidebar { display: none; }
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    background: rgba(20, 25, 34, 0.98);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
  }
  .mobile-brand { min-width: 0; }
  .mobile-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-menu-toggle { min-height: var(--touch-target); padding-inline: 14px; }
  .mobile-nav-panel {
    position: absolute;
    left: 10px;
    right: 10px;
    top: calc(100% + 8px);
    max-height: calc(100dvh - var(--header-h) - 20px);
    overflow: auto;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
  }
  .mobile-nav-panel .admin-nav { margin-bottom: 10px; }
  .mobile-nav-panel .nav-item,
  .mobile-nav-panel .btn { min-height: var(--touch-target); }
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: var(--page-pad-y) var(--page-pad-x) var(--page-pad-bottom);
    max-width: none;
  }
  .main-content.wide {
    width: 100%;
    margin-left: 0;
  }
  .stats-bar,
  .stats-six,
  .info-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .filter-grid { grid-template-columns: 1fr; }
  .cluster-controls { align-items: stretch; }
  .cluster-controls .compact-status { margin-left: 0; }
  .compact-input { max-width: none; }
  .summary-form { grid-template-columns: 1fr; }
  .summary-form > .btn { width: 100%; min-height: var(--touch-target); }
  .summary-range-buttons {
    margin-inline: -2px;
    padding: 0 2px 6px;
  }
  .form-input,
  .filter-grid input,
  .filter-grid select,
  .summary-form input,
  .btn { min-height: 42px; }
  .btn-sm { min-height: 38px; padding: 7px 10px; }
  .check-filter,
  .select-all-wrap { min-height: 42px; }
  .bulk-toolbar {
    align-items: stretch;
  }
  .bulk-toolbar .btn { flex: 1 1 150px; }
  .card-header-basic { align-items: flex-start; }
  .rotation-row { grid-template-columns: minmax(0, 1fr) 88px; gap: 6px 10px; }
  .rotation-label { text-align: left; }
  .rotation-track { grid-column: 1 / -1; }
  .rotation-counts { text-align: right; }
  .log-box { height: min(420px, 58vh); }
  .table th,
  .table td { padding: 9px 10px; }
  .login-error-table {
    min-width: 560px;
  }
  .login-error-table th:nth-child(4),
  .login-error-table td:nth-child(4),
  .login-error-table th:nth-child(5),
  .login-error-table td:nth-child(5) {
    display: none;
  }
  .login-error-table th:nth-child(1),
  .login-error-table td:nth-child(1) { width: 220px; }
  .login-error-table th:nth-child(2),
  .login-error-table td:nth-child(2),
  .login-error-table th:nth-child(3),
  .login-error-table td:nth-child(3) { width: 72px; }
  .login-error-table th:nth-child(6),
  .login-error-table td:nth-child(6) { width: 190px; }
  .like-error-table { min-width: 520px; }
  .login-error-actions {
    justify-content: flex-end;
    gap: 6px;
  }
  .login-error-actions .btn {
    min-height: 36px;
    padding-inline: 8px;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 19px; }
  .login-wrap { align-items: stretch; padding: 16px; }
  .login-card { padding: 24px; align-self: center; }
  .stats-bar,
  .stats-six,
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { min-height: 78px; padding: 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }
  .card-header-basic,
  .card-body,
  .control-panel { padding: 12px; }
  .card-footer { flex-direction: column; align-items: stretch; }
  .action-group { justify-content: stretch; }
  .action-group .btn { flex: 1 1 auto; }
  .page-actions .btn,
  .page-actions form,
  .page-actions form .btn { width: 100%; }
  .summary-grid { gap: 12px; }
  .summary-hint { line-height: 1.35; }
  .ops-table { min-width: 1060px; }
  .monitor-table { min-width: 900px; }
  .login-error-table { min-width: 560px; }
  .failed-rotation-table { min-width: 860px; }
  .summary-main-table { min-width: 430px; }
  .summary-rate-table { min-width: 0; }
  .summary-snapshot-table { min-width: 520px; }
  .table-compact { min-width: 560px; }
  .asset-cell,
  .error-cell { max-width: 240px; }
  .log-header { align-items: flex-start; }
  .log-box { min-height: 240px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}

@media (max-width: 380px) {
  .stats-bar,
  .stats-six,
  .info-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 68px; }
}
