/* Unicode Management System - styles */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --border: #d4dce3;
  --text: #0b1520;   /* near-black: crisp on white */
  --text-2: #2b3946;
  --muted: #55626f;  /* secondary text still clearly readable (about 6:1 on white) */
  --brand: #19e6e6;
  --primary: #00848a;
  --primary-hover: #006d72;
  --primary-ink: #ffffff;
  --primary-soft: #dcf6f6;
  --accent: #19e6e6;
  --accent-soft: #dcf6f6;
  --danger: #c2352f;
  --danger-soft: #fbe9e8;
  --warn: #9a6400;
  --warn-soft: #fff3d9;
  --ok: #1d7f45;
  --ok-soft: #e3f3ea;
  --info: #1f5fa8;
  --info-soft: #e5eef9;
  --chart: #00939a;
  --grid: #e7ebef;
  --side: #000000;
  --side-text: #c9d3d6;
  --side-active: #0c2526;
  --shadow: 0 1px 2px rgba(16, 32, 44, .06), 0 6px 18px rgba(16, 32, 44, .06);
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07090b; --surface: #111518; --surface-2: #161b1f; --surface-3: #1d2428; --border: #283136;
    --text: #e8eef0; --text-2: #b8c4c8; --muted: #84939a;
    --primary: #19e6e6; --primary-hover: #63f0f0; --primary-ink: #001a1b; --primary-soft: #0a2a2b;
    --accent: #19e6e6; --accent-soft: #0a2a2b;
    --danger: #f06a63; --danger-soft: #3d1a19; --warn: #e8b04a; --warn-soft: #3a2c10;
    --ok: #45c47e; --ok-soft: #133524; --info: #6aa7ef; --info-soft: #15263b;
    --chart: #19d3d6; --grid: #222b30; --side: #000000; --side-text: #b8c4c8; --side-active: #0c2526;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07090b; --surface: #111518; --surface-2: #161b1f; --surface-3: #1d2428; --border: #283136;
  --text: #e8eef0; --text-2: #b8c4c8; --muted: #84939a;
  --primary: #19e6e6; --primary-hover: #63f0f0; --primary-ink: #001a1b; --primary-soft: #0a2a2b;
  --accent: #19e6e6; --accent-soft: #0a2a2b;
  --danger: #f06a63; --danger-soft: #3d1a19; --warn: #e8b04a; --warn-soft: #3a2c10;
  --ok: #45c47e; --ok-soft: #133524; --info: #6aa7ef; --info-soft: #15263b;
  --chart: #19d3d6; --grid: #222b30; --side: #000000; --side-text: #b8c4c8; --side-active: #0c2526;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); text-rendering: optimizeLegibility; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
a { color: var(--primary); }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }
.ic { flex: none; vertical-align: middle; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
a.btn { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: 52px; font-size: 17px; padding: 0 20px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-height: 36px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 12px 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field small { font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; font: inherit; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: var(--primary-ink); font-weight: 600; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 18px 18px 14px; display: flex; gap: 10px; align-items: center; }
.logo { width: 40px; height: 38px; flex: none; display: block; }
.brand b { display: block; color: #19e6e6; font-size: 15px; line-height: 1.1; font-weight: 800; letter-spacing: .02em; }
.brand span { display: block; font-size: 9.5px; color: #fff; letter-spacing: .2em; text-transform: uppercase; }
.brand-full { background: #000; border-radius: 12px; padding: 6px; text-align: center; margin-bottom: 18px; overflow: hidden; }
.brand-full img { width: 100%; max-width: 460px; height: auto; display: block; margin: 0 auto; }
/* Start-up splash (index.html): the animated logo, then a fade to the sign-in screen. */
.splash { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: pointer; transition: opacity .6s ease; }
.splash.out { opacity: 0; pointer-events: none; }
.splash img { width: 92vmin; max-width: 680px; height: auto; -webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 95%, transparent); mask-image: linear-gradient(to right, transparent, #000 7%, #000 95%, transparent); }
/* Sign-in logo: one soft sweep of light when the screen opens. */
.brand-full { position: relative; }
.brand-full::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 45%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .16) 50%, transparent); transform: translateX(-120%); animation: brand-shine 1.6s ease-in-out .4s 1 both; pointer-events: none; }
@keyframes brand-shine { to { transform: translateX(260%); } }
.brand-full .logo { width: 64px; height: 54px; margin: 0 auto 6px; }
.brand-full b { display: block; color: #19e6e6; font-size: 22px; font-weight: 800; letter-spacing: .03em; line-height: 1.05; }
.brand-full span { display: block; color: #fff; font-size: 11px; letter-spacing: .35em; margin-top: 6px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.side-foot .who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand, #19e6e6); color: #001a1b; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex: none; }
.side-foot .who b { color: #fff; display: block; font-size: 13px; }
.side-foot .icon-btn { color: var(--side-text); margin-left: auto; }
.side-foot .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.net { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #19e6e6; flex: none; }
.net.off .dot { background: #f0be2e; }
.main { overflow-y: auto; min-width: 0; }
.page { padding: 22px 26px 40px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .spacer { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Cards, tables, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); grid-gap: 14px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.stat .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); border-bottom: 0; }
td input, td select { min-height: 30px; padding: 4px 6px; }
td input[type="number"] { width: 86px; text-align: right; }
table.compact th { white-space: normal; font-size: 11px; vertical-align: bottom; }
table.compact th, table.compact td { padding: 8px 6px; }
table.compact td input[type="number"] { width: 64px; }
table.compact td:first-child { min-width: 120px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; grid-gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--info-soft); color: var(--text); border: 1px solid transparent; font-size: 13px; }
.notice.warn { background: var(--warn-soft); }
.notice.danger { background: var(--danger-soft); }
.notice.ic-row { display: flex; gap: 10px; align-items: flex-start; }
.notice.ic-row > .ic { flex: none; margin-top: 1px; }
.nowrap { white-space: nowrap; }

/* ---------- POS ---------- */
.page-pos { max-width: none; padding: 0; height: 100vh; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100vh; }
.pos-left { display: flex; flex-direction: column; min-height: 0; padding: 16px 18px 0; }
.pos-top { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.pos-search { position: relative; flex: 1; }
.pos-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pos-search input { padding-left: 38px; min-height: 46px; font-size: 15px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; font-weight: 550; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.pgrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-gap: 10px; align-content: start; padding-bottom: 18px; }
.tile { position: relative; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 10px; cursor: pointer; font: inherit; color: var(--text); min-height: 104px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); overflow: hidden; }
.tile::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--c, var(--primary)); }
.tile:hover { border-color: var(--primary); }
.tile:active { transform: scale(.98); }
.tile .nm { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.tile .pr { margin-top: auto; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.tile .st { font-size: 11.5px; color: var(--muted); }
.tile.out { opacity: .55; }
.tile .tx { position: absolute; top: 10px; right: 10px; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.pos-cart { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.cart-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.cart-cust { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px dashed var(--border); border-radius: 8px; cursor: pointer; background: transparent; font: inherit; color: var(--text); text-align: left; }
.cart-cust:hover { border-color: var(--primary); }
.cart-cust b { display: block; font-size: 13.5px; }
.cart-cust small { display: block; }
.cart-items { flex: 1; overflow-y: auto; }
.cline { display: grid; grid-template-columns: 1fr auto; grid-gap: 2px 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.cline:hover { background: var(--surface-2); }
.cline .nm { font-weight: 600; }
.cline .meta { font-size: 12.5px; color: var(--muted); }
.cline .amt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; justify-self: end; }
.qty button { width: 30px; height: 28px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 16px; color: var(--text); }
.qty button:hover { background: var(--surface-3); }
.qty span { min-width: 34px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.cart-totals { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.cart-totals .row { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.cart-totals .row.total { font-size: 22px; font-weight: 750; padding-top: 6px; letter-spacing: -.3px; }
.cart-actions { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 6px; padding: 10px 16px 0; }
.cart-actions .btn { padding: 0 6px; font-size: 12.5px; }
.cart-pay { padding: 10px 16px 16px; }
.pay-due { text-align: center; padding: 8px 0 14px; }
.pay-due .big { font-size: 36px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 8px; margin-bottom: 12px; }
.pay-methods button { padding: 12px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; font-weight: 600; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pay-methods button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.pay-methods button:disabled { opacity: .4; cursor: not-allowed; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 6px; margin: 10px 0; }
.pay-input { display: flex; gap: 8px; }
.pay-input input { font-size: 20px; font-weight: 700; text-align: right; min-height: 48px; }
.pay-list { margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; }
.pay-list .list-row { padding: 8px 12px; }
.change-big { font-size: 46px; font-weight: 800; text-align: center; color: var(--primary); letter-spacing: -1px; font-variant-numeric: tabular-nums; }

/* ---------- PIN pad ---------- */
.pin-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.pin-card { width: 100%; max-width: 400px; padding: 28px; }
.pin-brand { text-align: center; margin-bottom: 16px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 16px 0 18px; height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dots i.on { background: var(--primary); border-color: var(--primary); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 10px; }
.pinpad button { height: 58px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 22px; font-weight: 600; color: var(--text); cursor: pointer; }
.pinpad button:hover { background: var(--surface-3); }
.pinpad button.fn { font-size: 14px; color: var(--muted); }
.pin-err { color: var(--danger); text-align: center; min-height: 20px; font-size: 13px; margin-top: 10px; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- Modal, toast, tooltip ---------- */
.modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(8, 14, 20, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); border: 1px solid var(--border); }
.modal.md { max-width: 640px; } .modal.lg { max-width: 900px; } .modal.xl { max-width: 1200px; }
.modal-head { display: flex; align-items: center; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 550; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; max-width: 90vw; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--primary); color: var(--primary-ink); }
.toast.out { opacity: 0; transform: translateY(8px); }
#tip { position: fixed; pointer-events: none; z-index: 90; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 6px; font-size: 12.5px; white-space: pre; display: none; box-shadow: var(--shadow); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--chart); transition: opacity .1s; }
.chart g.b:hover .bar { opacity: .75; }
.chart .hit { fill: transparent; cursor: default; }

.cart-order { display: flex; align-items: center; gap: 8px; width: calc(100% - 32px); margin: 10px 16px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-align: left; }
.cart-order:hover { border-color: var(--primary); }

/* ---------- Kitchen display ---------- */
.kds-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-size: 15px; }
.kds-bar .btn { margin-left: auto; }
.kds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-gap: 12px; align-items: start; }
.kds-card { background: var(--surface); border: 1px solid var(--border); border-top: 6px solid var(--ok); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.kds-card.slow { border-top-color: var(--warn); }
.kds-card.late { border-top-color: var(--danger); background: var(--danger-soft); }
.kds-head { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.kds-head b { font-size: 22px; }
.kds-head span:nth-child(2) { flex: 1; font-weight: 600; min-width: 0; }
.kds-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.kds-card.late .kds-time { color: var(--danger); }
.kds-st { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kds-card ul { list-style: none; margin: 0; padding: 0; font-size: 17px; }
.kds-card li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.kds-card li:last-child { border-bottom: 0; }
.kds-card li em { display: block; font-style: normal; color: var(--warn); font-weight: 600; font-size: 14px; }
.kds-card .btn { min-height: 46px; font-size: 16px; }

/* ---------- Misc ---------- */
.clock-big { font-size: 40px; font-weight: 750; text-align: center; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.denoms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 8px 16px; }
.denoms .d { display: grid; grid-template-columns: 70px 1fr 100px; align-items: center; grid-gap: 8px; }
.denoms .d span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.split { display: flex; justify-content: space-between; gap: 10px; }
.payslip-preview { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--surface-2); }

#print-area { display: none; }

@media (max-width: 1100px) {
  .grid-main, .grid-3 { grid-template-columns: 1fr; }
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .side { flex-direction: row; align-items: center; overflow-x: auto; }
  .brand span, .side-foot .who div, .net span { display: none; }
  .nav { display: flex; padding: 6px; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; white-space: nowrap; }
  .side-foot { border: 0; padding: 6px 10px; }
  .net { display: none; }
  .main { overflow: visible; }
  .page { padding: 16px 16px 32px; }
  .page-pos { height: auto; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .pgrid { max-height: 55vh; }
  .pos-cart { border-left: 0; border-top: 1px solid var(--border); }
  .grid-2, .form-grid, .form-grid.three, .denoms { grid-template-columns: 1fr; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
}
#print-area { color: #000; font-family: Arial, Helvetica, sans-serif; }
#print-area.receipt { width: 72mm; font: 12px/1.35 "Courier New", monospace; }
#print-area .r-center { text-align: center; }
#print-area .r-row { display: flex; justify-content: space-between; gap: 6px; }
#print-area .r-row span { white-space: pre-wrap; }
#print-area .r-hr { border-top: 1px dashed #000; margin: 6px 0; }
#print-area .r-big { font-size: 15px; font-weight: bold; }
#print-area.doc { font-size: 12px; }
#print-area.doc h1 { font-size: 18px; } #print-area.doc h2 { font-size: 14px; margin: 12px 0 6px; }
#print-area.doc table { width: 100%; border-collapse: collapse; margin: 6px 0; }
#print-area.doc th, #print-area.doc td { border: 1px solid #999; padding: 4px 6px; font-size: 11px; position: static; background: none; color: #000; text-transform: none; letter-spacing: 0; }
#print-area.doc th { background: #eee; }
#print-area .pslip { page-break-after: always; padding: 4px; }
#print-area .pslip:last-child { page-break-after: auto; }
#print-area .doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 8px; }
#print-area .two { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 12px; }
#print-area .netpay { border: 2px solid #000; padding: 8px; font-size: 15px; font-weight: bold; display: flex; justify-content: space-between; margin-top: 8px; }

/* ---------- Older Android WebView (e.g. Android 7.1 terminals) ---------- */
/* No flexbox gap (Chrome < 84): js/polyfills.js adds .no-flexgap and margins stand in for it. */
.no-flexgap .btn > * + *, .no-flexgap .badge > * + *, .no-flexgap .chip > * + * { margin-left: 5px; }
/* Icons followed by plain text (not an element), e.g. buttons and notices. */
.no-flexgap .btn > .ic:not(:last-child), .no-flexgap .notice > .ic, .no-flexgap .nav a > .ic, .no-flexgap .tile .ic, .no-flexgap .badge > .ic { margin-right: 6px; }
.no-flexgap .notice > * + * { margin-left: 10px; }
.no-flexgap .toolbar > *, .no-flexgap .page-head .actions > *, .no-flexgap .card-head .actions > *, .no-flexgap .modal-foot > *, .no-flexgap .kds-bar > *, .no-flexgap .chips > * { margin-right: 8px; }
.no-flexgap .toolbar > * { margin-bottom: 6px; }
.no-flexgap .page-head > * + *:not(.actions), .no-flexgap .card-head > * + *:not(.actions), .no-flexgap .list-row > * + *, .no-flexgap .brand > * + *, .no-flexgap .nav a > * + *,
.no-flexgap .side-foot .who > * + *, .no-flexgap .net > * + *, .no-flexgap .pos-top > * + *, .no-flexgap .cart-head > * + *, .no-flexgap .cart-cust > * + *, .no-flexgap .pay-input > * + *,
.no-flexgap .check > * + *, .no-flexgap .kds-head > * + *, .no-flexgap .split > * + *, .no-flexgap .cart-order > * + *, .no-flexgap .tabs > * + * { margin-left: 10px; }
.no-flexgap .stack > * + * { margin-top: 16px; }
.no-flexgap .field > * + * { margin-top: 5px; }
.no-flexgap .kds-card > * + * { margin-top: 8px; }
.no-flexgap .pay-methods button > * + * { margin-top: 4px; }

/* No CSS grid (Chrome < 57): flexbox versions of the grid layouts. */
@supports not (display: grid) {
  .shell, .pos { display: flex; }
  .side { width: 230px; flex: none; }
  .main, .pos-left { flex: 1; min-width: 0; }
  .pos-cart { width: 420px; flex: none; }
  .form-grid, .grid-2, .grid-3, .grid-main, .stats, .pgrid, .kds-grid, .denoms, .pay-methods, .quick, .cart-actions, .pinpad, .kv { display: flex; flex-wrap: wrap; margin-left: -6px; margin-right: -6px; }
  .form-grid > *, .grid-2 > *, .denoms > * { width: calc(50% - 12px); margin: 0 6px 12px; }
  .form-grid.three > *, .grid-3 > * { width: calc(33.33% - 12px); margin: 0 6px 12px; }
  .form-grid > .field.full { width: calc(100% - 12px); }
  .grid-main > :first-child { width: calc(66.66% - 12px); margin: 0 6px 12px; }
  .grid-main > :last-child { width: calc(33.33% - 12px); margin: 0 6px 12px; }
  .stats > * { flex: 1 1 180px; margin: 0 6px 12px; }
  .pgrid { align-content: flex-start; }
  .pgrid > .tile { flex: 1 1 150px; max-width: 240px; margin: 0 5px 10px; }
  .kds-grid > * { flex: 1 1 250px; max-width: 380px; margin: 0 6px 12px; }
  .pay-methods > *, .quick > *, .cart-actions > * { flex: 1; margin: 0 3px 6px; }
  .pinpad > * { width: calc(33.33% - 10px); margin: 0 5px 10px; }
  .kv > dt, .kv > dd { width: 50%; margin: 0 0 6px; padding: 0 6px; }
  .cline { display: flex; flex-wrap: wrap; justify-content: space-between; }
  .cline > :nth-child(1) { width: 70%; }
  .cline > :nth-child(3) { display: none; }
  .denoms .d { display: flex; align-items: center; }
  .denoms .d > * { margin-right: 8px; }
  #print-area .two { display: flex; }
  #print-area .two > * { flex: 1; margin-right: 12px; }
}

/* First-run set-up */
.welcome-card { max-width: 520px; }
.welcome-opts { display: flex; flex-direction: column; margin-top: 16px; }
.welcome-opt { display: flex; align-items: center; text-align: left; width: 100%; margin-bottom: 10px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.welcome-opt:hover, .welcome-opt:focus-visible { border-color: var(--primary); }
.welcome-opt.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.welcome-opt > .ic { flex: none; margin-right: 14px; color: var(--primary); }
.welcome-opt b { display: block; font-size: 15px; }
.welcome-opt small { display: block; color: var(--muted); margin-top: 2px; font-size: 12.5px; }

/* Restaurant: modifier / quick-note buttons, table floor */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); grid-gap: 8px; margin-bottom: 12px; }
.mod-btn { padding: 12px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.mod-btn small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.mod-btn.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-gap: 12px; }
.table-tile { min-height: 104px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; padding: 14px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.table-tile b { font-size: 18px; }
.table-tile span { color: var(--muted); font-size: 13px; }
.table-tile small { color: var(--muted); font-size: 12px; }
.table-tile.busy { border-color: var(--warn); background: var(--warn-soft); }
.table-tile.busy span { color: var(--text); font-weight: 600; }
.table-tile.long { border-color: var(--danger); background: var(--danger-soft); }
.kds-course { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(25, 230, 230, .15); margin-left: 4px; }

/* Appointments calendar */
.appt-cal { overflow-x: auto; }
.appt-head, .appt-body { display: grid; min-width: 520px; }
.appt-head > div { padding: 10px 8px; font-weight: 700; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.appt-times > div { font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-6px); }
.appt-col { position: relative; border-left: 1px solid var(--border); }
.appt-slot { border-top: 1px dashed transparent; cursor: pointer; }
.appt-slot.hour { border-top-color: var(--border); }
.appt-slot:hover { background: var(--primary-soft); }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 6px; background: var(--primary-soft); border-left: 3px solid var(--primary); overflow: hidden; cursor: pointer; font-size: 12px; }
.appt b { display: block; font-size: 12px; }
.appt span { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.arrived { background: var(--warn-soft); border-left-color: var(--warn); }
.appt.done { background: var(--ok-soft, #e6f4ea); border-left-color: var(--ok); opacity: .8; }
.appt.noshow { background: var(--danger-soft); border-left-color: var(--danger); opacity: .7; }

/* WhatsApp chats */
.wa-wrap { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 14px; align-items: start; }
.wa-list { max-height: 70vh; overflow: auto; }
.wa-list .list-row.on { background: var(--primary-soft, rgba(25, 230, 230, .12)); }
.wa-snip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.wa-chat { display: flex; flex-direction: column; min-height: 420px; max-height: 70vh; }
.wa-msgs { flex: 1; overflow: auto; padding: 12px 16px; background: var(--bg); }
.wa-msg { max-width: 75%; margin: 0 0 8px; padding: 8px 11px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); }
.wa-msg.out { margin-left: auto; background: #d9fdd3; color: #111; border-color: #c4ecbd; }
.wa-msg small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.wa-msg.out small { color: #4b6b47; }
.wa-reply { display: flex; padding: 10px; border-top: 1px solid var(--border); }
.wa-reply textarea { flex: 1; margin-right: 8px; resize: vertical; }
@media (max-width: 760px) { .wa-wrap { grid-template-columns: 1fr; } }
