/* ── Vela Sans font (Binom) ── */
@font-face { font-family: "Vela Sans"; src: url("/static/fonts/VelaSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Vela Sans"; src: url("/static/fonts/VelaSans-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Vela Sans"; src: url("/static/fonts/VelaSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Vela Sans"; src: url("/static/fonts/VelaSans-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ── Common styles shared across all pages ── */
:root {
  --bg: #11151a;
  --bg2: #191c23;
  --bg3: #22252e;
  --border: #383d4e;
  --border2: #585a5e;
  --text: #bebebe;
  --text2: #949faf;
  --text3: #445062;
  --green: #0b9852;
  --green-dim: #4c5c4a;
  --red: #ff4d4f;
  --red-dim: #47393c;
  --yellow: #f5b700;
  --yellow-dim: #575033;
  --blue: #008fe1;
  --blue-dim: #274561;
  --cyan: #72b3ff;
  --purple: #a088bf;
  --accent: var(--blue);
  --accent-dim: var(--blue-dim);

  --header-bg: #090909;
  --nav-bg: #171d23;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;

  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 8px;
  --r-xl: 10px;

  --sidebar-w: 240px;
  --subpage-pad-x: 24px;
  --subpage-pad-y: 20px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-med: 200ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Vela Sans", sans-serif;
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  min-height: 100vh;
  animation: page-in 0.25s var(--ease-out) both;
}
@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.header-top {
  background: var(--header-bg);
  border-bottom: none;
  padding: 0 24px;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo img { height: 18px; width: 18px; opacity: 0.9; }
.logo span { color: var(--text); }
.logo-sep {
  width: 1px;
  height: 16px;
  background: var(--border2);
  margin: 0 4px;
}
.logo-page {
  font-family: "Vela Sans", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-link {
  background: none; border: none; color: var(--text2); font-size: 11px;
  font-family: "Vela Sans", sans-serif; cursor: pointer; padding: 0;
  transition: color 0.15s;
}
.header-link:hover { color: var(--text);
}
.header-bell { position: relative; font-size: 14px; line-height: 1; padding: 2px 4px; }
.bell-badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--red, #e54848); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 14px; height: 14px; line-height: 14px;
  padding: 0 4px; border-radius: 7px; text-align: center;
}
.act-panel {
  position: fixed; top: 38px; right: 12px; z-index: 9500;
  width: 380px; max-height: 480px;
  background: var(--bg2, #1b2028); border: 1px solid var(--border, #2a3038);
  border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  animation: dropdown-in 0.16s var(--ease-out);
}
.act-head {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text); font-size: 12px; font-weight: 600;
}
.act-head .act-clear {
  background: none; border: none; color: var(--text3);
  font-size: 10px; cursor: pointer; padding: 2px 6px;
}
.act-head .act-clear:hover { color: var(--text); }
.act-list { overflow-y: auto; flex: 1; }
.act-empty { padding: 24px; text-align: center; color: var(--text3); font-size: 11px; }
.act-item {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-start;
  color: var(--text2);
}
.act-item:last-child { border-bottom: none; }
.act-item.unread { background: rgba(255,255,255,0.03); }
.act-icon { font-size: 12px; flex-shrink: 0; width: 14px; text-align: center; }
.act-icon.success { color: var(--green, #2ecc71); }
.act-icon.error { color: var(--red, #e54848); }
.act-icon.warn { color: var(--orange, #f0a040); }
.act-icon.info { color: var(--cyan, #4ac4d6); }
.act-body { flex: 1; min-width: 0; }
.act-msg { color: var(--text); white-space: normal; word-break: break-word; }
.act-meta { color: var(--text3); font-size: 10px; margin-top: 2px; display: flex; gap: 6px; }
.act-meta a { color: var(--cyan, #4ac4d6); text-decoration: none; }
.act-meta a:hover { text-decoration: underline; }

.header-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 45px;
  display: flex;
  align-items: stretch;
  gap: 0;
  position: relative;
  box-shadow: 0 -13px 80px rgba(0,0,0,0.07), 0 -6px 29px rgba(0,0,0,0.06);
}

.header-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
  font-size: 11px;
}

/* ── Header balances bar ── */
.header-balances-bar {
  background: var(--header-bg);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 0 24px; min-height: 0;
}
.header-balances-bar:empty { display: none; }
.header-balances-bar .hbal {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 0; white-space: nowrap;
}
.header-balances-bar .hbal-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.header-balances-bar .hbal-name { font-size: 11px; font-weight: 600; text-decoration: none; }
.header-balances-bar .hbal-name:hover { text-decoration: underline; }
.header-balances-bar .hbal-value { font-size: 11px; font-weight: 700; }

/* ── Navigation links ── */
.nav-link {
  color: var(--text2);
  text-decoration: none;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  padding: 0 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
  font-family: "Vela Sans", sans-serif;
  white-space: nowrap;
}
.nav-link:first-child { padding-left: 0; }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: #fff; border-bottom-color: #fff; }

/* ── Buttons ── */
.btn {
  font-family: "Vela Sans", sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 5px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn:not(:disabled):active { transform: translateY(1px); }

/* Primary action: solid blue (matches SPA btn-create / btn-save). */
.btn-run { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-run:hover { background: #1f86db; border-color: #1f86db; }

/* Secondary action: neutral bg3 + border (matches SPA btn-bulk). */
.btn-dry { background: var(--bg3); border-color: var(--border); color: var(--text2); }
.btn-dry:hover { border-color: var(--border2); color: var(--text); }

/* Tertiary / subtle action: transparent + border (matches SPA btn-cancel). */
.btn-settings { background: transparent; border-color: var(--border); color: var(--text2); }
.btn-settings:hover { border-color: var(--border2); color: var(--text); }

/* Destructive: bg3 + red-dim border (matches SPA btn-bulk-delete). */
.btn-danger { background: var(--bg3); border-color: var(--red-dim); color: var(--red); font-size: 11px; }
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

/* Modal save (kept identical to btn-run for SPA compatibility). */
.btn-save { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-save:hover { background: #1f86db; border-color: #1f86db; }

.btn-cancel { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-cancel:hover { border-color: var(--text3); color: var(--text); }

/* ── Panel ── */
.panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
}
.panel-title {
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text2);
}
.panel-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--text3);
}

/* ── Date range bar (zones/dates panels) ── */
.date-range-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dr-preset {
  font-family: "Vela Sans", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 3px 10px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
}
.dr-preset:hover { border-color: var(--text2); color: var(--text2); }
.dr-preset.active { background: var(--blue-dim); border-color: var(--blue); color: var(--blue); }
.dr-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}
.dr-dash { color: var(--text3); font-size: 11px; }
.dr-date-wrap { position: relative; }
.dr-date-btn {
  font-family: "Vela Sans", sans-serif;
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  padding: 3px 8px;
  height: 24px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.dr-date-btn:hover { border-color: var(--text3); color: var(--text); }
.dr-date-btn.open { border-color: var(--blue); color: var(--text); }

/* ── Custom calendar dropdown ── */
.cal-dropdown {
  display: none;
  position: fixed;
  z-index: 999;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  user-select: none;
  width: 252px;
}
.cal-dropdown.visible { display: block; animation: dropdown-in 0.14s var(--ease-out); }
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.cal-nav-btn:hover { border-color: var(--text2); color: var(--text); }
.cal-month-label {
  font-family: "Vela Sans", sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .5px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  font-family: "Vela Sans", sans-serif;
  font-size: 9px;
  color: var(--text3);
  text-align: center;
  padding: 4px 0 2px;
  letter-spacing: .5px;
}
.cal-day {
  font-family: "Vela Sans", sans-serif;
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  padding: 4px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: all .12s;
  border: 1px solid transparent;
}
.cal-day:hover { background: var(--bg3); color: var(--text); }
.cal-day.other-month { color: var(--text3); opacity: .4; }
.cal-day.today { border-color: var(--border2); color: var(--text); }
.cal-day.selected { background: var(--blue-dim); border-color: var(--blue); color: var(--blue); }
.cal-day.in-range { background: rgba(88,166,255,.08); }
.cal-day.empty { pointer-events: none; }

/* ── Panel refresh button ── */
.btn-panel-refresh {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 14px; width: 22px; height: 22px; display: flex; align-items: center;
  justify-content: center; transition: all 0.15s; padding: 0; border-radius: 50%;
  flex-shrink: 0;
}
.btn-panel-refresh:hover { color: var(--text); background: var(--bg3); }
.btn-panel-refresh.spinning { pointer-events: none; color: var(--blue); }
.btn-panel-refresh.spinning span { display: inline-block; animation: spin 0.8s linear infinite; }

/* ── View toolbar (Aff. networks, Traffic sources, etc.) ── */
.view-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  width: fit-content;
}
.view-toolbar button:focus,
.view-toolbar select:focus,
.view-toolbar input:focus { outline: none; }
.view-toolbar .search-input {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text2); font-size: 10px; font-family: "Vela Sans", sans-serif;
  padding: 5px 8px; width: 160px; outline: none; transition: all 0.15s;
}
.view-toolbar .search-input::placeholder { color: var(--text3); }
.view-toolbar .search-input:hover { border-color: var(--border2); color: var(--text); }
.view-toolbar .search-input:focus { border-color: var(--border2); }
.view-toolbar .period-select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text2); font-size: 10px; font-family: "Vela Sans", sans-serif;
  padding: 5px 8px; cursor: pointer; font-weight: 600; outline: none;
  transition: all 0.15s; white-space: nowrap;
}
.view-toolbar .period-select:hover { border-color: var(--border2); color: var(--text); }
.view-toolbar .period-select:focus { border-color: var(--border2); }
.btn-refresh {
  background: var(--blue); border: none; border-radius: 4px; color: #f1f1f1;
  font-size: 11px; font-family: "Vela Sans", sans-serif; font-weight: 600;
  padding: 5px 12px; cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-refresh:hover { background: #1f86db; }
.btn-refresh.spinning { pointer-events: none; opacity: 0.7; }
.btn-refresh.spinning .refresh-icon { display: inline-block; animation: spin 0.8s linear infinite; }

/* ── Status badges ── */
.status-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.status-running { background: var(--yellow-dim); color: var(--yellow); }
.status-success { background: var(--green-dim); color: var(--green); }
.status-error { background: var(--red-dim); color: var(--red); }
.status-idle { background: var(--bg3); color: var(--text3); }
.status-active { background: var(--green-dim); color: var(--green); }
.status-paused { background: var(--bg3); color: var(--text3); }

/* ── Status pills (unified across pages) ── */
.status-pill {
  font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 1px; display: inline-block; flex-shrink: 0;
}
.st-ok, .st-success, .st-clean { background: var(--green-dim); color: var(--green); }
.st-error, .st-danger, .st-substituted { background: var(--red-dim); color: var(--red); }
.st-warning { background: var(--yellow-dim); color: var(--yellow); }
.st-flagged { background: var(--red-dim); color: var(--red); }
.st-running { background: var(--yellow-dim); color: var(--yellow); }
.st-info { background: var(--blue-dim); color: var(--blue); }
.st-timeout, .st-none, .st-nokey, .st-pending { background: var(--bg3); color: var(--text3); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9500;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open,
.modal-overlay.show { display: flex; animation: overlay-in 0.18s ease-out; }
@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.modal-title {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.btn-cp {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text2); font-size: 10px; font-family: "Vela Sans", sans-serif;
  padding: 3px 8px; cursor: pointer; font-weight: 600; transition: all 0.15s;
}
.btn-cp:hover { border-color: var(--border2); color: var(--text); background: var(--bg3); }
.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; flex: 1; min-height: 0; overflow-y: auto; }

.modal-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: -20px -20px 16px; padding: 0 20px; }
.modal-tab {
  padding: 10px 16px; font-size: 11px; cursor: pointer; color: var(--text3);
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.modal-tab:hover { color: var(--text2); }
.modal-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.network-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 5px; margin-bottom: 6px; cursor: pointer;
}
.network-row:hover { border-color: var(--border2); }
.network-row input[type="checkbox"] { accent-color: var(--blue); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.network-row-name { flex: 1; font-size: 12px; color: var(--text); }
.network-row-hint { font-size: 10px; color: var(--text3); }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text3);
  margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 8px 12px;
  color: var(--text);
  font-family: "Vela Sans", sans-serif;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 143, 225, 0.15);
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ── Select dropdowns ── */
select,
.form-group select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 8px 32px 8px 12px;
  color: var(--text);
  font-family: "Vela Sans", sans-serif;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select:hover,
.form-group select:hover { border-color: var(--text3); }
select option {
  background: var(--bg3);
  color: var(--text);
  padding: 6px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-check { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.form-check input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--blue); cursor: pointer; }
.form-check label {
  font-size: 12px; color: var(--text); cursor: pointer;
  margin-bottom: 0; text-transform: none; letter-spacing: 0;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: "Vela Sans", sans-serif;
  font-size: 12px;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateX(30px);
  animation: toast-in 0.25s ease forwards;
  min-width: 200px;
  max-width: 400px;
}
.toast-item.removing {
  animation: toast-out 0.2s ease forwards;
}
.toast-item .toast-icon { font-size: 14px; flex-shrink: 0; }
.toast-item .toast-text { flex: 1; }
.toast-item.success {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--green);
}
.toast-item.error {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
}
@keyframes toast-in {
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(30px); }
}



/* ── Page container (subpages: domains, scripts, offers, monitor, spy) ── */
.page-container {
  max-width: 1000px; margin: 20px auto; padding: 0 20px;
  display: flex; flex-direction: column; gap: 16px;
}
@media (max-width: 768px) {
  .page-container { padding: 0 10px; margin: 10px auto; }
}

/* ── Subpage layout (settings-like sidebar + content) ── */
.subpage-layout {
  display: flex;
  height: calc(100vh - 92px);
  overflow: hidden;
}
.subpage-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  flex-direction: column;
}
.subpage-sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.subpage-sidebar-title {
  font-family: "Syne", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
}
.subpage-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.subpage-sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.subpage-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  font-family: "Vela Sans", sans-serif;
  border-left: 2px solid transparent;
}
.subpage-nav-item:hover { color: var(--text); background: rgba(255,255,255,0.02); }
.subpage-nav-item.active { color: var(--blue); border-left-color: var(--blue); background: rgba(0,143,225,0.06); }
.subpage-nav-item .nav-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--text3);
}
.subpage-nav-item .nav-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}
.subpage-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-7);
  min-height: 0;
}
.subpage-content h2 {
  font-family: "Syne", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}
.subpage-content-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.subpage-content-header h2 { margin: 0; }
.subpage-content-header .spacer { flex: 1; }

/* Sidebar form controls */
.sidebar-field {
  padding: 0 16px;
  margin-bottom: 10px;
}
.sidebar-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  margin-bottom: 4px;
}
.sidebar-field input,
.sidebar-field select,
.sidebar-field textarea {
  width: 100%;
  font-family: "Vela Sans", sans-serif;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 8px;
}
.sidebar-field textarea { resize: vertical; min-height: 60px; }
.sidebar-field input::placeholder,
.sidebar-field textarea::placeholder { color: var(--text3); }
.sidebar-actions {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-actions .btn { width: 100%; justify-content: center; font-size: 11px; }
.sidebar-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

@media (max-width: 768px) {
  .subpage-layout { flex-direction: column; height: auto; min-height: calc(100vh - 92px); }
  .subpage-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    overflow: visible;
  }
  .subpage-sidebar-body { padding: 4px 0; }
  .subpage-nav-item { padding: 6px 14px; border-left: none; border-bottom: 2px solid transparent; }
  .subpage-nav-item.active { border-left-color: transparent; border-bottom-color: var(--blue); }
  .subpage-content { padding: 16px; }
  .sidebar-field { padding: 0 12px; }
  .sidebar-actions { padding: 0 12px; }
}

/* ── Settings body/row (shared across subpages) ── */
.settings-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.settings-row { display: flex; align-items: center; gap: 10px; }
.settings-row label { font-size: 11px; color: var(--text2); min-width: 120px; }
.settings-row input, .settings-row select {
  font-family: "Vela Sans", sans-serif; font-size: 12px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 6px 10px; flex: 1;
}

/* ── Subpage panel header override ── */
.page-container .panel-header { font-weight: 600; font-size: 13px; }

/* ── Utility classes ── */
.text-r { text-align: right; }
.text-c { text-align: center; }
.bold { font-weight: 700; }
.mono { font-family: "JetBrains Mono", monospace; font-size: 11px; }
.c-red { color: var(--red); }
.c-yellow { color: var(--yellow); }
.c-cyan { color: var(--cyan); }
.c-blue { color: var(--blue); }
.c-purple { color: var(--purple); }

/* ── Button sizes ── */
.btn-sm { padding: 2px 8px; font-size: 10px; }

/* ── Icons (SVG sprite, Lucide-style) ──
   Usage: <svg class="icon"><use href="/static/icons.svg#icon-NAME"/></svg>
   Inherits color from parent via currentColor. */
.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: middle;
  color: currentColor;
  pointer-events: none;
}
.icon-xs { width: 10px; height: 10px; }
.icon-sm { width: 12px; height: 12px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* ── Schedule pill (shared across subpages) ── */
.sched-pill {
  font-size: 9px; padding: 1px 5px; border-radius: var(--r-sm);
  border: 1px solid; transition: all 0.15s;
}
.sched-on { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.sched-off { background: var(--bg3); color: var(--text3); border-color: var(--border); }

/* ── Toggle button (shared) ── */
.toggle-btn {
  padding: 2px 8px; font-size: 10px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid; font-family: "Vela Sans", sans-serif; font-weight: 600;
}
.toggle-on { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.toggle-off { background: var(--bg3); border-color: var(--border2); color: var(--text3); }

/* ── Form section title (settings-modal) ── */
.form-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 10px;
}

/* ── State messages ── */
.state-loading, .state-empty, .state-error {
  text-align: center; padding: 24px 16px; font-size: 12px;
}
.state-loading { color: var(--text3); }
.state-empty { color: var(--text3); }
.state-error { color: var(--red); }

/* ── Skeleton loader (opt-in) ── */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 50%, var(--bg3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ── Subpage simple modal (domains, scripts, offers) ── */
.page-modal { padding: 20px; min-width: 320px; max-width: 400px; width: auto; }
.page-modal h3 { font-size: 13px; margin-bottom: 14px; }
.page-modal label { font-size: 11px; color: var(--text2); display: block; margin-bottom: 4px; }
.page-modal input, .page-modal select, .page-modal textarea {
  font-family: "Vela Sans", sans-serif; font-size: 12px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 6px 10px; width: 100%; margin-bottom: 12px;
}
.page-modal .btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.page-modal-wide { max-width: 680px; width: 90vw; max-height: 85vh; overflow-y: auto; }
@media (max-width: 768px) {
  .page-modal { min-width: unset; width: calc(100vw - 32px); }
}

/* ── Base table (.t) — unified table styling ── */
.t { width: 100%; border-collapse: collapse; font-size: 12px; font-family: "Vela Sans", sans-serif; }
.t thead { position: sticky; top: 0; z-index: 2; }
.t tfoot { position: sticky; bottom: 0; z-index: 2; }
.t th {
  padding: 6px 10px; text-align: left; color: var(--text3); font-size: 10px;
  font-weight: 600; background: var(--bg3); border-bottom: 1px solid var(--border2);
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; user-select: none;
}
.t td { padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.t tbody tr { transition: background-color 0.12s ease-out; }
.t tbody tr:hover { background: rgba(255,255,255,0.03); }
.t tfoot td { background: var(--bg3); border-top: 1px solid var(--border2); font-weight: 700; }
.t .t-num { font-variant-numeric: tabular-nums; }
@media (max-width: 768px) {
  .t { font-size: 10px; }
  .t th, .t td { padding: 5px 6px; }
}

/* ── Table column settings (gear + dropdown) ── */
.t-col-gear { cursor: pointer; color: var(--text); font-size: 13px; opacity: 0.5; transition: opacity 0.15s; vertical-align: middle; display: inline-block; }
.t-col-gear:hover { opacity: 1; }
.t-col-dropdown {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 0; z-index: 100; min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.t-col-dropdown.open { display: block; animation: dropdown-in 0.14s var(--ease-out); }
.t-col-item {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px;
  font-size: 11px; color: var(--text); cursor: default;
}
.t-col-item:hover { background: rgba(255,255,255,0.04); }
.t-col-item input { cursor: pointer; accent-color: var(--blue); }
.t-col-grip { cursor: grab; color: var(--text3); font-size: 10px; user-select: none; }
.t-col-item[draggable="true"]:active .t-col-grip { cursor: grabbing; }

/* ── Empty state ── */
.empty-state { padding: 40px; text-align: center; color: var(--text3); }

/* ── Terminal ── */
.terminal {
  background: var(--bg, #11151a);
  padding: 16px;
  min-height: 200px;
  overflow-y: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  scroll-behavior: smooth;
}
.terminal::-webkit-scrollbar { width: 4px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Responsive: header + common ── */
@media (max-width: 768px) {
  .header-top {
    padding: 0 12px;
    height: 32px;
  }
  .header-top .mob-sidebar-toggle { display: block; }
  .logo { font-size: 14px; }
  .logo-sep, .logo-page { display: none; }
  .header-right .btn { font-size: 9px !important; padding: 3px 8px !important; }
  .header-balances-bar { padding: 0 12px; gap: 10px; }
  .header-balances-bar .hbal-name { font-size: 10px; }
  .header-balances-bar .hbal-value { font-size: 10px; }
  .header-nav {
    padding: 0 8px;
    height: auto;
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .nav-link { font-size: 10px; padding: 6px 8px; flex-shrink: 0; }
  #header-balances {
    width: 100%;
    margin-left: 0 !important;
    gap: 6px !important;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
  }
  #header-balances > span { font-size: 10px !important; gap: 3px !important; }
  #header-balances a { font-size: 9px !important; font-weight: 600; }

  .btn { font-size: 11px; padding: 8px 12px; }

  .terminal {
    height: calc(100vh - 300px);
    min-height: 200px;
    max-height: 400px;
    font-size: 11px;
  }

  .modal { width: calc(100vw - 24px); max-height: 90vh; }
  .modal-body { padding: 14px; flex: 1; min-height: 0; overflow-y: auto; }
  .form-row { grid-template-columns: 1fr; gap: 10px; }

  .panel-header { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .panel-title { font-size: 11px; }

  /* Toast: full-width on mobile */
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast-item { max-width: unset; }
}

@media (max-width: 400px) {
  .terminal {
    height: calc(100vh - 260px);
    min-height: 180px;
  }
  .nav-link { font-size: 9px; padding: 5px 6px; }
}