/* ==========================================================================
   CSC POS — Theme 2026
   Drop-in skin for Bootstrap 5.3 pages. Load AFTER bootstrap.min.css.
   Sections: 1 Tokens · 2 Base · 3 App shell · 4 Components · 5 Dashboard kit
             6 Mobile · 7 Print · 8 Motion
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9ecf5;
  --border: #e4e7f0;
  --text: #0f172a;
  --muted: #64748b;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eceefe;
  --primary-rgb: 79, 70, 229;
  --accent: #06b6d4;

  --success: #059669;  --success-soft: #dcfce7;
  --warning: #b45309;  --warning-soft: #fef3c7;
  --danger:  #dc2626;  --danger-soft:  #fee2e2;
  --info:    #0369a1;  --info-soft:    #e0f2fe;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(var(--primary-rgb), .25);

  --sidebar-w: 268px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* Bootstrap bridge */
  --bs-font-sans-serif: var(--font);
  --bs-body-font-family: var(--font);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-secondary-color: var(--muted);
  --bs-border-color: var(--border);
  --bs-primary: var(--primary);
  --bs-primary-rgb: var(--primary-rgb);
  --bs-link-color: var(--primary);
  --bs-link-hover-color: var(--primary-hover);
  --bs-link-color-rgb: var(--primary-rgb);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-success-rgb: 5, 150, 105;
  --bs-danger-rgb: 220, 38, 38;
  --bs-warning-rgb: 217, 119, 6;
  --bs-info-rgb: 3, 105, 161;
  color-scheme: light;
}

[data-bs-theme="dark"] {
  --bg: #0b0e17;
  --surface: #131826;
  --surface-2: #1a2132;
  --surface-3: #232b40;
  --border: #252d42;
  --text: #e7eaf3;
  --muted: #98a2b8;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, .14);
  --primary-rgb: 129, 140, 248;

  --success: #34d399;  --success-soft: rgba(52, 211, 153, .14);
  --warning: #fbbf24;  --warning-soft: rgba(251, 191, 36, .14);
  --danger:  #f87171;  --danger-soft:  rgba(248, 113, 113, .14);
  --info:    #38bdf8;  --info-soft:    rgba(56, 189, 248, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  --bs-success-rgb: 52, 211, 153;
  --bs-danger-rgb: 248, 113, 113;
  --bs-warning-rgb: 251, 191, 36;
  --bs-info-rgb: 56, 189, 248;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  color-scheme: dark;
}

/* ---------- 2. Base ------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: .9375rem;
  line-height: 1.55;
  padding: 0 !important;          /* legacy header used body padding-top */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 650; letter-spacing: -.01em; }
a { text-decoration: none; }
.text-muted, .text-body-secondary { color: var(--muted) !important; }
.tnum, .table td, .kpi-value, h4, h5 { font-variant-numeric: tabular-nums; }
::selection { background: rgba(var(--primary-rgb), .25); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 3000; background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: 10px; transition: top .15s;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- 3. App shell ------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.app.no-sidebar { grid-template-columns: minmax(0, 1fr); }

.app-sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 1040;
}
.brand {
  display: flex; align-items: center; gap: 12px; padding: 18px 20px; min-height: var(--topbar-h);
  color: var(--text); font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  color: #fff; font-size: 1.05rem;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 60%, var(--accent) 140%);
  box-shadow: 0 6px 16px rgba(var(--primary-rgb), .35);
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.brand-sub { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.side-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 16px; overscroll-behavior: contain; }
.nav-group-label {
  padding: 18px 12px 6px; font-size: .68rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0;
  border-radius: 10px; color: var(--muted); font-weight: 520; font-size: .9rem; position: relative;
  transition: background .15s, color .15s;
}
.side-link i { width: 20px; text-align: center; font-size: .95rem; flex: none; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.side-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--primary);
}
.side-link.is-alert { color: var(--danger); }
.side-link .pill { margin-left: auto; }

.side-user {
  margin: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
}
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; color: var(--primary); background: var(--primary-soft);
}
.side-user-meta { min-width: 0; flex: 1; line-height: 1.25; }
.side-user-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: .72rem; color: var(--muted); text-transform: capitalize; }
.side-user .btn-icon { margin-left: auto; }

.app-main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }

.app-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h); padding: 0 28px;
  padding-top: var(--safe-t); box-sizing: content-box;
  display: flex; align-items: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-title h1 {
  margin: 0; font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title .t-icon {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-size: .95rem;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--muted); font-size: 1rem; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.bordered { border-color: var(--border); background: var(--surface); }
.menu-toggle { display: none; }
.theme-toggle .fa-sun { display: none; }
[data-bs-theme="dark"] .theme-toggle .fa-sun { display: inline; }
[data-bs-theme="dark"] .theme-toggle .fa-moon { display: none; }

.main-content { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 28px; margin-left: 0 !important; min-height: 0 !important; }
#pageTitle { display: none; }
.app-footer {
  padding: 18px 28px; color: var(--muted); font-size: .78rem; display: flex; flex-wrap: wrap; gap: 8px 20px;
  justify-content: space-between; border-top: 1px solid var(--border); margin-top: 24px;
}

/* Subscription banner */
.expired-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 20px;
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius); color: var(--text);
}
.expired-banner i { color: var(--danger); font-size: 1.3rem; }
.expired-banner .grow { flex: 1; min-width: 0; }

/* Bottom nav (mobile) + drawer scrim */
.bottom-nav { display: none; }
.scrim {
  position: fixed; inset: 0; background: rgba(8, 11, 22, .55); z-index: 1035; opacity: 0; visibility: hidden;
  transition: opacity .2s, visibility .2s; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.scrim.show { opacity: 1; visibility: visible; }

/* ---------- 4. Components ------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border) !important; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); margin-bottom: 20px; color: var(--text);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--border); padding: 16px 20px; font-weight: 650;
  font-size: 1rem; border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-header h5, .card-header h6, .card-header .card-title { font-size: 1rem; font-weight: 650; margin: 0; }
.card-header i { color: var(--primary); }
.card-header[class*="bg-"] { color: #fff; }
.card-header[class*="bg-"] i { color: inherit; }
.card-body { padding: 20px; }
.card-footer { background: transparent; border-top: 1px solid var(--border); }

.btn {
  --bs-btn-border-radius: 10px; font-weight: 600; font-size: .875rem; padding: .55rem 1rem;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
}
.btn { background-image: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-sm { padding: .38rem .7rem; font-size: .8rem; --bs-btn-border-radius: 8px; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; --bs-btn-border-radius: 12px; }
.btn:focus-visible { box-shadow: var(--ring); outline: none; }
.btn-primary {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover); --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover); --bs-btn-color: #fff; --bs-btn-hover-color: #fff;
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(var(--primary-rgb), .3), 0 4px 12px rgba(var(--primary-rgb), .22);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b0e17; --bs-btn-hover-color: #0b0e17; --bs-btn-active-color: #0b0e17; }
.btn-outline-primary {
  --bs-btn-color: var(--primary); --bs-btn-border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  --bs-btn-hover-bg: var(--primary-soft); --bs-btn-hover-color: var(--primary); --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary-soft); --bs-btn-active-color: var(--primary); --bs-btn-active-border-color: var(--primary);
}
.btn-outline-secondary {
  --bs-btn-color: var(--text); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-2);
  --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border);
  --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: var(--text);
}
.btn-outline-secondary, .btn-outline-primary { color: var(--bs-btn-color); }
.btn-outline-secondary:hover, .btn-outline-primary:hover { color: var(--bs-btn-hover-color); }
.btn-light { --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--border); --bs-btn-color: var(--text);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border); }
.btn-success { --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: color-mix(in srgb, var(--success) 85%, #000); --bs-btn-hover-border-color: var(--success); }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); --bs-btn-hover-bg: color-mix(in srgb, var(--danger) 85%, #000); --bs-btn-hover-border-color: var(--danger); }
[data-bs-theme="dark"] .btn-success, [data-bs-theme="dark"] .btn-danger { --bs-btn-color: #0b0e17; --bs-btn-hover-color: #0b0e17; }

.form-control, .form-select {
  background-color: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  padding: .6rem .85rem; font-size: .9375rem; min-height: 42px;
}
.form-control::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.form-control:focus, .form-select:focus {
  background-color: var(--surface); color: var(--text); border-color: var(--primary); box-shadow: var(--ring);
}
.form-control:disabled, .form-control[readonly], .form-select:disabled { background: var(--surface-2); opacity: .85; }
.form-label { font-weight: 600; font-size: .82rem; color: var(--text); margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); border-radius: 10px; }

/* Soft badges: any .badge.bg-* becomes a tinted pill */
.badge { font-weight: 600; font-size: .72rem; padding: .38em .7em; border-radius: 999px; letter-spacing: .01em; }
.badge[class*="bg-"] { color: var(--_c) !important; background: var(--_s) !important; }
.badge.bg-success, .badge.text-bg-success { --_c: var(--success); --_s: var(--success-soft); }
.badge.bg-warning, .badge.text-bg-warning { --_c: var(--warning); --_s: var(--warning-soft); }
.badge.bg-danger,  .badge.text-bg-danger  { --_c: var(--danger);  --_s: var(--danger-soft); }
.badge.bg-info,    .badge.text-bg-info    { --_c: var(--info);    --_s: var(--info-soft); }
.badge.bg-primary, .badge.text-bg-primary { --_c: var(--primary); --_s: var(--primary-soft); }
.badge.bg-secondary, .badge.bg-dark, .badge.bg-light { --_c: var(--muted); --_s: var(--surface-2); }
.pill { display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); }

/* Tables */
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--surface-2); --bs-table-hover-color: var(--text);
  --bs-table-striped-bg: var(--surface-2); --bs-table-striped-color: var(--text);
  margin-bottom: 0; vertical-align: middle;
}
.table > :not(caption) > * > * { padding: .8rem 1rem; }
.table thead th, .table-light, .table-light > th, .table > thead.table-light > tr > th {
  --bs-table-bg: var(--surface-2); --bs-table-color: var(--muted); --bs-table-border-color: var(--border);
  background: var(--surface-2) !important; color: var(--muted) !important; font-size: .72rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.table-responsive { border-radius: inherit; -webkit-overflow-scrolling: touch; }
.card > .table-responsive:last-child, .card-body.p-0 > .table-responsive { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-2); }
.bg-light { background-color: var(--surface-2) !important; }
.bg-white { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--text) !important; }
.border-top, .border-bottom, .border, hr { border-color: var(--border) !important; }

/* Modals, dropdowns, alerts, lists, tabs */
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); padding: 16px 22px; }
.modal-body { padding: 22px; }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-backdrop.show { opacity: .55; }
.dropdown-menu { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.dropdown-item { border-radius: 8px; padding: 9px 12px; color: var(--text); font-weight: 500; font-size: .875rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.alert { border-radius: var(--radius); border-width: 1px; }
.list-group-item { background: transparent; border-color: var(--border); color: var(--text); }
.nav-tabs { border-color: var(--border); }
.nav-tabs .nav-link { color: var(--muted); border: 0; border-bottom: 2px solid transparent; font-weight: 600; }
.nav-tabs .nav-link.active { background: transparent; color: var(--primary); border-bottom-color: var(--primary); }
.pagination { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text);
  --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary);
  --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-border-radius: 10px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); }
.progress-bar { background: var(--primary); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.toast-container-2026 { position: fixed; right: 16px; top: calc(var(--topbar-h) + 12px); z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.t-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: 14px; box-shadow: var(--shadow-lg); animation: toast-in .25s ease; }
.t-item.success { border-left-color: var(--success); } .t-item.danger, .t-item.error { border-left-color: var(--danger); }
.t-item.warning { border-left-color: var(--warning); }
.t-item .t-msg { flex: 1; font-size: .875rem; }
.t-item button { background: none; border: 0; color: var(--muted); cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 5. Dashboard kit -------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h2 { font-size: 1.6rem; margin: 0; font-weight: 750; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: .95rem; color: var(--_c); background: var(--_s); }
.kpi-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; }
.kpi-sub { margin-top: 8px; font-size: .8rem; color: var(--muted); }
.kpi.primary { --_c: var(--primary); --_s: var(--primary-soft); }
.kpi.success { --_c: var(--success); --_s: var(--success-soft); }
.kpi.warning { --_c: var(--warning); --_s: var(--warning-soft); }
.kpi.danger  { --_c: var(--danger);  --_s: var(--danger-soft); }
.kpi.info    { --_c: var(--info);    --_s: var(--info-soft); }
.kpi.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 70%, #0ea5e9 150%); color: #fff; border: 0;
  box-shadow: 0 12px 32px rgba(79, 70, 229, .35);
}
.kpi.hero .kpi-label, .kpi.hero .kpi-sub { color: rgba(255, 255, 255, .78); }
.kpi.hero .kpi-icon { background: rgba(255, 255, 255, .18); color: #fff; }

.mini-grid { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 20px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.mini .m-label { font-size: .72rem; color: var(--muted); font-weight: 600; }
.mini .m-value { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }

.grid-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); margin-bottom: 20px; }
.grid-2 > .card, .grid-2 > div > .card { margin-bottom: 0; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack > .card { margin-bottom: 0; }

.bars { display: flex; align-items: flex-end; gap: clamp(6px, 2vw, 18px); height: 190px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; min-width: 0; }
.bar-fill {
  width: 100%; max-width: 54px; border-radius: 10px 10px 4px 4px; min-height: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 55%, transparent), color-mix(in srgb, var(--primary) 20%, transparent));
  transition: filter .15s, transform .15s; transform-origin: bottom;
}
.bar.today .bar-fill { background: linear-gradient(180deg, var(--primary), #7c3aed); box-shadow: 0 6px 16px rgba(var(--primary-rgb), .35); }
.bar:hover .bar-fill { filter: brightness(1.1); }
.bar-val { font-size: .68rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.bar-day { font-size: .72rem; font-weight: 600; color: var(--muted); }
.bar.today .bar-day { color: var(--primary); }

.rank { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-row:first-child { padding-top: 0; }
.rank-n { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.rank-row:nth-child(1) .rank-n { background: var(--warning-soft); color: var(--warning); }
.rank-main { flex: 1; min-width: 0; }
.rank-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-sub { font-size: .76rem; color: var(--muted); }
.rank-amt { font-weight: 700; font-size: .9rem; white-space: nowrap; }

.split-row { margin-bottom: 14px; }
.split-row .progress { margin-top: 6px; }
.split-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .86rem; }

.empty-state { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty-state i { display: block; font-size: 1.8rem; margin-bottom: 10px; opacity: .45; }

.summary-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
.summary-list dt { font-size: .74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-list dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; }

/* Compact bill rows for phones (dashboard "Recent bills") */
.bill-list { display: flex; flex-direction: column; }
.bill-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--border); color: var(--text); }
.bill-item:first-child { border-top: 0; }
.bill-item:active { background: var(--surface-2); }
.bill-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.bill-top strong { color: var(--primary); font-size: .92rem; flex: none; }
.bill-cust { color: var(--text); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-meta { margin-top: 5px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.bill-amt { text-align: right; font-weight: 700; white-space: nowrap; }
.bill-amt small { display: block; font-weight: 500; color: var(--muted); font-size: .7rem; }
.bill-main { min-width: 0; }
.nowrap { white-space: nowrap; }

/* ---------- 6. Mobile ---------------------------------------------------- */
@media (max-width: 1199.98px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 991.98px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%);
    transition: transform .25s cubic-bezier(.32, .72, 0, 1); box-shadow: var(--shadow-lg);
    padding-top: var(--safe-t); padding-bottom: var(--safe-b);
  }
  .app-sidebar.open { transform: none; }
  .menu-toggle { display: inline-grid; }
  .app-topbar { padding-left: 12px; padding-right: 14px; --topbar-h: 58px; }
  .main-content { padding: 16px 14px calc(var(--bottomnav-h) + var(--safe-b) + 20px); }
  .app-footer { padding: 16px 14px calc(var(--bottomnav-h) + var(--safe-b) + 12px); }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: calc(var(--bottomnav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--muted); font-size: .66rem; font-weight: 600; padding: 6px 2px; min-width: 0; position: relative;
  }
  .bn-item i { font-size: 1.15rem; }
  .bn-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bn-item[aria-current="page"] { color: var(--primary); }
  .bn-item[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primary); }
  .bn-item.bn-fab i {
    width: 46px; height: 46px; margin-top: -22px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 1.15rem;
    background: linear-gradient(135deg, var(--primary), #7c3aed); box-shadow: 0 8px 20px rgba(var(--primary-rgb), .45); border: 3px solid var(--bg);
  }
  .bn-item.bn-fab { color: var(--text); }
  body.no-bottom-nav .bottom-nav { display: none; }
  body.no-bottom-nav .main-content { padding-bottom: calc(var(--safe-b) + 16px); }
  .toast-container-2026 { top: auto; bottom: calc(var(--bottomnav-h) + var(--safe-b) + 12px); right: 12px; left: 12px; width: auto; }
}

@media (max-width: 767.98px) {
  body { font-size: 1rem; }
  .topbar-title h1 { font-size: 1.05rem; }
  .topbar-title .t-icon { display: none; }
  .page-head h2 { font-size: 1.35rem; }
  .quick-actions { width: 100%; } .quick-actions .btn { flex: 1; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-icon { width: 32px; height: 32px; font-size: .8rem; }
  .kpi-label { font-size: .68rem; }
  .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2.even { grid-template-columns: 1fr; }
  .card-body { padding: 16px; } .card-header { padding: 14px 16px; }
  .summary-list { grid-template-columns: 1fr 1fr; }

  /* 16px inputs stop iOS zoom; 44px targets */
  .form-control, .form-select, .btn { font-size: 1rem; min-height: 44px; }
  .btn-sm { min-height: 38px; font-size: .875rem; }
  .btn-group-sm > .btn { min-height: 38px; }

  /* Modals → bottom sheets */
  .modal-dialog:not(.modal-fullscreen) { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; width: 100%; min-height: 0; align-items: flex-end; }
  .modal.fade .modal-dialog { transform: translateY(100%); transition: transform .3s cubic-bezier(.32, .72, 0, 1); }
  .modal.show .modal-dialog { transform: none; }
  .modal-content { border-radius: 22px 22px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); }
  .modal-body { overflow-y: auto; }

  /* Tables → stacked cards (applied by theme-2026.js, opt-out with .no-stack) */
  table.is-stacked { display: block; width: 100%; }
  table.is-stacked thead { display: none; }
  table.is-stacked tbody { display: grid; gap: 12px; padding: 12px; }
  table.is-stacked tr {
    display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px;
    box-shadow: var(--shadow-sm);
  }
  table.is-stacked td {
    display: flex !important; justify-content: space-between; align-items: center; gap: 16px; text-align: right !important;
    padding: 9px 0 !important; border: 0 !important; border-bottom: 1px dashed var(--border) !important; background: transparent !important;
    min-width: 0; word-break: break-word;
  }
  table.is-stacked td:last-child { border-bottom: 0 !important; }
  table.is-stacked td::before {
    content: attr(data-label); flex: none; color: var(--muted); font-size: .72rem; font-weight: 650; text-transform: uppercase;
    letter-spacing: .05em; text-align: left; max-width: 45%;
  }
  table.is-stacked td:not([data-label])::before, table.is-stacked td[data-label=""]::before { display: none; }
  table.is-stacked td[colspan] { justify-content: center; text-align: center !important; }
  table.is-stacked td[colspan]::before { display: none; }
  table.is-stacked td.ps-3, table.is-stacked td.pe-3 { padding-left: 0 !important; padding-right: 0 !important; }
  table.is-stacked tfoot { display: block; padding: 0 12px 12px; } table.is-stacked tfoot tr { background: var(--surface-2); }
  .card:has(> .table-responsive > table.is-stacked), .card:has(.card-body.p-0 > .table-responsive > table.is-stacked) { background: transparent; border: 0 !important; box-shadow: none; }
  .card:has(table.is-stacked) > .card-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg) !important; margin-bottom: 4px; }
}

@media (max-width: 420px) {
  .kpi-grid { gap: 10px; }
  .bar-val { display: none; }
  .bars { height: 150px; }
}

/* Sticky action bar helper for long forms on phones: <div class="sticky-actions">…</div> */
@media (max-width: 991.98px) {
  .sticky-actions { position: sticky; bottom: calc(var(--bottomnav-h) + var(--safe-b)); background: var(--surface); padding: 12px 14px; margin: 16px -14px -4px; border-top: 1px solid var(--border); display: flex; gap: 10px; z-index: 20; }
  .sticky-actions .btn { flex: 1; }
}

/* ---------- 7. Print ----------------------------------------------------- */
@media print {
  .app-sidebar, .app-topbar, .bottom-nav, .scrim, .app-footer, .toast-container-2026, .skip-link, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff !important; color: #000 !important; }
  .main-content { padding: 0 !important; max-width: none; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  table.is-stacked { display: table !important; } table.is-stacked thead { display: table-header-group !important; }
  table.is-stacked tbody { display: table-row-group !important; padding: 0; }
  table.is-stacked tr { display: table-row !important; border: 0; box-shadow: none; padding: 0; }
  table.is-stacked td { display: table-cell !important; text-align: left !important; padding: 6px !important; }
  table.is-stacked td::before { display: none !important; }
}

/* ---------- 8. Motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
