/* Cuadrin — phone first; the count screen is used standing at a register. */
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #6b665e;
  --line: #e4e1d8;
  --brand: #14532d;
  --brand-ink: #fef3c7;
  --accent: #166534;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --radius: 12px;
  --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f; --card: #1c1b18; --ink: #f2efe8; --muted: #a39d92; --line: #34312b;
    --ok-bg: #14331f; --warn-bg: #3a2a0c; --bad-bg: #3b1414; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --accent: #4ade80; --on-accent: #052e16;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .money, input.qty { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
[hidden] { display: none !important; }

/* header and tabs */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 1.15rem; min-width: 0; }
.logo { font-family: Georgia, serif; font-size: 1.4rem; }
.merchant { font-weight: 400; font-size: .9rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(254, 243, 199, .5);
  background: transparent; color: var(--brand-ink); cursor: pointer; font-weight: 600; }
.tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 12px 4px; color: var(--muted); text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 0; }
p { line-height: 1.45; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.big { font-size: 1.8rem; font-weight: 700; margin: 6px 0 2px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row.total { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 4px; padding-top: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .wide { grid-column: 1 / -1; }
details summary { cursor: pointer; color: var(--muted); padding: 6px 0; }

/* buttons */
.btn { min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn:disabled { opacity: .5; cursor: default; }
a.btn { color: inherit; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { flex: 1; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px 0; font-weight: 600; text-align: left; }

/* status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge.balanced { background: var(--ok-bg); color: var(--ok); }
.badge.over { background: var(--warn-bg); color: var(--warn); }
.badge.short { background: var(--bad-bg); color: var(--bad); }
.badge.open { background: var(--line); color: var(--ink); }
.var-over { color: var(--warn); }
.var-short { color: var(--bad); }

/* forms */
label.field { display: block; margin: 14px 0 4px; font-weight: 600; }
.help { font-size: .88rem; color: var(--muted); margin: 4px 0 0; }
input[type=text], input[type=email], input[type=date], input[type=number], select, textarea, input.money-in {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
textarea { min-height: 72px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .step:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 22px; height: 22px; }
.inline { display: flex; gap: 8px; align-items: end; }
.inline > * { flex: 1; }

/* count screen */
.denoms { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px; margin-bottom: 12px; }
.denoms h3 { padding: 10px 0 4px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.denom { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) 4.6rem; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.denom .label { font-weight: 700; }
.denom .sub { text-align: right; color: var(--muted); }
.denom .sub.has { color: var(--ink); font-weight: 600; }
.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; max-width: 240px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.step { border: 0; background: var(--bg); font-size: 1.3rem; font-weight: 700; cursor: pointer; min-height: var(--tap); }
input.qty { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center;
  font-size: 1.15rem; min-width: 0; width: 100%; padding: 0; background: var(--card); }
.totalbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); z-index: 10; }
.totalbar-in { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.totalbar .sum { flex: 1; }
.totalbar .sum small { display: block; color: var(--muted); }
.totalbar .sum strong { font-size: 1.5rem; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 12px 0; }
.segmented button { min-height: 42px; border: 0; background: var(--card); cursor: pointer; font-weight: 600; }
.segmented button.on { background: var(--accent); color: var(--on-accent); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }

.drawer-edit { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 20; }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.notice { background: var(--ok-bg); color: var(--ink); padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.notice.warn { background: var(--warn-bg); }
.signin { text-align: center; padding-top: 40px; }
.signin .logo-big { font-family: Georgia, serif; font-size: 3.5rem; color: var(--accent); }

@media (min-width: 600px) {
  .actions { grid-template-columns: repeat(4, 1fr); }
  .actions .wide { grid-column: auto; }
}

@media print {
  .top, .tabs, .btn-row, .totalbar, .toast, .no-print { display: none !important; }
  body, :root { background: #fff; color: #000; }
  main { padding: 0; }
  .card { border: 0; padding: 0; }
}

.site-foot { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; text-align: center; font-size: .85rem; color: var(--muted); }
.site-foot a { color: var(--muted); }
@media print { .site-foot { display: none !important; } }
