:root,
[data-theme="dark"] {
  --bg: #07080c;
  --bg-elevated: #0d0f16;
  --bg-card: #11141d;
  --bg-card-hover: #151925;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef0f6;
  --text-muted: #8b92a8;
  --text-dim: #5c647a;
  --primary: #7c6cff;
  --primary-2: #9b8cff;
  --accent: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sidebar: 248px;
  --sidebar-bg: rgba(7, 8, 12, 0.7);
  --nav-hover: rgba(255, 255, 255, 0.04);
  --nav-active-bg: linear-gradient(90deg, rgba(124, 108, 255, 0.18), rgba(124, 108, 255, 0.05));
  --nav-active-border: rgba(124, 108, 255, 0.25);
  --btn-bg: rgba(255, 255, 255, 0.03);
  --btn-hover: rgba(255, 255, 255, 0.06);
  --item-bg: rgba(255, 255, 255, 0.02);
  --input-bg: rgba(0, 0, 0, 0.28);
  --search-bg: rgba(0, 0, 0, 0.25);
  --pill-bg: rgba(255, 255, 255, 0.03);
  --toast-bg: #151925;
  --modal-scrim: rgba(0, 0, 0, 0.55);
  --glow-a: rgba(124, 108, 255, 0.18);
  --glow-b: rgba(34, 211, 238, 0.1);
  --stat-glow: rgba(124, 108, 255, 0.2);
  --table-row-hover: rgba(255, 255, 255, 0.015);
  --table-border: rgba(255, 255, 255, 0.04);
  --accent-btn-text: #042f2e;
  --logo-shadow: 0 8px 24px rgba(124, 108, 255, 0.35);
  --primary-btn-shadow: 0 8px 20px rgba(124, 108, 255, 0.3);
  --accent-btn-shadow: 0 8px 20px rgba(34, 211, 238, 0.22);
  --card-inset: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
  --avatar-bg: rgba(255, 255, 255, 0.04);
  --badge-bg: rgba(255, 255, 255, 0.02);
  --theme-toggle-bg: rgba(255, 255, 255, 0.04);
  --theme-toggle-hover: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  /* models.run-like soft mint panel */
  --bg: #e7f4ef;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f3faf7;
  --border: rgba(15, 61, 46, 0.12);
  --border-strong: rgba(15, 61, 46, 0.2);
  --text: #0f172a;
  --text-muted: #4b635a;
  --text-dim: #6f857c;
  --primary: #0f9f6e;
  --primary-2: #0b8a5e;
  --accent: #0d9488;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(15, 61, 46, 0.08);
  --sidebar-bg: rgba(255, 255, 255, 0.9);
  --nav-hover: rgba(15, 61, 46, 0.05);
  --nav-active-bg: linear-gradient(90deg, rgba(15, 159, 110, 0.14), rgba(15, 159, 110, 0.04));
  --nav-active-border: rgba(15, 159, 110, 0.28);
  --btn-bg: #ffffff;
  --btn-hover: #eef8f3;
  --item-bg: #f4fbf7;
  --input-bg: #f4fbf7;
  --search-bg: #f4fbf7;
  --pill-bg: #eef8f3;
  --toast-bg: #ffffff;
  --modal-scrim: rgba(15, 61, 46, 0.28);
  --glow-a: rgba(16, 185, 129, 0.14);
  --glow-b: rgba(13, 148, 136, 0.1);
  --stat-glow: rgba(16, 185, 129, 0.16);
  --table-row-hover: rgba(15, 61, 46, 0.03);
  --table-border: rgba(15, 61, 46, 0.08);
  --accent-btn-text: #ffffff;
  --logo-shadow: 0 8px 20px rgba(15, 159, 110, 0.22);
  --primary-btn-shadow: 0 8px 18px rgba(15, 159, 110, 0.22);
  --accent-btn-shadow: 0 8px 18px rgba(13, 148, 136, 0.18);
  --card-inset: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  --avatar-bg: #e8f6ef;
  --badge-bg: #eef8f3;
  --theme-toggle-bg: #eef8f3;
  --theme-toggle-hover: #dff3ea;
  --card-border: #d5e8df;
  --card-shadow: 0 1px 2px rgba(15, 61, 46, 0.04), 0 8px 20px rgba(15, 61, 46, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--glow-a), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--glow-b), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
[data-theme="light"] body,
html[data-theme="light"] body {
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(16, 185, 129, 0.12), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(13, 148, 136, 0.08), transparent 50%),
    #e7f4ef;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--logo-shadow);
  background: transparent;
}
.logo svg {
  width: 100%;
  height: 100%;
  display: block;
}
.brand-title { font-weight: 650; font-size: 15px; line-height: 1.2; }
.brand-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: 0.15s ease;
}
.nav-item:hover { background: var(--nav-hover); color: var(--text); }
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--nav-active-border);
}
.nav-icon {
  width: 20px;
  text-align: center;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--theme-toggle-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  transition: 0.15s ease;
}
.theme-toggle:hover {
  background: var(--theme-toggle-hover);
  border-color: var(--border-strong);
}
.theme-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
  line-height: 1;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--pill-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  width: fit-content;
}
.pill.ok { color: var(--success); }
.pill.bad { color: var(--danger); }

/* Main */
.main {
  padding: 28px 32px 48px;
  max-width: 1280px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.danger { color: var(--danger) !important; }

.view { display: none; }
.view.active { display: block; animation: fade 0.2s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:hover { background: var(--btn-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #7c6cff, #6a5af9);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--primary-btn-shadow);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.accent {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: var(--accent-btn-text);
  border-color: transparent;
  box-shadow: var(--accent-btn-shadow);
}
[data-theme="light"] .btn.accent {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.link {
  background: none;
  border: 0;
  color: var(--primary-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--nav-hover); color: var(--text); }

/* Cards / stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-inset);
}
[data-theme="light"] .stat {
  background: var(--bg-card);
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: var(--card-shadow, 0 1px 2px rgba(15, 61, 46, 0.04), 0 8px 20px rgba(15, 61, 46, 0.06));
}
.stat::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, var(--stat-glow), transparent 70%);
  pointer-events: none;
}
.stat .label { color: var(--text-muted); font-size: 12.5px; margin-bottom: 8px; }
.stat .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.stat .hint { margin-top: 6px; font-size: 12px; color: var(--text-dim); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--card-inset);
}
[data-theme="light"] .card {
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: var(--card-shadow, 0 1px 2px rgba(15, 61, 46, 0.04), 0 8px 20px rgba(15, 61, 46, 0.06));
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list.dense { gap: 6px; }
.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
}

.item {
  display: block;
  padding: 12px 12px;
  border-radius: 12px;
  background: var(--item-bg);
  border: 1px solid transparent;
  transition: 0.15s ease;
}
.item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
[data-theme="light"] .item {
  background: #ffffff;
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: 0 1px 2px rgba(15, 61, 46, 0.03);
}
.item:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
}
[data-theme="light"] .item:hover {
  border-color: #b9d8cb;
  background: #f7fcf9;
  box-shadow: 0 6px 16px rgba(15, 61, 46, 0.06);
}
.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.item-copy {
  min-width: 0;
  flex: 1;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--avatar-bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.item-title {
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.35;
  word-break: break-word;
}
.item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}
.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.item-log .item-main {
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--badge-bg);
}
.badge.success { color: var(--success); border-color: rgba(52,211,153,0.25); background: rgba(52,211,153,0.08); }
.badge.failed { color: var(--danger); border-color: rgba(248,113,113,0.25); background: rgba(248,113,113,0.08); }
.badge.off { color: var(--text-dim); }
.balance-cell { min-width: 88px; }
.balance-value {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
[data-theme="light"] .balance-value { color: #0f172a; }
[data-theme="light"] .badge.success {
  border-color: rgba(5, 150, 105, 0.22);
  background: rgba(5, 150, 105, 0.08);
}
[data-theme="light"] .badge.failed {
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(220, 38, 38, 0.06);
}

/* Table */
.table-wrap { overflow: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--table-border);
  vertical-align: middle;
}
.table tr:hover td { background: var(--table-row-hover); }
.filters input {
  background: var(--search-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  width: 220px;
}

/* Sites */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: 0.15s ease;
}
[data-theme="light"] .site-card {
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: var(--card-shadow, 0 1px 2px rgba(15, 61, 46, 0.04), 0 8px 20px rgba(15, 61, 46, 0.06));
}
.site-card:hover {
  border-color: rgba(124,108,255,0.35);
  transform: translateY(-1px);
}
[data-theme="light"] .site-card:hover {
  border-color: rgba(15, 159, 110, 0.45);
  box-shadow: 0 10px 28px rgba(15, 61, 46, 0.1);
}
.site-top { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; min-width: 0; }
.site-copy { min-width: 0; flex: 1; }
.site-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: color-mix(in srgb, var(--c, var(--primary)) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--primary)) 30%, transparent);
}
.site-name { font-weight: 650; }
.site-id { color: var(--text-dim); font-size: 12px; font-family: var(--mono); margin-top: 2px; }
.site-desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  min-height: 40px;
  word-break: break-word;
}
.site-meta {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.site-actions {
  margin-left: auto;
}

.tip-card { margin-top: 4px; }
.help-list { color: var(--text-muted); line-height: 1.7; padding-left: 18px; }
.prose h3 { margin-top: 0; }
.prose ol, .prose ul { color: var(--text-muted); line-height: 1.75; }
.prose p { color: var(--text-muted); line-height: 1.7; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(520px, 100%);
  max-height: min(90vh, 800px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
[data-theme="light"] .modal {
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: 0 18px 48px rgba(15, 61, 46, 0.14);
}
[data-theme="light"] .btn.primary {
  background: linear-gradient(135deg, #12b981, #0f9f6e);
  box-shadow: var(--primary-btn-shadow);
}
[data-theme="light"] .btn.accent {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}
[data-theme="light"] .table-wrap,
[data-theme="light"] .gate-card {
  border: 1.5px solid var(--card-border, #d5e8df);
  box-shadow: var(--card-shadow, 0 1px 2px rgba(15, 61, 46, 0.04), 0 8px 20px rgba(15, 61, 46, 0.06));
  background: #ffffff;
}
[data-theme="light"] .table-wrap {
  border-radius: var(--radius);
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.form label.row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13.5px;
}
.form input[type="text"],
.form input[type="password"],
.form input:not([type]),
.form input[type="search"],
.form select,
.form textarea {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
.form textarea {
  min-height: 100px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: rgba(124,108,255,0.55);
  box-shadow: 0 0 0 3px rgba(124,108,255,0.15);
}
[data-theme="light"] .form input:focus,
[data-theme="light"] .form select:focus,
[data-theme="light"] .form textarea:focus {
  border-color: rgba(109, 94, 252, 0.55);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.12);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.field-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: -2px;
}
.field-with-action {
  display: flex;
  gap: 8px;
  align-items: center;
}
.field-with-action select,
.field-with-action input {
  flex: 1;
  min-width: 0;
}
.field-with-action .btn,
.field-with-action a.btn {
  flex-shrink: 0;
  white-space: nowrap;
  text-decoration: none;
}
.section-label {
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.secret-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 2px;
}
.secret-box {
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}
[data-theme="light"] .secret-box {
  background: #f4fbf7;
  border: 1.5px solid var(--card-border, #d5e8df);
}
.secret-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}
.secret-row > span {
  width: 42px;
  color: var(--text-muted);
  flex-shrink: 0;
  padding-top: 2px;
}
.secret-row code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.45;
}
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
}

/* Toast */
.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}
.toast {
  min-width: 240px;
  max-width: 360px;
  background: var(--toast-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: slide 0.2s ease;
  color: var(--text);
}
.toast.success { border-color: rgba(52,211,153,0.35); }
.toast.failed, .toast.error { border-color: rgba(248,113,113,0.35); }
@keyframes slide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Log detail */
.log-detail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  max-width: 100%;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Mobile / small screens */
.menu-btn,
.sidebar-close { display: none; }
.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.sidebar-backdrop {
  display: none;
}

/* Access gate */
.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.gate[hidden],
.app[hidden] { display: none !important; }
.gate-card {
  width: min(380px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 22px 22px;
  text-align: center;
}
.gate-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--logo-shadow);
}
.gate-logo svg { width: 100%; height: 100%; display: block; }
.gate-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.gate-sub {
  margin: 8px 0 18px;
  font-size: 13.5px;
}
.gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.gate-form input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  outline: none;
}
.gate-form input:focus {
  border-color: rgba(124,108,255,0.55);
  box-shadow: 0 0 0 3px rgba(124,108,255,0.15);
}
.gate-btn {
  width: 100%;
  justify-content: center;
  padding: 12px 14px;
  font-size: 15px;
}
.gate-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}
.settings-form {
  max-width: 520px;
}
.settings-form .row {
  margin: 2px 0;
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .menu-btn { display: grid; place-items: center; margin-top: 2px; flex-shrink: 0; }
  .sidebar-close {
    display: grid;
    place-items: center;
    margin-left: auto;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 50px rgba(0,0,0,0.35);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
  }
  .sidebar-backdrop[hidden] { display: none !important; }
  .brand { padding-right: 4px; }
  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow: auto;
  }
  .main {
    padding: 14px 12px 28px;
    max-width: none;
    width: 100%;
    overflow-x: hidden;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .topbar h1 { font-size: 22px; }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .top-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .top-actions .btn.accent { grid-column: 1 / -1; }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .stat { padding: 12px 12px; min-width: 0; }
  .stat .value { font-size: 22px; word-break: break-word; }
  .card { padding: 12px 12px; min-width: 0; }
  .item-main {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .item-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .item-log .item-actions {
    width: auto;
    margin-left: auto;
  }
  .site-meta {
    flex-direction: column;
    align-items: stretch;
  }
  .site-actions {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .site-actions .btn,
  .site-actions a.btn {
    width: 100%;
    justify-content: center;
    min-width: 0;
  }
  .card-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-head .btn {
    flex-shrink: 0;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }
  .table {
    min-width: 720px;
    font-size: 12.5px;
  }
  .filters input { width: 100%; max-width: none; }
  .card-head { flex-wrap: wrap; }
  .sites-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    width: 100%;
    max-height: min(92dvh, 900px);
    border-radius: 14px 14px 12px 12px;
  }
  .modal-backdrop { padding: 10px; align-items: end; }
  .toast-wrap {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .field-with-action { flex-wrap: wrap; }
  .field-with-action .btn,
  .field-with-action a.btn { width: 100%; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .top-actions { grid-template-columns: 1fr; }
  .top-actions .btn.accent { grid-column: auto; }
  .nav-item { font-size: 13.5px; padding: 10px 10px; }
}
