:root {
  --bg: #f6f3ee; --card: #ffffff; --ink: #1d1b18; --muted: #6f6a62; --line: #e4ded4;
  --brand: #1d1b18; --accent: #a8743d; --ok: #2f7d4f; --bad: #b3261e; --warn: #9a6b00;
  --r: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 5; }
.top .brand { color: #fff; text-decoration: none; font-size: 17px; letter-spacing: .3px; }
.top .brand b { color: #e2b27a; }
.top .co { font-weight: 600; opacity: .9; }
.top .me { font-size: 13px; opacity: .8; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.spacer { flex: 1; }
.view { max-width: 1000px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.login { max-width: 380px; margin: 8vh auto 0; }
.login h1 { text-align: center; margin-bottom: 2px; }
.login .sub { text-align: center; margin: 0 0 20px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input, select { width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; margin-top: 18px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; color: inherit; text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile b { display: block; font-size: 16px; margin-bottom: 4px; }
.tile.off { opacity: .6; pointer-events: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: #efe8dc; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tag.owner { background: #1d1b18; color: #e2b27a; }
.tag.off { background: #fbe9e7; color: var(--bad); }
.tag.on { background: #e5f4e4; color: var(--ok); }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { background: #faf7f2; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td .btn + .btn { margin-left: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1ece3; padding: 2px 6px; border-radius: 5px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 20px; }
dialog h3 { margin: 0 0 6px; }
dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.table-wrap { overflow-x: auto; }
@media (max-width: 640px) {
  .top .me { display: none; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

/* ---------- POS ---------- */
body[data-page="pos"] .view { max-width: 1400px; padding-top: 12px; }
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.pos-bar { display: flex; gap: 8px; }
.pos-bar input { font-size: 17px; padding: 12px 14px; }
.pos-day { font-size: 13px; margin: 8px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile.prod { text-align: left; cursor: pointer; font: inherit; padding: 12px; display: flex; flex-direction: column; gap: 4px; min-height: 92px; }
.tile.prod b { font-size: 14px; margin: 0; }
.tile.prod span { font-weight: 700; color: var(--accent); }
.tile.prod small { font-size: 11px; }
.tile.prod.added { animation: pop .35s ease; }
@keyframes pop { 0% { background: #f3e3cc; } 100% { background: var(--card); } }
.neg { color: var(--bad); font-weight: 600; }
.pos-right { position: sticky; top: 64px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; max-height: calc(100vh - 84px); }
.cart { overflow-y: auto; flex: 1; padding: 6px 12px; min-height: 160px; }
.line { display: grid; grid-template-columns: 1fr auto 64px 24px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line .nm { font-size: 14px; display: flex; flex-direction: column; }
.line .nm small { font-size: 12px; }
.line .qty { display: flex; align-items: center; gap: 6px; }
.line .qty button, .line .x { width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 16px; cursor: pointer; color: var(--ink); }
.line .x { border: 0; color: var(--muted); }
.line .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pay { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tot { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.tot b { font-size: 28px; font-variant-numeric: tabular-nums; }
.paybtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.paybtns .btn { padding: 14px 0; font-size: 16px; }
.paybig { font-size: 34px; font-weight: 700; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.change { font-size: 18px; margin: 12px 0 0; }
.change b { font-size: 24px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.kpis .card { padding: 12px; display: flex; flex-direction: column; }
.kpis b { font-size: 20px; font-variant-numeric: tabular-nums; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }

/* ---------- Receipt ---------- */
.rcpt { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #000; background: #fff; line-height: 1.35; }
.rcpt.w80 { width: 72mm; } .rcpt.w58 { width: 48mm; font-size: 10.5px; }
.rcpt table { width: 100%; border: 0; border-collapse: collapse; background: none; }
.rcpt td { border: 0; padding: 0; font-size: inherit; }
.rcpt .r { text-align: right; } .rcpt .c { text-align: center; } .rcpt .b { font-weight: 700; } .rcpt .big { font-size: 1.25em; }
.rcpt hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.rcpt-preview { display: flex; justify-content: center; background: #f1ece3; padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; }
.rcpt-preview .rcpt { padding: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
#printArea { display: none; }
@media print {
  @page { margin: 0; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block !important; }
  body.printing { background: #fff; }
  .rcpt { padding: 2mm; }
}

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; }
  .pos-right { position: static; max-height: none; order: -1; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- GRN ---------- */
.qtyin { width: 70px; text-align: center; padding: 6px; display: inline-block; }
.a4 { font-family: system-ui, sans-serif; font-size: 12px; color: #000; background: #fff; width: 190mm; padding: 10mm; }
.a4 .c { text-align: center; } .a4 .b { font-weight: 700; } .a4 .big { font-size: 18px; } .a4 .r { text-align: right; }
.a4 hr { border: 0; border-top: 1px solid #000; margin: 8px 0; }
.a4 table { width: 100%; border-collapse: collapse; border: 0; background: none; }
.a4 td, .a4 th { border: 0; padding: 3px 4px; font-size: 12px; color: #000; background: none; text-transform: none; letter-spacing: 0; }
.a4 table.grid th, .a4 table.grid td { border: 1px solid #000; }
.a4 .sign { display: flex; justify-content: space-between; margin-top: 30mm; }
@media print { body.print-a4 { } body.print-a4 @page { size: A4; } }

/* ---------- Dashboard ---------- */
.dash { margin: 22px 0 28px; }
.dash-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.kpis small { font-size: 12px; margin-top: 2px; }
.up { color: var(--ok); } .down { color: var(--bad); }
.paysplit { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin: 4px 0 14px; }
.paysplit b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dash-grid h3 { font-size: 14px; margin: 0 0 10px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bcol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bcol i { display: block; width: 100%; max-width: 26px; background: #d8c2a4; border-radius: 4px 4px 0 0; min-height: 2px; }
.bcol.now i { background: var(--accent); }
.bcol span { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
table.mini { border: 0; background: none; }
table.mini td { padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
table.mini td.r { text-align: right; padding-left: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) { .dash-grid { grid-template-columns: 1fr; } .bcol span { font-size: 9px; } }
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; }
  .tile b { font-size: 15px; }
  .tile .muted { font-size: 12.5px; }
}
