/*
 * Sheridan BJJ brand, matched to the Sales Dashboard: a black masthead with a
 * gold rule, gold for actions and selection, warm off-white pages, Montserrat
 * for headings and numbers, Source Sans 3 for text. Token names and values are
 * the dashboard's own, so the two stay in step.
 */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-2: #4d4a43;
  --muted: #857f73;
  --grid: #e8e4da;
  --line: rgba(26, 26, 26, 0.10);
  --gold: #e3ab33;
  --gold-ink: #1a1a1a;
  --band: #1a1a1a;
  --band-ink: #f7f5f0;
  --band-muted: #b9b3a5;
  --good: #1f7a3a;
  --bad: #c0362f;
  --warn-bg: #fbf0d6;
  --warn-ink: #7a5600;
  --hover: rgba(26, 26, 26, 0.05);
  --font-display: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1c1b19;
    --ink: #f3f1ec;
    --ink-2: #c9c4b8;
    --muted: #8f8a7e;
    --grid: #2c2a26;
    --line: rgba(255, 255, 255, 0.10);
    --gold: #e8b444;
    --band: #050505;
    --band-ink: #f3f1ec;
    --band-muted: #a9a395;
    --good: #4cc26a;
    --bad: #f07470;
    --warn-bg: #2e2510;
    --warn-ink: #f2c665;
    --hover: rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: 26px; font-weight: 700; line-height: 1.15; margin-bottom: 14px; }
h2 { font-size: 17px; font-weight: 700; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.shell { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 0; }

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---- masthead ---- */

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 4px solid var(--gold);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.mast-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.mast-logo { flex: none; width: 48px; height: 48px; }

.mast-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--band-ink);
}

.mast-name { font-size: 14px; font-weight: 600; color: var(--band-ink); white-space: nowrap; }

/* The smallest phones (iPhone SE): give the name and account room. */
@media (max-width: 359px) {
  .mast-logo { width: 40px; height: 40px; }
  .mast-title { font-size: 17px; }
}

.account-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--grid);
  font-size: 14px;
  color: var(--muted);
}

.account-footer .link-button { color: var(--ink-2); }

/* ---- section navigation (admins) and person filter: dashboard pills ---- */

.app-nav,
.person-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-nav { margin-bottom: 14px; }
.person-filter { margin: 4px 0 22px; }

.app-nav-link,
.pill {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

@media (hover: hover) { .app-nav-link:hover, .pill:hover { border-color: var(--gold); } }

.app-nav-link.active,
.pill.active {
  background: var(--band);
  color: var(--band-ink);
  border-color: var(--band);
  box-shadow: inset 0 -3px 0 var(--gold);
}

.pill.is-inactive:not(.active) { color: var(--muted); }

/* ---- flash ---- */

.flash {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  font-size: 15px;
}

.flash-alert { border-left-color: var(--bad); }

/* ---- period navigation ---- */

.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.period-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  flex: 1;
}

.period-step {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

@media (hover: hover) { .period-step:hover { border-color: var(--gold); } }

/* ---- KPI cards and panels ---- */

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.kpi { display: grid; gap: 2px; margin-bottom: 12px; }
.kpis .kpi { margin-bottom: 0; }

.kpi-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-unit {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0;
}

.panel { margin-bottom: 14px; }
.panel > :last-child { margin-bottom: 0; }

.status-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--ink-2);
}

.status-line strong { color: var(--ink); }

.status-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translateY(1px);
}

.status-dot.is-open { background: var(--good); }
.status-dot.is-closed { background: var(--muted); }

.period-closed {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 10px;
  color: var(--ink-2);
}

.lock-history {
  margin: 12px 0 0;
  padding: 10px 0 0 18px;
  border-top: 1px solid var(--grid);
  font-size: 14px;
  color: var(--ink-2);
}

.reopen summary {
  cursor: pointer;
  color: var(--bad);
  font-weight: 600;
  font-size: 15px;
}

.reopen .entry-form { margin-top: 12px; }

/* ---- buttons ---- */

.button-primary,
.button-secondary,
.button-dark,
.button-danger {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}

.button-primary { background: var(--gold); color: var(--gold-ink); }
@media (hover: hover) { .button-primary:hover { filter: brightness(0.96); } }

.button-dark { background: var(--band); color: var(--band-ink); box-shadow: inset 0 -3px 0 var(--gold); margin-bottom: 0; }
@media (hover: hover) { .button-dark:hover { color: var(--gold); } }

.button-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
@media (hover: hover) { .button-secondary:hover { border-color: var(--gold); } }

.button-danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }

.actions { margin-bottom: 8px; }

.link-button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* button_to wraps each button in a form; keep those from breaking lines oddly */
form.button_to { margin: 0; }

/* ---- entries ---- */

/* Hover highlights are wrapped in (hover: hover) throughout: on a phone,
   Safari leaves :hover stuck on whatever was last touched. */

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.entry-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

@media (hover: hover) { a.entry-row:hover { border-color: var(--gold); } }

/* the cue that a row opens for editing; closed-period rows don't get one */
.entry-edit {
  align-self: center;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

@media (hover: hover) { a.entry-row:hover .entry-edit { border-color: var(--gold); color: var(--ink); } }

.entry-row.is-closed { background: transparent; color: var(--ink-2); }

.entry-date { font-weight: 600; }

.entry-hours {
  margin-left: auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.entry-unit {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.entry-note { flex-basis: 100%; color: var(--ink-2); }

.entry-flag {
  flex-basis: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 14px;
}

.empty-state { color: var(--muted); margin: 6px 0 0; }

.backup-status { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.backup-status.is-overdue { color: var(--bad); font-weight: 600; }

.person-group { margin-bottom: 24px; }

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--grid);
}

.group-total {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- forms ---- */

.entry-form .field { margin-bottom: 16px; }

.entry-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.entry-form input[type="date"],
.entry-form input[type="number"],
.entry-form input[type="text"],
.entry-form input[type="email"],
.entry-form select,
.entry-form textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* iPhone Safari gives date boxes a built-in minimum width and centered
   text, so they ignore width: 100% and run off the right edge. Dropping the
   native look lets them size like every other box. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.entry-form input:focus,
.entry-form select:focus,
.entry-form textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

.field-hint { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

/* the "Reuse a recent note" menu sits between the label and the note box */
.entry-form select.note-reuse { margin-bottom: 8px; color: var(--ink-2); }

.form-errors {
  margin-bottom: 16px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  border-radius: 10px;
  color: var(--bad);
}

.form-errors ul { margin: 0; padding-left: 18px; }

/* ---- people ---- */

.page-intro { color: var(--ink-2); margin: -6px 0 14px; }

.people-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.person-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.person-row.is-left { background: transparent; color: var(--ink-2); }

.person-details { display: flex; flex-direction: column; min-width: 0; }
.person-name { font-weight: 600; }
.person-email { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }

.person-actions {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 15px;
}

.person-actions a { text-underline-offset: 2px; }
.person-actions .is-consequential { color: var(--bad); }

.person-note { flex-basis: 100%; font-size: 14px; color: var(--muted); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 12px;
  font-weight: 700;
  vertical-align: 1px;
}

/* ---- sign-in ---- */

.intro { color: var(--ink-2); margin-top: -6px; }

.entry-form input.code-input {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
