/* My panel design system, shared by the login page, setup wizard, and dashboard. */

/* Every theme defines the same tokens, and I make "auto" follow the system light or dark
   setting. The Appearance dialog can override the accent (see common.js). */

:root, :root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f6;
  --border: #e1e6ee;
  --border-strong: #cfd6e2;
  --text: #17202e;
  --text-muted: #5d6b80;
  --text-faint: #8a96a8;
  --accent: #229ed9;
  --accent-strong: #1683b8;
  --accent-2: #8b5cf6;
  --success: #1f9d61;
  --warning: #c27a00;
  --danger: #d6404c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --glass: rgba(255, 255, 255, 0.66);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="auto"] {
    --bg: #0f141b; --bg-elev: #161d27; --bg-sunken: #121821; --border: #232d3a; --border-strong: #2f3b4b;
    --text: #e6ebf2; --text-muted: #9aa8bb; --text-faint: #6b7a8f;
    --accent: #3cb1ec; --accent-strong: #62c3f3; --accent-2: #a78bfa;
    --success: #3cc985; --warning: #e9a23b; --danger: #f06470;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --glass: rgba(22, 29, 39, 0.62);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f141b; --bg-elev: #161d27; --bg-sunken: #121821; --border: #232d3a; --border-strong: #2f3b4b;
  --text: #e6ebf2; --text-muted: #9aa8bb; --text-faint: #6b7a8f;
  --accent: #3cb1ec; --accent-strong: #62c3f3; --accent-2: #a78bfa;
  --success: #3cc985; --warning: #e9a23b; --danger: #f06470;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --glass: rgba(22, 29, 39, 0.62);
  color-scheme: dark;
}

:root[data-theme="amoled"] {
  --bg: #000000; --bg-elev: #0a0a0a; --bg-sunken: #050505; --border: #1d1d1d; --border-strong: #2a2a2a;
  --text: #f2f2f2; --text-muted: #a3a3a3; --text-faint: #6e6e6e;
  --accent: #3cb1ec; --accent-strong: #62c3f3; --accent-2: #f472b6;
  --success: #3cc985; --warning: #f0b23e; --danger: #ff5c6c;
  --shadow: none; --glass: rgba(10, 10, 10, 0.7);
  color-scheme: dark;
}

:root[data-theme="midnight"] {
  --bg: #0b1020; --bg-elev: #121a33; --bg-sunken: #0e1529; --border: #222c4d; --border-strong: #2e3a63;
  --text: #e6eaff; --text-muted: #9aa3c7; --text-faint: #6c759b;
  --accent: #7c8cff; --accent-strong: #a0abff; --accent-2: #38bdf8;
  --success: #34d399; --warning: #fbbf24; --danger: #fb7185;
  --shadow: 0 8px 30px rgba(3, 6, 20, 0.5); --glass: rgba(18, 26, 51, 0.6);
  color-scheme: dark;
}

:root[data-theme="ocean"] {
  --bg: #061f28; --bg-elev: #0a2c37; --bg-sunken: #082530; --border: #134456; --border-strong: #1b5a70;
  --text: #e3f6fb; --text-muted: #8fbccb; --text-faint: #5f8e9d;
  --accent: #21d4c4; --accent-strong: #5ee6d9; --accent-2: #38bdf8;
  --success: #4ade80; --warning: #fbbf24; --danger: #fb7185;
  --shadow: 0 8px 30px rgba(0, 10, 15, 0.45); --glass: rgba(10, 44, 55, 0.6);
  color-scheme: dark;
}

:root[data-theme="forest"] {
  --bg: #0e1a12; --bg-elev: #15261a; --bg-sunken: #112017; --border: #24402c; --border-strong: #30553b;
  --text: #e6f2e8; --text-muted: #9dbda4; --text-faint: #6c8a73;
  --accent: #4fc97a; --accent-strong: #7bdc9c; --accent-2: #d9b44a;
  --success: #4fc97a; --warning: #e7b94b; --danger: #f2777a;
  --shadow: 0 8px 30px rgba(0, 10, 4, 0.45); --glass: rgba(21, 38, 26, 0.6);
  color-scheme: dark;
}

:root[data-theme="sunset"] {
  --bg: #fff6ef; --bg-elev: #ffffff; --bg-sunken: #fdeee3; --border: #f3dccb; --border-strong: #e8c6ae;
  --text: #2b1a12; --text-muted: #8a6553; --text-faint: #b28f7d;
  --accent: #f2633a; --accent-strong: #d84a22; --accent-2: #f59e0b;
  --success: #2f9e5a; --warning: #c9790a; --danger: #d43d4d;
  --shadow: 0 4px 18px rgba(120, 50, 10, 0.08); --glass: rgba(255, 255, 255, 0.66);
  color-scheme: light;
}

:root[data-theme="rose"] {
  --bg: #fff5f8; --bg-elev: #ffffff; --bg-sunken: #fde9ef; --border: #f6d3de; --border-strong: #edb8c9;
  --text: #2d1520; --text-muted: #8d5a6d; --text-faint: #b88c9c;
  --accent: #e64980; --accent-strong: #c2255c; --accent-2: #9775fa;
  --success: #2f9e5a; --warning: #c9790a; --danger: #d43d4d;
  --shadow: 0 4px 18px rgba(120, 20, 60, 0.08); --glass: rgba(255, 255, 255, 0.66);
  color-scheme: light;
}

:root[data-theme="nord"] {
  --bg: #2e3440; --bg-elev: #3b4252; --bg-sunken: #343a47; --border: #4c566a; --border-strong: #5a657b;
  --text: #eceff4; --text-muted: #c0c8d6; --text-faint: #8e99ad;
  --accent: #88c0d0; --accent-strong: #a3d4e1; --accent-2: #b48ead;
  --success: #a3be8c; --warning: #ebcb8b; --danger: #bf616a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25); --glass: rgba(59, 66, 82, 0.66);
  color-scheme: dark;
}

:root[data-theme="dracula"] {
  --bg: #1e1f29; --bg-elev: #282a36; --bg-sunken: #23242f; --border: #3a3c4e; --border-strong: #4b4e65;
  --text: #f8f8f2; --text-muted: #b4b7c9; --text-faint: #7d8099;
  --accent: #bd93f9; --accent-strong: #d4b8ff; --accent-2: #ff79c6;
  --success: #50fa7b; --warning: #f1fa8c; --danger: #ff5555;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35); --glass: rgba(40, 42, 54, 0.66);
  color-scheme: dark;
}

:root[data-theme="contrast"] {
  --bg: #000000; --bg-elev: #000000; --bg-sunken: #0d0d0d; --border: #ffffff; --border-strong: #ffffff;
  --text: #ffffff; --text-muted: #f0f0f0; --text-faint: #d0d0d0;
  --accent: #ffd400; --accent-strong: #ffe14d; --accent-2: #00e5ff;
  --success: #00ff7f; --warning: #ffd400; --danger: #ff4d4d;
  --shadow: none; --glass: #000000;
  color-scheme: dark;
}

/* I derive soft tints of the semantic colors, valid for every theme and accent. */
:root {
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --success-soft: color-mix(in srgb, var(--success) 15%, transparent);
  --warning-soft: color-mix(in srgb, var(--warning) 15%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 15%, transparent);
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  font-weight: 680;
  font-size: 16px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  flex: none;
}

.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-faint); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  width: 100%;
}

.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--bg-sunken); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }

.main { padding: 26px 30px 60px; min-width: 0; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head p { margin: 4px 0 0; color: var(--text-muted); }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }

.stat-label { color: var(--text-muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 680; margin-top: 6px; letter-spacing: -0.01em; }
.stat-sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover { background: var(--bg-sunken); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-primary:hover { filter: brightness(1.08); }
:root[data-theme="contrast"] .btn-primary { background: var(--accent); color: #000; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

textarea.input { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 560; font-size: 13px; }
.field .hint { color: var(--text-faint); font-size: 12px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); display: inline-block; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: 0; }

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.empty { text-align: center; padding: 32px 12px; color: var(--text-faint); }

.code-block {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow: auto;
}

.log-line { font-family: var(--mono); font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 10px; }
.log-line .lvl { width: 46px; flex: none; font-weight: 700; }
.lvl-ERROR { color: var(--danger); }
.lvl-WARN { color: var(--warning); }
.lvl-INFO { color: var(--accent); }
.lvl-DEBUG, .lvl-TRACE { color: var(--text-faint); }

.tabs { display: inline-flex; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 3px; gap: 2px; border: 1px solid var(--border); }
.tab { border: 0; background: none; color: var(--text-muted); padding: 6px 12px; border-radius: 7px; font: inherit; font-weight: 560; cursor: pointer; }
.tab.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); }

.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  min-width: 240px;
  max-width: 380px;
  animation: toast-in 0.18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); border: 1px solid transparent; }
.alert.err { background: var(--danger-soft); }
.alert.warn { background: var(--warning-soft); }
.alert.ok { background: var(--success-soft); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: min(720px, 100%); max-height: 88vh; overflow: auto; }

.chart { width: 100%; height: 160px; display: block; }
.chart .area { fill: var(--accent-soft); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .line2 { fill: none; stroke: var(--success); stroke-width: 2; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--text-faint); font-size: 10px; font-family: var(--sans); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); padding: 28px; }
.wizard-card { width: min(560px, 100%); padding: 28px; }

.steps { display: flex; gap: 6px; margin: 18px 0 22px; }
.steps div { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps div.done { background: var(--accent); }

.topbar-mobile { display: none; }

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

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .main { padding: 18px 16px 48px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}


:root[data-effects="on"] body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 20%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(35% 30% at 85% 15%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 70%),
    radial-gradient(45% 40% at 60% 90%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
  animation: drift 28s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(-4%, 3%, 0) rotate(6deg); }
}

:root[data-effects="on"] .card,
:root[data-effects="on"] .sidebar,
:root[data-effects="on"] .topbar-mobile {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}

:root[data-effects="on"] .card.hover-lift { transition: transform 0.18s ease, box-shadow 0.18s ease; }
:root[data-effects="on"] .card.hover-lift:hover { transform: translateY(-3px); box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 18%, transparent); }

:root[data-effects="on"] .page:not(.hidden) > * { animation: rise 0.35s ease both; }
:root[data-effects="on"] .page:not(.hidden) > *:nth-child(2) { animation-delay: 0.04s; }
:root[data-effects="on"] .page:not(.hidden) > *:nth-child(3) { animation-delay: 0.08s; }
:root[data-effects="on"] .page:not(.hidden) > *:nth-child(4) { animation-delay: 0.12s; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

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

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  flex: none;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; }
.tint-1 { background: linear-gradient(135deg, #38bdf8, #6366f1); }
.tint-2 { background: linear-gradient(135deg, #34d399, #059669); }
.tint-3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.tint-4 { background: linear-gradient(135deg, #a78bfa, #ec4899); }
.tint-5 { background: linear-gradient(135deg, #22d3ee, #14b8a6); }
.tint-6 { background: linear-gradient(135deg, #f472b6, #fb7185); }

.gradient-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

.progress { height: 8px; border-radius: 8px; background: var(--bg-sunken); overflow: hidden; }
.progress > div { height: 100%; background: var(--gradient); border-radius: 8px; transition: width 0.4s ease; }
.progress.indeterminate > div { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.swatch {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch .preview { height: 44px; border-radius: 8px; margin-bottom: 8px; display: flex; overflow: hidden; }
.swatch .preview span { flex: 1; }
.accent-dots { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.accent-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bg-elev); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.accent-dot.active { box-shadow: 0 0 0 3px var(--accent); }

.palette-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 15, 0.45); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; z-index: 60; }
.palette { width: min(620px, calc(100% - 32px)); padding: 0; overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px; font-size: 16px; background: transparent; }
.palette input:focus { box-shadow: none; }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.palette-item .icon { width: 26px; text-align: center; font-size: 16px; }
.palette-item .hint { margin-left: auto; color: var(--text-faint); font-size: 12px; }
.palette-item.active { background: var(--accent-soft); color: var(--accent); }

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 11px; border: 1px dashed var(--border-strong); cursor: pointer; }
.check-item.done { border-style: solid; border-color: transparent; background: var(--success-soft); cursor: default; }
.check-item .mark { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; flex: none; }
.check-item.done .mark { background: var(--success); border-color: var(--success); color: #fff; }

.acct-card { display: flex; flex-direction: column; gap: 12px; position: relative; }
.acct-card.selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.acct-card .select { position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; accent-color: var(--accent); }
.avatar-lg { position: relative; overflow: hidden; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 19px; flex: none; }
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; opacity: 0; transition: opacity .25s ease; }
.av-img.loaded { opacity: 1; }
.persona-badge { align-self: flex-start; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.persona-grid .btn { justify-content: flex-start; gap: 8px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-stat { background: var(--bg-sunken); border-radius: 9px; padding: 8px 10px; }
.mini-stat b { display: block; font-size: 16px; }
.mini-stat span { font-size: 11.5px; color: var(--text-muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; }
.toolbar.sticky { position: sticky; top: 10px; z-index: 5; }

.stepper { display: flex; gap: 8px; margin-bottom: 4px; }
.stepper div { flex: 1; text-align: center; font-size: 12px; color: var(--text-faint); padding-bottom: 8px; border-bottom: 3px solid var(--border); }
.stepper div.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.option { display: flex; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { accent-color: var(--accent); width: 16px; height: 16px; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.type-card { text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--bg-elev); color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.type-card:hover { border-color: var(--accent); }
.type-card .icon { font-size: 22px; }

.rule-card { display: flex; gap: 14px; align-items: center; }
.rule-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none; color: #fff; }

.job-card { display: flex; flex-direction: column; gap: 10px; }
.job-log { font-family: var(--mono); font-size: 12px; background: var(--bg-sunken); border-radius: 8px; padding: 8px 10px; max-height: 180px; overflow: auto; white-space: pre-wrap; }

.nav-badge { margin-left: auto; background: var(--gradient); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }

.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

/* I keep dialogs opaque even with glass effects on, so forms are easy to read. */
:root[data-effects="on"] .modal.card,
:root[data-effects="on"] .palette.card {
  background: var(--bg-elev);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.modal-backdrop, .palette-backdrop { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
i[data-icon] { display: inline-flex; font-style: normal; }
.btn .ic, .badge .ic, .chip .ic { width: 15px; height: 15px; }
.btn { gap: 6px; }
.brand-logo .ic { width: 17px; height: 17px; }
.stat-icon .ic, .rule-icon .ic { width: 19px; height: 19px; }
.type-card .icon .ic { width: 24px; height: 24px; color: var(--accent); }
.palette-item .icon .ic { width: 17px; height: 17px; }
.check-item .mark .ic { width: 13px; height: 13px; }
.done-icon .ic { width: 46px; height: 46px; color: var(--accent); }
.modal .btn-ghost .ic { width: 16px; height: 16px; }

.export-card { display: flex; flex-direction: column; gap: 10px; }
.export-card .row { flex-wrap: wrap; }
.export-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-muted); }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.method-card { text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--bg-elev); color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.method-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.method-card ul { margin: 0; padding-left: 18px; color: var(--text-muted); font-size: 12.5px; }
.chat-picker { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.chat-picker label { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-picker label:last-child { border-bottom: 0; }
.chat-picker label:hover { background: var(--bg-sunken); }
.chat-picker .kind { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }
.rules-form fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.rules-form legend { font-weight: 650; padding: 0 6px; display: inline-flex; gap: 6px; align-items: center; }
.recovery-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.recovery-row:last-child { border-bottom: 0; }
.recovery-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.icon-grid label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.icon-grid .glyph { width: 26px; text-align: center; font-size: 17px; }
@media (max-width: 820px) {
  .recovery-row { grid-template-columns: 1fr; }
  .recovery-row .actions { justify-content: flex-start; }
}
