/* =====================================================================
   Inventory & Billing — main stylesheet
   Change the colours in :root to re-theme the whole application.
   ===================================================================== */
:root {
  --primary: #15803d;
  --primary-600: #166534;
  --primary-50: #ecfdf3;
  --primary-100: #d1fadf;
  --accent: #0ea5e9;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --border: #e4e9e6;
  --text: #17231d;
  --text-2: #4b5a52;
  --muted: #7a8a82;
  --danger: #d92d20;
  --danger-50: #fef3f2;
  --warning: #b54708;
  --warning-50: #fffaeb;
  --info: #175cd3;
  --info-50: #eff8ff;
  --success: #067647;
  --success-50: #ecfdf3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #22c55e;
  --primary-600: #16a34a;
  --primary-50: #0f2a1b;
  --primary-100: #14532d;
  --bg: #0d1411;
  --surface: #141d19;
  --surface-2: #19241f;
  --border: #25332c;
  --text: #e6efe9;
  --text-2: #b4c4bb;
  --muted: #7f9288;
  --danger: #f97066;
  --danger-50: #3b1512;
  --warning: #fdb022;
  --warning-50: #3a2a0c;
  --info: #53b1fd;
  --info-50: #0b2440;
  --success: #47cd89;
  --success-50: #0f2a1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }

.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px; height: var(--topbar-h); border-bottom: 1px solid var(--border); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #0f766e); color: #fff; flex-shrink: 0; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 11px; }
.sidebar .sidebar-close { display: none; margin-left: auto; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.nav-heading { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); font-weight: 500; margin-bottom: 2px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-50); color: var(--primary); }
.nav-link.active .icon { color: var(--primary); }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.content { padding: 24px; flex: 1; width: 100%; max-width: 1500px; }
.app-footer { padding: 16px 24px 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

/* ---------------- Buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; text-decoration: none !important; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(21, 128, 61, .3); }
.btn-primary:hover { background: var(--primary-600); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-soft-danger { background: var(--danger-50); color: var(--danger); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.act { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.act:hover { color: var(--primary); border-color: var(--primary); text-decoration: none; }
.act.danger:hover { color: var(--danger); border-color: var(--danger); }
.act .icon { width: 15px; height: 15px; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 0; }
.theme-dark { display: none; }
[data-theme="dark"] .theme-dark { display: inline; }
[data-theme="dark"] .theme-light { display: none; }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; margin: 0; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.stat-icon.blue { background: var(--info-50); color: var(--info); }
.stat-icon.amber { background: var(--warning-50); color: var(--warning); }
.stat-icon.red { background: var(--danger-50); color: var(--danger); }
.stat-icon.teal { background: #e6f7f5; color: #0f766e; }
[data-theme="dark"] .stat-icon.teal { background: #0f2927; color: #2dd4bf; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-value { font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
.stat-sub { font-size: 12px; color: var(--text-2); }
.stat-body { min-width: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 230px; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.req { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.input, select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], input[type="tel"], input[type="url"] {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
textarea, textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 70px; }
select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8a82' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, select:focus, textarea:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[readonly], .input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 500; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-weight: 600; }
.input-group .addon:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: 0; }
.input-group .addon:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.input-group input { border-radius: 0; }
.input-group input:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.stock-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; background: var(--primary-50); color: var(--primary); font-weight: 700; }
.stock-pill.low { background: var(--warning-50); color: var(--warning); }
.stock-pill.out { background: var(--danger-50); color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; font-weight: 500; }
.is-invalid { border-color: var(--danger) !important; }

/* ---------------- Filter bar ---------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filter-bar select { width: auto; min-width: 150px; height: 34px; font-size: 13px; }
.filter-bar input[type="date"] { width: 150px; height: 34px; font-size: 13px; }
.search-input { position: relative; flex: 1 1 220px; min-width: 180px; max-width: 360px; }
.search-input .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.search-input input { padding-left: 34px; height: 34px; font-size: 13px; }
.period-group { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.custom-dates { display: flex; align-items: center; gap: 6px; }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-50) 50%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
.table tr.row-cancelled td { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.table tr.row-cancelled td.actions-cell, .table tr.row-cancelled td .badge { text-decoration: none; }
.table .cell-title { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 12px; color: var(--muted); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { width: 44px; height: 44px; color: var(--border); margin-bottom: 10px; }
.empty-state h3 { color: var(--text-2); font-size: 15px; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page-btn { min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { padding: 0 4px; color: var(--muted); align-self: center; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-red { background: var(--danger-50); color: var(--danger); }
.badge-amber { background: var(--warning-50); color: var(--warning); }
.badge-blue { background: var(--info-50); color: var(--info); }
.badge-gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* ---------------- Alerts ---------------- */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-50); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-50); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-50); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-success { background: var(--success-50); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }

/* ---------------- Lists (activity, low stock) ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .li-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.list .li-icon .icon { width: 16px; height: 16px; }
.list .li-icon.red { background: var(--danger-50); color: var(--danger); }
.list .li-icon.amber { background: var(--warning-50); color: var(--warning); }
.list .li-icon.blue { background: var(--info-50); color: var(--info); }
.list .li-main { flex: 1; min-width: 0; }
.list .li-title { font-weight: 600; }
.list .li-sub { font-size: 12px; color: var(--muted); }
.rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--surface-2); color: var(--text-2); flex-shrink: 0; }
.rank.r1 { background: #fef0c7; color: #93370d; } .rank.r2 { background: #eaecf0; color: #344054; } .rank.r3 { background: #fbe4d6; color: #772917; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.quick { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; }
.quick:hover { border-color: var(--primary); text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.quick .icon { color: var(--primary); width: 22px; height: 22px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; }
.totals { width: 100%; max-width: 360px; margin-left: auto; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; color: var(--primary); }

/* ---------------- Dropdowns ---------------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.open .dropdown-menu { display: block; animation: pop .14s ease; }
.dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; gap: 10px; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-foot { display: block; text-align: center; padding: 9px; font-weight: 600; font-size: 13px; border-top: 1px solid var(--border); margin-top: 4px; }
.profile-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; color: var(--text); font: inherit; font-weight: 600; padding: 4px; border-radius: 10px; }
.profile-btn:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #0f766e); color: #fff; font-weight: 700; }
.notif-menu { width: 340px; max-width: calc(100vw - 24px); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: 8px; color: var(--text); }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.unread { background: var(--primary-50); }
.notif-item .li-title { font-weight: 600; font-size: 13px; }
.notif-item .li-sub { font-size: 12px; color: var(--muted); }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); }
.notif-count { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(10, 20, 15, .5); backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-dialog { width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .16s ease; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.confirm-body { text-align: center; }
.confirm-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--danger-50); color: var(--danger); }
.confirm-icon .icon { width: 26px; height: 26px; }
.confirm-reason { text-align: left; margin-top: 12px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------- Toasts ---------------- */
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); width: 360px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); animation: slidein .25s ease; font-weight: 500; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: var(--success); } .toast.error .icon { color: var(--danger); } .toast.warning .icon { color: var(--warning); } .toast.info .icon { color: var(--info); }
.toast .toast-close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.toast.hide { opacity: 0; transform: translateX(20px); transition: all .25s; }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* Loading */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(255, 255, 255, .5); }
[data-theme="dark"] .loading-overlay { background: rgba(0, 0, 0, .4); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Sale form ---------------- */
.items-table td { padding: 8px 6px; vertical-align: top; }
.items-table th { padding: 8px 6px; }
.items-table input, .items-table select { height: 36px; font-size: 13px; padding: 0 8px; }
.items-table select { padding-right: 26px; min-width: 190px; }
.items-table .w-qty { width: 90px; } .items-table .w-money { width: 110px; } .items-table .w-gst { width: 80px; }
.items-table .meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.items-table .line-total { font-weight: 700; white-space: nowrap; padding-top: 16px; text-align: right; }
.summary-card { position: sticky; top: calc(var(--topbar-h) + 16px); }

/* ---------------- Login ---------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.auth-hero { background: linear-gradient(145deg, #14532d, #15803d 55%, #0f766e); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .06); right: -120px; bottom: -120px; }
.auth-hero h1 { font-size: 34px; letter-spacing: -.02em; max-width: 440px; }
.auth-hero p { opacity: .85; max-width: 420px; }
.auth-hero ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); padding: 32px; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-card h2 { font-size: 22px; }
.password-wrap { position: relative; }
.password-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; }

/* ---------------- Bottom nav (mobile) ---------------- */
.bottom-nav { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle, .sidebar .sidebar-close { display: inline-grid; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }
  .grid-2, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .summary-card { position: static; }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 16px; }
  .hide-sm { display: none !important; }
  .form-grid, .form-grid.cols-3, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; flex-direction: column; gap: 8px; }
  .stat-icon { width: 34px; height: 34px; }
  .stat-value { font-size: 16px; }
  .card-head, .card-body { padding: 14px 16px; }
  .filter-bar { padding: 12px 16px; }
  .filter-bar select, .search-input { flex: 1 1 100%; max-width: none; }
  .custom-dates { flex: 1 1 100%; }
  .custom-dates input { flex: 1; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); background: none; border: 0; font-family: inherit; text-decoration: none; padding: 4px 0; cursor: pointer; }
  .bottom-nav .active { color: var(--primary); }
  .bottom-nav .bottom-nav-main .icon { background: var(--primary); color: #fff; width: 38px; height: 38px; padding: 9px; border-radius: 50%; margin-top: -18px; box-shadow: 0 4px 12px rgba(21, 128, 61, .4); }
  .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; }
  .modal { padding: 0; place-items: end center; }
  .modal-dialog { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .app-footer { display: none; }
}

/* ---------------- Print ---------------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .filter-bar, .page-actions, .pagination, .no-print, .toast-stack, .actions-cell, .app-footer { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
form.inline { display: inline; margin: 0; }
