/* ═══════════════════════════════════════════════════════════
   COSMOS — Design System
   Used across every page of the new Hells Hub.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg: #fafafa;
  --bg-2: #f4f4f5;
  --surface: #ffffff;
  --surface-hover: #f9f9fa;
  --surface-sel: #f0f1f5;
  --border: #e4e4e7;
  --border-2: #d4d4d8;
  --border-3: #a1a1aa;

  /* Ink */
  --ink: #09090b;
  --ink-2: #27272a;
  --ink-mid: #52525b;
  --ink-dim: #71717a;
  --ink-faint: #a1a1aa;

  /* Accent (indigo) */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-tint: #e0e7ff;

  /* Status */
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --pink: #db2777;
  --pink-soft: #fce7f3;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 6px -1px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px -6px rgba(0,0,0,0.10);
  --shadow-accent: 0 4px 14px -3px rgba(99,102,241,0.45);
}

/* ── DARK MODE ─────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #0b0b0e;
  --bg-2: #15151a;
  --surface: #16161b;
  --surface-hover: #1c1c22;
  --surface-sel: #232331;
  --border: #27272e;
  --border-2: #3f3f49;
  --border-3: #5a5a66;

  --ink: #f5f5f7;
  --ink-2: #e4e4e8;
  --ink-mid: #a1a1aa;
  --ink-dim: #71717a;
  --ink-faint: #52525b;

  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1e1b3a;
  --accent-tint: #2d2855;

  --green: #4ade80;
  --green-soft: #14271b;
  --red: #f87171;
  --red-soft: #2b1414;
  --amber: #fbbf24;
  --amber-soft: #2a1e0a;
  --blue: #60a5fa;
  --blue-soft: #0f1d33;
  --pink: #f472b6;
  --pink-soft: #2b1424;
  --violet: #a78bfa;
  --violet-soft: #221b35;
  --teal: #2dd4bf;
  --teal-soft: #0d2522;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
  --shadow: 0 2px 6px -1px rgba(0,0,0,0.40), 0 1px 3px rgba(0,0,0,0.30);
  --shadow-lg: 0 8px 24px -6px rgba(0,0,0,0.50);
  --shadow-accent: 0 4px 14px -3px rgba(99,102,241,0.55);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
/* Inputs need explicit overrides in dark mode */
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: var(--surface); color: var(--ink); border-color: var(--border-2);
}
html[data-theme="dark"] .btn { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
html[data-theme="dark"] .btn:hover { background: var(--surface-hover); }
html[data-theme="dark"] .btn.accent { background: var(--accent); color: #0b0b0e; border-color: transparent; }
html[data-theme="dark"] .btn.accent:hover { background: var(--accent-hover); }
html[data-theme="dark"] .modal { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.55); }
html[data-theme="dark"] .iconbtn:hover { background: var(--surface-hover); }
html[data-theme="dark"] .nav-item.active { background: #2a2a40; color: #fff; }
html[data-theme="dark"] .nav-item:hover { background: var(--surface-hover); }
html[data-theme="dark"] .topbar { background: var(--bg); }
html[data-theme="dark"] table.cosmos thead { background: var(--bg-2); }
html[data-theme="dark"] table.cosmos tbody tr:hover { background: var(--surface-hover); }
html[data-theme="dark"] .top-search { background: var(--surface); border-color: var(--border-2); color: var(--ink-mid); }
html[data-theme="dark"] .top-search:hover { background: var(--surface-hover); }
html[data-theme="dark"] .kbd { background: var(--bg-2); color: var(--ink-mid); border-color: var(--border-2); }
html[data-theme="dark"] .chat-bubble { background: var(--accent); color: #0b0b0e; }
html[data-theme="dark"] .chat-panel { background: var(--surface); border-color: var(--border); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
.serif { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; }

/* ── APP SHELL ────────────────────────────────────── */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ──────────────────────────────────────── */
.sidebar { background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 0; overflow-y: auto; }
.brand { padding: 0 20px 22px; display: flex; align-items: center; gap: 11px; }
.brand .glyph {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, 0.5);
}
.brand .name { font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.brand .name span { color: var(--ink-dim); font-weight: 400; }

.nav-section { margin: 6px 0; padding: 0 12px; }
.nav-section-lab {
  padding: 14px 8px 6px; font-size: 11px; color: var(--ink-faint);
  font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
}
.nav-item {
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-mid); margin-bottom: 1px;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #fff; }
.nav-item.active svg { stroke: #fff; }
.nav-item svg { width: 15px; height: 15px; stroke: currentColor; opacity: 0.75; }
.nav-item.active svg { opacity: 1; }
.nav-item .badge {
  margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--ink-dim);
  background: var(--bg-2); padding: 1px 7px; border-radius: 9px;
}
.nav-item.active .badge { background: rgba(255, 255, 255, 0.15); color: #fff; }

.sidebar-footer {
  margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.sidebar-footer:hover { background: var(--bg-2); }
.sidebar-footer .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff;
}
.sidebar-footer .nm { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .rl { font-size: 11px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer #footer-signout { opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.sidebar-footer:hover #footer-signout { opacity: 1; }

/* ── MAIN ─────────────────────────────────────────── */
.main { overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  padding: 13px 32px; display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-mid); font-size: 13px; }
.crumbs .cur { color: var(--ink); font-weight: 500; }
.crumbs .sep { color: var(--ink-faint); font-size: 11px; }
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-search {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 12px; display: flex; align-items: center; gap: 8px;
  width: 280px; font-size: 13px; color: var(--ink-dim); cursor: text;
}
.top-search:hover { border-color: var(--border-2); }
.top-search .kbd {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 5px; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--ink-dim);
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn {
  background: var(--surface); border: 1px solid var(--border-2); color: var(--ink);
  padding: 6px 13px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.4;
}
.btn:hover { background: var(--bg-2); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #27272a; }
.btn.accent {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}
.btn.accent:hover { background: var(--accent-hover); }
.btn.subtle { background: transparent; border-color: transparent; color: var(--ink-mid); }
.btn.subtle:hover { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red-soft); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.iconbtn {
  width: 32px; height: 32px; border-radius: 7px; background: transparent; border: 1px solid transparent;
  color: var(--ink-mid); cursor: pointer; display: grid; place-items: center;
}
.iconbtn:hover { background: var(--bg-2); color: var(--ink); }
.iconbtn svg { width: 17px; height: 17px; }

/* ── PAGE ─────────────────────────────────────────── */
.page-scroll { flex: 1; overflow-y: auto; }
.page { padding: 32px 40px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-hd { margin-bottom: 32px; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-title { font-size: 32px; font-weight: 500; letter-spacing: -0.025em; color: var(--ink); }
.page-title.serif { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; font-size: 36px; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-mid); font-size: 14.5px; margin-top: 4px; }

/* ── CARDS / PANELS ───────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: none; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.panel-hd { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.panel-hd h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.panel-hd .lk { font-size: 12.5px; color: var(--ink-mid); cursor: pointer; text-decoration: none; }
.panel-hd .lk:hover { color: var(--ink); }

/* ── KPI ──────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.kpi-card .lab { font-size: 12.5px; color: var(--ink-mid); font-weight: 500; }
.kpi-card .val { font-size: 32px; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; font-feature-settings: 'tnum'; line-height: 1; }
.kpi-card .ft { font-size: 12px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.kpi-card .ft .pos { color: var(--green); font-weight: 500; }
.kpi-card .ft .neg { color: var(--red); font-weight: 500; }

/* ── PILLS ────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 14px;
  font-size: 11.5px; font-weight: 500;
}
.pill.reddit { background: #fff1ec; color: #c2410c; }
.pill.instagram { background: var(--pink-soft); color: var(--pink); }
.pill.twitter { background: var(--blue-soft); color: var(--blue); }
.pill.tiktok { background: var(--violet-soft); color: var(--violet); }
.pill.icloud { background: #dbeafe; color: #1e40af; }
.pill.email { background: var(--green-soft); color: var(--green); }
.pill.onlyfans { background: #fff1ec; color: #c2410c; }
.pill.active { background: var(--green-soft); color: var(--green); }
.pill.banned { background: var(--red-soft); color: var(--red); }
.pill.shadow { background: var(--amber-soft); color: var(--amber); }
.pill.suspended { background: var(--bg-2); color: var(--ink-dim); }
.pill.used { background: var(--green-soft); color: var(--green); }
.pill.farmed { background: var(--teal-soft); color: var(--teal); }
.pill.proc { background: var(--amber-soft); color: var(--amber); }
.pill.blank { background: var(--bg-2); color: var(--ink-dim); }

/* ── TABLES ───────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table.cosmos { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.cosmos thead th {
  text-align: left; padding: 11px 22px; background: var(--surface); color: var(--ink-mid);
  font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
table.cosmos thead th.num { text-align: right; }
table.cosmos tbody td { padding: 13px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--ink); }
table.cosmos tbody tr { cursor: pointer; }
table.cosmos tbody tr:hover td { background: var(--bg-2); }
table.cosmos tbody tr:last-child td { border-bottom: none; }
table.cosmos td.num { text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink-mid); }
table.cosmos .uname { font-weight: 600; color: var(--ink); }
table.cosmos .uname.banned { color: var(--ink-dim); text-decoration: line-through; }
table.cosmos .sub { color: var(--ink-dim); font-size: 12px; margin-top: 2px; }

/* ── INPUTS ───────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], textarea, select {
  background: var(--surface); border: 1px solid var(--border-2);
  padding: 7px 11px; border-radius: 7px; font: inherit; font-size: 13px;
  color: var(--ink); outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.10);
}
input::placeholder, textarea::placeholder { color: var(--ink-dim); }

/* ── CHAT POPUP ───────────────────────────────────── */
.chat-bubble {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px -4px rgba(99, 102, 241, 0.55);
  z-index: 500; transition: transform 0.15s, box-shadow 0.15s;
}
.chat-bubble:hover { transform: scale(1.05); box-shadow: 0 8px 28px -4px rgba(99, 102, 241, 0.65); }
.chat-bubble svg { width: 22px; height: 22px; }
.chat-bubble .badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--red); color: #fff; border-radius: 50%;
  min-width: 18px; height: 18px; font-size: 10px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid #fff;
}
.chat-bubble.has-unread .badge { display: flex; }

.chat-panel {
  position: fixed; bottom: 88px; right: 24px;
  width: 360px; height: 500px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.25);
  z-index: 499; display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-panel-header h3 { font-size: 14px; font-weight: 600; }
.chat-panel-list { flex: 1; overflow-y: auto; padding: 6px; }
.chat-conv-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center;
}
.chat-conv-item:hover { background: var(--bg-2); }
.chat-conv-item .av { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 11.5px; font-weight: 600; }
.chat-conv-item .av-wrap .online-dot { position: absolute; bottom: 0; right: 0; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; border: 2px solid var(--surface); display: inline-block; }
.chat-conv-item .body { flex: 1; min-width: 0; }
.chat-conv-item .nm { font-size: 13px; font-weight: 500; }
.chat-conv-item .preview { font-size: 11.5px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-item .when { font-size: 10.5px; color: var(--ink-faint); }

/* ── PLACEHOLDER ─────────────────────────────────── */
.placeholder {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 80px 40px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px;
}
.placeholder .ico {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 26px;
  background: var(--accent-soft); color: var(--accent);
}
.placeholder h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.placeholder p { font-size: 14px; color: var(--ink-mid); max-width: 420px; line-height: 1.55; }

/* ── LOADING ─────────────────────────────────────── */
.loading { color: var(--ink-dim); font-size: 13px; padding: 20px; text-align: center; }
.skeleton {
  display: inline-block; background: linear-gradient(90deg, var(--bg-2) 0%, var(--surface) 50%, var(--bg-2) 100%);
  background-size: 200% 100%; animation: skeleton 1.4s ease-in-out infinite;
  border-radius: 4px; height: 1em; width: 4em;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── MODAL ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.30);
  border: 1px solid var(--border);
}
.modal.wide { max-width: 720px; }
.modal-hd {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-hd h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.modal-hd .close {
  width: 32px; height: 32px; border-radius: 7px; background: transparent;
  border: 1px solid transparent; color: var(--ink-mid); cursor: pointer; display: grid; place-items: center;
}
.modal-hd .close:hover { background: var(--bg-2); color: var(--ink); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-ft {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
}
.modal-ft .err { margin-right: auto; color: var(--red); font-size: 12.5px; }
.modal-ft .left { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--ink-mid); }
.field > label .req { color: var(--red); }
.field > input, .field > select, .field > textarea {
  background: var(--surface); border: 1px solid var(--border-2);
  padding: 8px 12px; border-radius: 7px; font: inherit; font-size: 13.5px;
  color: var(--ink); outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
.field > input:focus, .field > select:focus, .field > textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.10);
}
.field > textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.field-help { font-size: 11.5px; color: var(--ink-dim); }

/* ── SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }
