/* =====================================================================
   Coffee tab · Floor 12
   Style: warm minimal (one style, flat surfaces, single elevation scale)
   Brand cue: the espresso machine's black control panel + amber display
   All text pairs verified ≥ 4.5:1 in light and dark.
   ===================================================================== */

:root {
  /* primitives */
  --cream-50: #FAF6F0;
  --cream-100: #F3ECE3;
  --cream-200: #E6DCD0;
  --brown-700: #92400E;
  --brown-800: #7A350B;
  --brown-100: #F7EADB;
  --ink-900: #1F1712;
  --ink-600: #5C4A3D;
  --ink-450: #8F7B6B;
  --panel-900: #17120F;
  --panel-800: #241C17;
  --amber-400: #F3A64A;
  --mint-300: #7BD3A0;

  /* semantic tokens (light) */
  --bg: var(--cream-50);
  --surface: #FFFFFF;
  --surface-2: var(--cream-100);
  --text: var(--ink-900);
  --text-2: var(--ink-600);
  --border: var(--cream-200);
  --border-strong: var(--ink-450);
  --primary: var(--brown-700);
  --primary-hover: var(--brown-800);
  --on-primary: #FFFFFF;
  --primary-soft: var(--brown-100);
  --success: #166534;
  --success-soft: #E7F4EC;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warning-soft: #FFF4DC;
  --wa: #157A42;
  --panel: var(--panel-900);
  --panel-2: var(--panel-800);
  --on-panel: #F5EEE6;
  --on-panel-2: #B9AA9C;
  --display: #9FDCFF;          /* machine readout: icy blue */
  --led: var(--amber-400);       /* active indicator */
  --display-ok: var(--mint-300);
  --focus: #1D5FD1;

  /* type */
  --font-body: "IBM Plex Sans Hebrew", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-display: "Noto Serif Hebrew", "IBM Plex Sans Hebrew", Georgia, serif;
  --fs-xs: 0.8125rem;  /* 13 */
  --fs-sm: 0.875rem;   /* 14 */
  --fs-md: 1rem;       /* 16 */
  --fs-lg: 1.125rem;   /* 18 */
  --fs-xl: 1.375rem;   /* 22 */
  --fs-2xl: 1.75rem;   /* 28 */
  --fs-3xl: 2.25rem;   /* 36 */
  --fs-num: 3rem;      /* 48 */

  /* space (4pt) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* shape + elevation */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-full: 999px;
  --e1: 0 1px 2px rgba(31, 23, 18, .06), 0 1px 1px rgba(31, 23, 18, .04);
  --e2: 0 1px 2px rgba(31, 23, 18, .05), 0 8px 24px -12px rgba(31, 23, 18, .18);

  /* motion */
  --dur-1: 120ms; --dur-2: 220ms; --dur-3: 320ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);

  /* layers */
  --z-sticky: 20; --z-nav: 30; --z-toast: 40; --z-skip: 100;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120E0B;
    --surface: #1C1612;
    --surface-2: #261E18;
    --text: #F4EDE6;
    --text-2: #BBAA9B;
    --border: #382C23;
    --border-strong: #7A6656;
    --primary: #E0975A;
    --primary-hover: #EBA770;
    --on-primary: #1A0F08;
    --primary-soft: #3A2617;
    --success: #7BD3A0;
    --success-soft: #173326;
    --danger: #FF9B8F;
    --danger-soft: #3A1D17;
    --warning-soft: #352A17;
    --wa: #3FBF77;
    --panel: #0B0907;
    --panel-2: #1A1410;
    --focus: #8AB4FF;
    --e1: none;
    --e2: 0 0 0 1px var(--border);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, [role="button"], summary, label.choice, a { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
main:focus { outline: none; }

.icon { flex: none; display: block; }
.num { font-variant-numeric: tabular-nums; }
.ltr-inline { direction: ltr; unicode-bidi: isolate; }
.center { text-align: center; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }

.skip {
  position: fixed; inset-inline-start: var(--s3); top: var(--s3); z-index: var(--z-skip);
  transform: translateY(-200%);
  background: var(--panel); color: var(--on-panel); padding: var(--s3) var(--s4); border-radius: var(--r-md);
}
.skip:focus { transform: none; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  max-width: 560px; margin: 0 auto; padding: var(--s3) var(--s4);
  padding-top: max(var(--s3), env(safe-area-inset-top));
}
.is-admin .topbar, .is-admin .subnav { max-width: 1040px; }
main { max-width: 560px; margin: 0 auto; padding: var(--s2) var(--s4) var(--s10); }
main.wide { max-width: 1040px; }
.has-tabbar main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--text); min-height: 44px; }
.brand-name { font-weight: 700; font-size: var(--fs-md); }
.brand-mark {
  --s: 40px;
  display: grid; place-items: center; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .28);
  background: var(--panel); color: var(--display);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.logout { margin: 0; }
.btn-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background var(--dur-1), color var(--dur-1);
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* bottom navigation (≤3 items, icon + label) */
.tabbar {
  position: fixed; z-index: var(--z-nav); inset-inline: 0; bottom: 0;
  display: flex; justify-content: center; gap: var(--s1);
  padding: var(--s2) var(--s3) calc(var(--s2) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav-item {
  flex: 0 1 140px; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); text-decoration: none; font-size: var(--fs-xs); font-weight: 500;
  border-radius: var(--r-md);
}
.nav-ic { display: grid; place-items: center; width: 56px; height: 30px; border-radius: var(--r-full); transition: background var(--dur-2) var(--ease-out); }
.nav-item.on { color: var(--text); font-weight: 600; }
.nav-item.on .nav-ic { background: var(--primary-soft); color: var(--primary); }
.nav-item:hover:not(.on) { color: var(--text); }

.subnav { display: flex; gap: var(--s2); overflow-x: auto; margin: 0 auto; padding: 0 var(--s4) var(--s3); scrollbar-width: none; }
.subnav a {
  flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 0 var(--s4);
  border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
}

/* ---------- type ---------- */
.page-head { margin: var(--s2) 0 var(--s5); }
.eyebrow { color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.display { font-family: var(--font-display); font-size: var(--fs-3xl); line-height: 1.2; font-weight: 700; }
.title { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.25; font-weight: 700; margin-bottom: var(--s1); }
.lead { color: var(--text-2); font-size: var(--fs-md); }
.page-head .lead { margin-top: var(--s2); }
.section-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--s3); }
.help { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5); margin-bottom: var(--s4); box-shadow: var(--e1);
}
.card.center { margin-top: var(--s6); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: var(--s1) var(--s3); border-radius: var(--r-full);
  background: var(--primary-soft); color: var(--primary); font-size: var(--fs-sm); font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5); border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-md); line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-1), border-color var(--dur-1), transform var(--dur-1) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { min-height: 56px; font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-light { background: var(--on-panel); color: var(--panel); }
.btn-light:hover { background: #fff; }
.btn-panel { background: transparent; color: var(--on-panel); border-color: rgba(245, 238, 230, .28); }
.btn-panel:hover { background: rgba(245, 238, 230, .08); }
button.link { background: none; border: 0; padding: var(--s1) 0; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
button.link.danger { color: var(--danger); }

.btn-sep { width: 1px; height: 20px; background: currentColor; opacity: .35; }
.spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite;
}
.is-loading .spinner { display: block; }
.is-loading .btn-sep, .is-loading [data-total] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--s4); margin-top: var(--s5); }
.field { display: flex; flex-direction: column; gap: var(--s2); }
.field label, .stack > label, .grid2 label { font-weight: 600; font-size: var(--fs-sm); }
.input, .stack input, .stack select, .stack textarea, .grid2 input, .inline-form input, .inline-form select, textarea {
  width: 100%; min-height: 48px; padding: var(--s3) var(--s4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); font-size: var(--fs-md);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input:focus, .stack input:focus, .stack select:focus, textarea:focus, .inline-form input:focus, .inline-form select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);
}
.input::placeholder { color: var(--text-2); opacity: .8; }
.ltr-input, input[type="tel"] { direction: ltr; text-align: right; }
.has-error .input { border-color: var(--danger); }
.field-error { display: flex; align-items: center; gap: var(--s2); color: var(--danger); font-size: var(--fs-sm); font-weight: 500; }
.form-foot { text-align: center; margin-top: var(--s4); font-size: var(--fs-sm); }
.pin-wrap { position: relative; }
.pin { text-align: center; font-size: var(--fs-xl); letter-spacing: .5em; padding-inline: 56px; direction: ltr; font-variant-numeric: tabular-nums; }
.pin-toggle {
  position: absolute; inset-inline-end: 2px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--text-2); border-radius: var(--r-sm);
}

.alert { display: flex; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-md); margin-bottom: var(--s4); font-weight: 500; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--success-soft); color: var(--success); }
.alert.warn { background: var(--warning-soft); color: var(--text); }

/* ---------- auth: the machine panel is the form ---------- */
.auth .topbar { padding-bottom: 0; }
.auth-wrap { display: flex; flex-direction: column; gap: var(--s4); padding-top: var(--s2); }
.auth-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.auth-head .display { font-size: var(--fs-2xl); }
.auth-head .lead { margin-top: calc(var(--s1) * -1); }
/* machine reacts when the number / code is complete */
.machine.is-ready .m-steam path { animation: steam 2200ms ease-out infinite; }
.machine.is-ready .m-steam path:nth-child(2) { animation-delay: 400ms; }
.machine.is-ready .m-steam path:nth-child(3) { animation-delay: 800ms; }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-machine-wrap { margin: 22px 0 0; }
.auth-machine { position: relative; direction: ltr; }
.auth-machine .m-hopper { top: -22px; }
.a-glass { padding: 12px 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.a-top { position: relative; display: flex; justify-content: center; align-items: center; width: 100%; min-height: 20px; }
.a-label { direction: rtl; font-size: 12px; font-weight: 600; color: rgba(255,255,255,.88); letter-spacing: .02em; }
.a-screen {
  --ice: #9fdcff; --ice-glow: rgba(120,200,255,.55);
  position: relative; width: 100%; display: flex; justify-content: center;
  padding: 12px 8px; border-radius: 8px;
  background: linear-gradient(180deg, #030304, #0b0d10);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 4px 12px rgba(0,0,0,.85);
  transition: box-shadow var(--dur-2);
}
.a-screen:focus-within { box-shadow: inset 0 0 0 1px rgba(159,220,255,.55), 0 0 0 3px rgba(159,220,255,.25), inset 0 4px 12px rgba(0,0,0,.85); }
.has-error .a-screen { box-shadow: inset 0 0 0 1px rgba(255,140,120,.7), inset 0 4px 12px rgba(0,0,0,.85); }
.a-digits { display: none; align-items: center; gap: 3px; color: var(--ice); direction: ltr; }
.a-slot .seg { width: 22px; height: 38px; }
.a-screen[data-slots="4"] .a-slot .seg { width: 34px; height: 58px; }
.a-screen[data-slots="4"] .a-digits { gap: 12px; }
.a-sep { width: 8px; height: 3px; margin: 0 2px; border-radius: 2px; background: var(--ice); opacity: .55; box-shadow: 0 0 3px var(--ice-glow); }
.a-screen:focus-within .a-slot.is-cursor .seg polygon:nth-child(4) { opacity: 1; animation: blink 1s steps(2) infinite; } /* blinking underscore */
/* no-JS: the input is a normal visible field on the screen */
.a-input {
  width: 100%; min-height: 48px; border: 0; background: transparent; outline: none;
  color: var(--ice); font: 600 1.6rem/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; text-align: center; direction: ltr;
}
/* JS: digits rendered as LEDs, the real input stays on top (transparent) */
.a-screen.is-live .a-digits { display: inline-flex; }
.a-screen.is-live .a-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.01; color: transparent; caret-color: transparent;
  font-size: 16px; /* prevents iOS zoom */
}
.a-under { position: relative; width: 100%; display: flex; justify-content: center; min-height: 18px; }
.a-sub { direction: rtl; font-size: 10px; color: rgba(159,220,255,.75); }
.a-top .a-toggle { position: absolute; right: -4px; top: -6px; flex-direction: row; gap: 6px; min-height: 36px; }
.a-toggle .p-cap { width: 24px; height: 24px; }
.a-toggle[aria-pressed="true"] .p-cap { box-shadow: 0 0 0 1.5px #0a0a0a, 0 0 0 3px #9fdcff, inset 0 1px 1px rgba(255,255,255,.9); }
.a-start { border-radius: 0 0 18px 18px; }
.a-start.is-loading .spinner { display: block; }
.a-error { display: flex; align-items: center; gap: var(--s2); margin: 0; color: var(--danger); font-weight: 500; font-size: var(--fs-sm); }
.a-help { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; margin-top: calc(var(--s2) * -1); }
.link-row {
  display: flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px;
  color: var(--text); font-weight: 600; text-decoration: none;
}
.link-row:hover { color: var(--primary); }
@media (max-width: 370px) { .a-slot .seg { width: 19px; height: 33px; } }

/* ---------- balance panel (machine control panel) ---------- */
.panel {
  background: var(--panel); color: var(--on-panel);
  border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s4);
  box-shadow: var(--e2), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.panel-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.panel-label { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 600; }
.panel-meta { color: var(--on-panel-2); font-size: var(--fs-sm); }
.panel-amount {
  display: flex; align-items: flex-end; justify-content: flex-end; gap: 6px;
  margin: var(--s3) 0 var(--s1); color: var(--display); direction: ltr;
}
.panel-amount .cur { font-size: var(--fs-2xl); font-weight: 700; line-height: 1; }
.is-clear .panel-amount, .is-clear .panel-label { color: var(--display-ok); }
.panel-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }
.panel-note { display: flex; gap: var(--s2); align-items: flex-start; margin-top: var(--s4); color: var(--on-panel-2); font-size: var(--fs-sm); line-height: 1.5; }
.panel-note .icon { margin-top: 2px; }

/* =====================================================================
   The machine (home), drawn after the real one:
   steel-framed black glass panel with icy-blue readout, chrome buttons and a
   big chrome knob · polished stainless body · three-part drip tray.
   ===================================================================== */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-head.compact { margin: 0 0 var(--s3); }
.greet { font-size: var(--fs-lg); font-weight: 500; color: var(--text-2); }
.greet b { color: var(--text); font-weight: 700; }

.machine {
  --ice: #9fdcff;
  --ice-glow: rgba(120, 200, 255, .55);
  --chrome: radial-gradient(circle at 38% 30%, #ffffff 0%, #dfe3e6 35%, #9aa2a8 75%, #6d757b 100%);
  position: relative; margin: 26px 0 var(--s3); direction: ltr;
  border-radius: 14px 14px 18px 18px;
  background: linear-gradient(90deg, #6f777e, #f2f4f5 12%, #9aa2a8 30%, #e7eaec 52%, #7c848a 70%, #f5f6f7 88%, #868e94);
  box-shadow: 0 0 0 1px rgba(31,23,18,.2), 0 26px 40px -24px rgba(31,23,18,.6);
}
.machine .p-label, .machine .m-sec, .machine .m-start, .machine .m-status { direction: rtl; }

/* bean hopper peeking above the panel (left, like the real machine) */
.m-hopper {
  position: absolute; left: 6%; top: -22px; width: 30%; height: 30px; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #2a2a2e, #111113); box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.m-hopper::after { content: ""; position: absolute; inset: 6px 10px auto; height: 3px; border-radius: 2px; background: rgba(255,255,255,.12); }

/* steel bezel + black glass */
.m-panel {
  position: relative; z-index: 2; padding: 4px; border-radius: 14px;
  background: linear-gradient(180deg, #f7f8f9, #a7afb5 45%, #e9ecee 70%, #8a9298);
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.m-glass {
  position: relative; border-radius: 10px; padding: 10px 10px 0;
  background: linear-gradient(175deg, #1c1d20 0%, #08090a 45%, #030304 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 0 0 1px rgba(0,0,0,.6);
}
.m-glass::before { /* glass reflection */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, transparent 0 55%, rgba(255,255,255,.05) 55% 70%, transparent 70%);
}
.m-sections { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; min-height: 68px; }
.m-sec { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 0 6px; }
.m-sec + .m-sec { border-left: 1px solid rgba(255,255,255,.22); }
.m-sec-title { font-size: 11px; font-weight: 500; color: rgba(255,255,255,.85); line-height: 1; }
.m-sec-sub { font-size: 9px; color: rgba(159,220,255,.75); line-height: 1; }
.m-sec-logo { justify-content: center; gap: 6px; padding: 0 12px; }
.m-logo { font: 700 13px/1 Georgia, "Times New Roman", serif; letter-spacing: .12em; color: #c7ccd0; text-shadow: 0 1px 0 rgba(0,0,0,.8); direction: ltr; }
.m-status { font-size: 9px; font-weight: 600; color: rgba(159,220,255,.7); line-height: 1; }
.m-status.busy { color: var(--ice); animation: blink .6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }
.m-sum { display: inline-flex; align-items: flex-end; gap: 3px; direction: ltr; }
.m-cur { font-size: 12px; font-weight: 700; color: var(--ice); margin-bottom: 2px; text-shadow: 0 0 4px var(--ice-glow); }
.m-inds { display: inline-flex; gap: 6px; }
.m-ind { display: inline-flex; color: rgba(159,220,255,.16); transition: color var(--dur-2); }
.m-ind.on { color: var(--ice); filter: drop-shadow(0 0 2px var(--ice-glow)); }

/* seven-segment digits (icy blue, like the machine's readout) */
.m-digits { display: inline-flex; gap: 2px; direction: ltr; color: var(--ice); }
.seg { width: 14px; height: 24px; display: block; }
.seg polygon, .seg circle { fill: currentColor; opacity: .07; transition: opacity 90ms; }
.seg .on { opacity: 1; filter: drop-shadow(0 0 2px var(--ice-glow)); }
.seg-dot { width: 5px; }
.m-digits.big .seg { width: 30px; height: 50px; }
.m-digits.big .seg-dot { width: 9px; }
.m-digits.tick { animation: tick 160ms ease-out; }
@keyframes tick { 0% { opacity: .35; } 100% { opacity: 1; } }

/* controls row: small chrome buttons with labels above, big knob in the middle */
.m-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; margin-top: 8px; }
.p-group { display: flex; gap: 2px; border: 0; margin: 0; padding: 0 0 8px; min-width: 0; }
.p-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 48px; min-height: 52px; padding: 0; border: 0; background: none; color: #222; cursor: pointer;
}
.p-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.p-label { font-size: 10px; font-weight: 500; color: rgba(255,255,255,.82); white-space: nowrap; line-height: 1.1; }
.p-label .num { color: rgba(159,220,255,.85); }
.p-cap {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--chrome); color: #2a2d30;
  box-shadow: 0 0 0 1.5px #0a0a0a, 0 2px 4px rgba(0,0,0,.8), inset 0 1px 1px rgba(255,255,255,.9);
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2);
}
.p-btn:active:not(:disabled) .p-cap { transform: scale(.9); }
.p-btn:disabled { cursor: not-allowed; }
.p-btn:disabled .p-cap { opacity: .4; }
.p-kind input:checked ~ .p-cap { box-shadow: 0 0 0 1.5px #0a0a0a, 0 0 0 4px var(--ice), 0 0 12px var(--ice-glow), inset 0 1px 1px rgba(255,255,255,.9); }
.p-kind input:checked ~ .p-label { color: #fff; font-weight: 700; }
.p-kind input:focus-visible ~ .p-cap, .p-btn:focus-visible .p-cap { outline: 3px solid var(--focus); outline-offset: 5px; }
.p-btn:focus-visible { outline: none; }

.m-knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: -26px; position: relative; z-index: 3; }
.m-dial { position: relative; width: 86px; height: 86px; border-radius: 50%; cursor: grab; touch-action: none; }
.m-dial:active { cursor: grabbing; }
.m-dial:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.m-dial-ticks i { /* LED ring showing the quantity */
  position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%;
  background: rgba(159,220,255,.18); transform: rotate(var(--a)) translateY(-41px); transition: background var(--dur-2), box-shadow var(--dur-2);
}
.m-dial-ticks i.lit { background: var(--ice); box-shadow: 0 0 4px var(--ice-glow); }
.m-knob {
  position: absolute; inset: 8px; border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.12) 0 1px, rgba(0,0,0,.05) 1px 2px),
    conic-gradient(from 210deg, #f8f9fa, #9aa2a8 18%, #eef0f2 32%, #7e868c 52%, #f4f6f7 68%, #a5adb3 84%, #f8f9fa);
  box-shadow: 0 0 0 2px #0a0a0a, 0 8px 14px rgba(0,0,0,.55), inset 0 1px 2px rgba(255,255,255,.9), inset 0 -2px 4px rgba(0,0,0,.3);
  transform: rotate(var(--rot, -121.5deg));
  transition: transform 260ms cubic-bezier(.3, 1.4, .5, 1);
}
.m-dial.dragging .m-knob { transition: none; }
.m-knob-mark { position: absolute; left: 50%; top: 6px; width: 3px; height: 11px; margin-left: -1.5px; border-radius: 2px; background: #1d1f21; opacity: .75; }

/* thin chrome bar buttons under the panel (decorative) */
.m-bars { display: flex; align-items: center; gap: 6px; padding: 5px 16px 0; }
.m-bars i { width: 34px; height: 5px; border-radius: 3px; background: linear-gradient(180deg, #ffffff, #8f979d); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.m-bars span { flex: 1; }

.m-body-art { display: block; width: 100%; height: auto; margin-top: -4px; }
.m-stream { transform-box: fill-box; transform-origin: top; transform: scaleY(0); opacity: 0; }
.m-fill { transform: translateY(76px); transition: transform 300ms var(--ease-out); }
.m-cup.has-coffee .m-fill { transform: translateY(26px); }
.m-steam path { fill: none; stroke: rgba(255,255,255,.95); stroke-width: 2.5; stroke-linecap: round; opacity: 0; }
.m-froth circle { fill: rgba(255,255,255,.95); opacity: 0; }

.m-start { margin: 0; border-radius: 0 0 18px 18px; min-height: 60px; }

/* brewing sequence (JS toggles .is-brewing while the request runs) */
.machine.is-brewing .m-stream-1 { animation: pour 1100ms ease-in-out both; }
.machine.is-brewing.kind-double .m-stream-2 { animation: pour 1100ms 60ms ease-in-out both; }
.machine.is-brewing .m-fill { animation: fill 1000ms 150ms var(--ease-out) both; }
.machine.is-brewing .m-dial-ticks i.lit { animation: blink .4s steps(2) infinite; }
.machine.is-served .m-steam path { animation: steam 1600ms ease-out both; }
.machine.is-served .m-steam path:nth-child(2) { animation-delay: 150ms; }
.machine.is-served .m-steam path:nth-child(3) { animation-delay: 300ms; }
@keyframes pour { 0% { transform: scaleY(0); opacity: 1; } 20%, 80% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1) translateY(30px); opacity: 0; } }
@keyframes fill { from { transform: translateY(76px); } to { transform: translateY(26px); } }
@keyframes steam { 0% { opacity: 0; transform: translateY(4px); } 30% { opacity: .9; } 100% { opacity: 0; transform: translateY(-10px); } }
.panel.is-updated { animation: panel-flash 700ms ease-out; }
@keyframes panel-flash { 0% { box-shadow: 0 0 0 3px #9fdcff; } 100% { box-shadow: var(--e2); } }

@media (max-width: 370px) {
  .p-btn { min-width: 42px; }
  .m-dial { width: 78px; height: 78px; } .m-dial-ticks i { transform: rotate(var(--a)) translateY(-37px); }
  .seg { width: 12px; height: 21px; }
}

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; }
.h-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border); }
.h-row:first-child { border-top: 0; padding-top: 0; }
.h-ic { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); }
.is-pay .h-ic { background: var(--success-soft); color: var(--success); }
.h-text { flex: 1; display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.h-title { font-weight: 500; }
.h-when { color: var(--text-2); font-size: var(--fs-sm); }
.h-amt { font-weight: 600; direction: ltr; }
.is-pay .h-amt { color: var(--success); }
.h-undo { margin: 0; }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s6) 0; color: var(--text-2); text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: sticky; top: var(--s2); z-index: var(--z-toast);
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s4); padding-inline-start: var(--s3);
  margin-bottom: var(--s4); border-radius: var(--r-md);
  background: var(--panel); color: var(--on-panel); box-shadow: 0 12px 28px -12px rgba(0, 0, 0, .5);
  animation: toast-in var(--dur-3) var(--ease-out) both;
}
.toast-ic { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--display-ok); color: var(--panel); }
.toast-text { flex: 1; font-weight: 500; line-height: 1.4; }
.toast form { margin: 0; }
.toast-btn {
  min-height: 44px; padding: 0 var(--s4); border: 0; border-radius: var(--r-sm);
  background: rgba(245, 238, 230, .12); color: var(--display); font-weight: 700;
}
.toast-btn:hover { background: rgba(245, 238, 230, .2); }
.toast.is-leaving { animation: toast-out calc(var(--dur-3) * .65) var(--ease-in) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px); } }

/* ---------- guide ---------- */
.accordion { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s6); }
.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e1); overflow: hidden; }
.acc[open] { border-color: var(--border-strong); }
.acc-head { display: flex; align-items: center; gap: var(--s4); min-height: 80px; padding: var(--s4); list-style: none; }
.acc-head::-webkit-details-marker { display: none; }
.acc-head:focus-visible { outline-offset: -3px; border-radius: var(--r-lg); }
.acc-ic { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: var(--r-md); background: var(--panel); color: var(--display); }
.acc-text { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.acc-step { color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.acc-title { font-weight: 700; font-size: var(--fs-lg); }
.acc-sub { color: var(--text-2); font-size: var(--fs-sm); }
.acc-caret { display: grid; place-items: center; width: 32px; height: 32px; color: var(--text-2); transition: transform var(--dur-2) var(--ease-out); }
.acc[open] .acc-caret { transform: rotate(180deg); }
.acc-body { padding: 0 var(--s4) var(--s5); border-top: 1px solid var(--border); padding-top: var(--s4); animation: reveal var(--dur-2) var(--ease-out); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }

.steps { list-style: none; margin: 0 0 var(--s4); padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: var(--s3); }
.steps li { counter-increment: step; position: relative; padding-inline-start: 40px; line-height: 1.6; }
.steps li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: var(--fs-sm);
}
.note { display: flex; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); line-height: 1.55; }
.note .icon { color: var(--primary); margin-top: 1px; }
.wait {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s3);
  margin-top: var(--s3); padding: var(--s4); border-radius: var(--r-md);
  background: var(--primary-soft);
}
.wait-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--primary); }
.wait-text { font-size: var(--fs-sm); line-height: 1.55; }
.wait-title { font-weight: 700; font-size: var(--fs-md); margin-bottom: 2px; }
.wait-cta { grid-column: 2; justify-self: start; }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--e1); }
.stat-v { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-l { color: var(--text-2); font-size: var(--fs-sm); }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.card h1 { font-family: var(--font-display); font-size: var(--fs-2xl); }
.card h2 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--s3); }
.card > p { margin-bottom: var(--s3); }
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: start; color: var(--text-2); font-weight: 600; padding: var(--s2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--s3) var(--s2); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.hot td { background: var(--danger-soft); }
.table tr.inactive td { opacity: .55; }
.num, td.num { font-variant-numeric: tabular-nums; }
td.num { font-weight: 700; direction: ltr; text-align: right; }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.badge { display: inline-block; padding: 0 var(--s2); border-radius: var(--r-full); background: var(--primary-soft); color: var(--primary); font-size: var(--fs-xs); font-weight: 600; }
.badge.warn { background: var(--warning-soft); color: var(--text); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack > label, .grid2 label { display: flex; flex-direction: column; gap: var(--s2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.inline { display: inline; margin: 0 var(--s1); }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s2); }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.inline-form.compact { flex-wrap: nowrap; margin: 0 0 var(--s1); }
.inline-form.compact select { min-height: 36px; padding: var(--s1) var(--s2); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.actions form { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0 0 var(--s2); }
.plain li { padding: var(--s1) 0; }
ol.steps.small, .card ol { color: var(--text-2); }
.warn-text { color: var(--danger); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

/* reminder list */
.remind { list-style: none; margin: 0; padding: 0; }
.remind-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border); }
.remind-row:first-child { border-top: 0; }
.remind-who { flex: 1; display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.remind-who a { font-weight: 600; color: var(--text); }
.remind-amt { font-weight: 700; }
.remind-row .btn-wa { min-width: 112px; }
.remind-row.is-sent .btn-wa { background: var(--surface); color: var(--wa); border-color: var(--wa); }
.remind-row.is-sent .remind-who a::after { content: " ✓"; color: var(--success); }

/* ---------- printable QR sign ---------- */
body.print { background: #fff; color: #1F1712; }
.sign { max-width: 560px; margin: var(--s8) auto; padding: var(--s6) var(--s4); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.sign .brand-mark { color: #F3A64A; background: #17120F; }
.sign h1 { font-family: var(--font-display); font-size: 2.75rem; line-height: 1.15; }
.sign-floor { font-size: var(--fs-xl); font-weight: 700; color: #92400E; }
.sign-sub { font-size: var(--fs-xl); }
.qr { padding: var(--s4); border: 2px solid #1F1712; border-radius: var(--r-lg); margin: var(--s2) 0; }
.qr svg { display: block; width: min(70vw, 300px); height: auto; }
.sign-prices { font-size: var(--fs-xl); font-weight: 700; }
.sign-url { color: #5C4A3D; }
@media print { .no-print { display: none; } .sign { margin: 0 auto; } }

/* ---------- responsive ---------- */
@media (max-width: 360px) {
  .display { font-size: var(--fs-2xl); }
  .panel-amount { font-size: 2.5rem; }
  .choice-title { font-size: var(--fs-md); }
}
@media (min-width: 768px) {
  main { padding-top: var(--s4); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .spinner { animation: none; border-inline-end-color: currentColor; opacity: .6; }
}
