/* ============================================================================
   Nestwatch design system — hand-authored, no build step, offline, theme-aware.
   Tokens are CSS custom properties; light is default, dark via
   [data-theme=dark] or prefers-color-scheme.
   ============================================================================ */

:root {
  --bg: #f4f2eb;
  --surface: #fffdf8;
  --surface-2: #efece2;
  --surface-3: #e7e3d6;
  --border: #e6e1d3;
  --border-strong: #d7d1bf;
  --text: #182420;
  --muted: #6a7168;
  --faint: #9a9f92;

  --primary: #11916a;          /* nest green */
  --primary-600: #0c7a58;
  --primary-fg: #ffffff;
  --primary-soft: #dcf0e6;

  --honey: #e59a26;            /* warm amber */
  --honey-soft: #f8ead0;
  --honey-ink: #8a5a08;
  --clay: #dd6244;             /* danger / favourite */
  --clay-soft: #f9e2da;
  --clay-ink: #9e3a20;
  --sky: #4a7fd4;
  --sky-soft: #e0eafb;
  --sky-ink: #2f5aa8;
  --violet: #7a6cc4;
  --violet-soft: #e9e5f7;

  /* legacy aliases (older markup) */
  --accent: var(--honey);
  --accent-soft: var(--honey-soft);
  --danger: var(--clay);
  --danger-soft: var(--clay-soft);
  --blue: var(--sky);
  --blue-soft: var(--sky-soft);
  --amber: var(--honey-ink);
  --amber-soft: var(--honey-soft);

  --ring: rgba(17, 145, 106, 0.32);
  --shadow-sm: 0 1px 2px rgba(24, 40, 32, 0.05), 0 3px 10px rgba(24, 40, 32, 0.05);
  --shadow: 0 2px 6px rgba(24, 40, 32, 0.05), 0 16px 34px rgba(24, 40, 32, 0.08);
  --shadow-lg: 0 24px 60px rgba(24, 40, 32, 0.16);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius: 15px;
  --radius-sm: 11px;
  --side-w: 250px;
  --topbar-h: 58px;
  --font: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: 'Bricolage Grotesque', var(--font);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1310;
  --surface: #111b16;
  --surface-2: #17221c;
  --surface-3: #1f2d25;
  --border: #243029;
  --border-strong: #33463b;
  --text: #e9efe9;
  --muted: #95a099;
  --faint: #657069;

  --primary: #33c78a;
  --primary-600: #48d69a;
  --primary-fg: #04140d;
  --primary-soft: rgba(51, 199, 138, 0.15);

  --honey: #eeb254;
  --honey-soft: rgba(238, 178, 84, 0.16);
  --honey-ink: #f3c377;
  --clay: #ee8266;
  --clay-soft: rgba(238, 130, 102, 0.16);
  --clay-ink: #f2997f;
  --sky: #6fa2ec;
  --sky-soft: rgba(111, 162, 236, 0.16);
  --sky-ink: #8fb6f0;
  --violet: #9a8ce0;
  --violet-soft: rgba(154, 140, 224, 0.16);

  --ring: rgba(51, 199, 138, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 3px 10px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1310; --surface: #111b16; --surface-2: #17221c; --surface-3: #1f2d25;
    --border: #243029; --border-strong: #33463b;
    --text: #e9efe9; --muted: #95a099; --faint: #657069;
    --primary: #33c78a; --primary-600: #48d69a; --primary-fg: #04140d; --primary-soft: rgba(51,199,138,0.15);
    --honey: #eeb254; --honey-soft: rgba(238,178,84,0.16); --honey-ink: #f3c377;
    --clay: #ee8266; --clay-soft: rgba(238,130,102,0.16); --clay-ink: #f2997f;
    --sky: #6fa2ec; --sky-soft: rgba(111,162,236,0.16); --sky-ink: #8fb6f0;
    --violet: #9a8ce0; --violet-soft: rgba(154,140,224,0.16);
    --ring: rgba(51,199,138,0.4);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35), 0 3px 10px rgba(0,0,0,0.3);
    --shadow: 0 2px 6px rgba(0,0,0,0.35), 0 18px 40px rgba(0,0,0,0.45);
    --shadow-lg: 0 28px 70px rgba(0,0,0,0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
::selection { background: var(--primary-soft); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.4); } 70% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Shell: sidebar + main ──────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w); flex: none;
  position: sticky; top: 0; height: 100vh; z-index: 50;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 6px;
}
.side .brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; }
.brand-mark {
  width: 40px; height: 40px; flex: none; border-radius: 13px;
  background: linear-gradient(150deg, var(--primary), #2fb98a);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.brand-mark svg { display: block; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.03em; }

.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius);
  font-weight: 600; font-size: 0.9rem; color: var(--muted);
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary-600); }
.side-nav a svg { width: 20px; height: 20px; flex: none; }
.side-nav .nav-badge {
  margin-left: auto; font-size: 0.72rem; font-weight: 700;
  color: var(--honey-ink); background: var(--honey-soft);
  padding: 1px 8px; border-radius: 999px;
}

.side-cta { margin-top: 14px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.side-status {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 13px;
}
.side-status .line1 { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.side-status .line1 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); flex: none; }
.side-status .line2 { font-size: 0.74rem; color: var(--faint); margin-top: 4px; }
.side-actions { display: flex; align-items: center; gap: 6px; }
.side-actions .btn-icon { flex: 1; }
.side-actions form { display: contents; }

.main { flex: 1; min-width: 0; max-width: 1220px; }
/* Animate children, not the container: an animated .wrap would create a
   stacking context that traps the fixed .overlay below the sidebar/topbar. */
.wrap { padding: 34px 40px 72px; }
.wrap > :not(.overlay) { animation: rise .4s ease both; }

/* Mobile topbar (hidden on desktop) */
.topbar {
  display: none; position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  align-items: center; gap: 10px; padding: 0 14px;
}
.topbar .brand { display: flex; align-items: center; gap: 9px; }
.topbar .brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.topbar .brand-name { font-size: 1.05rem; }
.side-backdrop {
  display: none; position: fixed; inset: 0; z-index: 49;
  background: rgba(10, 20, 15, 0.45);
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.9rem; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 0.94rem; }
.section-title { font-family: var(--display); font-weight: 700; font-size: 1.05rem; margin: 30px 0 14px; display: flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.section-title .count { color: var(--faint); font-weight: 500; font-size: 0.85rem; font-family: var(--font); }

/* ── Hero (dashboard greeting) ──────────────────────────────────────────── */
.hero {
  border-radius: var(--radius-xl); padding: 30px 32px;
  background: linear-gradient(135deg, var(--primary-soft), transparent 62%), var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px;
  border-radius: 50%; background: radial-gradient(circle, var(--honey-soft), transparent 68%);
}
.hero > * { position: relative; z-index: 1; }
.hero .kicker { font-size: 0.82rem; font-weight: 600; color: var(--primary-600); letter-spacing: 0.02em; }
.hero h1 { font-size: 2rem; margin-top: 6px; }
.hero p { color: var(--muted); margin: 6px 0 0; max-width: 44ch; }
.hero p strong { color: var(--text); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card.pad { padding: 19px; }
.card.hover { transition: box-shadow .18s, transform .18s, border-color .18s; }
.card.hover:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }

.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.listings { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 20px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 17px; border-radius: var(--radius); border: 1px solid transparent;
  font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, opacity .15s, filter .15s;
  white-space: nowrap; background: transparent; color: var(--text);
}
.btn svg { width: 17px; height: 17px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(150deg, var(--primary), var(--primary-600));
  color: var(--primary-fg); box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { border-color: var(--border); background: var(--surface); color: var(--muted); font-weight: 600; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-soft { background: var(--surface-2); color: var(--text); font-weight: 600; }
.btn-soft:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: var(--clay); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-danger-ghost { border-color: var(--clay-soft); color: var(--clay-ink); background: transparent; font-weight: 600; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--clay-soft); }
.btn-sm { padding: 8px 13px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-icon {
  width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm);
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-strong); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

/* ── Badges & pills ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge.green { background: var(--primary-soft); color: var(--primary-600); }
.badge.amber { background: var(--honey-soft); color: var(--honey-ink); }
.badge.red { background: var(--clay-soft); color: var(--clay-ink); }
.badge.blue { background: var(--sky-soft); color: var(--sky-ink); }
.badge.mono { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; border-radius: 7px; }
.badge.dot::before { content: "●"; font-size: 0.6em; }

.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px;
}
.seg button {
  padding: 7px 15px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.83rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button svg { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--text); }
.chip.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }

.tag {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

.live-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 700; color: var(--primary-600);
  background: var(--primary-soft); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.live-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.live-pill.off { color: var(--faint); background: var(--surface-2); }
.live-pill.off::before { background: var(--faint); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 0.84rem; font-weight: 600; margin-bottom: 7px; color: var(--text); }
.label .opt { color: var(--faint); font-weight: 400; }
.hint { font-size: 0.77rem; color: var(--faint); margin-top: 6px; }
.input, .select, textarea.input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.92rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--ring);
}
textarea.input { resize: vertical; min-height: 72px; }
.input.mono { font-family: var(--mono); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat .top { display: flex; align-items: center; justify-content: space-between; }
.stat .ico {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-600);
}
.stat .ico svg { width: 19px; height: 19px; }
.stat .ico.honey { background: var(--honey-soft); color: var(--honey-ink); }
.stat .ico.sky { background: var(--sky-soft); color: var(--sky-ink); }
.stat .ico.clay { background: var(--clay-soft); color: var(--clay-ink); }
.stat .ico.violet { background: var(--violet-soft); color: var(--violet); }
.stat .trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.74rem; font-weight: 700; color: var(--muted);
  background: var(--surface-2); padding: 2px 8px; border-radius: 999px;
}
.stat .trend.up { color: var(--primary-600); background: var(--primary-soft); }
.stat .v {
  font-family: var(--display); font-weight: 700; font-size: 1.95rem;
  letter-spacing: -0.02em; margin-top: 12px; font-variant-numeric: tabular-nums;
}
.stat .k { color: var(--muted); font-size: 0.84rem; margin-top: 1px; }

/* ── Run list (dashboard) ───────────────────────────────────────────────── */
.run-list { overflow: hidden; }
.run-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.run-row:last-child { border-bottom: 0; }
.run-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); }
.run-row .dot.success { background: var(--primary); }
.run-row .dot.partial { background: var(--honey); }
.run-row .dot.failed { background: var(--clay); }
.run-row .dot.running { background: var(--sky); animation: pulse 1.8s ease infinite; }
.run-row .body { flex: 1; min-width: 0; }
.run-row .t { font-size: 0.86rem; font-weight: 600; }
.run-row .w { font-size: 0.76rem; color: var(--faint); }
.run-row .n { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Listing card ───────────────────────────────────────────────────────── */
.listing { overflow: hidden; display: flex; flex-direction: column; position: relative; }
.listing.fav::after, .listing.applied::after {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--clay);
  border-radius: var(--radius-lg); pointer-events: none; z-index: 2;
}
.listing.applied::after { border-color: var(--sky); }
.listing.fav.applied::after { border-color: var(--clay); }
.listing .media {
  height: 158px; position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--surface-2), var(--primary-soft));
  display: flex; align-items: center; justify-content: center;
}
.listing .media img { width: 100%; height: 100%; object-fit: cover; }
.listing .media .ph {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 78%;
  color: var(--primary); opacity: .13;
}
.listing .media .ph svg { width: 100%; height: 100%; }
.listing .fab {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); color: var(--muted);
  backdrop-filter: blur(6px); border: 0; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .18s, color .18s, transform .12s;
}
:root[data-theme="dark"] .listing .fab { background: rgba(17, 27, 22, 0.85); }
.listing .fab:hover { transform: scale(1.08); }
.listing .fab svg { width: 18px; height: 18px; }
.listing .fab.on-heart { background: var(--clay); color: #fff; }
.listing .fab.on-send { background: var(--sky); color: #fff; }
.listing .fab .pop { animation: pop .4s ease; }
.listing .price-tag {
  position: absolute; bottom: 11px; left: 12px; padding: 5px 12px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-weight: 800; font-size: 0.92rem;
  box-shadow: var(--shadow-sm); font-variant-numeric: tabular-nums;
}
.listing .price-tag.none { color: var(--faint); font-weight: 600; font-size: 0.8rem; }
.listing .new-tag {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.9); color: #1a2b22;
  font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.listing .new-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); animation: pulse 1.8s ease infinite;
}
.listing .body { padding: 15px 16px; display: flex; flex-direction: column; flex: 1; }
.listing .title { font-weight: 700; font-size: 0.96rem; line-height: 1.25; }
.listing .addr { color: var(--muted); font-size: 0.8rem; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.listing .addr svg { width: 14px; height: 14px; flex: none; }
.listing .meta { display: flex; align-items: center; gap: 14px; margin: 12px 0; color: var(--muted); font-size: 0.8rem; flex-wrap: wrap; }
.listing .meta span { display: inline-flex; align-items: center; gap: 5px; }
.listing .meta svg { width: 15px; height: 15px; }
.listing .foot { margin-top: auto; padding-top: 13px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.listing .foot .btn-block { flex: 1; }
.listing .stamp { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; font-size: 0.7rem; color: var(--faint); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 560px; }
.tbl th { text-align: left; padding: 12px 16px; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }

/* ── Modal / drawer ─────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 15, 0.5); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 86vh;
  display: flex; flex-direction: column; transform: translateY(8px) scale(.99); transition: transform .18s;
}
.overlay.open .modal { transform: none; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.modal-head .sub { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* drawer variant slides from the right */
.overlay.drawer { justify-content: flex-end; padding: 0; }
.overlay.drawer .modal {
  max-width: 460px; max-height: 100vh; height: 100vh; border-radius: 0;
  border-left: 1px solid var(--border); transform: translateX(20px);
}
.overlay.drawer.open .modal { transform: none; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px 16px; font-size: 0.88rem;
  max-width: 340px; display: flex; align-items: center; gap: 10px;
  animation: toast-in .2s ease; color: var(--text);
}
.toast.err { border-left-color: var(--clay); }
.toast.ok { border-left-color: var(--primary); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty .empty-ico {
  width: 66px; height: 66px; border-radius: var(--radius-lg); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: var(--faint);
}
.empty .empty-ico svg { width: 30px; height: 30px; }
.empty svg { opacity: .9; }
.empty strong { color: var(--text); font-weight: 600; }
.empty p { font-size: 0.88rem; margin: 4px 0 0; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
.spinner.lg { width: 30px; height: 30px; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.log { background: #0c1512; color: #7fd6a3; font-family: var(--mono); font-size: 0.76rem; padding: 10px 12px; border-radius: 8px; max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
details > summary { cursor: pointer; }

.steps { display: flex; flex-direction: column; gap: 9px; }
.step { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 0.87rem; font-weight: 500; }
.step .dot { width: 20px; height: 20px; flex-shrink: 0; color: var(--faint); display: flex; align-items: center; justify-content: center; }
.step .dot svg { width: 18px; height: 18px; }
.step.active { background: var(--primary-soft); }
.step.active .dot { color: var(--primary); }
.step.done { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.step.done .dot { color: var(--primary-600); }
.step.failed { border-color: color-mix(in srgb, var(--clay) 40%, var(--border)); background: var(--clay-soft); }
.step.failed .dot { color: var(--clay-ink); }

.banner { padding: 12px 14px; border-radius: var(--radius); display: flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 500; }
.banner svg { width: 18px; height: 18px; flex: none; }
.note-icon { width: 14px; height: 14px; vertical-align: -2px; flex: none; }
.banner.ok { background: var(--primary-soft); color: var(--primary-600); }
.banner.warn { background: var(--honey-soft); color: var(--honey-ink); }
.banner.err { background: var(--clay-soft); color: var(--clay-ink); }
.banner.info { background: var(--sky-soft); color: var(--sky-ink); }

.menu { position: relative; display: inline-block; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); min-width: 168px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu-pop button { width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.88rem; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 9px; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--clay-ink); }
.menu-pop button.danger:hover { background: var(--clay-soft); }
.menu-pop .sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu-pop svg { width: 15px; height: 15px; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login-wrap::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(1100px 620px at 78% -8%, var(--primary-soft), transparent 60%),
              radial-gradient(900px 520px at 8% 108%, var(--honey-soft), transparent 55%);
}
.login-card { position: relative; width: 100%; max-width: 392px; animation: rise .5s ease both; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand .brand-mark { width: 66px; height: 66px; border-radius: 20px; box-shadow: var(--shadow); }
.login-brand .brand-name { font-size: 1.9rem; }
.login-brand .sub { color: var(--muted); margin-top: 2px; font-size: 0.95rem; text-align: center; }
.login-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 26px;
}
.login-foot { margin-top: 16px; text-align: center; font-size: 0.78rem; color: var(--faint); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 560px) { .hide-sm { display: none; } }
@media (max-width: 900px) {
  .topbar { display: flex; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: none;
  }
  body.side-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.side-open .side-backdrop { display: block; }
  .wrap { padding: 22px 16px 64px; }
  .page-head h1 { font-size: 1.5rem; }
  .hero { padding: 22px 20px; }
  .hero h1 { font-size: 1.6rem; }
  .row { flex-direction: column; }
}
