@import url('/fonts.css');

:root {
  /* Night navy. One theme, no light mode — the printed cards stay on paper white. */
  --bg: #0a1020;
  --bg-deep: #070c18;
  --surface: #121c33;
  --surface-2: #1a2542;
  --surface-3: #223056;
  --ink: #eef2fb;
  --muted: #94a4c6;
  --faint: #63769c;
  --line: #223052;
  --line-strong: #33456e;

  --accent: #ff6f91;
  --accent-ink: #2a0713;
  --accent-soft: rgba(255, 111, 145, .15);
  --amber: #ffb545;
  --amber-ink: #2b1a02;
  --amber-soft: rgba(255, 181, 69, .15);
  --green: #3ddfa2;
  --green-ink: #032118;
  --green-soft: rgba(61, 223, 162, .15);
  --sky: #56c6ff;

  --radius: 11px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 14px 34px -22px rgba(0, 0, 0, .9);

  --sans: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: dark;
}

/* Light mode is opt-in: same palette, inverted surfaces. Everything downstream
   reads the tokens, so nothing else in the app needs to know. */
body.light {
  --bg: #eef1f6;
  --bg-deep: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --surface-3: #e7ebf2;
  --ink: #101725;
  --muted: #56637a;
  --faint: #8390a5;
  --line: #dde2ea;
  --line-strong: #c2cad8;

  --accent: #c81e4d;
  --accent-ink: #ffffff;
  --accent-soft: rgba(200, 30, 77, .1);
  --amber: #9a6410;
  --amber-ink: #fff8ec;
  --amber-soft: rgba(154, 100, 16, .12);
  --green: #14795c;
  --green-ink: #ffffff;
  --green-soft: rgba(20, 121, 92, .12);
  --sky: #1667a8;

  --shadow: 0 1px 2px rgba(16, 23, 37, .06), 0 10px 26px -20px rgba(16, 23, 37, .5);
  color-scheme: light;
}

body.light {
  background-image: radial-gradient(120% 60% at 50% 0%, #ffffff 0%, var(--bg) 60%);
}

body.light .topbar { background: rgba(255, 255, 255, .84); }
body.light .switch .track::after { background: #fff; }
body.light .fam-card .qr { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(120% 60% at 50% 0%, #16223d 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -.015em;
  line-height: 1.2;
}
p { margin: 0; }
a { color: inherit; }

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.num, .seq, .qty, .amount, .price, .v, .code, td.n, th.n, .clock {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* A category's hue, set inline as --hue on the element. */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hue, var(--faint));
  display: inline-block;
  flex: none;
}

/* ------------------------------------------------------------- structure */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 16, 32, .82);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand { display: flex; flex-direction: column; min-width: 0; }
.brand h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .eyebrow { font-size: 10px; }

.spacer { flex: 1 1 auto; }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab .count {
  display: inline-block;
  margin-left: 6px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.tab .count[hidden] { display: none; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 18px 120px; }
main.narrow { max-width: 620px; }

.section { margin-bottom: 30px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 15px; }
.section-head .meta { margin-left: auto; font-size: 13px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* --------------------------------------------------------------- controls */

.btn {
  appearance: none;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover { background: #ff87a3; border-color: #ff87a3; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--accent); background: transparent; border-color: var(--line-strong); }
.btn.danger:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn.wide { padding: 12px 18px; font-size: 15px; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}

input[type="text"], input[type="number"], input[type="password"], input[type="url"], select, textarea {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-deep);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--sky); }
textarea { resize: vertical; min-height: 66px; }
input::placeholder, textarea::placeholder { color: var(--faint); }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 20px; background: var(--surface-3);
  border: 1px solid var(--line-strong);
  position: relative; transition: background .15s ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; inset: 2px auto 2px 2px; width: 16px; border-radius: 50%;
  background: var(--muted); transition: transform .15s ease, background .15s ease;
}
.switch input:checked + .track { background: var(--green); border-color: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--green-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--sky); outline-offset: 2px; }

/* ----------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.new { color: var(--accent); background: var(--accent-soft); border-color: rgba(255, 111, 145, .3); }
.chip.preparing { color: var(--amber); background: var(--amber-soft); border-color: rgba(255, 181, 69, .3); }
.chip.ready { color: var(--green); background: var(--green-soft); border-color: rgba(61, 223, 162, .3); }
.chip.served { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.chip.cancelled { color: var(--faint); background: transparent; border-color: var(--line-strong); }

/* ---------------------------------------------------------------- receipt */

.receipt { font-size: 14px; }
.receipt ul { margin: 0; padding: 0; }
.receipt li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  list-style: none;
}
.receipt .qty { font-size: 13px; color: var(--muted); min-width: 26px; }
.receipt .leader {
  flex: 1;
  border-bottom: 1px dotted var(--line-strong);
  transform: translateY(-3px);
}
.receipt .amount { font-size: 13px; color: var(--ink); }
.receipt .total {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-weight: 600;
}
.receipt .total .num { font-family: var(--mono); }

/* ----------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: center;
  gap: 9px;
  z-index: 60;
  background: var(--ink);
  color: var(--bg-deep);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  max-width: min(440px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--accent); color: var(--accent-ink); }
#toast.good { background: var(--green); color: var(--green-ink); font-weight: 600; }

/* Anchored to the top on the family screens: the bottom of a phone is where the
   cart bar lives and where the browser chrome eats the last few pixels. */
#toast.at-top {
  bottom: auto;
  top: calc(12px + env(safe-area-inset-top));
  transform: translate(-50%, -20px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
}
#toast.at-top.show { transform: translate(-50%, 0); }
#toast .icon { font-size: 17px; line-height: 1; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; font-family: var(--display); }

/* ------------------------------------------------------------ language */

.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; flex: none; }
.lang-switch .lang-opt {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--faint);
  padding: 5px 9px;
  cursor: pointer;
}
.lang-switch .lang-opt + .lang-opt { border-left: 1px solid var(--line-strong); }
.lang-switch .lang-opt:hover { color: var(--ink); }
.lang-switch .lang-opt[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
}

/* Small icon-style toggle used in the top bar for theme and text size. */
.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: none;
  padding: 5px 9px;
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--sky); }
