/* AfterHourz.tv admin portal: dark UI, no external assets (the CSP allows only 'self'). */
:root {
  color-scheme: dark;
  --bg: #09090d;
  --surface: #121217;
  --elevated: #19181f;
  --border: #2a2632;
  --border-strong: #3a3444;
  --text: #f3f0f7;
  --muted: #9a94a6;
  --purple: #b28aff;
  --accent: #9764ef;
  --danger: #f06a8a;
  --danger-bg: #b23a5a26;
  --warn: #f0c060;
  --warn-bg: #c0902a22;
  --ok: #6fd69a;
  --ok-bg: #2f7a4a26;
  --info: #8ab4ff;
  --info-bg: #3a5ab026;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
a { color: var(--purple); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

/* ---- Layout ---- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { font-weight: 700; font-size: 16px; }
.brand span { color: var(--purple); }
.brand em { font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--danger); margin-left: 4px; }
.sidebar nav { display: grid; gap: 2px; }
.nav-link { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.nav-link:hover { color: var(--text); background: #ffffff08; }
.nav-link.on { color: var(--text); background: #9764ef26; }
.me { margin-top: auto; display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.content { padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
/* minmax(0, 1fr) stops wide tables from stretching the page; they scroll inside .table-wrap. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stack-lg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel > h2 { margin-bottom: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }

/* ---- Controls ---- */
.btn {
  font: inherit; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--elevated); color: var(--text);
  cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #544a63; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn-primary { background: linear-gradient(105deg, #a370f6, #8b55e1); border-color: transparent; color: #fff; }
.btn-danger { background: #c23b5f; border-color: transparent; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d6456b; }
.btn-outline-danger { color: var(--danger); border-color: #7a3448; background: transparent; }
.icon-btn { font: inherit; font-size: 22px; line-height: 1; width: 34px; height: 34px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: #ffffff0c; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: #0d0b12;
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-height: 36px; width: 100%;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.field { display: grid; gap: 6px; font-size: 13px; color: #c9c0d6; }
.field.inline { grid-auto-flow: column; align-items: center; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.check small { display: block; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 260px; width: auto; }
.toolbar select { flex: 0 1 260px; width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: none; color: var(--muted); cursor: pointer; }
.chip.on { color: var(--text); background: #9764ef2e; border-color: var(--accent); }
.chip-danger.on { background: var(--danger-bg); border-color: var(--danger); }
.action-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Badges, notices ---- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #ffffff10; color: #cfc6dc; white-space: nowrap; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-info { background: var(--info-bg); color: var(--info); }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.notice-error { background: var(--danger-bg); color: #f7a9bc; border: 1px solid #7a3448; }
.notice-ok { background: var(--ok-bg); color: #a6e3bb; border: 1px solid #3f6b4e; }
.notice-info { background: var(--info-bg); color: #bcd2ff; border: 1px solid #3c4f80; }
.empty { padding: 32px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.loading { padding: 12px 0; }

/* ---- Stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat-card {
  display: grid; gap: 4px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
a.stat-card:hover { border-color: var(--border-strong); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 11px; color: var(--muted); }
.stat-warn { border-color: #6b5320; }
.stat-warn .stat-value { color: var(--warn); }
.stat-danger { border-color: #7a3448; background: linear-gradient(180deg, #b23a5a1a, var(--surface)); }
.stat-danger .stat-value { color: var(--danger); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: #ffffff05; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #ffffff04; }
.row-danger { background: #b23a5a14; }
.row-warn { background: #c0902a10; }
td.details { max-width: 280px; }
.actions-col { min-width: 260px; }
.uuid { word-break: break-all; }

/* ---- Moderation ---- */
.result-list { display: grid; gap: 6px; }
.result {
  font: inherit; text-align: left; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.result.on, .result:hover { border-color: var(--accent); }
.user-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 0; }
.facts dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.facts dd { margin: 2px 0 0; }
.facts .span-2 { grid-column: span 2; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.file-list { margin: 0; padding-left: 18px; font-size: 13px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* ---- Upload review ---- */
.upload-list { display: grid; gap: 14px; }
.upload-card { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 18px; }
.upload-media video, .upload-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; }
.upload-thumb { position: relative; display: grid; place-items: center; padding: 0; border: 1px solid var(--border); cursor: pointer; overflow: hidden; }
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb .play { position: absolute; font-size: 28px; color: #fff; text-shadow: 0 2px 12px #000; }
.upload-desc { white-space: pre-wrap; color: #d9d2e2; max-height: 8.5em; overflow: auto; }
@media (max-width: 860px) { .upload-card { grid-template-columns: 1fr; } }

/* ---- Age verification ---- */
.verify-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.evidence { display: grid; gap: 10px; }
.evidence-frame { display: grid; place-items: center; width: 100%; height: 340px; padding: 0; overflow: hidden; cursor: zoom-in;
  border: 1px solid var(--border); border-radius: 10px; background: #050408; }
.evidence-frame img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.2s; user-select: none; }
.evidence-frame.zoomed { overflow: auto; cursor: zoom-out; place-items: start; }
.evidence-frame.zoomed img { max-width: none; max-height: none; width: 200%; }
@media (max-width: 860px) { .verify-layout { grid-template-columns: 1fr; } }

/* ---- Email ---- */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; width: max-content; }
.segmented button { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.on { background: #9764ef2e; color: var(--text); }
.segmented.small button { font-size: 12px; padding: 5px 10px; }
.row.between { justify-content: space-between; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.5; tab-size: 2; }
.email-preview { border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 640px; background: #f4f2f7; }
.preview-text { margin: 0; padding: 14px; border-radius: 10px; background: #f7f5fa; color: #1b1722; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; max-height: 640px; overflow: auto; }

.preview h2 { margin-bottom: 8px; }
.preview-body { margin-top: 12px; padding: 14px; border-radius: 8px; background: #f7f5fa; color: #1b1722; display: grid; gap: 10px; }
.preview-body .muted { color: #6b6477; }

/* ---- Modal ---- */
.modal {
  width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--border-strong); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: 0 30px 100px #000a;
}
.modal-wide { width: min(720px, calc(100% - 24px)); }
.modal::backdrop { background: #050408cc; backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; }

/* ---- Auth ---- */
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at top, #301d434d, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); display: grid; gap: 22px; padding: 30px 26px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); }
.qr { background: #fff; padding: 10px; border-radius: 10px; justify-self: center; }
.secret { word-break: break-all; }
.code-input { font-size: 22px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); } /* minmax(0, …): a wide child must never stretch the page */
  .sidebar { min-width: 0; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; order: 3; width: 100%; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; grid-auto-flow: column; align-items: center; }
  .me .small { display: none; }
  .content { padding: 20px 16px 48px; }
  .split { grid-template-columns: 1fr; }
  .facts .span-2 { grid-column: auto; }
}

/* Phones: a slim sticky header with a one-row menu you swipe sideways, instead of a menu that fills a third of the screen. */
@media (max-width: 860px) {
  .sidebar { position: sticky; top: 0; z-index: 30; gap: 4px 12px; padding: 10px 14px 0; background: var(--surface); }
  .sidebar .brand { font-size: 15px; }
  .sidebar nav { min-width: 0; max-width: calc(100% + 28px); flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 2px 14px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: none; display: inline-flex; align-items: center; min-height: 40px; white-space: nowrap; }
  .page-head { flex-wrap: wrap; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .modal { width: calc(100% - 16px); }
  .modal-body { padding: 16px; }
  .row.end { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  h1 { font-size: 22px; }
}

/* ---- Phones: table rows become cards (cells are labelled by client/responsive-tables.ts) ---- */
@media (max-width: 720px) {
  .table-wrap { border: 0; overflow: visible; border-radius: 0; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-wrap tr { margin: 0 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
  .table-wrap td { display: grid; grid-template-columns: minmax(80px, 36%) minmax(0, 1fr); gap: 4px 12px; max-width: none; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: normal; overflow-wrap: anywhere; }
  .table-wrap td:last-child { border-bottom: 0; }
  .table-wrap td::before { content: attr(data-label); font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
  .table-wrap td[data-label=""] { display: block; }
  .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap tbody tr:last-child td { border-bottom: 1px solid var(--border); }
  .table-wrap tbody tr:last-child td:last-child { border-bottom: 0; }
}

/* iPhones zoom the page when a field under 16px gets focus: keep fields at 16px on touch screens, and make small controls easy to hit. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]), select, textarea { font-size: 16px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
}


.prewrap { white-space: pre-wrap; }
