/* Tillmoor shared styles */
:root {
  --ink: #10202B;
  --ink-2: #3A4A55;
  --muted: #5A6870;
  --ground: #F5F6F2;
  --panel: #FFFFFF;
  --line: #E2E5DD;
  --line-2: #C9CFC4;
  --accent: #1F6F5C;
  --accent-dark: #164F42;
  --accent-soft: #E6EEE9;
  --amber: #F2B33D;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 16px;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; touch-action: manipulation; user-select: none;
}
button:hover, .btn:hover { border-color: var(--ink-2); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(16,32,43,.06); border-color: transparent; }
.btn-lg { min-height: 60px; font-size: 18px; border-radius: 14px; }

label { font-size: 14px; font-weight: 600; display: block; margin-bottom: 6px; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: inherit; text-decoration: none; }
.brand svg { flex: none; }

/* Auth pages */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; }
.auth-card h1 { font-size: 26px; margin: 18px 0 6px; }
.auth-card p.sub { color: var(--ink-2); margin: 0 0 22px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(16,32,43,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 20px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; padding: 24px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.modal.wide { max-width: 760px; }
.modal h2 { font-size: 22px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

/* Toast */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.bad { background: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #F0F2EC; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); }
.pill.warn { background: #FFF4DB; color: #7A4B00; }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.off { background: #ECEDEA; color: var(--muted); }

/* ================= TILL ================= */
.till { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--ink); color: #fff; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.topbar button:hover { border-color: #fff; }
.status { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; color: #C3CCD2; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: #5DBB63; }
.status.offline .dot { background: var(--amber); }
.status.failed .dot { background: #FF6B5E; }

.till-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }
.catalogue { display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 12px; }
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; flex: none; }
.chip { flex: none; min-height: 40px; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding-bottom: 12px; }
.tile { flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left; min-height: 96px; padding: 12px; border-radius: 14px; border-left-width: 6px; font-weight: 600; }
.tile .price { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tile .stock { font-size: 12px; font-weight: 500; color: var(--muted); }
.tile .stock.low { color: #7A4B00; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.basket { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.basket-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.basket-head h2 { font-size: 18px; }
.lines { flex: 1; overflow-y: auto; padding: 4px 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.line .name { font-weight: 600; }
.line .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.line .ctrl { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.line .ctrl button { min-height: 40px; min-width: 44px; padding: 6px 10px; }
.line .ctrl .qty { min-width: 32px; text-align: center; font-weight: 700; }
.line .disc { font-size: 13px; color: var(--accent-dark); }
.totals { padding: 12px 16px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.totals .deal { color: var(--ok, #127a3a); }
.line .deal-tag { grid-column: 1 / -1; margin: 0; color: var(--ok, #127a3a); }
.totals .grand { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 6px; }
.basket-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 0 16px 10px; }
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }

/* PIN pad */
.lockscreen { position: fixed; inset: 0; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.pinbox { width: 100%; max-width: 340px; text-align: center; }
.pinbox h1 { font-size: 22px; margin: 16px 0 4px; }
.pinbox .shopname { color: #C3CCD2; margin-bottom: 18px; }
.pindots { display: flex; justify-content: center; gap: 14px; height: 24px; margin: 18px 0 8px; }
.pindots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #C3CCD2; }
.pindots span.on { background: var(--amber); border-color: var(--amber); }
.pinpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.pinpad button { min-height: 72px; font-size: 26px; background: #1C3140; color: #fff; border-color: #2C3D49; border-radius: 16px; }
.pinpad button:hover { border-color: #C3CCD2; }
.pinpad .ok { background: var(--accent); border-color: var(--accent); font-size: 18px; }
.lockscreen .error { color: #FFB4AA; }

/* Keypad in cash modal */
.cash-due { font-size: 15px; color: var(--ink-2); }
.cash-due strong { font-size: 30px; color: var(--ink); display: block; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 14px 0; }
.change { background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; padding: 14px; font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; }
.change.short { background: var(--danger-soft); color: var(--danger); }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button, .menu-list a { justify-content: flex-start; width: 100%; }

@media (max-width: 860px) {
  .till-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .basket { border-left: 0; border-top: 1px solid var(--line); max-height: 55vh; }
}

/* ================= BACK OFFICE ================= */
.bo-head { background: var(--ink); color: #fff; }
.bo-head .in { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bo-head .spacer { flex: 1; }
.bo-head a.btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.tabs { background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs .in { max-width: 1200px; margin: 0 auto; padding: 0 12px; display: flex; gap: 4px; overflow-x: auto; }
.tabs button { border: 0; border-radius: 0; border-bottom: 3px solid transparent; background: none; padding: 14px 14px; min-height: 52px; color: var(--ink-2); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.bo-main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 64px; }
.bo-main h2 { font-size: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card .k { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.bars .bar { flex: 1 0 14px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-variant-numeric: tabular-nums; }
.kv .tot { font-weight: 800; border-top: 1px solid var(--line); padding-top: 6px; }

/* Help button */
.help-details { background: #F3F5F6; border: 1px solid #DCE2E6; border-radius: 8px; padding: 10px 12px;
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; margin: 0; max-height: 180px; overflow: auto; }
.bo-head button.help-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }

/* Section tabs inside a page (Stock tools) */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid #DCE2E6; padding-bottom: 8px; }
.subtabs button { min-height: 38px; background: transparent; border-color: transparent; }
.subtabs button.on { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-soft); font-weight: 600; }

/* Printer settings */
.pr-opt { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 8px 0; cursor: pointer; }
.pr-opt input { width: auto; min-height: 0; margin-top: 4px; }

.card-state { font-size: 20px; font-weight: 700; padding: 14px; border-radius: 10px; background: var(--bg-2, #f3f4f6); text-align: center; margin: 8px 0; }
.card-state.ok { background: #e7f6ec; color: #127a3a; }
.card-state.bad { background: #fdecec; color: #b42318; }
