/*
 * DukaanPro styles on top of Bootstrap 5.3.
 *
 * Every colour is a variable below, with a light and a dark value: use the variables (or Bootstrap's
 * theme-aware classes such as bg-body-tertiary, text-body-secondary), never a fixed #fff / #e5e7eb,
 * so a new screen works in both modes. The brand colour comes from Super Admin → Settings (layouts/base).
 * Light / dark is set on <html data-bs-theme> by public/js/theme.js.
 */

@font-face {
    font-family: "Inter";
    src: url("../vendor/inter/InterVariable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ---------- colours: light ---------- */
:root, [data-bs-theme="light"] {
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #e6f4f2;
    --brand-rgb: 15, 118, 110;      /* the same colour as r, g, b: for see-through shades */
    --brand-text: var(--brand);     /* brand colour used for text and links (lighter in dark mode) */

    --page-bg: #f4f6f9;
    --surface: #ffffff;             /* cards, top bar, menus */
    --surface-2: #f7f9fb;           /* table heads, quiet panels */
    --surface-3: #eef2f6;           /* bars, hover */
    --input-bg: #ffffff;
    --border: #e4e8ee;
    --border-soft: #eef1f5;
    --heading: #0f172a;
    --muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 18px 40px -16px rgba(15, 23, 42, .28), 0 2px 6px rgba(15, 23, 42, .05);

    /* The sidebar is dark in both modes. */
    --sidebar-bg: #0b1220;
    --sidebar-border: transparent;
    --sidebar-text: #aab6c8;
    --sidebar-label: #5d6b80;
    --sidebar-hover: rgba(255, 255, 255, .05);

    --chart-text: #64748b;
    --chart-grid: #eef2f6;

    --bs-body-bg: var(--surface);
    --bs-body-color: #1e293b;
    --bs-emphasis-color: var(--heading);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--border);
}

/* ---------- colours: dark ---------- */
:root[data-bs-theme="dark"] {
    --brand-soft: rgba(var(--brand-rgb), .16);
    --brand-text: color-mix(in srgb, var(--brand) 62%, #ffffff);

    --page-bg: #0a0e16;
    --surface: #111724;
    --surface-2: #161d2d;
    --surface-3: #1e2738;
    --input-bg: #0d1320;
    --border: #232c3e;
    --border-soft: #1b2333;
    --heading: #eef2f8;
    --muted: #8b98ad;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 44px -16px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .03);

    --sidebar-bg: #070b12;
    --sidebar-border: #161d2b;

    --chart-text: #8b98ad;
    --chart-grid: #1e2738;

    --bs-body-bg: var(--surface);
    --bs-body-color: #d5dce7;
    --bs-emphasis-color: var(--heading);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-secondary-bg: var(--surface-3);
    --bs-border-color: var(--border);
    --bs-link-color: var(--brand-text);
    --bs-link-hover-color: color-mix(in srgb, var(--brand) 45%, #ffffff);
    --bs-link-color-rgb: var(--brand-rgb);
    color-scheme: dark;
}

:root {
    --bs-primary: var(--brand);
    --bs-primary-rgb: var(--brand-rgb);
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: var(--brand-rgb);
    --bs-link-hover-color: var(--brand-dark);
    --bs-link-hover-color-rgb: var(--brand-rgb);
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-border-radius: .6rem;
    --bs-border-radius-lg: .8rem;
    --bs-focus-ring-color: rgba(var(--brand-rgb), .25);
}
:root[data-bs-theme="dark"] { --bs-link-color: var(--brand-text); }

[data-bs-theme="dark"] .only-light, [data-bs-theme="light"] .only-dark { display: none !important; }
/* Plain links in dark mode: the lighter brand colour. :where() keeps this weaker than any class (buttons, menus). */
:where([data-bs-theme="dark"]) a { color: var(--brand-text); }
:where([data-bs-theme="dark"]) a:hover { color: var(--bs-link-hover-color); }

body {
    background: var(--page-bg);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
::selection { background: rgba(var(--brand-rgb), .22); }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--heading); letter-spacing: -.015em; }

/* ---------- buttons ---------- */
.btn { --bs-btn-font-weight: 500; border-radius: .6rem; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-sm { border-radius: .5rem; }
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 1px 2px rgba(var(--brand-rgb), .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-text);
    --bs-btn-border-color: rgba(var(--brand-rgb), .55);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}
.btn-light, .btn-soft {
    --bs-btn-color: var(--bs-body-color);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-color: var(--heading);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-active-color: var(--heading);
    --bs-btn-active-bg: var(--surface-3);
    --bs-btn-active-border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #b3bfd1; --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border); --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-outline-dark { --bs-btn-color: #d5dce7; --bs-btn-border-color: #3a465c; --bs-btn-hover-bg: #d5dce7; --bs-btn-hover-color: #0a0e16; }
[data-bs-theme="dark"] .btn-check:checked + .btn-outline-secondary, [data-bs-theme="dark"] .btn-outline-secondary.active { background: var(--surface-3); color: #fff; border-color: #3a465c; }

.text-primary { color: var(--brand-text) !important; }
.bg-primary { background-color: var(--brand) !important; }
.border-primary { border-color: var(--brand) !important; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); --bs-nav-pills-border-radius: .55rem; }
.nav-link { --bs-nav-link-color: var(--brand-text); --bs-nav-link-hover-color: var(--brand-dark); }
[data-bs-theme="dark"] .nav-link { --bs-nav-link-hover-color: var(--heading); }
.nav-tabs { --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--surface); --bs-nav-tabs-border-color: var(--border); }
.nav-tabs .nav-link { color: var(--muted); font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--heading); }
.page-link { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand-text); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-disabled-bg: var(--surface-2); }

/* ---------- menus and pop-ups ---------- */
.dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-link-active-bg: var(--brand-soft);
    --bs-dropdown-link-active-color: var(--brand-text);
    --bs-dropdown-link-hover-bg: var(--surface-2);
    --bs-dropdown-border-radius: .8rem;
    --bs-dropdown-item-border-radius: .5rem;
    --bs-dropdown-padding-x: .35rem;
    --bs-dropdown-font-size: .9rem;
    box-shadow: var(--shadow-lg);
}
.dropdown-item { display: flex; align-items: center; gap: .6rem; border-radius: .5rem; padding: .45rem .7rem; }
.dropdown-item > .bi { width: 1rem; opacity: .7; }
.dropdown-item.active > .bi, .dropdown-item.active { font-weight: 600; }
.modal { --bs-modal-border-radius: 1rem; --bs-modal-border-color: var(--border); --bs-modal-bg: var(--surface); }
.modal-content { box-shadow: var(--shadow-lg); }
.modal-backdrop { --bs-backdrop-opacity: .55; }
.offcanvas { --bs-offcanvas-bg: var(--surface); }
.tooltip { --bs-tooltip-bg: #0f172a; }
.toast { --bs-toast-bg: var(--surface); --bs-toast-border-color: var(--border); }

/* ---------- forms ---------- */
.form-control, .form-select { background-color: var(--input-bg); border-color: var(--border); border-radius: .6rem; }
.form-control-sm, .form-select-sm { border-radius: .5rem; }
.input-group > .form-control, .input-group > .form-select, .input-group > .btn, .input-group > .input-group-text { border-radius: .6rem; }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.form-control::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.form-control:focus, .form-select:focus { background-color: var(--input-bg); border-color: var(--brand); box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .16); }
.form-check-input { border-color: color-mix(in srgb, var(--muted) 55%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .16); }
.form-switch .form-check-input:focus:not(:checked) { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e"); }
.form-label { font-weight: 500; font-size: .875rem; color: var(--heading); margin-bottom: .35rem; }
.form-text { color: var(--muted); }
.required::after { content: " *"; color: #dc2626; }
:focus-visible { outline-color: rgba(var(--brand-rgb), .6); }

/* The platform logo (partials/brand): an uploaded picture, or the icon + name. */
.brand-mark { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; color: inherit; }
.brand-mark img { display: block; width: auto; object-fit: contain; }
.brand-mark .brand-icon { display: grid; place-items: center; border-radius: 9px; background: var(--brand); color: #fff; flex: none; }

/* ---------- the frame: sidebar + top bar + content ---------- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 1045;
}
.sidebar .brand { padding: 1.15rem 1.25rem .9rem; color: #fff; }
.sidebar-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 1rem; scrollbar-width: thin; scrollbar-color: #1f2a3c transparent; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: #1f2a3c; border-radius: 6px; }
.sidebar .section-label {
    font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
    color: var(--sidebar-label); padding: 1.1rem 1.5rem .4rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .nav-link {
    position: relative;
    color: var(--sidebar-text);
    margin: 1px .75rem;
    padding: .5rem .75rem;
    border-radius: .55rem;
    display: flex; align-items: center; gap: .7rem;
    font-size: .9rem; font-weight: 500;
    transition: background-color .15s, color .15s;
}
.sidebar .nav-link .bi { font-size: 1.05rem; opacity: .8; }
.sidebar .nav-link:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(var(--brand-rgb), .32), rgba(var(--brand-rgb), .12));
    box-shadow: inset 0 0 0 1px rgba(var(--brand-rgb), .25);
}
.sidebar .nav-link.active::before {
    content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar .nav-link.active .bi { opacity: 1; }
.sidebar .nav-link.locked { opacity: .45; }
.sidebar .sidebar-footer {
    padding: .9rem 1.5rem 1.1rem; font-size: .78rem; color: var(--sidebar-label);
    border-top: 1px solid rgba(255, 255, 255, .05);
}
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1030;
    min-height: 62px;
    padding: .6rem 2rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: color-mix(in srgb, var(--page-bg) 78%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.topbar-start, .topbar-context { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.topbar-end { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.topbar-shop { align-items: center; gap: .45rem; font-size: .875rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.topbar-brand .brand-mark { color: var(--heading); }
.icon-btn {
    width: 38px; height: 38px; border-radius: .65rem; flex-shrink: 0;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface); color: var(--bs-body-color);
    font-size: 1.1rem; box-shadow: var(--shadow-sm);
    transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--heading); }
.user-btn {
    display: flex; align-items: center; gap: .55rem; max-width: 230px;
    border: 1px solid var(--border); background: var(--surface); color: var(--bs-body-color);
    border-radius: 999px; padding: .22rem .75rem .22rem .22rem; font-size: .875rem; font-weight: 500;
    box-shadow: var(--shadow-sm);
}
.user-btn:hover { background: var(--surface-2); }
.user-btn .bi-chevron-down { font-size: .7rem; opacity: .6; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff;
    font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em;
}
.user-menu { min-width: 240px; }
.branch-btn { max-width: 190px; display: inline-flex; align-items: center; gap: .35rem; }

.content { padding: 1.75rem 2rem 2.5rem; width: 100%; max-width: 1680px; }

/* ---------- building blocks ---------- */
.page-title { font-size: 1.5rem; font-weight: 650; letter-spacing: -.025em; margin: 0; color: var(--heading); }
.card {
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--border);
    --bs-card-cap-bg: transparent;
    --bs-card-border-radius: .9rem;
    --bs-card-inner-border-radius: calc(.9rem - 1px);
    --bs-card-cap-padding-y: .85rem;
    --bs-card-cap-padding-x: 1.25rem;
    box-shadow: var(--shadow);
}
.card-header { border-bottom-color: var(--border-soft); font-weight: 600; color: var(--heading); }
.card-footer { background: transparent; border-top-color: var(--border-soft); }
.list-group { --bs-list-group-bg: var(--surface); --bs-list-group-border-color: var(--border-soft); --bs-list-group-action-hover-bg: var(--surface-2); --bs-list-group-active-bg: var(--brand); --bs-list-group-active-border-color: var(--brand); }
.stat-card .label { color: var(--muted); font-size: .85rem; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; color: var(--heading); }
.alert { border-radius: .8rem; }
.badge { font-weight: 600; letter-spacing: .01em; }
hr { border-color: var(--border); opacity: 1; }

/* Tables: quiet header row, numbers line up, rows light up on hover. */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border-soft);
    --bs-table-hover-bg: rgba(var(--brand-rgb), .045);
    --bs-table-striped-bg: var(--surface-2);
    font-variant-numeric: tabular-nums;
}
.table > :not(caption) > * > * { padding: .72rem .8rem; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
    color: var(--muted); background: var(--surface-2); white-space: nowrap;
    border-bottom-color: var(--border);
}
.card > .table-responsive:first-child thead th:first-child, .card > .table:first-child thead th:first-child { border-top-left-radius: var(--bs-card-inner-border-radius); }
.card > .table-responsive:first-child thead th:last-child, .card > .table:first-child thead th:last-child { border-top-right-radius: var(--bs-card-inner-border-radius); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td.text-end, .table th.text-end { white-space: nowrap; } /* amounts never break after "Rs" */
.table-hover > tbody > tr { transition: background-color .1s; }
.variant-row > * { --bs-table-bg-type: var(--surface-2); }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ---------- product pictures ---------- */
.product-thumb { border-radius: .5rem; object-fit: cover; flex-shrink: 0; display: inline-block; background: var(--surface-3); }
.product-thumb-empty { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; letter-spacing: .02em; }

/* ---------- login, sign-up, password pages ---------- */
.auth-page {
    min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 2.5rem 0;
    background:
        radial-gradient(1100px 560px at 12% -10%, rgba(var(--brand-rgb), .14), transparent 60%),
        radial-gradient(900px 520px at 110% 110%, rgba(var(--brand-rgb), .10), transparent 60%),
        var(--page-bg);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card { box-shadow: var(--shadow-lg); border-radius: 1.1rem; }
.auth-page .brand-mark { color: var(--heading); }
.auth-theme { position: fixed; top: 1rem; right: 1rem; z-index: 10; }

/* Report summary boxes (a table, so the same markup prints and makes PDFs). */
.report .kpis { width: 100%; border-collapse: separate; border-spacing: .75rem 0; margin-left: -.75rem; margin-bottom: 1rem; }
.report .kpis td { background: var(--surface); border: 1px solid var(--border); border-radius: .8rem; padding: .9rem 1.05rem; box-shadow: var(--shadow-sm); vertical-align: top; }
.report .kpis .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.report .kpis .value { font-size: 1.3rem; font-weight: 650; color: var(--heading); letter-spacing: -.02em; }
.report .table a { text-decoration: none; }
.report-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
.report-card:hover { border-color: rgba(var(--brand-rgb), .5); box-shadow: var(--shadow-lg); transform: translateY(-1px); }

/* ---------- dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.kpi { border: 1px solid var(--border); box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s, border-color .15s; color: inherit; }
a.kpi:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); border-color: rgba(var(--brand-rgb), .35); }
.kpi-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; margin: .35rem 0 .3rem; color: var(--heading); font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: .82rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; color: var(--muted); }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }
.kpi-icon.warn { background: #fef3c7; color: #b45309; }
[data-bs-theme="dark"] .kpi-icon.warn { background: rgba(234, 179, 8, .14); color: #facc15; }
.delta { font-weight: 700; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; }
.delta.up { background: #dcfce7; color: #15803d; }
.delta.down { background: #fee2e2; color: #b91c1c; }
[data-bs-theme="dark"] .delta.up { background: rgba(34, 197, 94, .15); color: #4ade80; }
[data-bs-theme="dark"] .delta.down { background: rgba(239, 68, 68, .15); color: #f87171; }
.chart-box { position: relative; }
.empty-chart { height: 220px; display: grid; place-items: center; color: var(--muted); font-size: .9rem; text-align: center; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar.danger span { background: #dc2626; }
.top-row { padding: .45rem 0; }
.top-row + .top-row { border-top: 1px dashed var(--border); }

/* Plan pill in the top bar (App\Support\SubscriptionStatus): green / yellow / red / blue. */
.plan-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .24rem .3rem .24rem .6rem; border-radius: 999px;
    font-size: .8rem; text-decoration: none; border: 1px solid; white-space: nowrap; vertical-align: middle; min-width: 0; }
.plan-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.plan-pill .sep { opacity: .45; margin: 0 .3rem; }
.plan-pill .state { margin-left: .15rem; padding: .08rem .5rem; border-radius: 999px; font-weight: 700; font-size: .7rem; color: #fff; }
.plan-green { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.plan-green .state { background: #16a34a; }
.plan-yellow { color: #a16207; background: #fefce8; border-color: #fde68a; }
.plan-yellow .state { background: #eab308; color: #422006; }
.plan-red { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.plan-red .state { background: #dc2626; }
.plan-red .dot { animation: plan-pulse 1.4s infinite; }
.plan-blue { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.plan-blue .state { background: #2563eb; }
[data-bs-theme="dark"] .plan-green { color: #4ade80; background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .28); }
[data-bs-theme="dark"] .plan-yellow { color: #facc15; background: rgba(234, 179, 8, .1); border-color: rgba(234, 179, 8, .28); }
[data-bs-theme="dark"] .plan-red { color: #f87171; background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .3); }
[data-bs-theme="dark"] .plan-blue { color: #60a5fa; background: rgba(59, 130, 246, .1); border-color: rgba(59, 130, 246, .3); }
@keyframes plan-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .plan-red .dot { animation: none; } * { transition: none !important; } }
.plan-alert { border-left-width: 4px; }
.plan-bar-green span { background: #16a34a; }
.plan-bar-yellow span { background: #eab308; }
.plan-bar-red span { background: #dc2626; }
.plan-bar-blue span { background: #2563eb; }

/* Profit on a bill: money stays on one line. */
.profit-table td.text-end, .profit-table th.text-end { white-space: nowrap; }

/* ---------- tablets and phones ---------- */
@media (max-width: 991.98px) {
    /* The sidebar slides in over the page (public/js/shell.js). */
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw);
        transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
        box-shadow: none;
    }
    body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .45); }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1040;
        background: rgba(2, 6, 23, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
        opacity: 0; pointer-events: none; transition: opacity .25s;
    }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    body.sidebar-open { overflow: hidden; }

    .topbar { padding: .55rem 1.25rem; min-height: 58px; }
    .content { padding: 1.25rem 1.25rem 2rem; }
}

@media (max-width: 575.98px) {
    :root { --bs-body-font-size: .9rem; }
    .topbar { padding: .5rem .85rem; gap: .5rem; }
    .topbar-start { gap: .5rem; }
    .topbar-brand img { max-width: 104px; }
    .topbar .icon-btn { width: 36px; height: 36px; }
    .avatar { width: 30px; height: 30px; }
    .topbar-end { gap: .35rem; }
    .user-btn { padding: .2rem; }
    .branch-btn { max-width: 110px; }
    .content { padding: 1rem .85rem 1.75rem; }
    .page-title { font-size: 1.25rem; }
    .card { --bs-card-border-radius: .8rem; --bs-card-inner-border-radius: calc(.8rem - 1px); --bs-card-cap-padding-x: 1rem; --bs-card-spacer-x: 1rem; }
    .table > :not(caption) > * > * { padding: .6rem .65rem; }
    .kpi .card-body { padding: .85rem .9rem; }
    .kpi-label { font-size: .66rem; letter-spacing: .05em; }
    .kpi-icon { width: 28px; height: 28px; border-radius: 8px; font-size: .85rem; flex-shrink: 0; }
    .kpi-value { font-size: clamp(.92rem, 4.2vw, 1.12rem); letter-spacing: -.025em; margin: .3rem 0 .25rem; white-space: nowrap; } /* shrinks to fit, never breaks after "Rs" */
    .kpi-foot { font-size: .74rem; gap: .3rem; }
    /* Top bar on a phone: branch as an icon, plan as its coloured status only. */
    .branch-btn > span { display: none; }
    .branch-btn.dropdown-toggle::after { display: none; }
    .topbar-context .plan-pill { padding: .2rem .25rem .2rem .45rem; }
    .stat-card .value { font-size: 1.35rem; }
    .dash-head { margin-bottom: 1rem; }
    /* Report summary boxes: a table (for print / PDF), shown two per row on a phone. */
    .report .kpis, .report .kpis tbody { display: block; margin: 0 0 1rem; }
    .report .kpis tr { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
    .report .kpis td { display: block; padding: .7rem .8rem; }
    .report .kpis .value { font-size: 1.05rem; white-space: nowrap; }
    /* Statement dates on one line. */
    .ledger td:first-child { white-space: nowrap; }
    .modal-dialog { margin: .6rem; }
}

@media print {
    .sidebar, .sidebar-backdrop, .topbar { display: none !important; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; }
}
