/* =====================================================================
   OJAFLOW — Application (dashboard / admin) styles
   ===================================================================== */

:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --ink: #0f172a;
    --body: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --sidebar-w: 250px;
    --topbar-h: 62px;
    --radius: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--body);
    font-size: .95rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -0.02em; }
a { text-decoration: none; }
a:hover { text-decoration: none; }

.text-muted-2 { color: var(--muted) !important; }

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    min-height: var(--topbar-h);
}
.sidebar-brand .brand-mark { background: var(--brand); }
.sidebar-brand .title {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.03em;
    color: #fff;
    line-height: 1.1;
}
.sidebar-brand .sub {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--sidebar-text);
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem;
}
.sidebar-nav .nav-section {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #64748b;
    font-weight: 700;
    padding: 1rem .65rem .45rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: .92rem;
    padding: .62rem .75rem;
    border-radius: 9px;
    margin-bottom: 2px;
    transition: background .12s ease, color .12s ease;
}
.sidebar-nav a i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav a.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .8rem;
    color: #64748b;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* ============ MAIN ============ */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 1.5rem;
}
.topbar .page-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.topbar .breadcrumb-soft { font-size: .8rem; color: var(--muted); }
.topbar-user {
    display: flex;
    align-items: center;
    gap: .8rem;
}
.topbar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
}
.topbar-user .who { line-height: 1.15; }
.topbar-user .who .name { font-size: .88rem; font-weight: 600; color: var(--ink); }
.topbar-user .who .role { font-size: .74rem; color: var(--muted); }

.sidebar-toggle {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    width: 38px;
    height: 38px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    cursor: pointer;
}

.page-content { padding: 1.5rem; flex: 1; }

/* ============ CARDS ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: .95rem;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-header .sub { font-weight: 400; font-size: .82rem; color: var(--muted); }
.card-body { padding: 1.25rem; }

/* ============ STAT CARDS ============ */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    height: 100%;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: .4rem;
}
.stat-card .stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1.15;
}
.stat-card .stat-note { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-icon.i-brand { background: var(--brand-soft); color: var(--brand); }
.stat-icon.i-success { background: #ecfdf5; color: var(--success); }
.stat-icon.i-warning { background: #fffbeb; color: var(--warning); }
.stat-icon.i-danger { background: #fef2f2; color: var(--danger); }
.stat-icon.i-info { background: #f0f9ff; color: var(--info); }

/* ============ TABLES ============ */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table {
    margin-bottom: 0;
    font-size: .9rem;
}
.table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: .7rem 1rem;
    white-space: nowrap;
}
.table tbody td {
    padding: .8rem 1rem;
    border-color: #f1f5f9;
    vertical-align: middle;
    color: var(--body);
}
.table-hover tbody tr:hover { background: #f8fafc; }
.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: .8rem; color: var(--muted); }

/* ============ BUTTONS ============ */
.btn {
    font-weight: 600;
    font-size: .88rem;
    border-radius: 9px;
    padding: .5rem 1rem;
    transition: all .13s ease;
}
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-soft {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--body);
}
.btn-outline-soft:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--ink); }
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: .9rem;
}

/* ============ FORMS ============ */
.form-label { font-size: .84rem; font-weight: 600; color: var(--ink); margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: 9px;
    border-color: var(--line);
    padding: .58rem .85rem;
    font-size: .92rem;
    color: var(--ink);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}
.form-control::placeholder { color: #94a3b8; }
.form-text { font-size: .78rem; color: var(--muted); }
.input-group-text { border-radius: 9px; border-color: var(--line); background: #f8fafc; color: var(--muted); }

/* ============ TOOLBAR ============ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .85rem;
    flex-wrap: wrap;
}
.toolbar .search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.toolbar .search-wrap i {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: .9rem;
}
.toolbar .search-wrap .form-control { padding-left: 2.3rem; }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}
.empty-state .empty-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1rem;
}
.empty-state h5 { font-size: 1.02rem; margin-bottom: .4rem; }
.empty-state p { color: var(--muted); font-size: .9rem; max-width: 380px; margin: 0 auto 1.25rem; }

/* ============ MODALS ============ */
.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
}
.modal-header {
    border-bottom: 1px solid var(--line);
    padding: 1.1rem 1.4rem;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 1.4rem; }
.modal-footer {
    border-top: 1px solid var(--line);
    padding: 1rem 1.4rem;
    background: #f8fafc;
    border-radius: 0 0 14px 14px;
}

/* Bootstrap's modal-dialog-scrollable expects .modal-header, .modal-body and
   .modal-footer to be DIRECT children of .modal-content. Where a <form> wraps
   them instead (the admin plan modal, the record-sale form), that form becomes
   the flex item and the three sections are laid out as normal blocks inside it.
   The body then never shrinks, its overflow-y never engages, and the
   overflow:hidden on .modal-content clips the footer - and with it the Save
   button - out of view on any window shorter than the form. Removing the
   wrapper box puts Bootstrap's flex layout back in charge: the body scrolls
   and the footer stays pinned. Submission is unaffected, because the element
   still exists in the DOM as the ancestor of every field. */
.modal-dialog-scrollable .modal-content > form {
    display: contents;
}

/* ============ BADGES ============ */
.badge {
    font-weight: 600;
    font-size: .72rem;
    padding: .35em .7em;
    border-radius: 6px;
    letter-spacing: .02em;
}

/* ============ DETAIL LISTS (view modals) ============ */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .85rem; }
.detail-item {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .75rem .9rem;
}
.detail-item .d-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: .2rem;
}
.detail-item .d-value { font-weight: 600; color: var(--ink); font-size: .95rem; word-break: break-word; }
.detail-full { grid-column: 1 / -1; }

/* ============ FILTER BAR ============ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}
.filter-bar .filter-group { flex: 1; min-width: 150px; }
.filter-bar .form-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ============ SIDEBAR QUICK ACTIONS ============ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
}
.quick-action {
    display: flex;
    align-items: center;
    gap: .7rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .85rem 1rem;
    color: var(--ink);
    font-weight: 600;
    font-size: .88rem;
    transition: all .13s ease;
}
.quick-action:hover {
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 4px 14px rgba(79, 70, 229, .12);
    transform: translateY(-1px);
}
.quick-action i {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ============ CHART BARS (reports / dashboard mini bars) ============ */
.bar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .7rem;
}
.bar-row .bar-label { width: 130px; font-size: .82rem; color: var(--body); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--brand); border-radius: 999px; min-width: 2px; }
.bar-row .bar-value { width: 90px; font-size: .8rem; font-weight: 600; color: var(--ink); text-align: right; flex-shrink: 0; }

/* ============ TOAST ============ */
.toast {
    border: none;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
.toast .toast-header { border-bottom: 1px solid var(--line); background: #fff; border-radius: 12px 12px 0 0; }

/* ============ AUTH ============ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 55% 45% at 50% -10%, rgba(79, 70, 229, .12), transparent 65%),
        #f1f5f9;
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .10);
    padding: 2.25rem 2rem;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: .7rem; margin-bottom: 1.75rem; text-align: center; }
.auth-brand .name { font-weight: 800; font-size: 1.3rem; color: var(--ink); letter-spacing: -0.03em; }
.auth-brand .tag { color: var(--muted); font-size: .9rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .92rem; color: var(--muted); }

/* ============ ADMIN SPECIFIC ============ */
.admin-brand .sub { color: #818cf8; }
.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: .74rem;
    font-weight: 700;
    padding: .3rem .7rem;
    border-radius: 999px;
}

/* ============ DOUGHNUT CHART (server-rendered SVG) ============ */
.fin-overview__body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.75rem;
}
.doughnut-chart {
    display: block;
    width: 100%;
    max-width: 230px;
    height: auto;
    flex: 0 0 auto;
    margin: 0 auto;
    overflow: visible;
}
.doughnut-slice {
    stroke: var(--surface);
    stroke-width: 2;
    transition: opacity .15s ease;
}
.doughnut-chart:hover .doughnut-slice { opacity: .55; }
.doughnut-chart .doughnut-slice:hover { opacity: 1; }

/* Summary sitting in the open centre of the ring */
.doughnut-center-value {
    fill: var(--ink);
    font-weight: 800;
    letter-spacing: -0.02em;
}
.doughnut-center-label {
    fill: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
}

.doughnut-legend {
    flex: 1 1 210px;
    min-width: 0;
}
.doughnut-legend__item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--line);
}
.doughnut-legend__item:last-child { border-bottom: 0; padding-bottom: 0; }
.doughnut-legend__dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}
.doughnut-legend__label { font-weight: 600; color: var(--ink); font-size: .92rem; }
.doughnut-legend__figures { margin-left: auto; text-align: right; line-height: 1.25; }
.doughnut-legend__value { font-weight: 700; color: var(--ink); font-size: .92rem; }
.doughnut-legend__pct { display: block; font-size: .74rem; color: var(--muted); font-weight: 600; }
.doughnut-legend__note {
    margin-top: .85rem;
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.5;
}
.doughnut-empty {
    text-align: center;
    padding: 1.5rem .5rem;
    color: var(--muted);
    font-size: .9rem;
}

/* ============ STAFF POS ============ */
.pos-results {
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .14);
}
.selected-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .5rem;
    padding: .5rem .65rem;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-radius: 9px;
    font-size: .86rem;
    font-weight: 600;
}
.selected-chip .btn-close { margin-left: auto; font-size: .7rem; }
[data-theme="dark"] .selected-chip { color: #a5b4fc; }

.pos-total {
    padding: .75rem .9rem;
    background: var(--brand-soft);
    border-radius: 10px;
}
.pos-total .text-muted { font-weight: 600; }
.pos-total__value { font-size: 1.35rem; font-weight: 800; color: var(--brand-dark); letter-spacing: -0.02em; }
[data-theme="dark"] .pos-total { background: #1e1b4b; }
[data-theme="dark"] .pos-total__value { color: #a5b4fc; }

.spin { animation: ojaSpin 1s linear infinite; display: inline-block; }
@keyframes ojaSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============ PLAN OPTION CARDS (subscription) ============ */
.plan-option {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem 1.15rem;
}
.plan-option.is-current { border-color: var(--success); box-shadow: 0 0 0 1px var(--success) inset; }
.plan-option__tag { position: absolute; top: -.6rem; right: .9rem; }
.plan-option__price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.03em;
    margin-bottom: .75rem;
}
.plan-option__price small { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.plan-option__limits {
    list-style: none;
    padding: 0;
    margin: 0 0 .9rem;
    display: grid;
    gap: .3rem;
    font-size: .84rem;
    color: var(--body);
}
.plan-option__limits i { color: var(--brand); width: 18px; display: inline-block; }

/* ============ ADMIN PLANS TABLE ============ */
.plan-desc {
    max-width: 240px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.btn-group .btn-icon { width: 32px; height: 32px; padding: 0; }

/* ============ PLAN USAGE (settings) ============ */
.plan-usage { display: grid; gap: .9rem; margin-top: .25rem; }
.plan-usage__label { font-size: .82rem; font-weight: 600; color: var(--ink); }
.plan-usage__label i { color: var(--brand); margin-right: .15rem; }
.plan-usage__count { font-size: .82rem; color: var(--ink); white-space: nowrap; }
.plan-usage__track {
    height: 7px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}
.plan-usage__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--brand);
    min-width: 3px;
    transition: width .2s ease;
}
.plan-usage__fill.is-mid  { background: var(--warning); }
.plan-usage__fill.is-high { background: var(--danger); }
[data-theme="dark"] .plan-usage__track { background: #1c2942; }

/* ============ PUBLIC PRICING LIMITS ============ */
.pricing-limits {
    display: grid;
    gap: .25rem;
    font-size: .8rem;
    color: var(--muted);
    text-align: left;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: .6rem 0;
    margin-bottom: .75rem;
}
.pricing-limits i { color: var(--brand); margin-right: .3rem; }

/* ============ PRODUCT GRID (dashboard) ============ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: .75rem;
}
.product-card {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .8rem .85rem;
    color: var(--body);
    min-width: 0;
    transition: border-color .13s ease, box-shadow .13s ease, transform .13s ease;
}
.product-card:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 14px rgba(79, 70, 229, .12);
    transform: translateY(-1px);
}
.product-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}
.product-card__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}
.product-card.pc-low .product-card__icon { background: #fffbeb; color: var(--warning); }
.product-card.pc-out .product-card__icon { background: #fef2f2; color: var(--danger); }
.product-card__top .badge { white-space: nowrap; }
.product-card__name {
    font-weight: 700;
    color: var(--ink);
    font-size: .92rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card__cat {
    font-size: .74rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-card__foot {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .55rem;
    padding-top: .5rem;
    border-top: 1px solid var(--line);
}
.product-card__price { font-weight: 700; color: var(--ink); font-size: .92rem; }
.product-card__qty { font-size: .74rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.product-card.pc-out .product-card__qty { color: var(--danger); }
.product-card.pc-low .product-card__qty { color: var(--warning); }
.product-grid__more {
    margin: .85rem 0 0;
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
}
.product-grid__more a { color: var(--brand); font-weight: 600; }
.product-grid__more a:hover { text-decoration: underline; }

[data-theme="dark"] .product-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
[data-theme="dark"] .product-card.pc-low .product-card__icon { background: #3a2a08; }
[data-theme="dark"] .product-card.pc-out .product-card__icon { background: #3d1416; }
[data-theme="dark"] .product-card__icon { color: #a5b4fc; }

/* ============ DASHBOARD SECTION ORDER (mobile only) ============
   Desktop keeps the normal document flow. On phones the sections are
   re-ordered so the essentials come first:
     Today's Sales -> Today's Expenses -> Financial Overview -> Products grid
   Implemented with flexbox `order` so no markup is duplicated and desktop
   is completely unaffected. */
@media (max-width: 767.98px) {
    .dash { display: flex; flex-direction: column; }
    .dash > .dash-quick   { order: 1; }
    .dash > .dash-today   { order: 2; }
    .dash > .dash-overview{ order: 3; }
    .dash > .dash-products{ order: 4; }
    .dash > .dash-stats   { order: 5; }
    .dash > .dash-welcome { order: 6; }
    .dash > .dash-bottom  { order: 7; }

    /* Two product cards per row wherever they fit */
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .product-card { padding: .7rem .7rem; }
    .product-card__foot { flex-direction: column; align-items: flex-start; gap: .1rem; }
}

/* ============ STAT CARDS ON MOBILE ============
   Every stat card stays visible on phones, sitting two-per-row beside its
   neighbour. The icon moves above the text so the figure gets the full card
   width, which is what stops long amounts like N116,000.00 from spilling out
   of the card when the row is only half the screen. */
@media (max-width: 767.98px) {
    .stat-card {
        flex-direction: column-reverse;
        align-items: stretch;
        justify-content: flex-start;
        gap: .5rem;
        padding: .8rem .85rem;
        height: 100%;
    }
    .stat-card > div:first-child { min-width: 0; }
    .stat-card .stat-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        font-size: .85rem;
        align-self: flex-start;
    }
    .stat-card .stat-label {
        font-size: .68rem;
        letter-spacing: .06em;
        margin-bottom: .25rem;
    }
    .stat-card .stat-value {
        font-size: 1.18rem;
        overflow-wrap: anywhere;
    }
    .stat-card .stat-note { font-size: .72rem; margin-top: .2rem; }
}

/* ============ RESPONSIVE TABLE CARDS ============
   Tables keep their normal layout on desktop. Below 768px each row
   becomes its own card: the <thead> is hidden and every <td> is turned
   into a "label ......... value" line using its data-label attribute.
   No horizontal scrolling, no JavaScript. */
@media (max-width: 767.98px) {
    .table-cards { overflow-x: visible; }
    .table-cards > table,
    .table-cards > table > tbody,
    .table-cards > table > tbody > tr,
    .table-cards > table > tbody > tr > td {
        display: block;
        width: 100%;
    }
    .table-cards > table { margin-bottom: 0; }
    .table-cards > table > thead { display: none; }

    .table-cards > table > tbody > tr {
        display: flex;
        flex-direction: column;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        padding: .3rem .15rem;
        margin: 0 0 .7rem;
    }
    .table-cards > table > tbody > tr:last-child { margin-bottom: 0; }
    .table-cards > table > tbody > tr:hover { background: var(--surface); }

    .table-cards > table > tbody > tr > td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: .9rem;
        padding: .45rem .85rem;
        border: 0;
        text-align: right;
        word-break: break-word;
    }
    .table-cards > table > tbody > tr > td::before {
        content: attr(data-label);
        flex: 0 1 auto;
        font-size: .68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--muted);
        text-align: left;
        padding-top: .15rem;
    }
    .table-cards > table > tbody > tr > td > * { min-width: 0; }
    .table-cards > table > tbody > tr > td .cell-sub { display: inline; }

    /* Primary cell becomes the card heading, and always sits on top even if
       it is not the first column in the table (e.g. Sales). */
    .table-cards > table > tbody > tr > td[data-cell="title"] {
        display: block;
        order: -1;
        text-align: left;
        padding: .8rem .9rem .5rem;
    }
    .table-cards > table > tbody > tr > td[data-cell="title"]::before { content: none; }
    .table-cards > table > tbody > tr > td[data-cell="title"] .cell-main {
        font-size: 1rem;
        font-weight: 700;
    }
    .table-cards > table > tbody > tr > td[data-cell="title"] .cell-sub {
        display: block;
        font-size: .8rem;
        margin-top: .1rem;
    }

    /* Actions sit in a full-width footer with real button labels */
    .table-cards > table > tbody > tr > td[data-cell="actions"] {
        order: 1;
        border-top: 1px solid var(--line);
        margin-top: .35rem;
        padding: .6rem .9rem .75rem;
        justify-content: flex-start;
    }
    .table-cards > table > tbody > tr > td[data-cell="actions"]::before { content: none; }
    .table-cards > table > tbody > tr > td[data-cell="actions"] .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: .4rem;
        width: 100%;
    }
    .table-cards > table > tbody > tr > td[data-cell="actions"] .btn-group .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
    .table-cards > table > tbody > tr > td[data-cell="actions"] .btn-group .btn::after {
        content: attr(title);
        margin-left: .35rem;
    }
    .table-cards > table > tbody > tr > td[data-cell="actions"] > .btn {
        width: 100%;
        justify-content: center;
    }
    .table-cards > table > tbody > tr > td[data-cell="actions"] > .btn::after {
        content: attr(title);
        margin-left: .35rem;
    }

    /* Secondary sale fields stay hidden on mobile until View is pressed;
       the View button opens the full sale details modal. */
    .table-cards > table > tbody > tr > td[data-cell="secondary"] { display: none; }

    /* Empty-state row keeps the full card, without a label */
    .table-cards > table > tbody > tr > td[colspan] {
        padding: 0;
        text-align: center;
    }
    .table-cards > table > tbody > tr > td[colspan]::before { content: none; }
    .table-cards > table > tbody > tr > td[colspan] .empty-state { padding: 1.75rem 1rem; }
}

/* ============ SALE CARD + DETAILS MODAL (mobile) ============
   Compact sale list: reference, customer, total and a View button.
   Everything else is revealed through the existing View modal. */
@media (max-width: 767.98px) {
    .sale-ref {
        font-size: .7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--brand);
    }
    .table-cards > table > tbody > tr > td[data-label="Customer"] .cell-main { font-size: 1rem; }
    .table-cards > table > tbody > tr > td.sale-total {
        font-size: 1.05rem;
        padding-top: .55rem;
    }
    .table-cards > table > tbody > tr > td.sale-date {
        font-size: .82rem;
        padding-top: .1rem;
    }
    .table-cards > table > tbody > tr > td[data-label="Customer"] { padding-top: .1rem; }

    /* Sale details fill the phone screen edge to edge */
    #viewSaleModal .modal-dialog { margin: 0; }
    #viewSaleModal .modal-content {
        border-radius: 0;
        min-height: 100%;
        border: 0;
    }
    #viewSaleModal .modal-body { flex: 1 1 auto; }
}


/* Very small screens: tighten the cards so nothing overflows */
@media (max-width: 400px) {
    /* Topbar must never push the page wider than the screen */
    .topbar { gap: .5rem; padding: .55rem .75rem; }
    .topbar > :first-child { min-width: 0; gap: .5rem !important; }
    .topbar .page-title {
        font-size: .95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-user { gap: .4rem; flex-shrink: 0; }

    .table-cards > table > tbody > tr { padding: .2rem .1rem; }
    .table-cards > table > tbody > tr > td { padding: .4rem .7rem; gap: .6rem; font-size: .88rem; }
    .table-cards > table > tbody > tr > td[data-cell="title"] { padding: .7rem .7rem .4rem; }
    .table-cards > table > tbody > tr > td[data-cell="actions"] { padding: .55rem .7rem .65rem; }
    .fin-overview__body { gap: 1rem; }
    .doughnut-chart { max-width: 190px; }
}


@media print {
    .sidebar, .topbar, .sidebar-overlay, .no-print, .btn, .toolbar, .modal { display: none !important; }
    .main-wrap { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    body { background: #fff; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .page-content { padding: 1rem; }
    .topbar { padding: .55rem 1rem; }
    .topbar-user .who { display: none; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .card-header { padding: .9rem 1rem; }
    .table thead th, .table tbody td { padding: .65rem .75rem; }
    .toolbar .search-wrap { max-width: none; }
    .filter-bar .filter-group { min-width: 100%; }
    .bar-row .bar-label { width: 90px; }
    .bar-row .bar-value { width: 70px; }
    /* Stack tables horizontally scrollable with visible affordance */
    .table-responsive { border: 0; }
}

/* ============ DARK MODE ============ */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

[data-theme="dark"] {
    --brand-soft: #1e1b4b;
    --ink: #eef2f9;
    --body: #c3ccdc;
    --muted: #8fa0b8;
    --line: #22304a;
    --bg: #0a1020;
    --surface: #111a2e;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #38bdf8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);

    /* Bootstrap variables, kept in sync so forms, modals and badges follow the theme */
    --bs-body-bg: #111a2e;
    --bs-body-bg-rgb: 17, 26, 46;
    --bs-body-color: #c3ccdc;
    --bs-body-color-rgb: 195, 204, 220;
    --bs-emphasis-color: #eef2f9;
    --bs-secondary-color: #8fa0b8;
    --bs-tertiary-color: rgba(238, 242, 249, .06);
    --bs-tertiary-bg: rgba(238, 242, 249, .06);
    --bs-tertiary-bg-rgb: 238, 242, 249;
    --bs-border-color: #22304a;
    --bs-border-color-translucent: rgba(34, 48, 74, .75);
    --bs-card-bg: #111a2e;
    --bs-dropdown-bg: #111a2e;
    --bs-list-group-bg: #111a2e;
    --bs-popover-bg: #111a2e;
}

[data-theme="dark"] .text-dark { color: var(--ink) !important; }

[data-theme="dark"] .sidebar-toggle,
[data-theme="dark"] .btn-outline-soft,
[data-theme="dark"] .quick-action { background: var(--surface); }
[data-theme="dark"] .btn-outline-soft:hover { background: #17223a; border-color: #33415c; color: var(--ink); }
[data-theme="dark"] .quick-action:hover { border-color: var(--brand); color: #a5b4fc; }

[data-theme="dark"] .table thead th { background: #0e1729; }
[data-theme="dark"] .table tbody td { border-color: #1a2437; }
[data-theme="dark"] .table-hover tbody tr:hover { background: #131d31; }

[data-theme="dark"] .input-group-text { background: #0d1526; border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .form-control::placeholder { color: #7d8da6; }

[data-theme="dark"] .stat-icon.i-brand { background: #241d5e; color: #a5b4fc; }
[data-theme="dark"] .stat-icon.i-success { background: #0b3325; color: #34d399; }
[data-theme="dark"] .stat-icon.i-warning { background: #3a2a08; color: #fbbf24; }
[data-theme="dark"] .stat-icon.i-danger { background: #3d1416; color: #f87171; }
[data-theme="dark"] .stat-icon.i-info { background: #0a2c42; color: #38bdf8; }

[data-theme="dark"] .topbar-user .avatar,
[data-theme="dark"] .empty-state .empty-icon,
[data-theme="dark"] .quick-action i { color: #a5b4fc; }

[data-theme="dark"] .detail-item { background: #0e1729; }
[data-theme="dark"] .detail-item[style*="#fef2f2"] { background: #3a1416 !important; border-color: #7f1d1d !important; }

[data-theme="dark"] .bar-row .bar-track { background: #1c2942; }

[data-theme="dark"] .modal-content { background: var(--surface); color: var(--body); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
[data-theme="dark"] .modal-footer { background: #0d1526; }
[data-theme="dark"] .toast .toast-header { background: #0d1526; color: var(--ink); }

[data-theme="dark"] .plan-badge { color: #a5b4fc; }

[data-theme="dark"] .auth-body {
    background:
        radial-gradient(ellipse 55% 45% at 50% -10%, rgba(79, 70, 229, .22), transparent 65%),
        var(--bg);
}
[data-theme="dark"] .auth-card { background: var(--surface); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }
