:root {
  --bg: #0a0a0c;
  --surface: #121216;
  --surface-2: #1a1a20;
  --surface-3: #22222a;
  --border: #26262e;
  --border-soft: #1f1f26;
  --text: #ededf2;
  --muted: #84848f;
  --muted-2: #5c5c66;
  --accent: #34d399;
  --accent-deep: #10b981;
  --accent-ghost: rgba(52, 211, 153, 0.12);
  --amber: #f0b429;
  --red: #f6685e;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 28px 70px -34px rgba(0, 0, 0, 0.85);
  /* layered surface gradient + top inner highlight for "expensive" depth */
  --surface-grad: linear-gradient(180deg, #16161d 0%, #121218 100%);
  --hairline: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "Geist Mono", ui-monospace, Menlo, monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

html { scroll-behavior: smooth; }
.mono, .num, table, input, .cnt { font-variant-numeric: tabular-nums; }

/* premium polish: subtle film grain to kill digital flatness */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 900; opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* thin, considered scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2a2a33; border-radius: 8px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #383843; }

/* accessible focus rings for keyboard nav */
button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-deep); outline-offset: 2px; border-radius: 8px;
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(80% 60% at 50% 0, rgba(52,211,153,0.07), var(--bg) 70%);
}
.login-screen.show { display: flex; }
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--surface-grad); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 34px 28px; box-shadow: var(--hairline), var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 20px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.5px; }
.login-card p { margin: 0 0 18px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: var(--r-sm); font-family: "Geist Mono", monospace; font-size: 13px; text-align: center;
}
.login-card input:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-ghost); }
.login-card .btn { justify-content: center; padding: 12px; }
.login-err { color: var(--red); font-size: 12.5px; min-height: 16px; margin-top: 10px !important; }
.logout-btn { margin-left: auto; background: none; border: none; color: var(--muted-2); font-size: 12px; cursor: pointer; font-family: inherit; }
.logout-btn:hover { color: var(--red); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--accent); color: #062019;
  font-weight: 700; border-radius: 9px; font-size: 13px;
}
.brand-text { font-weight: 600; letter-spacing: -0.3px; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 12px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; font-family: inherit;
  border-radius: var(--r-sm);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); background: var(--surface-2); }
.nav-item.active svg { color: var(--accent); }
.nav-count {
  margin-left: auto; font-size: 12px; color: var(--muted-2);
  background: var(--surface-3); padding: 1px 8px; border-radius: 20px;
  min-width: 22px; text-align: center;
}
.nav-count:empty { display: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; padding: 12px 8px 4px; }
.alerts-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--muted);
  padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer; font-family: inherit; font-size: 13px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.alerts-btn:hover { background: var(--surface-3); color: var(--text); }
.alerts-btn svg { width: 16px; height: 16px; }
.alerts-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 20px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 600;
  display: none; align-items: center; justify-content: center;
}
.alerts-badge.show { display: flex; }
.alert-item { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border-soft); }
.alert-item:last-child { border-bottom: none; }
.alert-item .ad { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--amber); }
.alert-item.error .ad { background: var(--red); }
.alert-item.unread { background: var(--surface-2); }
.alert-item .am { flex: 1; }
.alert-item .am .msg { font-size: 13.5px; line-height: 1.4; }
.alert-item .am .meta { font-size: 11.5px; color: var(--muted-2); margin-top: 3px; }
#alertsList { max-height: 380px; overflow-y: auto; margin: -4px -8px 4px; }
.health-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-ghost); animation: breathe 2.6s var(--ease) infinite; }
.dot.bad { background: var(--red); box-shadow: 0 0 0 4px rgba(246, 104, 94, 0.12); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 3px var(--accent-ghost); } 50% { box-shadow: 0 0 0 6px transparent; } }

.token-field { display: flex; flex-direction: column; gap: 5px; }
.token-field span { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.5px; }
.token-field input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 7px 10px; border-radius: var(--r-sm); font-size: 13px;
  font-family: inherit;
}
.token-field input:focus { outline: none; border-color: var(--accent-deep); }

/* ---------- Main ---------- */
.main { min-width: 0; position: relative; }
/* subtle ambient glow at the top for depth (not neon) */
.main::before {
  content: ""; position: fixed; top: 0; left: 248px; right: 0; height: 360px;
  background: radial-gradient(70% 100% at 72% -10%, rgba(52, 211, 153, 0.05), transparent 65%);
  pointer-events: none; z-index: 0;
}
.topbar, .content { position: relative; z-index: 1; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 30px 38px 18px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 62%, transparent);
}
.topbar-title h1 { font-size: 26px; margin: 0; letter-spacing: -0.8px; font-weight: 600; }
.topbar-title p { margin: 4px 0 0; font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; }

.content { padding: 8px 38px 56px; max-width: 1300px; }
.view { display: none; animation: fade 0.4s var(--ease); }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Surfaces ---------- */
.surface {
  background: var(--surface-grad);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: var(--hairline), var(--shadow);
}
.surface-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.surface-head h2 { font-size: 15px; margin: 0; letter-spacing: -0.2px; font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 9px 15px; border-radius: var(--r-sm); cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-3); border-color: #33333d; transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  background: linear-gradient(180deg, #3ee0a6, var(--accent-deep));
  color: #04231a; border-color: transparent; font-weight: 600;
  box-shadow: 0 8px 22px -10px rgba(52, 211, 153, 0.55), var(--hairline);
}
.btn.primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: rgba(246, 104, 94, 0.1); border-color: rgba(246, 104, 94, 0.35); }

.icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 22px; line-height: 1; width: 32px; height: 32px; border-radius: var(--r-sm);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface-grad); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: 22px;
  box-shadow: var(--hairline), var(--shadow);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
  animation: rise 0.5s var(--ease) backwards;
}
/* thin top hairline that lights up on the accent card */
.stat::after {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}
.stat:hover { transform: translateY(-3px); border-color: #2e2e38; }
.stat.accent-card { border-color: rgba(52, 211, 153, 0.25); }
.stat.accent-card::after { background: linear-gradient(90deg, transparent, rgba(52,211,153,0.5), transparent); }
.stat:nth-child(1) { animation-delay: 0.04s; }
.stat:nth-child(2) { animation-delay: 0.10s; }
.stat:nth-child(3) { animation-delay: 0.16s; }
.stat:nth-child(4) { animation-delay: 0.22s; }
.stat:nth-child(5) { animation-delay: 0.28s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stat .num { font-size: 34px; font-weight: 600; letter-spacing: -1.2px; font-family: "Geist Mono", monospace; line-height: 1; }
.stat .num.accent { color: var(--accent); }
.stat .label { color: var(--muted); margin-top: 8px; font-size: 13px; }
.stat-ico {
  position: absolute; top: 18px; right: 18px; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 10px;
  color: var(--muted-2); border: 1px solid var(--border-soft); background: rgba(255, 255, 255, 0.02);
}
.stat-ico svg { width: 16px; height: 16px; }
.stat.accent-card .stat-ico { color: var(--accent); border-color: rgba(52, 211, 153, 0.28); background: var(--accent-ghost); }

.status-surface .badges { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Dashboard panels ---------- */
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: stretch; margin-bottom: 18px; }
.dash-grid .surface { margin-bottom: 0; }
.dash-activity { min-height: 300px; }

.bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.bar span { height: 100%; transition: width 0.4s var(--ease); }

/* donut + health */
.health-donut { display: flex; flex-direction: column; align-items: center; padding: 6px 0 18px; }
.donut { width: 150px; height: 150px; }
.donut circle { transition: stroke-dasharray 0.5s var(--ease); }
.dn-num { fill: var(--text); font: 600 30px "Geist Mono", monospace; text-anchor: middle; }
.dn-lbl { fill: var(--muted-2); font: 500 10px "Geist"; text-anchor: middle; text-transform: uppercase; letter-spacing: 0.6px; }
.donut-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.donut-legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut-legend i { width: 8px; height: 8px; border-radius: 2px; }
.donut-legend b { color: var(--text); font-weight: 600; }
.health-sec { border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 14px; }
.health-cap { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); margin-bottom: 11px; }

.rolerow { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.rolerow .rl { width: 78px; font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.rolerow .rb { flex: 1; height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.rolerow .rb i { display: block; height: 100%; border-radius: 4px; transition: width 0.4s var(--ease); }
.rolerow .rv { width: 24px; text-align: right; font-size: 12.5px; color: var(--text); }

.bigstat { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.bigstat span { font-size: 18px; color: var(--text); }
.bigstat b { color: var(--accent); }

.feed-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.feed-row:last-child { border-bottom: none; }
.feed-ico { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--muted); }
.feed-ico svg { width: 16px; height: 16px; }
.feed-m { flex: 1; min-width: 0; }
.feed-t { font-size: 13.5px; }
.feed-s { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

.dash-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.dash-act {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 170px;
  padding: 14px 16px; border-radius: var(--r-md); cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border-soft);
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.dash-act:hover { transform: translateY(-2px); border-color: var(--accent-deep); background: var(--surface-3); }
.dash-act svg { width: 16px; height: 16px; color: var(--accent); }

@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---------- Tags (engineered chips, not AI pills) ---------- */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 6px;
  font-family: "Geist Mono", monospace; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.7px; text-transform: uppercase;
  border: 1px solid transparent; line-height: 1.35; white-space: nowrap;
}
.tag.new { background: rgba(255, 255, 255, 0.035); color: var(--muted); border-color: var(--border); }
.tag.active, .tag.done { background: rgba(52, 211, 153, 0.09); color: var(--accent); border-color: rgba(52, 211, 153, 0.28); }
.tag.flood, .tag.pending, .tag.running { background: rgba(240, 180, 41, 0.09); color: var(--amber); border-color: rgba(240, 180, 41, 0.30); }
.tag.banned, .tag.error, .tag.failed, .tag.cancelled { background: rgba(246, 104, 94, 0.09); color: var(--red); border-color: rgba(246, 104, 94, 0.30); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 14px; }
th {
  color: var(--muted-2); font-weight: 500; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0;
}
td { font-size: 13.5px; border-bottom: 1px solid var(--border-soft); }
tbody tr { transition: background 0.14s var(--ease); }
tbody tr:hover { background: linear-gradient(90deg, rgba(52,211,153,0.04), transparent 60%); }
tbody tr:last-child td { border-bottom: none; }
td.shrink { width: 1%; white-space: nowrap; }
.cell-strong { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.clickable { cursor: pointer; }
.err-text { color: var(--red); font-size: 12px; }

/* ---------- Selection / bulk bar ---------- */
th.chk, td.chk { width: 1%; padding-right: 0; }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border: 1.5px solid var(--border); border-radius: 5px;
  background: var(--bg); cursor: pointer; vertical-align: middle; position: relative;
  transition: border-color 0.15s, background 0.15s;
}
input[type="checkbox"]:hover { border-color: var(--accent-deep); }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px;
  border: solid #062019; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 14px;
  background: var(--accent-ghost); border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: var(--r-md);
  animation: rise 0.25s var(--ease);
}
.bulk-bar .bulk-label { font-size: 13.5px; font-weight: 500; }
.bulk-bar .spacer { flex: 1; }

/* ---------- Empty states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 24px; gap: 6px;
}
.empty .ico {
  width: 62px; height: 62px; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 50% 0, rgba(52,211,153,0.14), var(--surface-2) 70%);
  border: 1px solid rgba(52, 211, 153, 0.22); border-radius: 18px;
  box-shadow: 0 10px 30px -14px rgba(52, 211, 153, 0.35), var(--hairline);
  margin-bottom: 16px;
}
.empty .ico svg { width: 27px; height: 27px; color: var(--accent); }
.empty h3 { margin: 0; font-size: 18px; letter-spacing: -0.3px; }
.empty p { margin: 0; color: var(--muted); max-width: 380px; line-height: 1.55; }
.empty .steps {
  list-style: none; padding: 0; margin: 14px 0 18px; text-align: left;
  display: flex; flex-direction: column; gap: 9px; color: var(--muted); font-size: 13px;
}
.empty .steps li { display: flex; align-items: center; gap: 10px; }
.empty .steps .n {
  width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--surface-3); border-radius: 50%; font-size: 12px; color: var(--text);
  font-family: "Geist Mono", monospace;
}
.empty.mini { padding: 40px 20px; }

/* ---------- Skeleton ---------- */
.skel-row { display: flex; gap: 14px; padding: 13px 12px; align-items: center; }
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; border-radius: 6px; height: 13px;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Layout split (parser) ---------- */
.layout-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.layout-split .surface { margin-bottom: 0; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  background: rgba(4, 4, 6, 0.66); backdrop-filter: blur(6px);
  padding: 72px 20px 20px; overflow-y: auto;
}
.modal.open { display: flex; }
.modal-card {
  width: 100%; max-width: 520px;
  background: var(--surface-grad); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--hairline), var(--shadow-lg);
  animation: pop 0.32s var(--ease);
}
.modal-card.wide { max-width: 720px; }
.disco-results { max-height: 320px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: var(--r-sm); }
.disco-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.disco-row:last-child { border-bottom: none; }
.disco-row:hover { background: var(--surface-2); }
.disco-row .meta { flex: 1; min-width: 0; }
.disco-row .meta .t { font-size: 13.5px; }
.disco-row .meta .s { font-size: 12px; color: var(--muted); }
.disco-row .cnt { font-family: "Geist Mono", monospace; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -0.2px; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.seg { display: flex; gap: 4px; padding: 14px 20px 0; }
.seg button {
  flex: 1; padding: 8px; background: var(--surface-2); border: 1px solid var(--border-soft);
  color: var(--muted); cursor: pointer; border-radius: var(--r-sm); font-family: inherit; font-size: 13px;
  transition: all 0.18s var(--ease);
}
.seg button.active { color: var(--text); border-color: var(--accent-deep); background: var(--accent-ghost); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field-row .field.grow { flex: 2.2; }
.field-row .field.narrow { flex: 0.8; }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; font-family: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease); width: 100%;
}
.field textarea { resize: vertical; font-family: "Geist Mono", monospace; font-size: 13px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-ghost);
}
.field .hint { color: var(--muted-2); font-size: 12px; line-height: 1.45; }
.field input[type="file"] { padding: 8px; cursor: pointer; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--r-md);
  padding: 30px 20px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent-deep); background: var(--accent-ghost); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone .dz-main { margin: 2px 0 0; font-size: 14px; }
.dropzone .dz-main b { color: var(--accent); }
.dropzone .dz-sub { margin: 0; font-size: 12px; color: var(--muted); }
.dropzone.has-file { border-color: var(--accent-deep); border-style: solid; }

/* ---------- TData import ---------- */
.tdata-steps { display: flex; flex-direction: column; gap: 12px; }
.tdata-lead { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text); }
.tdata-lead b { color: var(--accent); }
.path-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px;
}
.path-label { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.5px; }
.path-box code { flex: 1; min-width: 120px; font-size: 12.5px; color: var(--text); word-break: break-all; }

/* ---------- Broadcast modal (preview + steps) ---------- */
.bc-card { max-width: 860px; }
.bc-layout { display: grid; grid-template-columns: 1fr 300px; }
.bc-form { gap: 20px; }
.bc-preview { border-left: 1px solid var(--border-soft); padding: 22px 18px; background: rgba(0,0,0,0.18); border-radius: 0 0 var(--r-lg) 0; }
.bc-preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); margin-bottom: 14px; }
.bc-chat {
  background:
    linear-gradient(rgba(10,12,16,0.86), rgba(10,12,16,0.86)),
    radial-gradient(circle at 30% 20%, #14323a, #0d1a1f 60%);
  border: 1px solid var(--border-soft); border-radius: 14px; padding: 16px 12px; min-height: 220px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.bc-bubble {
  align-self: flex-end; max-width: 92%; background: #1f6f5c; color: #f1fff9;
  border-radius: 14px 14px 4px 14px; padding: 8px 10px 6px; font-size: 13px; line-height: 1.45;
  box-shadow: 0 2px 8px -4px rgba(0,0,0,0.6); word-wrap: break-word; overflow-wrap: anywhere;
}
.bc-bubble img { width: 100%; border-radius: 9px; margin-bottom: 6px; display: block; }
.bc-bubble .bc-text { white-space: pre-wrap; }
.bc-bubble .bc-text a { color: #aef0d8; text-decoration: underline; }
.bc-bubble .bc-text b { font-weight: 700; }
.bc-time { text-align: right; font-size: 10px; color: rgba(255,255,255,0.55); margin-top: 3px; }

/* broadcast form inputs that live outside .field need explicit dark styling */
#broadcastForm input[name="brief"],
#broadcastForm textarea[name="message"] {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px;
  font-family: "Geist", -apple-system, "Segoe UI", Roboto, sans-serif; width: 100%;
}
#broadcastForm textarea[name="message"] { resize: vertical; line-height: 1.5; }
#broadcastForm input[name="brief"]:focus,
#broadcastForm textarea[name="message"]:focus {
  outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-ghost);
}
.bc-step-h { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; margin-bottom: 12px; }
.bc-num { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: var(--accent-ghost); color: var(--accent); font-size: 12px; font-family: "Geist Mono", monospace; }
.bc-fmt { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.fmt-btn { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 7px; cursor: pointer; font-size: 13px; }
.fmt-btn:hover { border-color: var(--accent-deep); }
.fmt-btn svg { width: 15px; height: 15px; vertical-align: -2px; }
.bc-time svg { vertical-align: -1px; opacity: 0.7; }
.fmt-photo { display: inline-flex; align-items: center; padding: 0 11px; height: 30px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.fmt-photo:hover { color: var(--text); border-color: var(--accent-deep); }
.bc-adv summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.bc-adv summary:hover { color: var(--text); }

@media (max-width: 760px) {
  .bc-layout { grid-template-columns: 1fr; }
  .bc-preview { border-left: none; border-top: 1px solid var(--border-soft); }
}

/* ---------- Docs ---------- */
.docs { max-width: 820px; }
.doc-block h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -0.3px; }
.doc-block p { color: var(--muted); line-height: 1.6; margin: 0 0 12px; max-width: 70ch; }
.doc-block ul, .doc-block ol { color: var(--muted); line-height: 1.7; margin: 0 0 8px; padding-left: 20px; }
.doc-block li { margin-bottom: 5px; }
.doc-block b { color: var(--text); font-weight: 600; }
.doc-block i { color: var(--text); }
.doc-steps { counter-reset: ds; list-style: none; padding-left: 0; }
.doc-steps li { position: relative; padding-left: 34px; margin-bottom: 10px; }
.doc-steps li::before {
  counter-increment: ds; content: counter(ds); position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px;
  background: var(--accent-ghost); color: var(--accent); font-size: 12px; font-family: "Geist Mono", monospace;
}
.doc-block img {
  width: 100%; border: 1px solid var(--border-soft); border-radius: var(--r-md);
  margin-top: 14px; display: block; box-shadow: var(--shadow);
}
.doc-note {
  background: var(--accent-ghost); border: 1px solid rgba(52,211,153,0.25);
  border-radius: var(--r-sm); padding: 11px 13px; color: var(--text) !important; font-size: 13px;
}

/* ---------- Warmup ---------- */
.wu-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.wu-chk { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--r-sm); padding: 11px 13px; cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease); }
.wu-chk:hover { border-color: var(--border); color: var(--text); }
/* hide the native checkbox (it was stretched by .field input) and draw our own */
.wu-chk input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.wu-chk::before {
  content: ""; width: 16px; height: 16px; flex-shrink: 0; border-radius: 5px;
  border: 1.5px solid var(--border); background: var(--bg); transition: background 0.15s, border-color 0.15s;
}
.wu-chk:has(input:checked) { color: var(--text); border-color: rgba(52, 211, 153, 0.4); background: var(--accent-ghost); }
.wu-chk:has(input:checked)::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4L19 7' fill='none' stroke='%23062019' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.wu-accs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-height: 120px; overflow-y: auto; }
.wu-acc { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 20px; padding: 5px 11px; cursor: pointer; color: var(--muted); }
.wu-acc.on { color: var(--accent); border-color: rgba(52,211,153,0.4); background: var(--accent-ghost); }

/* ---------- Messenger ---------- */
.msg-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 18px; height: calc(100dvh - 150px); }
.msg-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.msg-side select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--r-sm); font-family: inherit; font-size: 13.5px;
}
.msg-dialogs { flex: 1; overflow-y: auto; background: var(--surface-grad); border: 1px solid var(--border-soft); border-radius: var(--r-lg); box-shadow: var(--hairline); }
.dlg { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background 0.14s var(--ease); }
.dlg:hover { background: var(--surface-2); }
.dlg.active { background: var(--accent-ghost); }
.dlg-top { display: flex; justify-content: space-between; gap: 8px; }
.dlg-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-unread { background: var(--accent); color: #04231a; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 0 7px; min-width: 18px; text-align: center; }
.dlg-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-main { display: flex; flex-direction: column; background: var(--surface-grad); border: 1px solid var(--border-soft); border-radius: var(--r-lg); box-shadow: var(--hairline); min-height: 0; overflow: hidden; }
.msg-head { padding: 16px 18px; border-bottom: 1px solid var(--border-soft); font-weight: 600; font-size: 14px; }
.msg-history { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(rgba(10,12,16,0.5), rgba(10,12,16,0.5)), radial-gradient(circle at 30% 10%, #122a30, #0c1418 60%); }
.msg-bubble { max-width: 72%; padding: 8px 11px 6px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-bubble.in { align-self: flex-start; background: var(--surface-3); color: var(--text); border-radius: 14px 14px 14px 4px; }
.msg-bubble.out { align-self: flex-end; background: #1f6f5c; color: #f1fff9; border-radius: 14px 14px 4px 14px; }
.msg-bubble .b-time { font-size: 10px; opacity: 0.6; text-align: right; margin-top: 2px; }
.msg-compose { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border-soft); }
.msg-compose input { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--r-sm); font-family: inherit; font-size: 14px; }
.msg-compose input:focus { outline: none; border-color: var(--accent-deep); }
.msg-empty { flex: 1; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 860px) { .msg-wrap { grid-template-columns: 1fr; height: auto; } }

/* ---------- Export bar ---------- */
.export-bar { display: flex; align-items: center; gap: 8px; }
.export-bar select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 9px; border-radius: var(--r-sm); font-size: 12.5px; font-family: inherit;
}
.export-bar select:focus { outline: none; border-color: var(--accent-deep); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 13px 18px; border-radius: var(--r-md); box-shadow: var(--shadow);
  opacity: 0; transition: all 0.3s var(--ease); z-index: 200; max-width: 84vw;
  display: flex; align-items: center; gap: 10px; font-size: 13.5px;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok::before { background: var(--accent); }
.toast.err::before { background: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout-split { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 12px; overflow-x: auto;
  }
  .brand { padding: 0 12px 0 4px; }
  .nav { flex-direction: row; }
  .nav-item span:not(.nav-count) { display: none; }
  .sidebar-foot { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .field-row { flex-direction: column; gap: 16px; }
}
