/* =========================================================================
   MyShop billing — single stylesheet (no external dependency)
   ========================================================================= */
:root {
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --ink:     #0f172a;
  --muted:   #64748b;
  --line:    #e2e8f0;
  --primary: #1d4ed8;
  --primary-d:#1e40af;
  --danger:  #dc2626;
  --ok:      #059669;
  --radius:  10px;
  --shadow:  0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
.bg-soft { background: var(--bg); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 12px; }
a  { color: var(--primary); }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ topbar */
.topbar { background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 40; }
.topbar-in {
  max-width: 1200px; margin: 0 auto; padding: 0 14px;
  display: flex; align-items: center; gap: 14px; min-height: 54px; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: .3px; margin-right: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 7px; font-size: 14px; font-weight: 500;
}
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav-user { color: #94a3b8; font-size: 13px; padding: 0 8px; border-left: 1px solid #334155; margin-left: 6px; }
.nav-logout { color: #fca5a5 !important; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 16px 14px 120px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 20px; }

/* -------------------------------------------------------------- primitives */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: #475569; margin: 10px 0 4px; }
.lbl-block { margin-top: 14px; }
.input {
  width: 100%; padding: 9px 10px; font-size: 15px; font-family: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.14); }
.input[readonly] { background: #f8fafc; color: var(--muted); }
.input-sm { width: 120px; padding: 6px 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; }

.btn {
  display: inline-block; padding: 9px 14px; font: 600 14px inherit; color: var(--ink);
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

kbd {
  display: inline-block; padding: 1px 6px; font: 600 11px ui-monospace, monospace;
  background: #fff; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 4px; color: #334155;
}
.kbd-inline { font-size: 11px; opacity: .8; font-weight: 500; margin-left: 6px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1 1 150px; }
.grid-2 { display: grid; grid-template-columns: 380px 1fr; gap: 14px; align-items: start; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin-right: auto; }
.search-form { display: flex; gap: 8px; flex-wrap: wrap; }
.search-form .input { width: auto; min-width: 150px; }
.hint-bar { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 8px 8px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.table tbody tr:hover { background: #f8fafc; }
.row-off { opacity: .45; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #e2e8f0; color: #334155; }
.tag-cash { background: #ecfdf5; color: #047857; }
.tag-online { background: #eff6ff; color: #1d4ed8; }
.tag-both { background: #fef3c7; color: #92400e; }
.tag-credit { background: #fee2e2; color: #b91c1c; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 19px; }

/* ------------------------------------------------------------- login page */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; text-align: center; padding: 28px 24px; }
.login-card label { text-align: left; }
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 14px; background: var(--primary);
  color: #fff; font: 700 26px/54px inherit;
}
.setup-list { text-align: left; font-size: 14px; line-height: 1.9; padding-left: 18px; }

/* ---------------------------------------------------------- billing table */
.bill-table th, .bill-table td { padding: 5px 6px; vertical-align: middle; }
.bill-table .input { padding: 8px 8px; }
.c-sn   { width: 38px; color: var(--muted); font-size: 13px; }
.c-unit { width: 78px; }
.c-qty, .c-rate, .c-amt { width: 110px; }
.c-del  { width: 42px; }
.unit-tag { display: inline-block; font-size: 12px; font-weight: 600; color: #475569; background: #f1f5f9; padding: 4px 8px; border-radius: 6px; }
.js-amt { background: #f8fafc; font-weight: 700; }
.bill-actions { display: flex; gap: 8px; margin-top: 12px; }

.totals-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #0f172a; color: #fff; padding: 10px 14px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  box-shadow: 0 -2px 12px rgba(0,0,0,.18);
}
.tot span { display: block; font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: .4px; }
.tot b { font-size: 17px; }
.tot-main { margin-left: auto; }
.tot-main b { font-size: 24px; color: #4ade80; }
.totals-bar .btn { margin-left: 8px; }

/* ------------------------------------------------------------- suggestions */
.suggest {
  position: fixed; z-index: 90; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15,23,42,.16);
}
.sug-item { padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #f1f5f9; }
.sug-item:last-child { border-bottom: 0; }
.sug-item.active, .sug-item:hover { background: #eff6ff; }
.sug-name  { font-size: 14px; font-weight: 600; flex: 1; }
.sug-short { font-size: 11px; font-weight: 700; color: #7c3aed; background: #f5f3ff; padding: 1px 6px; border-radius: 4px; }
.sug-rate  { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ------------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; flex: 1; }
.modal-x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
.sum-cust { font-size: 14px; margin-bottom: 8px; }
.sum-scroll { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.sum-table th { position: sticky; top: 0; background: #f8fafc; }
.sum-line { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 15px; border-bottom: 1px dashed var(--line); }
.sum-grand { font-size: 20px; font-weight: 700; border-bottom: 0; padding-top: 10px; }
.sum-grand b { color: var(--ok); }
.pay-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pay-opt { display: block; margin: 0; text-align: center; padding: 10px 4px; border: 1px solid #cbd5e1; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.pay-opt input { display: none; }
.pay-opt:has(input:checked),
.pay-opt.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.split-row { margin-top: 10px; }
body.modal-on { overflow: hidden; }

/* ================================================================= mobile */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .nav-toggle { display: block; order: 3; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 8px; }
  body.nav-open .nav { display: flex; }
  .nav a, .nav-user { padding: 11px 10px; border-left: 0; margin: 0; }

  .wrap { padding: 12px 10px 150px; }
  .page-head h1 { font-size: 19px; width: 100%; }
  .search-form { width: 100%; }
  .search-form .input { flex: 1 1 130px; }

  /* stacked-card tables */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 4px 8px; background: #fff; }
  .table td { border: 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px; }
  .table td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
  .table td.ta-r { text-align: right; }

  /* billing rows as cards */
  .bill-table tr.item-row { position: relative; padding-top: 8px; }
  .bill-table .c-sn { justify-content: flex-start; font-weight: 700; color: var(--ink); }
  .bill-table .c-sn::before { content: 'Item '; }
  .bill-table .c-prod { display: block; }
  .bill-table .c-prod::before { display: none; }
  .bill-table .c-del { position: absolute; top: 6px; right: 6px; width: auto; border: 0; padding: 0; }
  .bill-table .input { font-size: 16px; }        /* stops iOS zoom-on-focus */
  .bill-table .c-qty .input, .bill-table .c-rate .input, .bill-table .c-amt .input { max-width: 150px; }

  .totals-bar { gap: 10px; padding: 8px 10px; }
  .tot-main b { font-size: 20px; }
  .totals-bar .btn-lg { padding: 11px 16px; font-size: 15px; width: 100%; margin: 4px 0 0; }
  .pay-modes { grid-template-columns: repeat(2, 1fr); }
  .modal-card { max-height: 96vh; }
  .modal-foot .btn { flex: 1; }
}

@media (max-width: 420px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .tot { min-width: 70px; }
}
