/* =====================================================================
 * Jackpot Entries — one stylesheet for the rider pages and the admin.
 *
 * Phone-first. This gets used standing in an arena on one bar of signal,
 * by people wearing gloves, so tap targets are big and nothing needs a
 * hover to be discoverable.
 * ===================================================================== */

:root {
  --brand:      #512888;          /* royal purple */
  --brand-ink:  #3d1e68;
  --brand-soft: #f3eefb;

  --bg:        #f4f5f6;
  --surface:   #ffffff;
  --surface-2: #f8f9fa;
  --text:      #16191d;
  --muted:     #5d666f;
  --faint:     #8a939c;
  --border:    #e0e4e8;
  --border-2:  #c9d0d7;

  --ok:        #127a4d;  --ok-bg:     #e6f4ec;
  --warn:      #9a5b12;  --warn-bg:   #fdf1e0;
  --danger:    #b3261e;  --danger-bg: #fbeae9;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px -10px rgba(0,0,0,.18);
  --tap: 44px;                    /* minimum comfortable touch target */

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* #512888 on a dark ground is too low-contrast to read, so the brand
       lifts to the tint rather than staying "correct" and unreadable. */
    --brand:      #9B72CF;
    --brand-ink:  #b79ae0;
    --brand-soft: #241a33;

    --bg:        #14161a;
    --surface:   #1b1e23;
    --surface-2: #22262c;
    --text:      #eef1f4;
    --muted:     #a7b0ba;
    --faint:     #7b848e;
    --border:    #2c3138;
    --border-2:  #3a4048;

    --ok:        #4ec98d;  --ok-bg:     #10281d;
    --warn:      #e0a45c;  --warn-bg:   #2a1f10;
    --danger:    #f08a83;  --danger-bg: #2b1513;
  }
}

/* `hidden` must beat every display rule below it. A container class that
   sets display:flex outranks the user-agent [hidden] rule on
   specificity, which is how a "hidden" field stays on screen. Fix it
   once, here. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}

/* --- header ---------------------------------------------------------- */
.hdr { background: var(--surface); border-bottom: 1px solid var(--border); }
.hdr-in {
  max-width: 820px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.hdr .who b { display: block; font-size: 17px; letter-spacing: -.01em; }
.hdr .who span { display: block; font-size: 13px; color: var(--muted); }
.brandbar { height: 4px; background: var(--brand); }

.wrap { max-width: 820px; margin: 0 auto; padding: 20px 16px 120px; }

h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 26px 0 10px; }
.sub { margin: 0 0 20px; color: var(--muted); }

/* --- panels and rows ------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.rowlink {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  text-decoration: none; color: inherit; min-height: var(--tap);
}
.rowlink:hover { border-color: var(--brand); }
.rowlink .nm { flex: 1; min-width: 0; }
.rowlink .nm b { display: block; }
.rowlink .nm span { display: block; font-size: 13px; color: var(--muted); }
.chev { color: var(--faint); font-size: 20px; }

/* --- the class picker ------------------------------------------------ */
.cls {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.cls:last-child { border-bottom: 0; }
.cls .nm { flex: 1; min-width: 0; }
.cls .nm b { display: block; }
.cls .nm span { display: block; font-size: 13px; color: var(--muted); }
.cls.full .nm b { color: var(--muted); }

.qty { display: flex; align-items: center; gap: 2px; flex: none; }
.qty button {
  width: var(--tap); height: var(--tap); font-size: 22px; line-height: 1;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text); border-radius: 8px; cursor: pointer;
}
.qty button:disabled { opacity: .35; cursor: not-allowed; }
.qty .n { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.pill {
  flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.ok      { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok); }
.pill.owed    { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn); }
.pill.gone    { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.pill.brand   { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* --- forms ----------------------------------------------------------- */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f { display: flex; flex-direction: column; gap: 5px; }
.f.wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px;           /* 16px stops iOS zooming on focus */
  padding: 10px 12px; min-height: var(--tap);
  border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
input.err { border-color: var(--danger); background: var(--danger-bg); }
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--faint); }

/* --- buttons --------------------------------------------------------- */
.btn {
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  min-height: 52px; width: 100%; padding: 0 20px;
  border: 0; border-radius: var(--radius);
  background: var(--brand); color: #fff;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:not(:disabled):active { filter: brightness(.94); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-2); }

.btn2 {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  min-height: 40px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
}
.btn2.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn2.danger  { color: var(--danger); border-color: var(--danger); }
.btn2:disabled { opacity: .5; cursor: not-allowed; }
.btn2.sm { min-height: 34px; font-size: 13px; padding: 0 11px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- messages -------------------------------------------------------- */
.banner {
  padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 14.5px; line-height: 1.5;
}
.banner.info { background: var(--surface); border: 1px solid var(--border); }
.banner.ok   { background: var(--ok-bg);     border: 1px solid var(--ok);     color: var(--ok); }
.banner.warn { background: var(--warn-bg);   border: 1px solid var(--warn);   color: var(--warn); }
.banner.err  { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.msg { font-size: 14px; margin: 10px 0 0; color: var(--danger); }
.msg:empty { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 60; max-width: 92vw; text-align: center;
}
.toast.err { background: var(--danger); color: #fff; }

/* --- totals bar ------------------------------------------------------ */
.owedbar {
  position: sticky; bottom: 0; margin: 0 -16px -120px;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.owedbar .t { flex: 1; }
.owedbar .t b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.owedbar .t span { font-size: 12.5px; color: var(--muted); }
.owedbar .btn { width: auto; flex: none; padding: 0 24px; }

/* --- tables (admin) -------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td {
  padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th { font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 16px; background: var(--surface);
        border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; min-height: var(--tap); padding: 0 14px; border: 0; background: none;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile dt { font-size: 12.5px; color: var(--muted); margin: 0 0 3px; }
.tile dd { margin: 0; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.money dd { color: var(--brand); }

.spin {
  width: 22px; height: 22px; border-radius: 50%; margin: 0 auto 10px;
  border: 2px solid var(--border-2); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

footer.site {
  max-width: 820px; margin: 0 auto; padding: 24px 16px 40px;
  color: var(--faint); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap;
}
