/* Rapid iPhone Repair point of sale. The same colors and parts as the shop's
   time clock (clock.rapidiphone.repair), so the two feel like one product. */

:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #5b6878;
  --line: #d9dfe7;
  --brand: #0b5cab;
  --brand-ink: #ffffff;
  --brand-soft: #e6f0fb;
  --good: #14804a;
  --good-soft: #e3f5eb;
  --warn: #9a5b00;
  --warn-soft: #fff3d6;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d;
    --card: #1a222c;
    --ink: #e8edf3;
    --muted: #9aa7b6;
    --line: #2d3947;
    --brand: #4b9bea;
    --brand-ink: #06121f;
    --brand-soft: #16304b;
    --good: #55c98b;
    --good-soft: #143424;
    --warn: #f0b64a;
    --warn-soft: #3a2c0c;
    --bad: #ff8a80;
    --bad-soft: #43201d;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.brand { color: inherit; text-decoration: none; font-weight: 700; white-space: nowrap; }
@media (max-width: 480px) { .brand span { display: none; } }
.brand span { font-weight: 400; opacity: .85; }
.who { font-size: .85rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: 0 0 auto; padding: 9px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; min-height: 40px; display: flex; align-items: center; gap: 6px; }
.tabs a.on { background: var(--brand-soft); color: var(--brand); }
.tabs .sep { flex: 0 0 1px; background: var(--line); margin: 6px 4px; }
.count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; font-weight: 700; }

main { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
main.narrow { max-width: 520px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card.tight { padding: 12px 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row.top-align { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.none { color: var(--muted); padding: 6px 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.big { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.num { font-variant-numeric: tabular-nums; }

/* buttons */
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-good { background: var(--good); color: #fff; border-color: var(--good); }
.btn-bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 8px 10px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns.bar { margin-top: 8px; }
h2.gap { margin-top: 16px; }
form.gap { margin-top: 14px; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; padding: 0; vertical-align: middle; margin-right: 8px; }
.check { display: flex; align-items: center; font-weight: 500; }
.field { margin: 0 0 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.fields .wide { grid-column: 1 / -1; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-weight: 600; }
.note { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.good { background: var(--good-soft); color: var(--good); }
.secret { font-size: 1.8rem; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; user-select: all; }

/* tags */
.tag { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--brand-soft); color: var(--brand); }

/* the store this screen is at, in the top bar */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.top .at { flex: 1 1 auto; display: flex; justify-content: flex-end; min-width: 0; }
.top select { width: auto; max-width: 100%; min-height: 34px; padding: 4px 10px; border-radius: 999px; border-color: transparent; background: rgba(255, 255, 255, .16); color: inherit; font-weight: 600; font-size: .9rem; }
.top select option { color: #16202c; background: #fff; }

/* the title row of a page: the title and its main button */
.head { margin: 0 0 12px; }
.head h1 { margin: 0; }

/* customers */
.search { display: flex; gap: 8px; margin: 0 0 12px; }
.search input { font-size: 1.15rem; min-height: 52px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li + li { border-top: 1px solid var(--line); }
.person-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; color: inherit; text-decoration: none; min-height: 56px; }
.person-row:hover, .person-row:focus-visible { background: var(--brand-soft); border-radius: 8px; }
.person-row b { display: block; }
.person-row .sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.person-row .tel { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
@media (max-width: 480px) { .fields { grid-template-columns: 1fr; } }

/* tickets */
.search select { width: auto; flex: 0 0 auto; min-height: 52px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.pills button { min-height: 38px; padding: 6px 12px; border-radius: 999px; font-size: .9rem; }
.pills button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pills .num { opacity: .75; font-weight: 500; }
.person-row .sub { display: block; }
.person-row .right { flex: 0 0 auto; }
.history { margin-top: 14px; }
.history .body { white-space: pre-line; overflow-wrap: anywhere; margin-top: 2px; }
@media (max-width: 600px) { .search { flex-wrap: wrap; } .search select { width: 100%; } }

/* sales */
table.lines td { padding: 4px 4px 4px 0; border-bottom: 0; }
table.lines th { padding-left: 0; }
table.lines input, table.lines select { min-height: 42px; padding: 8px 10px; }
table.lines input.n { text-align: right; width: 6.5rem; }
table.lines input[name=qty] { width: 4rem; }
table.lines input[name=description] { min-width: 12rem; }
table.lines select { min-width: 8.5rem; }
table.lines input:disabled { background: var(--bg); color: var(--muted); }
.totals { display: grid; grid-template-columns: 1fr max-content; gap: 4px 24px; margin: 14px 0 0 auto; max-width: 340px; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .big-line { font-size: 1.25rem; font-weight: 800; color: var(--ink); padding-top: 4px; }
.pay-btns { gap: 10px; }
.btn-pay { flex: 1 1 180px; min-height: 64px; font-size: 1.1rem; }

/* the price list picker */
.picker { position: relative; }
.picker-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-height: 320px; overflow-y: auto; padding: 4px 8px; }
.picker-list .pick { width: 100%; border: 0; background: transparent; text-align: left; font-weight: 400; min-height: 48px; padding: 8px 4px; border-radius: 8px; }
.picker-list .pick:hover, .picker-list .pick:focus-visible { background: var(--brand-soft); }
.picker-list .none { padding: 10px 4px; }
.bar-row { margin-top: 8px; align-items: flex-start; }
.bar-row .grow { min-width: 220px; }

/* products */
table.lines .part-of { font-size: .82rem; color: var(--muted); padding: 2px 2px 0; min-height: 0; }
table.lines .part-of:empty { display: none; }
table.lines td { vertical-align: top; }
dialog .people { max-height: 46vh; overflow-y: auto; }
dialog .pick { width: 100%; border: 0; background: transparent; text-align: left; font-weight: 400; padding: 8px 4px; border-radius: 8px; }
dialog .pick:hover, dialog .pick:focus-visible { background: var(--brand-soft); }

/* reports */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat small { display: block; color: var(--muted); }
.stat b { display: block; font-size: 1.35rem; }
.good-ink { color: var(--good); }
.bad-ink { color: var(--bad); }
.range { align-items: flex-end; justify-content: flex-start; gap: 12px; margin: 0 0 12px; }
.range .field { margin: 0; flex: 0 1 190px; }

/* register */
.totals.wide { max-width: 420px; margin-left: 0; }
.count-grid { display: grid; grid-template-columns: 4rem 6rem 1fr; gap: 6px 12px; align-items: center; }
.count-grid label { margin: 0; font-size: 1rem; }
.count-grid input { min-height: 40px; padding: 6px 10px; text-align: right; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 800; border-bottom: 0; }
tr.inactive td { color: var(--muted); }

/* dialog and toast */
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(8, 15, 25, .55); }
dialog h2 { font-size: 1.15rem; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; max-width: calc(100vw - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.toast.bad { background: var(--bad); color: #fff; }

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