/* MiniPOS - all styles. No CDN, no build step: fully offline. */

:root{
  --bg:#eef1f6;
  --panel:#ffffff;
  --ink:#131b2b;
  --muted:#6b7688;
  --line:#dfe4ec;
  --brand:#2563eb;
  --brand-dark:#1d4ed8;
  --ok:#16a34a;
  --ok-dark:#15803d;
  --warn:#d97706;
  --danger:#dc2626;
  --radius:10px;
  --shadow:0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --font:"Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--ink);
  font-family:var(--font);font-size:15px;line-height:1.45;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--brand);text-decoration:none}
button,input,select,textarea{font:inherit;color:inherit}

/* ---------- top bar ---------- */
.topbar{
  display:flex;align-items:center;gap:20px;
  height:56px;padding:0 16px;
  background:#101827;color:#fff;
}
.brand{font-weight:600;font-size:17px;display:flex;align-items:center;gap:10px;white-space:nowrap}
.logo{
  background:var(--brand);color:#fff;font-size:12px;font-weight:700;letter-spacing:.08em;
  padding:4px 8px;border-radius:6px;
}
.nav{display:flex;gap:4px;flex:1}
.nav a{color:#c3cbd9;padding:7px 14px;border-radius:8px;font-weight:500}
.nav a:hover{background:#1e2a3d;color:#fff}
.nav a.on{background:var(--brand);color:#fff}
.topright{display:flex;align-items:center;gap:14px;font-size:13px;color:#9aa5b6}
.logout{color:#9aa5b6}
.logout:hover{color:#fff}

.main{padding:16px;height:calc(100vh - 56px);overflow:auto}
body.page-pos .main{padding:0;overflow:hidden}

/* licence notice strip, sits between the top bar and the page */
.licbar{
  background:#fef3c7;color:#78350f;border-bottom:1px solid #fde68a;
  padding:9px 16px;text-align:center;font-weight:600;font-size:14px;
}
.licbar.hard{background:#fee2e2;color:#7f1d1d;border-color:#fecaca}
.licbar a{margin-left:10px;text-decoration:underline;color:inherit}
body.has-licbar .main{height:calc(100vh - 56px - 39px)}
body.has-licbar .pos{height:calc(100vh - 56px - 39px)}

/* ---------- generic bits ---------- */
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.pad{padding:16px}
h1{font-size:20px;margin:0 0 14px}
h2{font-size:16px;margin:0 0 12px}
.muted{color:var(--muted)}
.row{display:flex;gap:12px;flex-wrap:wrap;align-items:flex-end}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:12px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
input[type=text],input[type=number],input[type=password],input[type=date],input[type=file],select,textarea{
  padding:9px 11px;border:1px solid var(--line);border-radius:8px;background:#fff;min-width:0;
}
input:focus,select:focus,textarea:focus{outline:2px solid #bfdbfe;border-color:var(--brand)}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  padding:9px 16px;border:1px solid var(--line);border-radius:8px;background:#fff;
  font-weight:600;cursor:pointer;white-space:nowrap;
}
.btn:hover{background:#f5f7fa}
.btn-primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-dark)}
.btn-ok{background:var(--ok);border-color:var(--ok);color:#fff}
.btn-ok:hover{background:var(--ok-dark)}
.btn-danger{color:var(--danger);border-color:#f3c9c9}
.btn-danger:hover{background:#fee2e2}
.btn-sm{padding:5px 10px;font-size:13px}
.btn:disabled{opacity:.5;cursor:not-allowed}

table{width:100%;border-collapse:collapse}
th,td{padding:9px 10px;text-align:left;border-bottom:1px solid var(--line)}
th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);font-weight:600}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
tbody tr:hover{background:#f8fafc}

.flash{padding:10px 14px;border-radius:8px;margin-bottom:14px;font-weight:500}
.flash.ok{background:#dcfce7;color:#14532d}
.flash.err{background:#fee2e2;color:#7f1d1d}

/* ---------- POS split screen ---------- */
.pos{display:flex;height:calc(100vh - 56px)}
.pos-left{flex:1;display:flex;flex-direction:column;min-width:0}
.pos-right{
  width:390px;flex:none;background:var(--panel);border-left:1px solid var(--line);
  display:flex;flex-direction:column;
}

.pos-tools{
  display:flex;gap:10px;padding:12px 14px;background:var(--panel);
  border-bottom:1px solid var(--line);align-items:center;
}
.pos-tools .search{flex:1;padding:11px 13px;font-size:15px}
.scan{width:190px}

.grid{
  flex:1;overflow:auto;padding:14px;
  display:grid;gap:12px;
  grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
  align-content:start;
  /* Rows must stay at content height. Without this the tiles' overflow:hidden
     gives each row a minimum size of 0, so once there are more items than fit
     the grid squeezes the rows instead of scrolling and the name and price get
     clipped away. */
  grid-auto-rows:max-content;
}
.tile{
  background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);
  overflow:hidden;cursor:pointer;text-align:left;padding:0;box-shadow:var(--shadow);
  transition:transform .06s ease, box-shadow .12s ease;
}
.tile:hover{box-shadow:0 4px 16px rgba(16,24,40,.14);transform:translateY(-1px)}
.tile:active{transform:translateY(1px)}
.tile .thumb{
  height:104px;background:#f1f4f9 center/cover no-repeat;
  display:flex;align-items:center;justify-content:center;
  color:#aab3c2;font-size:30px;font-weight:700;
}
.tile .info{padding:9px 10px}
.tile .nm{font-weight:600;font-size:14px;line-height:1.25;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:35px}
.tile .pr{color:var(--brand);font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums}
.tile .cd{font-size:11px;color:var(--muted)}
.empty{padding:50px 20px;text-align:center;color:var(--muted)}

/* bill panel */
.bill-head{
  padding:12px 14px;border-bottom:1px solid var(--line);
  display:flex;justify-content:space-between;align-items:center;
}
.bill-head .t{font-weight:700;font-size:16px}
/* Always keep room for a few bill lines. Without a floor the tall totals
   block squeezes this to nothing on a short screen and the cashier cannot
   see what is on the bill. */
.lines{flex:1 1 auto;overflow:auto;min-height:132px}
.lines table{font-size:14px}
.lines th{position:sticky;top:0;background:var(--panel);z-index:1}
.lines td{padding:7px 8px;vertical-align:middle}
.ln-name{font-weight:600;line-height:1.2}
.ln-price{font-size:12px;color:var(--muted)}
.qty{display:flex;align-items:center;gap:4px}
.qty button{
  width:26px;height:26px;border:1px solid var(--line);background:#fff;border-radius:6px;
  cursor:pointer;font-weight:700;line-height:1;
}
.qty button:hover{background:#eef2ff;border-color:var(--brand);color:var(--brand)}
.qty input{width:46px;text-align:center;padding:4px 2px;border:1px solid var(--line);border-radius:6px}
.rm{border:none;background:none;color:var(--danger);cursor:pointer;font-size:16px;padding:2px 4px;border-radius:6px}
.rm:hover{background:#fee2e2}
.bill-empty{padding:44px 16px;text-align:center;color:var(--muted)}

/* The totals give way instead: they scroll if there is genuinely no room,
   so the item list and the Print & Save button always stay usable. */
.totals{border-top:1px solid var(--line);padding:12px 14px;background:#fbfcfe;
  flex:0 1 auto;overflow-y:auto}
.trow{display:flex;justify-content:space-between;align-items:center;margin-bottom:7px;font-size:14px}
.trow .lbl{color:var(--muted)}
.trow input{width:120px;text-align:right;padding:6px 9px}
.grand{
  display:flex;justify-content:space-between;align-items:baseline;
  border-top:2px solid var(--ink);margin-top:10px;padding-top:10px;
}
.grand .lbl{font-weight:700;font-size:15px}
.grand .val{font-weight:800;font-size:27px;font-variant-numeric:tabular-nums}
.balance{color:var(--ok);font-weight:700}
.balance.due{color:var(--danger)}
.actions{display:flex;gap:10px;padding:12px 14px;border-top:1px solid var(--line)}
.actions .btn{flex:1;padding:14px;font-size:15px}
.actions .btn-ok{flex:2}
.hint{padding:0 14px 10px;font-size:11px;color:var(--muted);text-align:center}

/* Short screens - 1366x768 laptops are common on shop counters. Tighten the
   bill panel so the list, the total and the buttons all still fit. */
@media (max-height: 800px){
  .cust-bar{padding:6px 14px}
  .totals{padding:8px 14px}
  .trow{margin-bottom:4px}
  .grand{margin-top:6px;padding-top:6px}
  .grand .val{font-size:23px}
  .actions .btn{padding:11px}
  .hint{display:none}
  .lines{min-height:110px}
}

/* ---------- modal ---------- */
.modal{position:fixed;inset:0;background:rgba(16,24,40,.5);display:flex;align-items:center;justify-content:center;z-index:50}
.modal[hidden]{display:none}
.modal-box{background:#fff;border-radius:12px;width:440px;max-width:94vw;max-height:92vh;overflow:auto;box-shadow:0 20px 50px rgba(0,0,0,.3)}
.modal-head{padding:14px 18px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center}
.modal-head h2{margin:0}
.x{border:none;background:none;font-size:22px;cursor:pointer;color:var(--muted);line-height:1}
.modal-body{padding:18px;display:grid;gap:14px}
.modal-body .field input,.modal-body .field select{width:100%}
.two{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.modal-foot{padding:14px 18px;border-top:1px solid var(--line);display:flex;gap:10px;justify-content:flex-end}

/* ---------- login ---------- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:#101827}
.login-box{background:#fff;border-radius:14px;padding:32px;width:360px;box-shadow:0 20px 60px rgba(0,0,0,.4)}
.login-box h1{text-align:center;margin-bottom:6px}
.login-box .sub{text-align:center;color:var(--muted);margin:0 0 22px;font-size:13px}
.login-box .field{margin-bottom:14px}
.login-box input{width:100%;padding:11px}
.login-box .btn{width:100%;padding:12px;margin-top:6px}

/* ---------- reports ---------- */
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;margin-bottom:16px}
.stat{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:14px;box-shadow:var(--shadow)}
.stat .k{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;font-weight:600}
.stat .v{font-size:24px;font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums}
.stat.profit .v{color:var(--ok)}
.thumb-sm{width:40px;height:40px;border-radius:6px;object-fit:cover;background:#f1f4f9;display:block}

@media print{
  .topbar,.no-print{display:none !important}
  .main{height:auto;padding:0;overflow:visible}
  .card{box-shadow:none;border:none}
}

/* refund badge in the bill list */
.tag{
  display:inline-block;font-size:10px;font-weight:700;letter-spacing:.06em;
  padding:2px 6px;border-radius:5px;vertical-align:middle;margin-left:4px;
}
.tag.ret{background:#fee2e2;color:#991b1b}

/* logo preview in Settings - shows how wide it lands on the paper roll */
.logo-box{display:flex;align-items:flex-start;gap:16px;margin-bottom:12px}
.logo-preview{max-width:180px;max-height:90px;border:1px solid var(--line);
  border-radius:8px;padding:6px;background:#fff;object-fit:contain}
.logo-paper{
  width:86px;height:90px;border:1px dashed var(--line);border-radius:6px;
  background:repeating-linear-gradient(45deg,#fafbfd,#fafbfd 6px,#f1f4f9 6px,#f1f4f9 12px);
  padding:6px;
}
.logo-paper span{display:block;height:22px;background:var(--ink);border-radius:2px;opacity:.75}
.logo-paper span.full{width:100%}
.logo-paper span.left{width:50%;margin-right:auto}
.logo-paper span.right{width:50%;margin-left:auto}
.logo-paper span.center{width:50%;margin-left:auto;margin-right:auto}
.tag.paid{background:#dcfce7;color:#14532d}
.tag.credit{background:#fef3c7;color:#78350f}
.cust-bar{padding:9px 14px;border-bottom:1px solid var(--line);background:#f8fafc}
.cust-bar select{width:100%;padding:7px 9px}

/* "editing bill #" strip on the POS */
.edit-bar{background:#fef3c7;color:#78350f;border-bottom:1px solid #fde68a;padding:8px 14px;font-size:13px}
.edit-bar a{margin-left:8px;color:inherit;text-decoration:underline}
.tag.void{background:#e5e7eb;color:#374151}
.tag.edit{background:#dbeafe;color:#1e40af}
