/* Toss Pizzeria & Pub — Manager Sheet
   Built for a tablet behind the bar: large hit targets, numbers you can read
   from arm's length, and colour that means something (green balances, red is
   short, amber is unfinished). */

:root {
  color-scheme: light dark;

  --tomato: #c8352b;
  --tomato-dark: #a52a22;
  --basil: #1f7a4d;
  --crust: #e8dcc8;
  --char: #1b1917;

  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --surface-3: #f1ede6;
  --border: #e2dcd1;
  --border-strong: #cdc4b5;
  --text: #241f1c;
  --text-dim: #6d6459;
  --text-faint: #968c7e;

  --ok: #1f7a4d;
  --ok-bg: #e6f4ec;
  --warn: #9a6408;
  --warn-bg: #fdf3e0;
  --bad: #c0322a;
  --bad-bg: #fbeae8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(36, 31, 28, .06), 0 4px 16px rgba(36, 31, 28, .05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f;
    --surface: #211e19;
    --surface-2: #1b1914;
    --surface-3: #2a261f;
    --border: #35302a;
    --border-strong: #4a443b;
    --text: #f2ece1;
    --text-dim: #a89d8d;
    --text-faint: #7d7264;
    --ok: #5cc98d;
    --ok-bg: #16301f;
    --warn: #e0a94a;
    --warn-bg: #322612;
    --bad: #ef7b6f;
    --bad-bg: #34191a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- app shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--char);
  color: var(--crust);
  border-bottom: 3px solid var(--tomato);
}

@media (prefers-color-scheme: dark) { .topbar { background: #100e0b; } }

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand-mark {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .14em;
  color: #fff;
}
.brand-sub { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: #b6a98f; }

.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: #cabca0;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: var(--tomato); color: #fff; }

.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b6a98f;
}
.whoami .chip {
  background: rgba(255, 255, 255, .1);
  border-radius: 999px;
  padding: 4px 11px;
  color: #fff;
  font-weight: 600;
}
.whoami button {
  background: none;
  border: 1px solid rgba(255, 255, 255, .22);
  color: #cabca0;
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  font-size: 12px;
}
.whoami button:hover { border-color: #fff; color: #fff; }

main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 80px; }

.banner {
  border-radius: var(--radius);
  padding: 11px 15px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.banner-info { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.banner-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.banner-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.banner a { color: inherit; font-weight: 600; }

/* ------------------------------------------------------------------- header */
.daybar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.daybar h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.daybar .spacer { flex: 1 1 40px; }
.date-input {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-family: var(--mono);
}

.pill {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-open { background: var(--warn-bg); color: var(--warn); }
.pill-closed { background: var(--ok-bg); color: var(--ok); }

/* -------------------------------------------------------------------- cards */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.hint { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; }
.hint:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field input, .field select, .field textarea {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
.field textarea { min-height: 62px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus,
.count-row input:focus, .tip-table input:focus, .tip-table select:focus {
  outline: 2px solid var(--tomato);
  outline-offset: -1px;
  background: var(--surface);
}
.field input[type="number"], .field.money input { font-family: var(--mono); }

/* --------------------------------------------------------------- bill counts */
.count-table { width: 100%; border-collapse: collapse; }
.count-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.count-table th:last-child, .count-table td:last-child { text-align: right; }
.count-row td { padding: 4px 12px; border-bottom: 1px solid var(--border); }
.count-row .denom { font-family: var(--mono); font-weight: 700; width: 66px; }
.count-row input {
  width: 100%;
  min-width: 60px;
  border: 1px solid transparent;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 17px;
  text-align: right;
  -moz-appearance: textfield;
}
.count-row input::-webkit-outer-spin-button,
.count-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count-row .ext { font-family: var(--mono); color: var(--text-dim); white-space: nowrap; }
.count-row.mismatch input { background: var(--bad-bg); border-color: var(--bad); }
.count-total td {
  padding: 11px 12px;
  font-weight: 800;
  font-family: var(--mono);
  font-size: 18px;
  background: var(--surface-2);
}

/* -------------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); }
.tile { background: var(--surface); padding: 14px 16px; }
.tile .k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.tile .v { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.tile .n { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tile.big .v { font-size: 30px; }
.tile.ok .v { color: var(--ok); }
.tile.bad .v { color: var(--bad); }
.tile.warn .v { color: var(--warn); }
.tile.ok { background: var(--ok-bg); }
.tile.bad { background: var(--bad-bg); }
.tile.warn { background: var(--warn-bg); }

/* ---------------------------------------------------------------- checklists */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 3px 16px;
  border-bottom: 1px solid var(--border);
}
.check-item:last-child { border-bottom: 0; }
.check-item .label { flex: 1; font-size: 15px; }
.check-item.done { background: var(--ok-bg); }
.check-item.done .label { color: var(--text-dim); }
.initial-btn {
  min-width: 62px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border-strong);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 15px;
  text-transform: lowercase;
}
.initial-btn:hover { border-color: var(--tomato); color: var(--tomato); }
.initial-btn.set {
  border-style: solid;
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}
.progress {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- tip table */
.table-scroll { overflow-x: auto; }
.tip-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.tip-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tip-table td { padding: 5px 12px; border-bottom: 1px solid var(--border); }
.tip-table input, .tip-table select {
  border: 1px solid transparent;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  width: 100%;
}
.tip-table input[type="number"] { font-family: var(--mono); text-align: right; }
.tip-table .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.tip-table .short { color: var(--bad); font-weight: 700; }
.tip-table tfoot td {
  font-family: var(--mono);
  font-weight: 800;
  background: var(--surface-2);
  border-bottom: 0;
}
.row-del {
  background: none;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.row-del:hover { background: var(--bad-bg); color: var(--bad); }

/* ------------------------------------------------------------------ buttons */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.btn:hover { border-color: var(--text-dim); }
.btn-primary { background: var(--tomato); border-color: var(--tomato); color: #fff; }
.btn-primary:hover { background: var(--tomato-dark); border-color: var(--tomato-dark); }
.btn-ghost { background: none; border-style: dashed; color: var(--text-dim); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: none; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------- calendar */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-head h1 { margin: 0; font-size: 22px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow {
  background: var(--surface-2);
  padding: 7px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
}
.cal-cell {
  background: var(--surface);
  min-height: 96px;
  padding: 7px 8px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-cell.empty { background: var(--surface-2); }
.cal-cell:hover { background: var(--surface-3); }
.cal-cell .dnum { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--text-dim); }
.cal-cell.today .dnum { background: var(--tomato); color: #fff; border-radius: 999px; padding: 0 7px; align-self: flex-start; }
.cal-cell .sales { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.cal-cell .os { font-family: var(--mono); font-size: 12px; }
.cal-cell .os.ok { color: var(--ok); }
.cal-cell .os.bad { color: var(--bad); }
.cal-cell .flag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--warn); margin-top: auto; }
.cal-cell .nosheet { font-size: 12px; color: var(--text-faint); margin-top: auto; }

/* ------------------------------------------------------------------- gates */
.gate { max-width: 460px; margin: 8vh auto; }
.gate .card-body { padding: 22px; }
.gate h1 { margin: 0 0 6px; font-size: 22px; }
.gate p { color: var(--text-dim); font-size: 14px; margin: 0 0 18px; }
.mgr-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.mgr-tile {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
}
.mgr-tile:hover { border-color: var(--tomato); background: var(--surface-3); }
.mgr-tile .nm { font-weight: 700; }
.mgr-tile .in { font-family: var(--mono); font-size: 12px; color: var(--text-faint); text-transform: lowercase; }
.pin-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: .5em;
  text-align: center;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.err { color: var(--bad); font-size: 14px; font-weight: 600; margin: 10px 0 0; }
.ok-msg { color: var(--ok); font-size: 14px; font-weight: 600; margin: 10px 0 0; }

/* -------------------------------------------------------------------- lists */
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.rowlist li:last-child { border-bottom: 0; }
.rowlist .grow { flex: 1; min-width: 0; }
.rowlist .nm { font-weight: 600; }
.rowlist .meta { font-size: 13px; color: var(--text-dim); }
.tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
}
.tag.pool { background: var(--ok-bg); color: var(--ok); }
.tag.admin { background: var(--warn-bg); color: var(--warn); }
.tag.off { background: var(--bad-bg); color: var(--bad); }

.savebar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
.savebar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.savebar .status { font-size: 13px; color: var(--text-dim); margin-right: auto; }
.savebar .status.dirty { color: var(--warn); font-weight: 600; }
.savebar .status.saved { color: var(--ok); font-weight: 600; }
.savebar .status.error { color: var(--bad); font-weight: 700; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--tomato);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  main { padding: 14px 11px 90px; }
  .daybar h1 { font-size: 19px; }
  .tile .v { font-size: 19px; }
  .tile.big .v { font-size: 25px; }
  .cal-cell { min-height: 74px; padding: 5px; }
  .cal-cell .sales { font-size: 13px; }
  .check-item { padding: 3px 11px; gap: 8px; }
}

@media print {
  .topbar, .savebar, .btn, .row-del, .banner { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ------------------------------------------------------------------- games */
.games-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}
.games-toggle:hover { border-color: var(--tomato); }
.games-toggle .count {
  background: var(--tomato);
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-family: var(--mono);
}
.games-toggle[aria-expanded="true"] { border-color: var(--tomato); }

.game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.game-row:last-child { border-bottom: 0; }
.game-row.fav { border-left-color: var(--tomato); background: var(--surface-2); }
.game-row .when {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  min-width: 76px;
  white-space: nowrap;
}
.game-row .who { flex: 1; min-width: 0; font-size: 15px; }
.game-row.fav .who { font-weight: 700; }
.game-row .chan {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--char);
  color: #fff;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .game-row .chan { background: var(--surface-3); color: var(--text); } }
.game-row .chan.none { background: none; color: var(--text-faint); border: 1px dashed var(--border-strong); }
.game-row .lg {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  min-width: 48px;
}
@media (max-width: 640px) {
  .game-row { flex-wrap: wrap; gap: 7px 10px; }
  .game-row .who { flex-basis: 100%; order: 3; }
}
