/* Admin console — every custom class is prefixed adm- and scoped to the console. */

/* --------------------------------- shell ---------------------------------- */

.adm-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.adm-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -------------------------------- sidebar --------------------------------- */

.adm-side {
  position: sticky;
  top: calc(var(--hdr) + 58px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.adm-side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--line);
}

.adm-side-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--red), #8e0f1c);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 6px 16px rgba(225, 29, 46, 0.35);
  flex: none;
}

.adm-side-brand b {
  display: block;
  font-size: 14px;
}

.adm-side-brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.adm-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.adm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: 0.15s;
}

.adm-nav-item:hover {
  color: #fff;
  background: var(--panel-2);
}

.adm-nav-item.active {
  color: #fff;
  background: var(--red-dim);
  border-color: rgba(225, 29, 46, 0.35);
  box-shadow: inset 3px 0 0 var(--red);
}

.adm-nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex: none;
}

.adm-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.adm-back:hover {
  color: var(--gold);
}

/* -------------------------------- page head -------------------------------- */

.adm-page-head {
  margin-bottom: 2px;
  align-items: flex-end;
}

.adm-page-title h1 {
  margin: 0;
  font-size: 23px;
}

.adm-page-title .sub {
  margin-top: 2px;
}

.adm-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.adm-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------- KPI tiles ------------------------------- */

.adm-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}

.adm-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 15px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
}

.adm-kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--line-2);
}

.adm-kpi.tone-green::before {
  background: var(--green);
}

.adm-kpi.tone-gold::before {
  background: var(--gold);
}

.adm-kpi.tone-red::before {
  background: var(--red);
}

.adm-kpi.tone-blue::before {
  background: var(--blue);
}

a.adm-kpi {
  transition: 0.15s;
}

a.adm-kpi:hover {
  border-color: var(--line-2);
  transform: translateY(-1px);
}

.adm-kpi-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 16px;
  opacity: 0.7;
}

.adm-kpi-label {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.adm-kpi-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.adm-kpi-sub {
  color: var(--muted);
  font-size: 11.5px;
}

.adm-kpis-sm .adm-kpi {
  padding: 12px 13px;
}

.adm-kpis-sm .adm-kpi-value {
  font-size: 19px;
}

/* ------------------------------- dashboard -------------------------------- */

.adm-dash {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.adm-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.adm-chart-card .card-title {
  margin-bottom: 8px;
}

.adm-bars {
  position: relative;
  display: flex;
  gap: 6px;
  height: 180px;
  padding-top: 6px;
}

.adm-bar-col {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.adm-bar-slot {
  position: relative;
  flex: 1;
}

.adm-bar {
  position: absolute;
  left: 16%;
  right: 16%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: opacity 0.15s;
}

.adm-bar.pos {
  background: linear-gradient(180deg, rgba(32, 193, 90, 0.9), rgba(32, 193, 90, 0.32));
}

.adm-bar.neg {
  background: linear-gradient(0deg, rgba(225, 29, 46, 0.9), rgba(225, 29, 46, 0.3));
  border-radius: 0 0 3px 3px;
}

.adm-bar:hover {
  opacity: 0.85;
}

.adm-bar-zero {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--line-2);
  pointer-events: none;
}

.adm-bar-x {
  padding-top: 6px;
  text-align: center;
  font-size: 10px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.adm-chart-foot {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.adm-chart-foot b {
  color: var(--text);
}

.adm-recon .tablewrap {
  margin-top: 10px;
}

/* ---------------------------------- tables --------------------------------- */

.adm-tbl th,
.adm-tbl td {
  vertical-align: middle;
}

.adm-tbl td.num,
.adm-tbl th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.adm-total-row td {
  font-weight: 800;
  border-top: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
}

.adm-user-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.adm-user-cell b {
  font-size: 13.5px;
}

.adm-cell-action {
  text-align: right;
  white-space: nowrap;
}

.adm-row-click {
  cursor: pointer;
}

.adm-row-click:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.adm-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 200px;
}

/* -------------------------------- pagination ------------------------------- */

.adm-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
}

.adm-pager span {
  margin-right: auto;
}

/* ---------------------------------- search --------------------------------- */

.adm-search {
  display: flex;
  gap: 8px;
  max-width: 560px;
}

.adm-search .input {
  flex: 1;
}

/* ---------------------------------- users ---------------------------------- */

.adm-user-drawer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adm-drawer-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.adm-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--gold);
  background: linear-gradient(145deg, #2a3548, #1a2231);
  border: 1px solid var(--line-2);
  flex: none;
}

.adm-drawer-id {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.adm-drawer-id h2 {
  font-size: 20px;
}

.adm-drawer-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.adm-drawer-total b {
  font-size: 20px;
}

.adm-wallet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.adm-wallet-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.adm-wallet-cell span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.adm-wallet-cell b {
  font-size: 15px;
}

.adm-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adm-control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.adm-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
}

.adm-profile-grid .kv {
  padding: 7px 0;
}

.adm-adjust {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
  align-items: end;
}

.adm-adjust .field {
  margin-bottom: 12px;
}

.adm-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ----------------------------------- bets ---------------------------------- */

.adm-legs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 400px;
}

.adm-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.adm-leg-match {
  color: var(--text);
  font-weight: 600;
}

.adm-leg-market {
  color: var(--muted);
}

.adm-leg-line {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------- withdrawals ------------------------------- */

.adm-wd-summary {
  margin-bottom: 10px;
}

.adm-wd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.adm-wd {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adm-wd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.adm-wd-amount {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.adm-wd-amount b {
  font-size: 19px;
}

.adm-bank {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.adm-bank-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.adm-bank-row span {
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.adm-bank-row b {
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.adm-wd-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

/* ----------------------------------- chat ---------------------------------- */

.adm-chat {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: 540px;
}

.card.adm-chat-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  min-height: 0;
}

.adm-thread-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 560px;
}

.adm-thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.adm-thread:hover {
  background: var(--panel-2);
}

.adm-thread.active {
  background: var(--panel-2);
  border-color: var(--line-2);
  box-shadow: inset 3px 0 0 var(--red);
}

.adm-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.adm-thread-top b {
  font-size: 13.5px;
}

.adm-thread-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-thread-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card.adm-chat-pane {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

.adm-conv {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.adm-conv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.adm-conv-head h3 {
  font-size: 15px;
}

.adm-msgs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px 16px;
}

.adm-msg {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  align-self: flex-start;
}

.adm-msg.agent {
  align-self: flex-end;
  background: var(--red-dim);
  border-color: rgba(225, 29, 46, 0.3);
}

.adm-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.adm-msg-body {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.adm-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.adm-composer .textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
}

.adm-composer .btn {
  flex: none;
}

/* --------------------------------- reports --------------------------------- */

.adm-report {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adm-svg-chart {
  width: 100%;
  height: auto;
  display: block;
}

.adm-svg-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.adm-svg-zero {
  stroke: var(--line-2);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.adm-svg-axis {
  fill: var(--muted);
  font-size: 10px;
}

.adm-svg-bar {
  fill: rgba(59, 130, 246, 0.38);
  stroke: rgba(59, 130, 246, 0.72);
  stroke-width: 0.5;
}

.adm-svg-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.adm-svg-dot {
  fill: var(--gold);
}

.adm-svg-legend {
  fill: var(--muted);
  font-size: 11px;
}

/* ---------------------------------- audit ---------------------------------- */

.adm-audit-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.adm-audit-controls .input {
  max-width: 380px;
}

.adm-audit-controls span {
  margin-right: auto;
}

.adm-action {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--gold);
}

.adm-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 360px;
}

.adm-meta > span {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.adm-meta b {
  color: var(--text);
  font-weight: 600;
}

/* -------------------------------- settings --------------------------------- */

.adm-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.adm-switch-list {
  display: flex;
  flex-direction: column;
  padding-bottom: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.adm-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  position: relative;
}

.adm-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.adm-switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  transition: 0.15s;
}

.adm-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.15s;
}

.adm-switch input:checked + .adm-switch-track {
  background: var(--green-dim);
  border-color: rgba(32, 193, 90, 0.5);
}

.adm-switch input:checked + .adm-switch-track::after {
  left: 20px;
  background: var(--green);
}

.adm-switch input:focus-visible + .adm-switch-track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.adm-switch-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.adm-switch-text b {
  font-size: 13.5px;
}

.adm-switch-text small {
  color: var(--muted);
  font-size: 11.5px;
}

.adm-recon-result:empty {
  display: none;
}

.adm-recon-result {
  margin-top: 10px;
}

/* ---------------------------------- 403 ----------------------------------- */

.adm-403 {
  display: grid;
  place-items: center;
  padding: 40px 0;
}

.adm-403-card {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 30px;
  text-align: center;
}

.adm-403-icon {
  font-size: 44px;
  line-height: 1;
}

.adm-403-card .row {
  justify-content: center;
  margin-top: 6px;
}

/* -------------------------------- responsive ------------------------------- */

@media (max-width: 1080px) {
  .adm-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .adm-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .adm-side {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .adm-side::-webkit-scrollbar {
    display: none;
  }

  .adm-side-brand {
    display: none;
  }

  .adm-nav {
    flex-direction: row;
    gap: 4px;
  }

  .adm-nav-item {
    white-space: nowrap;
    padding: 8px 12px;
  }

  .adm-nav-item.active {
    box-shadow: inset 0 -2px 0 var(--red);
  }

  .adm-back {
    margin-left: auto;
    padding: 8px 12px;
    border-top: 0;
    border-left: 1px solid var(--line);
    white-space: nowrap;
  }

  .adm-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .adm-chat {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .adm-thread-list {
    max-height: 260px;
  }

  .adm-msgs {
    max-height: 420px;
  }
}

@media (max-width: 720px) {
  .adm-page-head {
    align-items: flex-start;
  }

  .adm-page-actions {
    margin-left: 0;
    width: 100%;
  }

  .adm-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .adm-kpi-value {
    font-size: 19px;
  }

  .adm-wallet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .adm-profile-grid,
  .adm-adjust,
  .adm-bank {
    grid-template-columns: minmax(0, 1fr);
  }

  .adm-drawer-head {
    align-items: flex-start;
  }

  .adm-drawer-total {
    align-items: flex-start;
  }

  .adm-wd-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .adm-bars {
    height: 140px;
    gap: 3px;
  }

  .adm-bar-x {
    font-size: 9px;
  }

  .adm-chart-foot {
    gap: 10px;
  }

  .adm-audit-controls .input {
    max-width: none;
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .adm-kpi,
  .adm-bar,
  .adm-nav-item {
    transition: none;
  }

  a.adm-kpi:hover {
    transform: none;
  }
}
