/* ==========================================================================
   M A L I K LedgerSystem UI
   Two themes chosen by <html data-bs-theme="dark|light"> (toggle in the top bar).
   Every colour that differs between themes is a token below; components use
   only tokens. Layout: phone (<768) drawer, tablet (768-1199) icon rail,
   desktop (>=1200) full sidebar or rail. Animations use transform/opacity only
   and are off for prefers-reduced-motion.
   ========================================================================== */

/* ---------- Tokens: shared ---------- */
:root {
    --topbar-h: 60px;
    --sidebar-w: 252px;
    --rail-w: 72px;
    --radius: 14px;
    --radius-sm: 9px;
    --ease: cubic-bezier(.2, .8, .2, 1);

    /* Sidebar is navy in both themes */
    --sidebar-bg: #070d19;
    --sidebar-bg-2: #0b1528;
    --sidebar-text: #9fb0d0;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-sm: 7px;
}

/* ---------- Tokens: dark (default) ---------- */
:root, [data-bs-theme="dark"] {
    color-scheme: dark;
    --bg: #0a101d;
    --surface: #111a2c;
    --surface-2: #162038;
    --surface-3: #1c2945;
    --input-bg: #0c1424;
    --border: #212e4a;
    --border-strong: #2d3d5f;
    --text: #e2e8f0;
    --text-strong: #f8fafc;
    --label: #cbd5e1;
    --muted: #94a3b8;
    --faint: #64748b;
    --topbar-bg: rgba(10, 16, 29, .82);
    --thead-bg: var(--surface-2);
    --card-thead-bg: rgba(0, 0, 0, .15);
    --group-text: #bfdbfe;

    --primary: #3b82f6;
    --btn-bg: #2563eb;
    --btn-hover: #3b82f6;
    --btn-active: #1d4ed8;
    --primary-text: #93c5fd;
    --primary-text-strong: #dbeafe;
    --primary-50: rgba(59, 130, 246, .12);
    --primary-100: rgba(59, 130, 246, .24);
    --primary-line: rgba(59, 130, 246, .35);
    --focus-ring: 0 0 0 4px rgba(59, 130, 246, .22);
    --hover-row: rgba(59, 130, 246, .06);
    --row-flash: rgba(59, 130, 246, .28);
    --avatar-bg: linear-gradient(135deg, rgba(99, 102, 241, .35), rgba(59, 130, 246, .3));
    --avatar-fg: #dbeafe;

    --success: #34d399;
    --danger: #f87171;
    --success-bg: rgba(52, 211, 153, .1);
    --success-fg: #6ee7b7;
    --danger-bg: rgba(248, 113, 113, .1);
    --danger-fg: #fca5a5;
    --muted-bg: rgba(148, 163, 184, .1);

    /* badge/tone colour pairs: fg on tinted bg */
    --violet-fg: #d8b4fe; --violet-bg: rgba(168, 85, 247, .16);
    --green-fg: #86efac;  --green-bg: rgba(34, 197, 94, .14);
    --rose-fg: #fda4af;   --rose-bg: rgba(244, 63, 94, .15);
    --teal-fg: #5eead4;   --teal-bg: rgba(20, 184, 166, .15);
    --amber-fg: #fcd34d;  --amber-bg: rgba(245, 158, 11, .15);
    --indigo-fg: #a5b4fc; --indigo-bg: rgba(99, 102, 241, .18);
    --blue-fg: #93c5fd;   --blue-bg: rgba(59, 130, 246, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 32px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .75);

    --bs-body-color: var(--text);
    --bs-body-bg: var(--surface);
    --bs-emphasis-color: var(--text-strong);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--border);
    --bs-primary: #3b82f6;
    --bs-primary-rgb: 59, 130, 246;
    --bs-link-color: #60a5fa;
    --bs-link-color-rgb: 96, 165, 250;
    --bs-link-hover-color-rgb: 147, 197, 253;
    --bs-danger-rgb: 248, 113, 113;
}

/* ---------- Tokens: light ---------- */
[data-bs-theme="light"] {
    color-scheme: light;
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --input-bg: #ffffff;
    --border: #e4e8f0;
    --border-strong: #d5dbe6;
    --text: #1e293b;
    --text-strong: #0f172a;
    --label: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --topbar-bg: rgba(255, 255, 255, .86);
    --thead-bg: var(--surface-2);
    --card-thead-bg: var(--surface-3);
    --group-text: #0f2a5c;

    --primary: #2563eb;
    --btn-bg: #2563eb;
    --btn-hover: #1d4ed8;
    --btn-active: #1e40af;
    --primary-text: #1d4ed8;
    --primary-text-strong: #1e3a8a;
    --primary-50: #eff5ff;
    --primary-100: #dbe7fe;
    --primary-line: #bcd0fb;
    --focus-ring: 0 0 0 4px rgba(37, 99, 235, .14);
    --hover-row: #f6f9ff;
    --row-flash: #dbe7fe;
    --avatar-bg: linear-gradient(135deg, #e0e7ff, #dbeafe);
    --avatar-fg: #1d4ed8;

    --success: #10b981;
    --danger: #dc2626;
    --success-bg: #ecfdf5;
    --success-fg: #047857;
    --danger-bg: #fef2f2;
    --danger-fg: #b91c1c;
    --muted-bg: #f1f5f9;

    --violet-fg: #7e22ce; --violet-bg: #f3e8ff;
    --green-fg: #15803d;  --green-bg: #dcfce7;
    --rose-fg: #be123c;   --rose-bg: #ffe4e6;
    --teal-fg: #0f766e;   --teal-bg: #ccfbf1;
    --amber-fg: #b45309;  --amber-bg: #fef3c7;
    --indigo-fg: #4338ca; --indigo-bg: #e0e7ff;
    --blue-fg: #1d4ed8;   --blue-bg: #e7efff;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -14px rgba(15, 23, 42, .14);
    --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, .3);

    --bs-body-color: var(--text);
    --bs-body-bg: #ffffff;
    --bs-emphasis-color: var(--text-strong);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--border);
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: #2563eb;
    --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color-rgb: 29, 78, 216;
    --bs-danger-rgb: 220, 38, 38;
}

/* Colour cross-fade only while switching theme (class added for ~400ms by app.js) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
    transition: background-color .35s ease, color .35s ease, border-color .35s ease, box-shadow .35s ease, fill .35s ease !important;
}

body { background: var(--bg); font-size: 14px; color: var(--text); -webkit-font-smoothing: antialiased; }
::selection { background: rgba(59, 130, 246, .4); color: #fff; }
.text-muted { color: var(--muted) !important; }
a { text-underline-offset: 2px; }
h1, h2, h3, h4, h5, h6, strong, b, .fw-bold, .fw-semibold { color: var(--text-strong); }
* { scrollbar-color: var(--border-strong) transparent; }

/* ---------- Motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes rowFlash { from { background-color: var(--row-flash); } to { background-color: transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floaty { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(24px, -18px); } }

.anim-in { animation: fadeUp .4s var(--ease) both; }
.stagger > * { animation: fadeUp .45s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(n+6) { animation-delay: .25s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 12px; height: var(--topbar-h);
    padding: 0 16px; background: var(--topbar-bg); backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex-shrink: 0; border: 0; border-radius: 10px;
    background: none; color: var(--muted); font-size: 17px; cursor: pointer; transition: background .15s, color .15s; }
.topbar-btn:hover { background: var(--surface-2); color: var(--text-strong); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 700; font-size: 18px; letter-spacing: -.3px; text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--text-strong); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px; color: #fff; font-size: 15px;
    background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 6px 18px -6px rgba(59, 130, 246, .8); }
.topbar-pin { margin-left: auto; align-items: center; gap: 6px; }
.topbar-pin select { width: 170px; border-radius: 9px; }
.pin-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 10px; border-radius: 9px; color: var(--muted);
    font-size: 13px; font-weight: 500; cursor: pointer; user-select: none; transition: background .15s, color .15s; }
.pin-toggle:hover { background: var(--surface-2); }
.pin-toggle input { display: none; }
.pin-toggle i { transition: transform .2s var(--ease); }
.pin-toggle:has(input:checked) { color: var(--primary-text); background: var(--primary-50); }
.pin-toggle:has(input:checked) i { transform: rotate(-30deg); }
.net-dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); margin: 0 4px 0 auto; }
.net-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, .2); }
@media (min-width: 768px) { .topbar-pin + .net-dot { margin-left: 8px; } }   /* pin box takes the auto margin when it is shown */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; line-height: 1.15; min-width: 0; }
.user-chip strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-chip small { color: var(--muted); font-size: 11.5px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
    background: var(--avatar-bg); color: var(--avatar-fg); font-weight: 700; font-size: 13px; box-shadow: inset 0 0 0 1px rgba(147, 197, 253, .2); }

/* Theme toggle: sun in dark mode (go light), moon in light mode (go dark) */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle i { position: absolute; transition: transform .45s var(--ease), opacity .3s; }
.theme-toggle .icon-sun { color: #fbbf24; }
[data-bs-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-bs-theme="light"]) .theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.4); }
[data-bs-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
[data-bs-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: none; color: #4f46e5; }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w); z-index: 1020; overflow: hidden auto;
    display: flex; flex-direction: column; background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    border-right: 1px solid rgba(255, 255, 255, .06); transform: translateX(-100%); transition: transform .28s var(--ease), width .28s var(--ease);
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .12) transparent; }
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.sidebar-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 1010; background: rgba(0, 0, 0, .5);
    opacity: 0; pointer-events: none; transition: opacity .25s; }
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
.side-label { padding: 22px 22px 8px; color: rgba(159, 176, 208, .5); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.side-menu, .side-sub { list-style: none; margin: 0; padding: 0; }
.side-menu { padding: 0 12px 16px; flex: 1; }
.side-item + .side-item { margin-top: 2px; }
.side-link { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px;
    background: none; color: var(--sidebar-text); font-weight: 500; white-space: nowrap; text-decoration: none; text-align: left; transition: background .15s, color .15s; }
.side-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px;
    background: rgba(255, 255, 255, .05); color: #c3cfe8; font-size: 13.5px; flex-shrink: 0; transition: background .2s, color .2s; }
.side-caret { margin-left: auto; font-size: 11px; opacity: .6; transition: transform .25s var(--ease); }
.side-item.expanded > .side-link .side-caret { transform: rotate(180deg); }
.side-item.active > .side-link { color: #fff; background: rgba(59, 130, 246, .14); }
.side-item.active > .side-link .side-icon { background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff; box-shadow: 0 6px 16px -6px rgba(59, 130, 246, .9); }
/* Smooth height animation without measuring: grid rows 0fr -> 1fr */
.side-sub-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s var(--ease); }
.side-item.expanded > .side-sub-wrap { grid-template-rows: 1fr; }
.side-sub { overflow: hidden; }
.side-sub a, .side-sub .soon { position: relative; display: block; margin: 1px 0; padding: 7px 12px 7px 56px; border-radius: 8px; color: var(--sidebar-text);
    font-size: 13.5px; white-space: nowrap; text-decoration: none; transition: background .15s, color .15s; }
.side-sub a::before { content: ""; position: absolute; left: 27px; top: 50%; width: 6px; height: 6px; border-radius: 50%;
    background: rgba(159, 176, 208, .3); transform: translateY(-50%); transition: background .15s, box-shadow .15s; }
.side-sub a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.side-sub a.active { color: #fff; }
.side-sub a.active::before { background: #60a5fa; box-shadow: 0 0 0 4px rgba(96, 165, 250, .2); }
.side-sub .soon { color: rgba(159, 176, 208, .4); cursor: default; }
.side-sub .soon small { margin-left: 4px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .05); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; }
.side-foot { padding: 14px 22px 18px; color: rgba(159, 176, 208, .4); font-size: 11.5px; white-space: nowrap; }

/* Tablet & desktop: sidebar docked; html.sb-rail (set before paint) shrinks it to an icon rail.
   An .open sidebar (tablet overlay) always shows in full on top of the content. */
@media (min-width: 768px) {
    .sidebar { transform: none; }
    .page { margin-left: var(--sidebar-w); transition: margin-left .28s var(--ease); }
    html.sb-rail .page { margin-left: var(--rail-w); }
    html.sb-rail .sidebar:not(.open) { width: var(--rail-w); }
    html.sb-rail .sidebar:not(.open) .side-label { padding: 18px 0 6px; text-align: center; font-size: 0; }
    html.sb-rail .sidebar:not(.open) .side-label::before { content: "•••"; font-size: 10px; letter-spacing: 2px; }
    html.sb-rail .sidebar:not(.open) .side-menu { padding: 0 10px 16px; }
    html.sb-rail .sidebar:not(.open) .side-link { justify-content: center; padding: 9px 0; }
    html.sb-rail .sidebar:not(.open) .side-text,
    html.sb-rail .sidebar:not(.open) .side-caret,
    html.sb-rail .sidebar:not(.open) .side-sub-wrap,
    html.sb-rail .sidebar:not(.open) .side-foot { display: none; }
}
@media (min-width: 1200px) { .sidebar-backdrop { display: none; } }

/* ---------- Page & panel ---------- */
.page { padding: 22px 24px 40px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px;
    border-bottom: 1px solid var(--border); }
.panel-head h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.2px; }
.panel-head h1 > i { color: var(--primary); font-size: 17px; }
.panel-head h1 small { font-size: 13px; font-weight: 500; }
.panel-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--input-bg); border: 1px solid var(--border); }
.panel-tabs:empty { display: none; }
.panel-tabs .tab { padding: 6px 16px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
    transition: background .15s, color .15s, box-shadow .15s; }
.panel-tabs .tab:hover { color: var(--text-strong); }
.panel-tabs .tab.active { background: var(--surface-3); color: var(--primary-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.panel-body { padding: 22px; }

/* ---------- Bootstrap refinements ---------- */
.form-control, .form-select { background-color: var(--input-bg); border-color: var(--border-strong); color: var(--text-strong); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s; }
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus { background-color: var(--input-bg); color: var(--text-strong); border-color: var(--primary); box-shadow: var(--focus-ring); }
.form-control:disabled, .form-control[readonly] { background-color: var(--surface-2); }
.form-label { font-weight: 500; color: var(--label); }
.form-label.small { color: var(--muted); }
.form-check-input { cursor: pointer; background-color: var(--input-bg); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--btn-bg); border-color: var(--btn-bg); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--primary); }

.btn { --bs-btn-font-weight: 500; border-radius: var(--radius-sm); transition: transform .12s var(--ease), box-shadow .15s, background-color .15s, border-color .15s, color .15s; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { --bs-btn-bg: var(--btn-bg); --bs-btn-border-color: var(--btn-bg); --bs-btn-hover-bg: var(--btn-hover); --bs-btn-hover-border-color: var(--btn-hover);
    --bs-btn-active-bg: var(--btn-active); --bs-btn-active-border-color: var(--btn-active); --bs-btn-disabled-bg: var(--btn-bg); --bs-btn-disabled-border-color: var(--btn-bg);
    box-shadow: 0 6px 18px -8px rgba(59, 130, 246, .8); }
.btn-primary:hover { box-shadow: 0 8px 22px -8px rgba(59, 130, 246, .95); }
.btn-outline-primary { --bs-btn-color: var(--primary-text); --bs-btn-border-color: var(--primary-line); --bs-btn-hover-bg: var(--primary-50);
    --bs-btn-hover-color: var(--primary-text-strong); --bs-btn-hover-border-color: var(--primary); --bs-btn-active-bg: var(--primary-100);
    --bs-btn-active-color: var(--primary-text-strong); --bs-btn-active-border-color: var(--primary); }
.btn-light { --bs-btn-color: var(--text); --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-color: var(--text-strong);
    --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-active-color: var(--text-strong);
    --bs-btn-active-bg: var(--surface-3); --bs-btn-active-border-color: var(--border-strong); }
.btn-light.text-danger { color: var(--danger) !important; }
.btn-sm { --bs-btn-padding-x: .7rem; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }

.alert { border: 0; border-radius: 12px; box-shadow: var(--shadow-sm); }
.alert-danger { background: var(--danger-bg); color: var(--danger-fg); box-shadow: inset 3px 0 0 var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success-fg); box-shadow: inset 3px 0 0 var(--success); }
.page > .alert { margin-bottom: 16px; }
.text-danger { color: var(--danger) !important; }

.modal-content { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal.fade .modal-dialog { transform: translateY(14px) scale(.98); transition: transform .25s var(--ease); }
.modal.show .modal-dialog { transform: none; }
.modal-backdrop.show { opacity: .55; }

.pagination { --bs-pagination-bg: var(--surface-2); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text);
    --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-hover-color: var(--text-strong); --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-border-radius: 9px; --bs-pagination-active-bg: var(--btn-bg); --bs-pagination-active-border-color: var(--btn-bg); gap: 4px; flex-wrap: wrap; }

/* Tom Select / flatpickr to match inputs (flatpickr's dark.css is switched on only in dark mode) */
.ts-wrapper .ts-control, .ts-wrapper.single .ts-control, .ts-wrapper.single.input-active .ts-control { background: var(--input-bg); color: var(--text-strong);
    border-color: var(--border-strong); border-radius: var(--radius-sm); box-shadow: none; min-height: 38px; }
.ts-control input { color: var(--text-strong) !important; }
.ts-control input::placeholder { color: var(--faint); }
.ts-wrapper.focus .ts-control { border-color: var(--primary); box-shadow: var(--focus-ring); }
.ts-dropdown { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
    overflow: hidden; margin-top: 6px; animation: fadeIn .15s; }
.ts-dropdown .option, .ts-dropdown .no-results { color: var(--text); }
.ts-dropdown .active { background: var(--primary-100); color: var(--text-strong); }
.ts-dropdown .text-muted { color: var(--muted) !important; }
.flatpickr-calendar { border: 1px solid var(--border-strong) !important; border-radius: 14px; box-shadow: var(--shadow-lg) !important; }
.flatpickr-calendar, .flatpickr-months .flatpickr-month, .flatpickr-weekdays, span.flatpickr-weekday,
.flatpickr-monthDropdown-months, .flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month { background: var(--surface-2) !important; }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after { border-bottom-color: var(--surface-2) !important; }
.flatpickr-calendar.arrowBottom::before, .flatpickr-calendar.arrowBottom::after { border-top-color: var(--surface-2) !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--btn-bg); border-color: var(--btn-bg); }
.flatpickr-day.today { border-color: var(--primary); }

/* ---------- Badges & pills ---------- */
.vbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding: 2px 8px; border-radius: 7px;
    font-size: 11.5px; font-weight: 650; letter-spacing: .02em; }
.vb-JV { background: var(--violet-bg); color: var(--violet-fg); }
.vb-CR { background: var(--green-bg); color: var(--green-fg); }
.vb-CP { background: var(--rose-bg); color: var(--rose-fg); }
.vb-BR { background: var(--teal-bg); color: var(--teal-fg); }
.vb-BP { background: var(--amber-bg); color: var(--amber-fg); }
.vb-CB { background: var(--indigo-bg); color: var(--indigo-fg); }
.vb-SI { background: var(--green-bg); color: var(--green-fg); }
.vb-SR { background: var(--rose-bg); color: var(--rose-fg); }
.vb-PI { background: var(--blue-bg); color: var(--blue-fg); }
.vb-PR { background: var(--amber-bg); color: var(--amber-fg); }
.vb-OB { background: var(--muted-bg); color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-posted { background: var(--success-bg); color: var(--success-fg); }
.pill-cancelled { background: var(--muted-bg); color: var(--muted); }
.pill-low { background: var(--danger-bg); color: var(--danger-fg); }

/* ---------- Data grids ---------- */
.grid { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: var(--hover-row); --bs-table-border-color: var(--border);
    margin-bottom: 18px; border: 1px solid var(--border); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden;
    font-variant-numeric: tabular-nums; }
.grid > :not(caption) > * > * { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.grid > tbody > tr:last-child > * { border-bottom: 0; }
.grid thead th { background: var(--thead-bg); color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; vertical-align: middle; white-space: nowrap; }
.grid td { vertical-align: middle; }
.grid td.fw-semibold, .grid td.fw-bold { color: var(--text-strong); }
.grid td.text-muted, .grid tr.text-muted > td { color: var(--muted); }
.grid > tbody > tr { transition: background-color .12s; }
.grid > tbody > tr:hover > * { background: var(--hover-row); }
.grid tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; color: var(--text-strong); }
.grid .table-light > * { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text-strong); background: var(--surface-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .grid, .table-scroll > .report-table { margin-bottom: 0; }
.table-scroll { margin-bottom: 18px; }
.table-scroll .grid td { white-space: nowrap; }   /* scroll sideways on small screens instead of wrapping dates/amounts */
.w-acc { width: 24%; } .w-amt { width: 10%; } .w-act { width: 8%; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; margin-left: 4px;
    border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface-3); color: var(--primary-text); font-size: 11px;
    vertical-align: middle; transition: background .15s, transform .2s var(--ease); }
.icon-btn:hover { background: var(--primary-100); }
#btnRefresh:active i { transform: rotate(180deg); transition: transform .3s; }

/* ---------- Voucher screen ---------- */
.voucher-head { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 18px; padding: 16px 18px;
    border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.vh-field { display: flex; align-items: center; gap: 10px; }
.vh-field label { margin: 0; color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.vh-field .form-control, .vh-field .form-select { width: 130px; }
.vh-field.wide .form-select { width: 260px; }
.form-control.ro, .form-control.ro[readonly] { background: var(--primary-50); border-color: var(--primary-line); color: var(--primary-text); font-weight: 650; text-align: center; }
/* The account picker's dropdown renders inside this table, so it must not clip. */
.grid.entry { overflow: visible; border-color: var(--primary-line); box-shadow: 0 0 0 4px rgba(59, 130, 246, .06); }
.grid.entry thead th { background: var(--primary-50); color: var(--primary-text); }
.grid.entry thead th:first-child { border-top-left-radius: 11px; }
.grid.entry thead th:last-child { border-top-right-radius: 11px; }
.grid.entry > tbody > tr:hover > * { background: transparent; }
.grid.lines tr.row-new > td { animation: rowFlash 1.2s ease-out; }
.grid.lines tfoot td { font-size: 13.5px; }
.voucher-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.voucher-actions #formError { flex-basis: 100%; }

/* ---------- Tiles (reports, settings) ---------- */
.tile-section { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; color: var(--muted); font-size: 12px; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; }
.tile-section:first-child { margin-top: 0; }
.tile-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { --c: var(--blue-fg); --c-bg: var(--blue-bg); position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text-strong); font-weight: 500; text-decoration: none;
    transition: transform .2s var(--ease), box-shadow .2s, border-color .2s, background .2s; }
.tile:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-3); box-shadow: var(--shadow); color: var(--text-strong); }
.tile::after { content: "\f061"; font: var(--fa-font-solid); margin-left: auto; color: var(--c); font-size: 12px; opacity: 0; transform: translateX(-6px);
    transition: opacity .2s, transform .2s var(--ease); }
.tile:hover::after { opacity: 1; transform: none; }
.tile .tile-icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 11px;
    background: var(--c-bg); color: var(--c); font-size: 17px; }
.tile.disabled { color: var(--faint); background: transparent; border-style: dashed; cursor: default; }
.tile.disabled:hover { transform: none; box-shadow: none; border-color: var(--border); background: transparent; }
/* Tom Select clear (×) button on report filters */
.ts-wrapper .clear-button { color: var(--muted); }
.tile.disabled .tile-icon { background: var(--muted-bg); color: var(--faint); }
.tile.disabled::after { content: "Soon"; font: 600 10px/1 var(--bs-body-font-family); letter-spacing: .05em; text-transform: uppercase; opacity: 1;
    transform: none; padding: 4px 7px; border-radius: 6px; background: var(--muted-bg); color: var(--faint); }
.tone-blue { --c: var(--blue-fg); --c-bg: var(--blue-bg); }
.tone-amber { --c: var(--amber-fg); --c-bg: var(--amber-bg); }
.tone-teal { --c: var(--teal-fg); --c-bg: var(--teal-bg); }
.tone-violet { --c: var(--violet-fg); --c-bg: var(--violet-bg); }
.tone-rose { --c: var(--rose-fg); --c-bg: var(--rose-bg); }

/* ---------- Reports ---------- */
.report-title { margin: 14px 0 2px; text-align: center; font-size: 19px; font-weight: 650; letter-spacing: -.2px; color: var(--text-strong); }
.report-meta { margin-bottom: 12px; color: var(--muted); font-size: 12.5px; text-align: center; }
.report-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    font-size: 13px; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.report-table th { background: var(--thead-bg); color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.report-table tbody tr:hover td { background: var(--hover-row); }
.report-table tr.group td { background: var(--primary-50); color: var(--text-strong); font-weight: 650; }
.report-table tfoot td { font-weight: 700; color: var(--text-strong); border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.report-table tbody tr:last-child td { border-bottom: 0; }
.report-table td.narr { white-space: pre-line; }   /* bill narration: one item per line */
.table-scroll .report-table { min-width: 620px; }
.generic-report td { white-space: nowrap; }
.generic-report tr.rk-subtotal td { background: var(--surface-2); color: var(--text-strong); font-weight: 650; }
.generic-report tr.rk-total td { background: var(--primary-50); color: var(--text-strong); font-weight: 750; border-top: 2px solid var(--border-strong); }
.generic-report td.neg { color: var(--danger-fg); }

/* ---------- Dashboard ---------- */
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.hello h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
    color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
    transition: transform .2s var(--ease), box-shadow .2s, border-color .2s, background .2s; }
.quick a:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-3); box-shadow: var(--shadow); color: var(--text-strong); }
.quick a .vbadge { min-width: 30px; }
.stat { position: relative; height: 100%; padding: 18px; overflow: hidden; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface-2); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--c-bg, var(--blue-bg)); opacity: .8; }
.stat-icon { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-bottom: 14px;
    border-radius: 11px; background: var(--c-bg, var(--blue-bg)); color: var(--c, var(--blue-fg)); font-size: 16px; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { margin-top: 2px; color: var(--text-strong); font-size: 25px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.card-box { height: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.card-box-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border);
    color: var(--text-strong); font-weight: 600; }
.card-box-head a { font-size: 12.5px; font-weight: 500; text-decoration: none; }
.card-box .table-scroll { margin: 0; }
.card-box .grid { margin: 0; border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.card-box .grid thead th { background: var(--card-thead-bg); }
.bank-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.bank-row:last-child { border-bottom: 0; }
.bank-row .tile-icon { width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    background: var(--teal-bg); color: var(--teal-fg); }
.bank-row .fw-medium { color: var(--text-strong); }
.bank-row strong { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 18px; color: var(--faint); text-align: center; }
.empty i { display: block; margin-bottom: 8px; font-size: 22px; opacity: .6; }

/* ---------- Chart of accounts tree ---------- */
.acc-row.is-group td:nth-child(2) { color: var(--group-text); }
.acc-row.lvl-1 > td { background: var(--hover-row); }
.acc-add .form-control { background: transparent; border-color: transparent; }
.acc-add .form-control:hover { border-color: var(--border); }
.acc-add .form-control:focus { background: var(--input-bg); border-color: var(--primary); }
.acc-code { color: var(--muted) !important; font-size: 12.5px; }

/* ---------- Toasts ---------- */
/* Bottom-centre so it never covers tabs (top-right) or Save buttons (bottom-right); top on phones. */
.toast-stack { position: fixed; bottom: 24px; left: 50%; z-index: 1090; display: grid; gap: 10px; transform: translateX(-50%); }
.lb-toast { position: relative; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 420px; padding: 13px 14px 15px 16px;
    overflow: hidden; border: 1px solid rgba(52, 211, 153, .3); border-radius: 13px; background: var(--surface-3); color: var(--text-strong);
    box-shadow: var(--shadow-lg); animation: toastIn .35s var(--ease) both; transition: opacity .25s, transform .25s var(--ease); }
.lb-toast > i { color: var(--success); font-size: 18px; }
.lb-toast span { font-weight: 500; }
.lb-toast-close { margin-left: auto; border: 0; background: none; color: var(--faint); font-size: 18px; line-height: 1; padding: 0 2px; }
.lb-toast-close:hover { color: var(--text-strong); }
.lb-toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--success); transform-origin: left; animation: toastBar 5s linear forwards; }
.lb-toast:hover .lb-toast-bar { animation-play-state: paused; }
.lb-toast.hide { opacity: 0; transform: translateY(14px); }

/* ---------- Login ---------- */
.login-body { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; background: var(--bg); }
.login-art { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 44px; overflow: hidden; color: #fff;
    background: linear-gradient(150deg, #050a14 0%, #0c1f45 55%, #1e40af 100%); }
.login-art .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; will-change: transform; animation: floaty 14s ease-in-out infinite; }
.login-art .blob.b1 { width: 340px; height: 340px; background: #3b82f6; top: -80px; right: -60px; }
.login-art .blob.b2 { width: 280px; height: 280px; background: #06b6d4; bottom: -60px; left: -40px; animation-delay: -5s; animation-duration: 18s; }
.login-art .blob.b3 { width: 200px; height: 200px; background: #8b5cf6; top: 45%; left: 40%; opacity: .3; animation-delay: -9s; }
.login-art > * { position: relative; }
.login-art .brand { color: #fff; }
.login-art .brand-mark { background: rgba(255, 255, 255, .12); box-shadow: none; }
.login-art h1 { max-width: 440px; margin: 0 0 14px; color: #fff; font-size: 34px; font-weight: 700; letter-spacing: -.8px; line-height: 1.15; }
.login-art p { max-width: 420px; color: rgba(255, 255, 255, .72); font-size: 15px; }
.login-points { display: grid; gap: 10px; margin: 24px 0 0; padding: 0; list-style: none; }
.login-points li { display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .86); }
.login-points i { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(255, 255, 255, .1); font-size: 12px; }
.login-art small { color: rgba(255, 255, 255, .45); }
.login-main { position: relative; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
    background: radial-gradient(600px 400px at 70% 20%, rgba(59, 130, 246, .08), transparent 70%); }
.login-theme { position: absolute; top: 16px; right: 16px; }
.login-card { width: 100%; max-width: 370px; animation: fadeUp .5s var(--ease) both; }
.login-card h2 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.login-card .sub { margin-bottom: 26px; color: var(--muted); }
.login-card .form-control { padding: .65rem .9rem .65rem 2.5rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 14px; pointer-events: none; transition: color .15s; }
.input-icon:focus-within > i { color: var(--primary-text); }
.input-icon .pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--faint); padding: 6px 8px; }
.input-icon .pw-toggle:hover { color: var(--text); }
.login-card .btn-primary { padding: .65rem; font-weight: 600; }
.login-brand-sm { display: none; margin-bottom: 26px; }

#permMatrix { transition: opacity .2s; }

/* ---------- Bills ---------- */
/* Segmented control (payment mode) */
.seg { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--input-bg); }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 12px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.seg label:hover span { color: var(--text-strong); }
.seg input:checked + span { background: var(--btn-bg); color: #fff; box-shadow: 0 4px 12px -6px rgba(59, 130, 246, .9); }
.seg input:focus-visible + span { box-shadow: var(--focus-ring); }
.bill-head .vh-field.wide { flex: 1 1 280px; }
.bill-head #bPartyBal { width: 170px; }   /* fits "1,234,567.00 CR" */
.bill-head .vh-field.wide .ts-wrapper, .bill-head .vh-field.wide .form-select { width: 100%; min-width: 220px; }
.scan-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.scan-bar .form-control { height: 42px; padding-left: 2.4rem; font-size: 15px; }
.scan-pick { flex: 1 1 280px; }
.scan-pick .ts-control { min-height: 42px !important; }
.bill-lines td .form-control { min-width: 90px; }
.bill-lines .stock-short { color: var(--danger); font-weight: 700; }
.bill-totals { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.bt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; }
.bt-row label, .bt-row > span { margin: 0; color: var(--muted); font-weight: 500; }
.bt-row .form-control { max-width: 170px; }
.bt-row strong { font-variant-numeric: tabular-nums; }
.bt-net { margin: 6px 0; padding: 10px 0; border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.bt-net span { color: var(--text-strong) !important; font-size: 15px; font-weight: 650 !important; }
.bt-net strong { color: var(--text-strong); font-size: 24px; letter-spacing: -.5px; }
.bt-info { min-height: 1.2em; margin-top: 4px; color: var(--muted); font-size: 13px; text-align: right; }
.bt-info b { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.bt-info .good b { color: var(--success-fg); }
.bt-info .bad, .bt-info .bad b { color: var(--danger-fg); }

/* ---------- Error pages (403/404/419) ---------- */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
    background: radial-gradient(600px 400px at 50% 20%, rgba(59, 130, 246, .1), transparent 70%); }
.error-card { max-width: 460px; text-align: center; }
.error-card .brand { justify-content: center; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -2px; line-height: 1; color: var(--primary); opacity: .9; }
.error-card h1 { margin: 10px 0 8px; font-size: 22px; font-weight: 700; }
.error-card p { margin-bottom: 24px; color: var(--muted); }

/* ---------- Opening balances / stock grids ---------- */
.ob-grid tr.ob-group > td { background: var(--primary-50); color: var(--text-strong); font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.ob-grid td { padding-top: 5px !important; padding-bottom: 5px !important; }
.ob-grid .form-control { min-width: 110px; }
/* Save bar stays in reach while scrolling a long list */
.ob-actions { position: sticky; bottom: 0; z-index: 5; margin: 0 -22px -22px; padding: 14px 22px; border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet and below: the voucher entry row becomes a form (2 columns), not a cramped table */
@media (max-width: 991.98px) {
    .grid.entry, .grid.entry tbody, .grid.entry tr, .grid.entry td { display: block; width: auto; }
    .grid.entry thead { display: block; }
    .grid.entry thead tr { display: flex; }
    .grid.entry thead th { display: none; }
    .grid.entry thead th:first-child { display: block; flex: 1; border-radius: 11px 11px 0 0; }
    .grid.entry tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 12px; }
    .grid.entry > tbody > tr > td { padding: 0; border: 0; }
    .grid.entry td.e-wide { grid-column: 1 / -1; }
    .grid.entry td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted);
        font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
    .login-body { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .login-brand-sm { display: flex; }
}

/* Phone */
@media (max-width: 767.98px) {
    .page { padding: 14px 10px 30px; }
    .panel-head { padding: 14px; }
    .panel-head h1 { font-size: 17px; }
    .panel-tabs { width: 100%; }
    .panel-tabs .tab { flex: 1; text-align: center; padding: 6px 10px; }
    .panel-body { padding: 16px 14px; }

    .voucher-head { gap: 12px; padding: 14px; }
    .vh-field { flex: 1 1 calc(50% - 6px); flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
    .vh-field.wide { flex-basis: 100%; }
    .vh-field .form-control, .vh-field .form-select, .vh-field.wide .form-select { width: 100%; }
    .grid.entry tbody tr { grid-template-columns: minmax(0, 1fr); }
    .voucher-actions .btn { flex: 1 1 auto; }
    .ob-actions { margin: 0 -14px -16px; padding: 12px 14px; }
    .seg { display: flex; width: 100%; }
    .seg label { flex: 1; text-align: center; }
    .bill-head .vh-field.wide .ts-wrapper, .bill-head .vh-field.wide .form-select { min-width: 0; }
    .bt-row .form-control { max-width: 150px; }

    .hello h2 { font-size: 19px; }
    .quick { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
    .quick::-webkit-scrollbar { display: none; }
    .stat { padding: 16px; }
    .stat-value { font-size: 22px; }
    .tiles { grid-template-columns: 1fr; gap: 8px; }

    .toast-stack { top: calc(var(--topbar-h) + 10px); bottom: auto; left: 10px; right: 10px; transform: none; }
    .lb-toast { min-width: 0; max-width: none; }
}

/* Small phones: tighten the top bar */
@media (max-width: 479.98px) {
    .topbar { gap: 6px; padding: 0 8px; }
    .brand-name { display: none; }
    .user-chip { padding: 0; }
}

/* Touch devices: comfortable tap targets */
@media (pointer: coarse) {
    .btn-sm { --bs-btn-padding-y: .4rem; }
    .side-sub a, .side-sub .soon { padding-top: 10px; padding-bottom: 10px; }
}

/* ---------- Print: always black on white ---------- */
@media print {
    .topbar, .sidebar, .sidebar-backdrop, .panel-tabs, .no-print, form.no-print, .toast-stack { display: none !important; }
    :root { color-scheme: light; }
    body, .page, .panel, .panel-body { background: #fff !important; color: #000 !important; }
    .page { margin: 0 !important; padding: 0; }
    .panel { border: 0; box-shadow: none; }
    .panel-head { display: none; }
    .panel-body { padding: 0; }
    .panel-body * { color: #000 !important; }
    .table-scroll { overflow: visible; }
    .report-table { border-radius: 0; border-collapse: collapse; min-width: 0 !important; }
    .report-table th, .report-table td { border: 1px solid #333; background: none !important; }
    .anim-in, .stagger > * { animation: none !important; }
}
