@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root{
  --bg: #F5F4F1;
  --surface: #FFFFFF;
  --surface-2: #FBFAF8;
  --ink: #21252B;
  --ink-soft: #6B7178;
  --line: #E4E2DC;
  --teal: #147D7F;
  --teal-dark: #0E5C5D;
  --coral: #FF6B4A;
  --success: #3FA34D;
  --warning: #C98A22;
  --danger: #D14343;
  --name-color: #1F7A4E;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20,20,25,.05), 0 1px 1px rgba(20,20,25,.04);
  --shadow-md: 0 8px 20px -6px rgba(20,20,25,.14);
  --shadow-lg: 0 24px 48px -20px rgba(20,20,25,.28);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}
html[data-theme="dark"]{
  --bg: #14171A;
  --surface: #1D2125;
  --surface-2: #23272B;
  --ink: #ECEDEB;
  --ink-soft: #9BA1A4;
  --line: #2B3034;
  --teal: #23A6A3;
  --teal-dark: #1B8582;
  --name-color: #4ADE9A;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 20px -6px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 48px -20px rgba(0,0,0,.6);
}
:focus-visible{outline:2px solid var(--teal);outline-offset:2px;}
/* Visually hidden but still announced by screen readers — for labels on
   fields whose visual design already conveys purpose via placeholder/icon. */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
*{box-sizing:border-box;}
html{transition:background-color .2s ease;}
html, body{overflow-x:hidden;max-width:100%;}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-body);-webkit-font-smoothing:antialiased;transition:background-color .2s ease, color .2s ease;}
/* color:inherit is the important part here — without it, buttons fall back
   to the browser's default black text instead of following the theme, which
   is invisible in light mode (black looks like the theme's own dark ink)
   but breaks outright in dark mode. Button variants below still set their
   own explicit color; this is just the safety net for ones that don't. */
button{font-family:inherit;color:inherit;cursor:pointer;}
input,select,textarea{font-family:inherit;}
a{color:inherit;text-decoration:none;}
::selection{background:var(--teal);color:#fff;}

/* ---------- Login ---------- */
.login-wrap{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;position:relative;padding:20px;background:
  radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--teal) 12%, transparent) 0%, transparent 45%),
  radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--coral) 12%, transparent) 0%, transparent 45%), var(--bg);}
.login-theme-toggle{position:absolute;top:20px;right:20px;}
.login-card{width:380px;max-width:100%;background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:36px;box-shadow:var(--shadow-lg);}
.login-brand{font-family:var(--font-display);font-weight:700;font-size:22px;display:flex;align-items:center;gap:10px;margin-bottom:4px;}
.login-brand .dot{width:10px;height:10px;border-radius:3px;background:var(--coral);display:inline-block;transform:rotate(45deg);}
.login-sub{color:var(--ink-soft);font-size:13px;margin-bottom:24px;}
.user-pick{display:flex;flex-direction:column;gap:8px;margin-bottom:18px;}
.user-pick button, .user-pick a{display:flex;align-items:center;gap:12px;text-align:left;background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:12px 14px;transition:.15s;width:100%;}
.user-pick button:hover, .user-pick a:hover{border-color:var(--teal);background:color-mix(in srgb, var(--teal) 10%, var(--surface));}
.user-avatar{width:34px;height:34px;border-radius:8px;background:var(--teal);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:600;font-family:var(--font-display);font-size:14px;flex-shrink:0;}
.user-meta b{display:block;font-size:14px;}
.user-meta span{font-size:12px;color:var(--ink-soft);text-transform:capitalize;}
.pin-row{display:flex;gap:8px;margin-bottom:12px;}
.pin-row input{flex:1;text-align:center;font-family:var(--font-mono);font-size:20px;letter-spacing:4px;padding:12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--ink);}
.pin-row input:focus{outline:2px solid var(--teal);}
.btn{border:none;border-radius:9px;padding:11px 16px;font-weight:600;font-size:14px;transition:.15s;display:inline-flex;align-items:center;justify-content:center;gap:7px;}
.btn:disabled{opacity:.6;cursor:not-allowed;}
.btn-primary{background:var(--teal);color:#fff;box-shadow:var(--shadow-sm);}
.btn-primary:hover:not(:disabled){background:var(--teal-dark);box-shadow:var(--shadow-md);}
.btn-block{width:100%;text-align:center;}
.btn-ghost{background:transparent;color:var(--ink-soft);border:1px solid var(--line);}
.btn-ghost:hover:not(:disabled){background:var(--surface-2);}
.btn-danger{background:#FCEBEB;color:var(--danger);}
.btn-danger:hover:not(:disabled){background:#F8D9D9;}
html[data-theme="dark"] .btn-danger{background:rgba(209,67,67,.16);}
html[data-theme="dark"] .btn-danger:hover:not(:disabled){background:rgba(209,67,67,.26);}
.login-err{color:var(--danger);font-size:12px;margin-bottom:10px;min-height:14px;}
.login-hint{font-size:11px;color:var(--ink-soft);margin-top:16px;text-align:center;line-height:1.5;}
.login-footer{margin-top:18px;font-size:11px;color:var(--ink-soft);text-align:center;}
.login-footer-link{background:none;border:none;padding:0;color:var(--ink-soft);font-size:11px;text-decoration:underline;cursor:pointer;}
.login-footer-link:hover{color:var(--ink);}

/* ---------- Shell ---------- */
/* .shell is pinned to exactly one viewport tall, with .main as the only
   scrolling region inside it — this is what keeps the sidebar (and the
   logout button at its bottom) always in view regardless of how tall a
   page's content gets. We tried position:sticky on .sidebar first, but
   html/body need overflow-x:hidden to stop mobile horizontal scroll, and
   setting overflow on only one axis forces the browser to silently treat
   the other axis as "auto" too — which broke position:sticky's containing
   block and made the sidebar scroll away like a normal element anyway. */
.shell{display:flex;height:100vh;overflow:hidden;}
.sidebar{background:#171B1E;color:#EDEEEC;padding:20px 14px;display:flex;flex-direction:column;width:220px;height:100%;flex-shrink:0;overflow-x:hidden;overflow-y:auto;white-space:nowrap;transition:width .25s ease, padding .25s ease;}
.sidebar.collapsed{width:0;padding-left:0;padding-right:0;border:none;}
.side-brand{font-family:var(--font-display);font-weight:700;font-size:17px;padding:6px 10px 20px;display:flex;align-items:center;gap:8px;}
.side-brand .dot{width:9px;height:9px;background:var(--coral);border-radius:3px;transform:rotate(45deg);display:inline-block;flex-shrink:0;}
.side-brand-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.nav-btn{display:flex;align-items:center;gap:10px;width:100%;text-align:left;background:none;border:none;color:#AEB3B0;padding:10px 12px;border-radius:8px;font-size:13.5px;font-weight:500;margin-bottom:2px;transition:background .12s ease,color .12s ease;}
.nav-btn:hover{background:#22272B;color:#fff;}
.nav-btn.active{background:var(--teal);color:#fff;box-shadow:var(--shadow-sm);}
.nav-icon{width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;}
.side-spacer{flex:1;}
.side-user{border-top:1px solid #2A2F33;padding-top:14px;font-size:12.5px;}
.side-user b{display:block;color:#fff;font-size:13px;}
.side-user span{color:#8B9091;text-transform:capitalize;}
.side-version{font-size:10.5px;color:#6B7075;text-align:center;padding:10px 0 2px;}
.side-version-link{background:none;border:none;padding:0;color:#8B9091;font-size:10.5px;text-decoration:underline;cursor:pointer;}
.side-version-link:hover{color:#fff;}
.about-table{width:100%;border-collapse:collapse;margin-bottom:14px;}
.about-table td{padding:7px 0;font-size:13px;border-bottom:1px solid var(--line);}
.about-table td:first-child{color:var(--ink-soft);width:46%;}
.about-table td:last-child{font-weight:600;color:var(--ink);}
.about-table tr:last-child td{border-bottom:none;}
.about-copyright{font-size:11.5px;color:var(--ink-soft);line-height:1.6;margin:0;}
.logout-btn{margin-top:10px;width:100%;background:#22272B;color:#D9DBD9;border:none;padding:8px;border-radius:7px;font-size:12px;display:flex;align-items:center;justify-content:center;gap:6px;}
.logout-btn:hover{background:#2C3236;}

.main{padding:24px 28px;overflow-x:hidden;overflow-y:auto;height:100%;flex:1;min-width:0;}
.page-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:20px;flex-wrap:wrap;gap:10px;}
.page-head-left{display:flex;align-items:flex-start;gap:12px;}
.page-title{font-family:var(--font-display);font-size:22px;font-weight:700;}
.page-sub{color:var(--ink-soft);font-size:13px;margin-top:2px;}
#sidebar-toggle, #theme-toggle{width:36px;height:36px;border-radius:9px;border:1px solid var(--line);background:var(--surface);color:var(--ink);font-size:15px;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;}
#sidebar-toggle:hover, #theme-toggle:hover{background:var(--surface-2);}

.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);}
.pad{padding:16px 18px;}

/* ---------- POS ---------- */
.pos-grid{display:grid;grid-template-columns:1fr 340px;gap:18px;align-items:start;}
/* Grid items default to min-width:auto, which refuses to shrink below the
   width of their widest child (here, the product table) — without this,
   a wide table forces the whole grid, and the page, wider than the viewport. */
.pos-grid > *{min-width:0;}
.scan-row{display:flex;gap:10px;margin-bottom:14px;}
.scan-row input{flex:1;padding:12px 14px;border:1px solid var(--line);border-radius:9px;font-size:14px;background:var(--surface);color:var(--ink);}
.scan-row input:focus{outline:2px solid var(--teal);}
.cat-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:14px;}
.cat-tab{padding:8px 14px;border-radius:999px;border:1px solid var(--line);background:var(--surface);font-size:12.5px;font-weight:500;color:var(--ink-soft);}
.cat-tab.active{background:var(--ink);color:var(--bg);border-color:var(--ink);}
.product-row{cursor:pointer;}
.product-row:hover{background:var(--surface-2);}
.product-row:focus{outline:2px solid var(--teal);outline-offset:-2px;}
.product-row[data-disabled]{opacity:.45;cursor:not-allowed;pointer-events:none;}
.product-row td{padding-top:12px;padding-bottom:12px;}

.receipt{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:0;overflow:hidden;position:sticky;top:20px;box-shadow:var(--shadow-md);transition:box-shadow .2s ease;}
.receipt-head{background:var(--ink);color:var(--bg);padding:14px 16px;font-family:var(--font-mono);}
.receipt-head-row{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;}
.receipt-head .shop{font-family:var(--font-display);font-weight:700;font-size:15px;}
.receipt-head .sub{font-size:11px;opacity:.7;margin-top:2px;}
/* .receipt-head always swaps in var(--ink) as its background (so it reads
   as a fixed dark accent bar in light mode) — but in dark mode --ink itself
   becomes light, so this button derives its fill from --bg (the header's
   text-color variable) rather than a hardcoded white, staying visible either way. */
.reprint-btn{display:flex;align-items:center;gap:5px;flex-shrink:0;background:color-mix(in srgb, var(--bg) 14%, transparent);border:1px solid color-mix(in srgb, var(--bg) 30%, transparent);color:var(--bg);padding:6px 10px;border-radius:7px;font-size:11px;font-weight:600;font-family:var(--font-body);white-space:nowrap;}
.reprint-btn:hover{background:color-mix(in srgb, var(--bg) 24%, transparent);}
.reprint-btn .icon{width:13px;height:13px;}
.receipt-body{padding:14px 16px;font-family:var(--font-mono);font-size:12.5px;max-height:280px;overflow-y:auto;border-bottom:1px dashed var(--line);}
@keyframes cart-flash{0%{background:color-mix(in srgb, var(--teal) 16%, transparent);}100%{background:transparent;}}
.receipt-body.just-added{animation:cart-flash .5s ease;}
.r-line{display:flex;justify-content:space-between;align-items:center;padding:8px 0;border-bottom:1px dashed var(--line);gap:8px;}
.r-line:last-child{border-bottom:none;}
.r-name{flex:1;font-size:12px;}
.r-qty-ctrl{display:flex;align-items:center;gap:6px;}
.r-qty-ctrl button{width:28px;height:28px;border-radius:6px;border:1px solid var(--line);background:var(--surface-2);color:var(--ink);font-size:15px;line-height:1;}
.r-qty-ctrl button:hover{background:var(--line);}
.r-qty-input{width:36px;text-align:center;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--ink);font-family:var(--font-mono);font-size:12.5px;padding:5px 2px;appearance:textfield;-moz-appearance:textfield;}
.r-qty-input::-webkit-outer-spin-button, .r-qty-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}
.r-amt{width:60px;text-align:right;font-weight:600;}
.r-rm{color:var(--danger);font-size:11px;border:none;background:none;padding:6px 0 6px 6px;display:flex;align-items:center;}
.empty-cart{color:var(--ink-soft);text-align:center;padding:24px 0;font-size:12.5px;}
.receipt-totals{padding:14px 16px;font-family:var(--font-mono);font-size:13px;}
.discount-row{display:flex;gap:6px;margin:10px 0 2px;padding-top:10px;border-top:1px dashed var(--line);font-family:var(--font-body);}
.discount-type-select{flex:1;padding:7px 8px;border:1px solid var(--line);border-radius:7px;background:var(--surface-2);color:var(--ink);font-size:12px;}
.discount-value-input{width:76px;padding:7px 8px;border:1px solid var(--line);border-radius:7px;background:var(--surface-2);color:var(--ink);font-size:12px;font-family:var(--font-mono);}
.discount-value-input:disabled{opacity:.5;}
.t-row{display:flex;justify-content:space-between;padding:3px 0;}
.t-row.grand{font-size:16px;font-weight:700;border-top:1px dashed var(--line);margin-top:6px;padding-top:9px;}
.receipt-actions{padding:14px 16px;border-top:1px solid var(--line);}
.field-label{font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-soft);margin-bottom:5px;display:block;font-weight:600;}
select, .input{width:100%;padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--ink);font-size:13px;margin-bottom:10px;}
.pay-toggle{display:flex;gap:6px;margin-bottom:10px;}
.pay-toggle button{flex:1;padding:11px 8px;border-radius:8px;border:1px solid var(--line);background:var(--surface-2);font-size:12.5px;font-weight:600;color:var(--ink-soft);}
.pay-toggle button.active{background:var(--teal);color:#fff;border-color:var(--teal);}
#complete-sale{padding:15px 16px;font-size:15px;}

/* ---------- Tables ---------- */
table{width:100%;border-collapse:collapse;font-size:13px;}
th{text-align:left;color:var(--ink-soft);font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.03em;padding:10px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:var(--surface);z-index:1;}
td{padding:10px 12px;border-bottom:1px solid var(--line);}
tr:last-child td{border-bottom:none;}
tbody tr:nth-child(even){background:var(--surface-2);}
tbody tr:hover{background:var(--line);}
th.sortable{cursor:pointer;user-select:none;}
th.sortable:hover{color:var(--ink);}
th.sortable::after{content:'⇅';margin-left:5px;opacity:.35;font-size:10px;}
th.sortable.sort-asc::after{content:'↑';opacity:1;color:var(--teal);}
th.sortable.sort-desc::after{content:'↓';opacity:1;color:var(--teal);}
.table-pager{display:flex;align-items:center;justify-content:center;gap:14px;padding:12px;border-top:1px solid var(--line);font-size:12.5px;}
.pager-btn{padding:6px 12px;border-radius:7px;border:1px solid var(--line);background:var(--surface-2);color:var(--ink);font-size:12.5px;font-weight:600;}
.pager-btn:hover:not(:disabled){background:var(--line);}
.pager-btn:disabled{opacity:.4;cursor:not-allowed;}
.pager-info{color:var(--ink-soft);}
.badge{font-size:11px;padding:3px 8px;border-radius:999px;font-weight:600;}
.badge-ok{background:#E7F5E9;color:var(--success);}
.badge-low{background:#FDEDE1;color:var(--warning);}
.badge-out{background:#FBE7E7;color:var(--danger);}
.badge-admin{background:#E9F1FD;color:#2563A6;}
.badge-cashier{background:#F1EEFB;color:#6C4FBE;}
.row-actions{display:flex;gap:6px;}
.icon-btn{width:28px;height:28px;border-radius:7px;border:1px solid var(--line);background:var(--surface-2);color:var(--ink);font-size:12px;display:inline-flex;align-items:center;justify-content:center;}
.icon-btn:hover{background:var(--line);}
.icon-btn .icon{width:14px;height:14px;}
.icon{width:18px;height:18px;flex-shrink:0;}
.toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;gap:10px;flex-wrap:wrap;}
.search-input{padding:9px 12px;border:1px solid var(--line);border-radius:8px;width:240px;max-width:100%;background:var(--surface);color:var(--ink);}

/* ---------- Modal ---------- */
.modal-overlay{position:fixed;inset:0;background:rgba(20,22,24,.5);display:flex;align-items:center;justify-content:center;z-index:50;padding:20px;}
/* Modals toggled by JS via the .is-open class (calculator, help, confirm
   dialogs, and any data-modal-open popover) need an explicit default-hidden
   rule that beats the .modal-overlay default above — unlike the modals that
   PHP only renders into the page when they should be shown (inventory/
   customers/users add-edit modals), which have no .is-open toggle at all. */
.modal-overlay.js-toggle-modal{display:none;}
.modal-overlay.js-toggle-modal.is-open{display:flex;}
.modal{background:var(--surface);border-radius:14px;width:420px;max-width:100%;max-height:88vh;overflow-y:auto;padding:22px;}
.modal h3{font-family:var(--font-display);margin:0 0 16px;font-size:18px;}
.form-row{margin-bottom:12px;}
.form-row label{display:block;font-size:12px;font-weight:600;color:var(--ink-soft);margin-bottom:5px;}
.form-row input, .form-row select{width:100%;padding:9px 11px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--ink);font-size:13.5px;}
.form-grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px;}

/* ---------- Stat cards / reports ---------- */
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px;margin-bottom:20px;}
.stat-card{padding:16px;}
.stat-label{font-size:11.5px;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.03em;font-weight:600;}
.stat-value{font-family:var(--font-display);font-size:24px;font-weight:700;margin-top:6px;}
.bar-row{display:flex;align-items:center;gap:10px;margin-bottom:10px;}
.bar-label{width:150px;font-size:12.5px;flex-shrink:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.bar-track{flex:1;background:var(--surface-2);border-radius:6px;height:16px;overflow:hidden;}
.bar-fill{height:100%;background:var(--teal);border-radius:6px;}
.bar-val{width:70px;text-align:right;font-family:var(--font-mono);font-size:12px;color:var(--ink-soft);}
.date-tabs{display:flex;gap:6px;}
.date-tabs a{padding:7px 12px;border-radius:8px;border:1px solid var(--line);background:var(--surface);font-size:12.5px;font-weight:500;}
.date-tabs a.active{background:var(--ink);color:var(--bg);border-color:var(--ink);}

.empty-state{text-align:center;padding:50px 20px;color:var(--ink-soft);}
.empty-state .big{font-size:32px;margin-bottom:8px;}

/* ---------- Dashboard ---------- */
.quick-actions{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px;}
.qa-btn{display:flex;align-items:center;gap:8px;padding:12px 16px;border-radius:10px;border:1px solid var(--line);background:var(--surface);font-weight:600;font-size:13px;color:var(--ink);box-shadow:var(--shadow-sm);transition:.12s;}
.qa-btn:hover{border-color:var(--teal);box-shadow:var(--shadow-md);transform:translateY(-1px);}
.qa-btn .icon{color:var(--teal);}
.dash-grid{display:grid;grid-template-columns:1.3fr 1fr;gap:16px;align-items:start;}
.dash-chart{width:100%;height:auto;display:block;}
.dash-bar{fill:var(--teal);}
.dash-bar-label{font-size:9px;fill:var(--ink-soft);font-family:var(--font-body);}
@media (max-width: 900px){
  .dash-grid{grid-template-columns:1fr;}
}

.alert{padding:10px 14px;border-radius:8px;font-size:13px;margin-bottom:14px;}
.alert-error{background:#FBE7E7;color:var(--danger);}
.alert-success{background:#E7F5E9;color:var(--success);}
.alert-warning{background:#FDEDE1;color:var(--warning);}

.low-stock-nudge{display:flex;align-items:center;gap:8px;background:#FDEDE1;color:var(--warning);padding:10px 14px;border-radius:8px;font-size:13px;font-weight:600;margin-bottom:14px;flex-wrap:wrap;}
.low-stock-nudge .icon{width:16px;height:16px;flex-shrink:0;}
.low-stock-nudge a{text-decoration:underline;font-weight:700;}

/* ---------- Pharmacy link row ---------- */
.mobile-link-row{display:flex;gap:10px;align-items:center;}
.mobile-link-row input{flex:1;font-family:var(--font-mono);font-size:12.5px;}

/* ---------- Calculator ---------- */
.calc-modal{width:300px;}
.calc-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;}
.calc-key{padding:14px 0;border-radius:8px;border:1px solid var(--line);background:var(--surface-2);color:var(--ink);font-size:16px;font-family:var(--font-mono);font-weight:600;}
.calc-key:hover{background:var(--line);}
.calc-key-op{background:var(--surface);color:var(--teal-dark);}
.calc-key-eq{background:var(--teal);color:#fff;border-color:var(--teal);}
.calc-key-eq:hover{background:var(--teal-dark);}

/* ---------- Help modal ---------- */
.help-section h4{font-family:var(--font-display);font-size:13.5px;margin:16px 0 6px;}
.help-section h4:first-child{margin-top:0;}
.help-section ul{margin:0 0 4px;padding-left:18px;font-size:13px;line-height:1.6;color:var(--ink);}
.help-section li{margin-bottom:2px;}

/* ---------- Print receipt ---------- */
.print-only{display:none;}
.print-tip{font-size:11.5px;color:var(--ink-soft);margin-top:10px;text-align:center;}
@media print{
  html, body{width:100%;height:auto;margin:0;padding:0;}
  @page{ size:auto; margin:2mm; }

  body *{visibility:hidden;}
  .print-only, .print-only *{visibility:visible;}

  .print-only{
    display:block !important;
    position:absolute;
    top:0; left:0;
    width:100%;
    max-width:100%;
    margin:0;
    padding:0 2mm;
    box-sizing:border-box;
    font-family:'IBM Plex Mono',monospace;
    font-size:13px;
    line-height:1.55;
    color:#000;
    page-break-after:avoid;
    page-break-inside:avoid;
  }

  /* Let every element stretch to fill whatever paper width the printer uses,
     and wrap instead of overflowing or getting clipped on narrow rolls. */
  .print-only *{
    max-width:100%;
    box-sizing:border-box;
  }

  .print-only .pr-title{
    font-weight:700;
    font-size:15px;
    text-align:center;
    width:100%;
    overflow-wrap:break-word;
    word-break:break-word;
  }

  .print-only .pr-sub{
    text-align:center;
    font-size:11px;
    line-height:1.5;
    margin-bottom:8px;
    width:100%;
    overflow-wrap:break-word;
    word-break:break-word;
  }

  .print-only hr{
    border:none;
    border-top:1px dashed #000;
    margin:6px 0;
    width:100%;
  }

  .print-only .pr-line{
    display:flex;
    flex-wrap:nowrap;
    justify-content:space-between;
    align-items:baseline;
    gap:0 6px;
    width:100%;
    padding:2px 0;
  }
  .print-only .pr-line span:first-child{
    flex:1 1 auto;
    min-width:0;
    overflow-wrap:break-word;
    word-break:break-word;
  }
  .print-only .pr-line span:last-child{
    flex:0 0 62px;
    width:62px;
    white-space:nowrap;
    text-align:right;
    font-variant-numeric:tabular-nums;
  }

  .print-only .pr-tot{
    font-weight:700;
    font-size:14px;
  }

  .print-only .pr-meta{
    display:flex;
    flex-wrap:nowrap;
    justify-content:space-between;
    align-items:baseline;
    gap:8px;
    width:100%;
    padding:1px 0;
    font-size:11px;
  }
  .print-only .pr-meta-label{
    flex:0 0 auto;
    font-weight:600;
    white-space:nowrap;
  }
  .print-only .pr-meta-value{
    flex:1 1 auto;
    min-width:0;
    overflow-wrap:break-word;
    word-break:break-word;
  }

  .cheatsheet-print{font-size:12px;line-height:1.5;}
  .cheatsheet-print .cs-section{margin:8px 0;}
  .cheatsheet-print .cs-section b{display:block;font-size:12.5px;margin-bottom:2px;}
}

@media (max-width: 900px){
  .sidebar{position:fixed;top:0;left:0;bottom:0;z-index:40;box-shadow:0 0 0 100vw rgba(0,0,0,0);}
  .sidebar:not(.collapsed){box-shadow:20px 0 40px rgba(0,0,0,.25);}
  .pos-grid{grid-template-columns:1fr;}
  .receipt{position:static;}
}

@media (max-width: 640px){
  .main{padding:14px 14px 28px;}
  .page-title{font-size:19px;}
  .page-head{margin-bottom:14px;}
  .login-card{padding:22px;}

  /* Tables scroll horizontally instead of squashing columns unreadably. */
  .card{overflow-x:auto;-webkit-overflow-scrolling:touch;}
  table{font-size:12px;}
  th, td{padding:8px 9px;white-space:nowrap;}

  /* Checkout is the one screen meant to be used one-handed on a phone (via
     the QR/phone-access link in Settings), so it gets a leaner column set
     instead of horizontal scrolling — Category/Barcode/Status matter less
     for a quick tap-to-add than seeing Product/Price/Stock at a glance. */
  #product-grid th:nth-child(2), #product-grid td:nth-child(2),
  #product-grid th:nth-child(3), #product-grid td:nth-child(3),
  #product-grid th:nth-child(6), #product-grid td:nth-child(6){
    display:none;
  }
  #product-grid td:first-child{white-space:normal;}

  .toolbar{flex-direction:column;align-items:stretch;}
  .search-input{width:100%;}

  .form-grid2{grid-template-columns:1fr;}
  .modal{padding:16px;}
  .calc-modal{width:100%;}

  .stat-grid{grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;}
  .bar-label{width:90px;font-size:11px;}
  .bar-val{width:56px;font-size:11px;}

  /* Bigger touch targets for the cart's +/- and remove controls. */
  .r-qty-ctrl button{width:26px;height:26px;font-size:14px;}
  .r-rm{font-size:14px;padding:4px;}
}

/* ---------- Toast notifications ---------- */
.toast-container{position:fixed;bottom:20px;right:20px;z-index:200;display:flex;flex-direction:column;gap:10px;width:340px;max-width:calc(100vw - 40px);}
.toast{display:flex;align-items:flex-start;gap:10px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-left:3px solid var(--ink-soft);padding:12px 12px 12px 14px;border-radius:10px;font-size:13px;box-shadow:var(--shadow-lg);opacity:0;transform:translateY(10px);transition:opacity .2s ease, transform .2s ease;}
.toast.is-visible{opacity:1;transform:translateY(0);}
.toast-icon{flex-shrink:0;margin-top:1px;}
.toast-icon .icon{width:17px;height:17px;}
.toast-msg{flex:1;line-height:1.45;}
.toast-close{background:none;border:none;color:var(--ink-soft);cursor:pointer;flex-shrink:0;padding:2px;line-height:0;}
.toast-close .icon{width:13px;height:13px;}
.toast-success{border-left-color:var(--success);}
.toast-success .toast-icon{color:var(--success);}
.toast-error{border-left-color:var(--danger);}
.toast-error .toast-icon{color:var(--danger);}
.toast-warning{border-left-color:var(--warning);}
.toast-warning .toast-icon{color:var(--warning);}
.toast-info{border-left-color:var(--teal);}
.toast-info .toast-icon{color:var(--teal);}

/* ---------- Confirm dialog ---------- */
.confirm-modal{width:360px;text-align:center;}
.confirm-modal h3{text-align:center;}
.confirm-icon{width:46px;height:46px;border-radius:50%;background:var(--surface-2);display:flex;align-items:center;justify-content:center;margin:0 auto 14px;color:var(--warning);}
.confirm-icon .icon{width:22px;height:22px;}
.confirm-message{color:var(--ink-soft);font-size:13.5px;margin:0 0 4px;line-height:1.55;}
.confirm-modal .modal-actions{justify-content:center;}

/* ---------- Page loading overlay ---------- */
.page-loading-overlay{position:fixed;inset:0;background:rgba(20,22,24,.45);display:none;align-items:center;justify-content:center;z-index:300;}
.page-loading-overlay.is-open{display:flex;}
.page-loading-spinner{width:46px;height:46px;border-radius:50%;border:4px solid rgba(255,255,255,.3);border-top-color:#fff;animation:page-loading-spin .7s linear infinite;}
@keyframes page-loading-spin{to{transform:rotate(360deg);}}

@media (max-width: 640px){
  .toast-container{left:14px;right:14px;bottom:14px;width:auto;max-width:none;}
}

/* ---------- Medication catalog live-search dropdown (inventory.php) ---------- */
.med-search-wrap{position:relative;}
.med-search-results{position:absolute;left:0;right:0;top:calc(100% + 4px);z-index:60;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-md);max-height:260px;overflow-y:auto;display:none;}
.med-search-results.is-open{display:block;}
.med-search-result{display:block;width:100%;text-align:left;background:none;border:none;border-bottom:1px solid var(--line);padding:9px 12px;cursor:pointer;font-family:var(--font-body);color:var(--ink);}
.med-search-result:last-child{border-bottom:none;}
.med-search-result:hover,.med-search-result:focus{background:var(--surface-2);}
.med-search-result b{font-size:13.5px;}
.med-search-result .page-sub{font-size:11.5px;margin-top:1px;}
.med-search-hint{padding:9px 12px;font-size:12px;color:var(--ink-soft);}