:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f172a;
  --accent: #2563eb;
  --work: #16a34a;
  --work-soft: #dcfce7;
  --work-ink: #14532d;
  --break: #d97706;
  --break-soft: #fef3c7;
  --break-ink: #78350f;
  --stop: #dc2626;
  --stop-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --ink: #e5e7eb; --muted: #94a3b8; --line: #1f2937;
    --brand: #020617; --work-soft: #052e16; --work-ink: #bbf7d0; --break-soft: #3b2604; --break-ink: #fde68a;
    --stop-soft: #3f0d0d; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 13px; opacity: .7; }
.icon-btn { background: rgba(255,255,255,.1); border: 0; color: #fff; border-radius: 10px; min-width: 44px; height: 44px; padding: 0 12px; font-size: 15px; }
.sync { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.12); white-space: nowrap; }
.sync.offline { background: #b45309; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(150px + var(--safe-bottom)); }

/* Status card */
.status { border-radius: var(--radius); padding: 18px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.status.working { background: var(--work-soft); border-color: transparent; color: var(--work-ink); }
.status.on-break { background: var(--break-soft); border-color: transparent; color: var(--break-ink); }
.status .label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; opacity: .8; }
.status .what { font-size: 24px; font-weight: 750; margin: 2px 0 6px; overflow-wrap: anywhere; }
.status .clock { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.status .since { font-size: 14px; opacity: .8; }

h2.section { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 10px; }

/* Customer buttons */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cust {
  min-height: 72px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); padding: 12px; text-align: left; font-weight: 650; font-size: 17px; position: relative;
  display: flex; flex-direction: column; justify-content: center; gap: 4px; overflow-wrap: anywhere;
}
.cust small { font-weight: 500; font-size: 13px; color: var(--muted); }
.cust.active { border-color: var(--work); background: var(--work-soft); color: var(--work-ink); }
.cust.active small { color: inherit; }
.cust.active::after { content: "● Running"; position: absolute; top: 8px; right: 10px; font-size: 11px; font-weight: 700; color: var(--work); }
.cust:active { transform: scale(.98); }

/* Bottom action bar */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-bottom)); display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.actions .inner { max-width: 720px; margin: 0 auto; width: 100%; display: contents; }
.big { min-height: 56px; border: 0; border-radius: var(--radius); font-weight: 750; font-size: 17px; }
.big.break { background: var(--break); color: #fff; }
.big.stop { background: var(--stop); color: #fff; }
.big:disabled { opacity: .35; }

/* Today list */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.rows .row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.rows .row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .num { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); }
.empty { padding: 18px; color: var(--muted); text-align: center; }

/* Forms */
.form { display: grid; gap: 14px; }
label.f { display: grid; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.in {
  width: 100%; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: var(--surface); font-size: 17px; color: var(--ink);
}
.in:focus { outline: none; border-color: var(--accent); }
.btn { min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px; font-weight: 650; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--stop); border-color: var(--stop-soft); background: var(--stop-soft); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 20px 24px; }
.login .box { width: 100%; max-width: 380px; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login p.lead { color: var(--muted); margin: 0 0 22px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 6px 0 14px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { min-height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 24px; font-weight: 650; box-shadow: var(--shadow); }
.keypad button.muted { font-size: 15px; color: var(--muted); }
.err { color: var(--stop); font-weight: 600; min-height: 22px; text-align: center; }
.brandline { margin-top: 26px; text-align: center; font-size: 12px; color: var(--muted); }

/* Toast + modal */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 50;
  background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600;
}
.modal-bg { position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; max-height: 92vh; overflow: auto;
  padding: 18px 16px calc(18px + var(--safe-bottom));
}
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h3 { margin: 0 0 14px; font-size: 20px; }
.menu-item { width: 100%; text-align: left; padding: 14px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 17px; }
.menu-item:last-child { border-bottom: 0; }

/* Manager */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: calc(64px + var(--safe-top)); z-index: 8; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: var(--surface-2); padding: 9px 14px; border-radius: 999px; font-weight: 650; white-space: nowrap; color: var(--muted); }
.tabs button.on { background: var(--ink); color: var(--surface); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.work { background: var(--work-soft); color: var(--work-ink); }
.pill.break { background: var(--break-soft); color: var(--break-ink); }
.pill.warn { background: var(--stop-soft); color: var(--stop); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar > * { flex: 1 1 140px; }
.list-click { cursor: pointer; }
.list-click:active { background: var(--surface-2); }
.bar { height: 6px; border-radius: 3px; background: var(--accent); opacity: .7; margin-top: 6px; }
.note { font-size: 13px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }
.banner .grow { flex: 1; font-size: 14px; }
.resume-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(120, 53, 15, .2); display: grid; gap: 10px; }
.big.resume { background: var(--work); color: #fff; width: 100%; }
.warn-banner { background: var(--stop-soft); border-color: transparent; color: var(--stop); }
.warn-banner b { color: inherit; }
.row.over { background: var(--stop-soft); }
