/* ==========================================================================
   Back office: built on the site tokens (app.css). Dense, calm, table-first,
   like the admin tools ops teams actually live in (Stripe, Linear).
   ========================================================================== */
body.admin { padding-bottom: 0; background: var(--bg-subtle); font-size: 14px; }
body.admin.switch-on { box-shadow: inset 0 0 0 4px var(--no-solid); }

/* ---------- Shell ---------- */
.adm-side {
  position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 20; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px 24px;
}
.adm-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px; color: var(--text); font-family: var(--display); font-weight: 700; font-size: 1.35rem; }
.adm-brand:hover { text-decoration: none; }
.adm-brand em, .adm-auth-brand em { font-style: normal; font-family: var(--font); font-size: 0.66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }
.adm-group { margin: 16px 10px 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.adm-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.adm-nav a:hover { background: var(--surface-2); text-decoration: none; }
.adm-nav a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.adm-nav a .i { width: 17px; height: 17px; color: var(--muted); }
.adm-nav a[aria-current] .i { color: var(--brand); }
.adm-nav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--no-solid); color: #fff; font-size: 0.7rem; display: inline-flex; align-items: center; justify-content: center; }

.adm-main { margin-left: 236px; min-height: 100vh; }
.adm-top {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 16px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg-subtle) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.adm-top .search { max-width: 520px; }
.adm-top .search input { background: var(--surface); }
.adm-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.who { display: flex; flex-direction: column; line-height: 1.2; }
.who strong { font-size: 0.82rem; }
.who small { color: var(--muted); font-size: 0.72rem; text-transform: capitalize; }
.switch-alert { background: var(--no-solid); color: #fff; font-weight: 700; font-size: 0.8rem; padding: 6px 12px; border-radius: 8px; animation: blink 1.6s infinite; }
.switch-alert:hover { text-decoration: none; }
.adm-content { padding: 24px 28px 48px; max-width: 1400px; }

@media (max-width: 960px) {
  .adm-side { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .adm-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .adm-group { display: none; }
  .adm-main { margin-left: 0; }
  .who { display: none; }
}

/* ---------- Auth ---------- */
.adm-auth { max-width: 440px; margin: 8vh auto; padding: 0 16px; }
.adm-auth-brand { display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: 18px; font-family: var(--display); font-weight: 700; font-size: 1.5rem; }
.adm-auth .card.auth { margin: 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1, .admin .page-title { font-family: var(--font); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels ---------- */
.admin .card { border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow-sm); }
.admin .card h2 { font-size: 0.95rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin .card h2 a { font-size: 0.82rem; font-weight: 600; }
.panel-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 1100px) { .panel-grid.two { grid-template-columns: 2fr 1fr; } .panel-grid.halves { grid-template-columns: 1fr 1fr; } }
.panel-grid > * { min-width: 0; }
.panel-grid .card + .card { margin-top: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); color: var(--text); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi-label { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.kpi-value { font-family: var(--display); font-size: 1.85rem; line-height: 1.05; }
.kpi-foot { display: flex; gap: 8px; align-items: center; font-size: 0.75rem; min-height: 1.1em; }
.delta { font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.delta.good { color: var(--yes); background: var(--yes-bg); }
.delta.bad { color: var(--no); background: var(--no-bg); }
.kpi.alarm { border-color: var(--no-solid); }
.up { color: var(--yes); }
.down { color: var(--no); }

/* ---------- Charts ---------- */
.bars { display: block; width: 100%; height: 140px; }
.bars rect.pos { fill: var(--brand); }
.bars rect.neg { fill: var(--no-solid); }
.bars rect.today { fill: var(--yes-solid); }
.bar-labels { display: flex; justify-content: space-between; color: var(--faint); font-size: 0.7rem; margin-top: 6px; }
.meter { display: block; width: 100%; height: 8px; margin: 10px 0 4px; }
.meter .track { fill: var(--surface-3); }
.meter .fill { fill: var(--brand); }
.meter .fill.warn { fill: var(--no-solid); }

/* ---------- Badges ---------- */
.badge-s { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; text-transform: capitalize; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge-s::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-s.green { background: var(--yes-bg); color: var(--yes); }
.badge-s.red { background: var(--no-bg); color: var(--no); }
.badge-s.amber { background: var(--gold-bg); color: var(--gold); }
.badge-s.blue { background: var(--brand-soft); color: var(--brand); }
.badge-s.purple { background: rgba(142, 68, 173, .12); color: #8e44ad; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th, .table td { text-align: left; padding: 10px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-subtle); white-space: nowrap; }
.table tbody tr:hover { background: var(--bg-subtle); }
.table .num { text-align: right; white-space: nowrap; font-family: var(--font); font-weight: 600; }
.table td.muted { max-width: 380px; overflow-wrap: anywhere; }
.table a { color: var(--text); font-weight: 600; }
.table a:hover { color: var(--brand); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 28px; height: 28px; font-size: 0.75rem; background: var(--surface-3); color: var(--text-2); }
.cell-market { display: flex; align-items: center; gap: 10px; }
.cell-market img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }
.empty-row { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Filters, toolbar, pager ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; height: 36px; padding: 0 10px; font-size: 0.86rem; border-radius: 8px; }
.toolbar input[type="search"], .toolbar input[type="text"] { min-width: 220px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; flex-wrap: wrap; }
.seg a { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg a small { color: var(--faint); margin-left: 3px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 0 0; }
.pager .muted { margin-right: auto; font-size: 0.8rem; }

/* ---------- Buttons ---------- */
.admin .btn-small { height: 34px; padding: 0 13px; font-size: 0.84rem; border-radius: 8px; }
.btn-small.subtle { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-small.subtle:hover { background: var(--surface-2); }
.btn-small.danger { background: var(--no-solid); color: #fff; }
.btn-small.success { background: var(--yes-solid); color: #fff; }
.inline-actions, .search-row, .switch-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.inline-actions input[type="text"], .inline-actions input[type="email"], .inline-actions select { width: auto; flex: 1 1 160px; height: 34px; padding: 0 10px; font-size: 0.84rem; border-radius: 8px; }
.switch-row { justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }
.switch-row:first-of-type { border-top: 0; }
.action-stack form + form { margin-top: 10px; }
.action-stack textarea { width: 100%; min-height: 70px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; font-size: 0.86rem; background: var(--surface); color: var(--text); }

/* ---------- Player profile ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.profile-head .avatar { width: 56px; height: 56px; font-size: 1.4rem; }
.profile-head h1 { font-size: 1.4rem; margin: 0; }
.profile-head .badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.subtabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.subtabs a { padding: 10px 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; text-transform: capitalize; white-space: nowrap; }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a[aria-current] { color: var(--text); border-bottom-color: var(--brand); }
.facts-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 0.86rem; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; font-weight: 500; }

/* ---------- Activity feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--border); font-size: 0.84rem; }
.feed li:first-child { border-top: 0; }
.feed li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.feed .when { color: var(--faint); font-size: 0.75rem; white-space: nowrap; }

.admin .card h2.mt { margin-top: 18px; }
.meter-row { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.risk-meter { flex: 1; height: 8px; appearance: none; border: 0; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.risk-meter::-webkit-progress-bar { background: var(--surface-3); }
.risk-meter::-webkit-progress-value { background: var(--brand); }
.risk-meter::-moz-progress-bar { background: var(--brand); }
.risk-meter.hot::-webkit-progress-value { background: var(--no-solid); }
.risk-meter.hot::-moz-progress-bar { background: var(--no-solid); }
.table tr.row-alert td { background: var(--no-bg); }
.review-card .review-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.review-form input[type=text] { width: 100%; margin: 10px 0 6px; }
.own-form { display: grid; gap: 14px; }
.own-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.own-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.88rem; margin: 0; }
.own-form label.check { flex-direction: row; align-items: center; align-self: end; font-weight: 500; padding-bottom: 10px; }
.own-form input:not([type=checkbox]), .own-form textarea, .own-form select,
.admin input[type=number], .admin input[type=datetime-local], .admin input[type=url], .admin textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 400; box-sizing: border-box;
}
.inline-actions input[type=number] { width: 90px; }
.own-form textarea { min-height: 90px; resize: vertical; }
@media (max-width: 760px) { .own-form .two { grid-template-columns: 1fr; } }
.side-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; }
.side-tag.side-yes { background: var(--yes-soft, rgba(16, 185, 129, 0.14)); color: var(--yes); }
.side-tag.side-no { background: var(--no-soft, rgba(244, 63, 94, 0.14)); color: var(--no); }
.cell-market > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-market .hint { font-size: 0.72rem; margin: 0; }
.seg .count { color: var(--faint); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg a[aria-current="true"] .count { color: inherit; opacity: 0.8; }
.profile-head .market-hero { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; flex: none; }

/* Legacy classes still used by some pages */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.stat strong { font-family: var(--display); font-size: 1.5rem; }
.stat.alarm { border-color: var(--no-solid); }
.bar-danger { fill: var(--no-solid); }
.search { position: relative; }
.idea-admin { margin-bottom: 12px; }
.idea-admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.idea-admin p { margin: 4px 0; }
.idea-admin .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.idea-admin input[type="text"] { min-width: 260px; height: 34px; }
.acca-mini { margin: 0; padding-left: 18px; font-size: 0.85rem; }
.acca-mini li { margin: 2px 0; }
.acca-mini .leg-won a { color: #1f9d6b; } .acca-mini .leg-lost a { color: #d92d3a; text-decoration: line-through; }
.acca-mini .leg-void a { color: #8d96a8; }
td.up { color: #1f9d6b; } td.down { color: #d92d3a; }
.ticket-admin { margin-bottom: 12px; }
.ticket-admin-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ticket-admin-body { white-space: pre-wrap; margin: 6px 0; }
.ticket-admin-reply { background: #eef2ff; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.ticket-admin-reply p { margin: 4px 0 0; white-space: pre-wrap; }
.ticket-admin-form textarea { width: 100%; margin: 6px 0; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid #d3d8e0; }
.funnel-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 110px; gap: 12px; align-items: center; padding: 8px 0; }
.funnel-bar { width: 100%; height: 14px; border: 0; border-radius: 99px; background: #eef1f5; overflow: hidden; appearance: none; -webkit-appearance: none; }
.funnel-bar::-webkit-progress-bar { background: #eef1f5; border-radius: 99px; }
.funnel-bar::-webkit-progress-value { background: #1f4dff; border-radius: 99px; }
.funnel-bar::-moz-progress-bar { background: #1f4dff; border-radius: 99px; }
.funnel-num { text-align: right; }
.cohort td.cohort-hot { background: #d3f0e1; font-weight: 700; }
.cohort td.cohort-warm { background: #eef8f2; }
