:root {
  --blue: #0000FF;
  --blue-d: #0000b8;
  --blue-l: #e8e8ff;
  --yellow: #FFF200;
  --ink: #12122a;
  --muted: #6b6b80;
  --line: #e3e3ec;
  --bg: #f4f4f8;
  --card: #fff;
  --ok: #0a8a4a;
  --ok-l: #e3f6ec;
  --warn: #b26a00;
  --warn-l: #fff4dc;
  --bad: #c62828;
  --bad-l: #fdeaea;
  --wa: #1fa855;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
body.role-owner, body.role-cashier { padding-bottom: 76px; }
a { color: var(--blue); }
h1 { font-size: 1.35rem; margin: 4px 0 14px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 16px 24px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; background: var(--blue); color: #fff; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.logo { background: var(--yellow); color: var(--blue); font-weight: 900; padding: 3px 7px; border-radius: 6px; letter-spacing: .02em; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; opacity: .9; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.18); opacity: 1; }
.usermenu { margin-left: auto; position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.15); font-size: .9rem; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: 40px; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); min-width: 200px; padding: 6px; }
.usermenu .menu a { display: block; padding: 10px 12px; color: var(--ink); text-decoration: none; border-radius: 6px; }
.usermenu .menu a:hover { background: var(--bg); }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 7px 0 8px; font-size: .72rem; color: var(--muted); text-decoration: none; }
.bottomnav a span { font-size: 1.25rem; line-height: 1.3; }
.bottomnav a.big span { background: var(--blue); color: var(--yellow); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; font-weight: 900; box-shadow: 0 4px 12px rgba(0,0,255,.35); }
@media (min-width: 900px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body.role-owner, body.role-cashier { padding-bottom: 0; }
}

/* cards & layout */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line); }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.between { justify-content: space-between; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.4rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.hl { background: var(--blue); color: #fff; border-color: var(--blue); }
.stat.hl .k { color: rgba(255,255,255,.8); }
.stat .v.neg { color: var(--bad); }

/* forms */
label { display: block; font-size: .85rem; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=month], select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #cfcfdc; border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
textarea { min-height: 70px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--blue); background: var(--blue); color: #fff; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { background: var(--blue-d); }
.btn.secondary { background: #fff; color: var(--blue); }
.btn.yellow { background: var(--yellow); border-color: #e0d400; color: var(--ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger { background: #fff; color: var(--bad); border-color: #e9b4b4; }
.btn.wa { background: var(--wa); border-color: var(--wa); }
.btn.block { width: 100%; }
.btn.lg { font-size: 1.1rem; padding: 14px 18px; min-height: 54px; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

/* chips / toggles */
.chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .chips { grid-template-columns: repeat(4, 1fr); } }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: block; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; min-height: 56px; }
.chip span small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.chip input:checked + span { border-color: var(--blue); background: var(--blue-l); }
.chip input:focus-visible + span { outline: 2px solid var(--blue); }
.svc-list .chip span { display: flex; justify-content: space-between; align-items: center; min-height: 50px; }
.svc-list { grid-template-columns: 1fr; }
@media (min-width: 600px) { .svc-list { grid-template-columns: 1fr 1fr; } }

/* plate */
.plate-input { font-size: 1.8rem !important; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; text-align: center; background: #111 !important; color: #fff !important; border: 3px solid #111 !important; border-radius: 8px !important; font-family: "Arial Narrow", Arial, sans-serif; }
.plate { display: inline-block; background: #111; color: #fff; font-weight: 800; letter-spacing: .06em; padding: 2px 8px; border-radius: 4px; font-family: "Arial Narrow", Arial, sans-serif; white-space: nowrap; }
.camera-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 18px; border: 2px dashed var(--blue); border-radius: var(--r); background: var(--blue-l); color: var(--blue); font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.camera-btn input { display: none; }
.preview { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 10px; display: none; }
.ocr-status { margin-top: 8px; font-size: .9rem; min-height: 1.4em; }
.found { background: var(--ok-l); border: 1px solid #bfe6cf; padding: 10px 12px; border-radius: 10px; margin-top: 10px; }

/* queue board */
.board { display: grid; gap: 14px; }
@media (min-width: 900px) { .board { grid-template-columns: repeat(3, 1fr); } }
.col h2 { display: flex; justify-content: space-between; align-items: center; }
.count { background: var(--blue); color: #fff; border-radius: 99px; padding: 1px 9px; font-size: .8rem; }
.jobcard { display: block; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; color: var(--ink); text-decoration: none; }
.jobcard:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.jobcard.done { border-left-color: var(--yellow); }
.jobcard.paid { border-left-color: var(--ok); opacity: .85; }
.jobcard .meta { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); font-size: .9rem; padding: 12px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; }
.b-queue { background: var(--blue-l); color: var(--blue); }
.b-done { background: var(--yellow); color: var(--ink); }
.b-paid { background: var(--ok-l); color: var(--ok); }
.b-unpaid { background: var(--warn-l); color: var(--warn); }
.b-cancelled { background: var(--bad-l); color: var(--bad); }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.sub td { color: var(--muted); }

/* WhatsApp step box */
.wa-box { background: #eafaf0; border: 1px solid #bde8cd; border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.wa-box .msg { white-space: pre-wrap; background: #fff; border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 8px 0 12px; border: 1px solid #d6efe0; max-height: 200px; overflow: auto; }
.wa-sent { font-size: .82rem; color: var(--ok); }

/* attendance */
.att { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.att:last-child { border-bottom: 0; }
.att .name { flex: 1; font-weight: 600; }
.switch { position: relative; width: 54px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #ccc; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch .sl:before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .sl { background: var(--ok); }
.switch input:checked + .sl:before { transform: translateX(22px); }

/* bars (reports) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover { background: var(--blue-d); }
.bars .bar.zero { background: var(--line); }
.bar-labels { display: flex; gap: 3px; font-size: .68rem; color: var(--muted); }
.bar-labels span { flex: 1; text-align: center; overflow: hidden; }
.hbar { height: 8px; background: var(--blue-l); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.hbar i { display: block; height: 100%; background: var(--blue); }

.tabs { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); padding: 4px; border-radius: 10px; margin-bottom: 12px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs a { padding: 7px 14px; border-radius: 7px; text-decoration: none; color: var(--ink); font-weight: 600; white-space: nowrap; }
.tabs a.on { background: var(--blue); color: #fff; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash-ok { background: var(--ok-l); color: var(--ok); }
.flash-err { background: var(--bad-l); color: var(--bad); }

/* login */
body.guest { background: var(--blue); min-height: 100vh; }
.login { max-width: 380px; margin: 10vh auto 0; }
.login .logo-big { text-align: center; margin-bottom: 18px; }
.login .logo-big span { display: inline-block; background: var(--yellow); color: var(--blue); font-weight: 900; font-size: 2rem; padding: 6px 16px; border-radius: 10px; }
.login .logo-big div { color: #fff; margin-top: 8px; font-weight: 600; }

/* invoice / receipt (public) */
.receipt { max-width: 420px; margin: 0 auto; background: #fff; padding: 20px; border-radius: var(--r); }
.receipt .head { text-align: center; border-bottom: 2px dashed var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.receipt table td { border: 0; padding: 4px 0; }
.status-pill { display: inline-block; padding: 6px 14px; border-radius: 99px; font-weight: 700; margin: 8px 0; }

@media print {
  .topbar, .bottomnav, .noprint, .flash { display: none !important; }
  body { background: #fff; padding: 0 !important; }
  .wrap { padding: 0; }
  .card { border: 0; box-shadow: none; }
  .receipt { max-width: 72mm; padding: 0; font-size: 12px; }
}
.bars .bar { border-radius: 4px 4px 0 0; }
.bars .bar[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .75rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 5; pointer-events: none; }
.bars .bar:first-child[data-tip]:hover::after { left: 0; transform: none; }
.bars .bar:last-child[data-tip]:hover::after { left: auto; right: 0; transform: none; }
@media (max-width: 699px) { .job-actions { order: -1; } }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid a { display: block; text-decoration: none; color: var(--muted); font-size: .78rem; }
.photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 4px; background: var(--line); }

/* fast check-in */
.size-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.size-row .chip span { min-height: 0; padding: 10px 4px; text-align: center; font-size: .88rem; }
.checkin-fast .svc-list .chip span { min-height: 46px; padding: 8px 12px; }
.sticky-submit { position: sticky; bottom: 70px; z-index: 15; padding: 8px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (min-width: 900px) { .sticky-submit { bottom: 0; } }
.sticky-submit .btn { box-shadow: 0 6px 18px rgba(0,0,255,.3); }

.wa-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.wa-mode .chip span { min-height: 0; padding: 9px 8px; text-align: center; font-size: .85rem; }
