/* Bham Ballers dashboard — hand-rolled, no build step.
   Light theme by default; dark theme via prefers-color-scheme. */

:root {
  --bg: #f7f7f5;
  --bg-panel: #ffffff;
  --text: #1c1c1e;
  --text-muted: #5b5b60;
  --border: #dcdcd8;
  --brand: #1d5f3a;
  --brand-dark: #123f27;
  --ok: #1d7a3a;
  --ok-bg: #e6f4ea;
  --fail: #a3271f;
  --fail-bg: #fbe9e7;
  --warn-bg: #fff6e0;
  --link: #14532d;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-panel: #1c1f24;
    --text: #eceef0;
    --text-muted: #a3a8ae;
    --border: #33373d;
    --brand: #4caf7d;
    --brand-dark: #79cba0;
    --ok: #6fcf97;
    --ok-bg: #16301f;
    --fail: #f28b82;
    --fail-bg: #3a1a17;
    --warn-bg: #3a3115;
    --link: #7fd3a0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
}

.lede {
  color: var(--text-muted);
  max-width: 60ch;
}

/* --- layout --- */

.site-header {
  background: var(--brand-dark);
  padding: 0.75rem 1rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: 960px;
  margin: 0 auto;
}

.site-nav a {
  color: #fff;
  font-weight: 500;
}

.site-nav a.brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-right: auto;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.site-footer {
  max-width: 960px;
  margin: 2rem auto 0;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.error-panel h1 {
  margin-top: 0;
  color: var(--fail);
}

/* --- nav cards on the landing page --- */

.nav-cards {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav-cards li a {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-weight: 600;
}

/* --- check total banner --- */

.check-total {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin: 0.75rem 0;
}

.check-total.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.check-total.fail {
  background: var(--fail-bg);
  color: var(--fail);
  font-weight: 700;
}

/* --- tables --- */

.table-scroll {
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

th a.sort-link {
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

tbody tr:hover {
  background: rgba(127, 127, 127, 0.06);
}

tr.near-bound {
  background: var(--warn-bg);
}

tr.voided td {
  color: var(--text-muted);
}

/* --- season selector --- */

.season-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.season-selector span {
  color: var(--text-muted);
}

.season-link {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.season-link.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* --- badges --- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--border);
  font-size: 0.8rem;
  text-transform: capitalize;
}

.badge-confirmed_dc {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-reverted,
.badge-rejected_bounds,
.badge-disputed {
  background: var(--fail-bg);
  color: var(--fail);
}

/* --- empty state --- */

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 0.75rem 0;
}

/* --- responsive --- */

@media (max-width: 600px) {
  .container {
    padding: 1rem 0.75rem 2rem;
  }

  .site-nav {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  h1 {
    font-size: 1.4rem;
  }

  .panel {
    padding: 1rem;
  }
}

/* --- nav: session controls --- */

.nav-user {
  color: #fff;
  opacity: 0.85;
  font-size: 0.9rem;
}

.nav-logout {
  margin: 0;
  display: inline;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: #fff;
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

/* --- admin: form panels --- */

.admin-form-panel + .admin-form-panel,
.panel + .panel {
  margin-top: 1.25rem;
}

.admin-form-panel form {
  margin-top: 0.75rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-row label,
label.full-width {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex: 1 1 160px;
}

label.full-width {
  margin-bottom: 0.75rem;
}

.form-row input,
.form-row select,
label.full-width input {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.checkbox-label input {
  width: auto;
}

.admin-form-panel button,
.inline-form button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.admin-form-panel button:hover,
.inline-form button:hover {
  background: var(--brand-dark);
}

.field-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0.25rem 0 0.75rem;
}

.form-error {
  background: var(--fail-bg);
  color: var(--fail);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

.inline-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0;
}

.inline-form input[type="text"] {
  font: inherit;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-width: 8rem;
}

.pending-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

/* --- admin flashes ------------------------------------------------------ */
/* A write that lands and re-renders an unchanged-looking panel is
   indistinguishable from one that did nothing, so both outcomes are loud. */
.flash {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  border-left: 4px solid;
  font-weight: 500;
}
.flash:focus { outline: 2px solid currentColor; outline-offset: 2px; }
.flash-success { border-color: #1a7f37; background: #dafbe1; color: #0d4a20; }
.flash-error   { border-color: #cf222e; background: #ffebe9; color: #82071e; }

/* --- audit log ---------------------------------------------------------- */
.audit-action {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.14);
}
.audit-detail { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.15rem; }
.audit-detail li { display: flex; gap: 0.4rem; font-size: 0.9em; }
.audit-detail .k { color: #57606a; min-width: 8ch; }
.audit-detail .v { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: #8b949e; }

@media (prefers-color-scheme: dark) {
  .flash-success { background: #10331b; color: #7ee2a8; }
  .flash-error   { background: #3a1416; color: #ff9d95; }
  .audit-detail .k { color: #9aa4af; }
}

/* --- linked accounts table ---------------------------------------------- */
.link-table td, .link-table th { padding: 0.4rem 0.6rem; }
.link-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; }
.link-table form { margin: 0; }
.row-unlinked { background: rgba(210, 153, 34, 0.10); }
.tag { font-size: 0.78em; padding: 0.1rem 0.45rem; border-radius: 999px; white-space: nowrap; }
.tag-ok   { background: #dafbe1; color: #0d4a20; }
.tag-warn { background: #fff3cd; color: #7a5b00; }
.badge {
  font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem; border-radius: 4px; background: #ddf4ff; color: #0a3069;
}
.btn-small { font-size: 0.82em; padding: 0.2rem 0.6rem; }
.btn-danger { background: #cf222e; color: #fff; border: none; border-radius: 5px; cursor: pointer; }
.btn-danger:hover { background: #a40e26; }
.hint { font-size: 0.87em; color: #57606a; margin-top: 0.6rem; }

@media (prefers-color-scheme: dark) {
  .tag-ok   { background: #10331b; color: #7ee2a8; }
  .tag-warn { background: #3a2f10; color: #e3c26a; }
  .badge    { background: #12263f; color: #9ecbff; }
  .hint     { color: #9aa4af; }
  .row-unlinked { background: rgba(210, 153, 34, 0.14); }
}
.tag-danger { background: #ffebe9; color: #82071e; font-weight: 600; }
@media (prefers-color-scheme: dark) { .tag-danger { background: #3a1416; color: #ff9d95; } }
