/* Admin panel — same palette as the board, denser layout.

   The panel carries its own form and button primitives: the public stylesheet
   is a faithful port of the board's design and has no generic components to
   borrow, so anything shared here is defined here. */

.admin-body {
  display: grid;
  grid-template-columns: 218px 1fr;
  min-height: 100vh;
}

.admin-side {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.admin-side .brand-lockup { margin-bottom: 18px; }

.admin-side nav { display: flex; flex-direction: column; gap: 2px; }

.admin-side nav a {
  padding: 8px 11px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 14px;
  color: var(--muted-foreground);
}

.admin-side nav a:hover { background: var(--muted); color: var(--foreground); }
.admin-side nav a.is-active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }

.admin-main { padding: 20px 22px 60px; max-width: 1180px; }

.admin-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-head h1 { font-size: 21px; margin: 0; letter-spacing: -0.02em; }
.admin-head .spacer { margin-inline-start: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.card h2 { margin: 0 0 10px; font-size: 15px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); font-weight: 600; }
tbody tr:hover { background: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
}

.pill--paid { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.pill--pending { background: var(--primary-soft); color: var(--primary-strong); }
.pill--cancelled, .pill--removed { background: color-mix(in srgb, var(--error) 15%, transparent); color: var(--error); }
/* A refund is money returned, not an error — give it its own muted tone. */
.pill--refunded { background: var(--muted); color: var(--muted-foreground); }
.pill--needs_review { background: var(--primary-soft); color: var(--primary-strong); }
.pill--published { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }

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

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin-bottom: 0; min-width: 150px; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card { width: 100%; max-width: 360px; }

.danger { color: var(--error); }

.btn--danger { background: var(--error); color: #fff; }

@media (max-width: 820px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .admin-side nav { flex-direction: row; flex-wrap: wrap; }
}


/* --- primitives ---------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint, .hint { font-size: 12px; color: var(--muted-foreground); line-height: 1.45; }

.admin-body input[type="text"],
.admin-body input[type="url"],
.admin-body input[type="number"],
.admin-body input[type="password"],
.admin-body select,
.admin-body textarea,
.login-card input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.admin-body input:focus, .admin-body select:focus, .admin-body textarea:focus, .login-card input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.admin-body input[type="checkbox"] { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s, background-color 0.12s, border-color 0.12s, transform 0.12s;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--primary-action);
  color: var(--primary-action-foreground);
  border-color: var(--primary-shadow);
  box-shadow: 0 3px 0 var(--primary-shadow);
}
.btn--primary:hover { filter: brightness(1.04); }
.btn--primary:active { box-shadow: 0 1px 0 var(--primary-shadow); transform: translateY(2px); }

.btn--ghost { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary-strong); }

.btn--danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn--danger:hover { filter: brightness(1.06); }

.btn--small { padding: 5px 10px; font-size: 12px; border-radius: 999px; }

.form-error { color: var(--error); font-size: 13px; margin: 0 0 10px; min-height: 18px; font-weight: 650; }

.notice {
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* --- stat tiles ---------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  padding: 13px 15px;
}

.stat__value {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat__label { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }

.login-card h1 { letter-spacing: -0.02em; }
.login-card code {
  font-size: 12px;
  background: var(--muted);
  border-radius: 5px;
  padding: 1px 5px;
}


/* --- analytics ----------------------------------------------------------- */

.range-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--muted);
  border-radius: 999px;
}

.range-switch a {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted-foreground);
  text-decoration: none;
}

.range-switch a.selected { background: var(--card); color: var(--primary-strong); box-shadow: 0 1px 4px #03163314; }

/* Bars are laid out with plain flex so the page needs no chart library and
   no JavaScript to render its main number. */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 168px;
  padding-top: 8px;
}

.chart__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }

.chart__bar {
  background: linear-gradient(180deg, var(--primary), var(--primary-shadow));
  border-radius: 5px 5px 2px 2px;
  min-height: 2px;
  transition: filter 0.14s;
}

.chart__col:hover .chart__bar { filter: brightness(1.12); }

.chart__label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-align: center;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; }


/* --- live socket --------------------------------------------------------- */

.live-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 650;
  text-transform: lowercase;
}

.live-state__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-foreground);
  flex: none;
  transition: background-color 0.2s;
}

.live-state.is-live { color: var(--live); }
.live-state.is-live .live-state__dot {
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 16%, transparent);
}

/* A number that moved should be noticed without hunting for it. */
@keyframes just-changed {
  from { background: color-mix(in srgb, var(--primary) 28%, transparent); }
  to   { background: transparent; }
}

.just-changed {
  animation: just-changed 1.4s ease-out;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .just-changed { animation: none; }
}


/* --- clarity helpers ----------------------------------------------------- */

.page-help {
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 14px;
  max-width: 760px;
}
.page-help b { color: var(--foreground); font-weight: 650; }

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.quick-filters a {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-decoration: none;
}
.quick-filters a:hover { background: var(--muted); color: var(--foreground); }
.quick-filters a.selected { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }

td .sub { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
td.muted, .muted { color: var(--muted-foreground); }

/* A row waiting for the admin to act catches the eye without shouting. */
.row-attention { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.row-attention:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }


/* --- payment log --------------------------------------------------------- */

.stat__value.danger { color: var(--error); }

.log-table td { vertical-align: top; }
.row-error { background: color-mix(in srgb, var(--error) 6%, transparent); }
.row-error:hover { background: color-mix(in srgb, var(--error) 9%, transparent); }

.note-cell { font-size: 12px; color: var(--muted-foreground); max-width: 260px; }
.row-error .note-cell { color: var(--error); font-weight: 600; }

.log-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--primary-strong);
  list-style: none;
  user-select: none;
}
.log-details summary::-webkit-details-marker { display: none; }
.log-details summary::before { content: "▸ "; }
.log-details[open] summary::before { content: "▾ "; }

.log-json {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 320px;
}
.log-json__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  background: var(--muted);
  padding: 4px 10px;
}
.log-json pre {
  margin: 0;
  padding: 10px;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 520px;
  max-height: 300px;
  overflow: auto;
  background: var(--card);
}
.log-json pre + .log-json__label { border-top: 1px solid var(--border); }

/* --- knockout bracket preview (admin) --- */
.bracket-admin { display: flex; gap: 14px; overflow-x: auto; padding: 4px 0; }
.bracket-admin__round { flex: none; min-width: 170px; display: flex; flex-direction: column; gap: 8px; }
.bracket-admin__label { font-size: 12px; font-weight: 700; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .03em; }
.bracket-admin__round.is-current .bracket-admin__label { color: var(--primary); }
.bracket-admin__match { border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; gap: 4px; background: var(--card); }
.bracket-admin__match span { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.bracket-admin__match span.win { color: var(--primary); font-weight: 700; }
.bracket-admin__match b { font-variant-numeric: tabular-nums; }
