:root {
    /* ---- Single, uniform colour palette used by every page ----
       Change --primary / --primary-dark here to re-theme the whole app
       (login page, sidebar, cards, buttons). */
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-soft: #f0fdf4;
    --secondary: #15803d;      /* kept for backwards compatibility */
    --ink: #111827;            /* sidebar / top bar / headings */
    --muted: #6b7280;
    --line: #e5e7eb;
    --surface: #ffffff;
    --page-bg: #f4f5f7;
    --success: #10b981;        /* status only (stock / payment) */
    --danger: #ef4444;         /* status + destructive actions only */
    --warning: #f59e0b;        /* status only */
    --info: #16a34a;

    /* Make Bootstrap's own "primary" follow the palette */
    --bs-primary: #16a34a;
    --bs-primary-rgb: 22, 163, 74;
    --bs-link-color: #16a34a;
    --bs-link-hover-color: #15803d;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--page-bg);
    color: #1f2937;
    margin: 0;
    padding: 0;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background: var(--ink);
    padding: 20px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-brand {
    color: white;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    padding: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background: var(--primary);
    color: white;
}

.sidebar-menu i {
    margin-right: 10px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    padding: 20px;
    min-height: 100vh;
}

/* Stat Cards */
.stat-card {
    background: var(--primary);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 32px;
    font-weight: bold;
    margin: 10px 0;
}

.stat-card p {
    margin: 0;
    opacity: 0.9;
}

.stat-card small {
    opacity: 0.8;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    background: white;
    border-bottom: 2px solid #f3f4f6;
    padding: 15px 20px;
    font-weight: 600;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Tables */
.table-hover tbody tr:hover {
    background-color: #f9fafb;
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* List Group */
.list-group-item {
    border-left: none;
    border-right: none;
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

/* NOTE: base rules stay ABOVE the media query below, otherwise their
   display:none would override the media query's display:flex/block. */

/* Mobile/tablet top header — injected via JS, hidden on desktop */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 12px;
    align-items: center;
    gap: 12px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1100; /* above the drawer so the toggler stays clickable */
}

.mobile-topbar .topbar-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.mobile-topbar .topbar-store {
    font-size: 12px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-topbar .topbar-page {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hamburger button — lives inside the top header */
.sidebar-toggle-btn {
    flex: 0 0 auto;
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 22px;
    cursor: pointer;
}

/* Click-away backdrop behind the open drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}

/* ============================================
   RESPONSIVE LAYOUT — tablets and phones
   Below 992px the sidebar becomes an off-canvas
   drawer (hidden by default, slides in over the
   content) instead of squeezing the page or
   stacking above it. Toggled by the hamburger
   button injected in assets/js/main.js.
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        width: 270px;
        padding-top: 75px; /* clear the top header */
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .main-content {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: 80px; /* room for the fixed top header */
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar-backdrop.active {
        display: block;
    }
}

/* Tighter stat cards on phones specifically */
@media (max-width: 575.98px) {
    .stat-card h3 {
        font-size: 22px;
    }

    .stat-card {
        padding: 18px;
    }
}

/* ============================================
   STAT CARD GRID (.stats-grid)
   Applied to the summary-card rows on the
   dashboard, debts, and expenses pages so they
   show 4-across on desktop, 2-across on tablets,
   and 1-across on phones — without touching
   Bootstrap's column system globally.
   ============================================ */
@media (min-width: 576px) and (max-width: 991.98px) {
    .stats-grid > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 575.98px) {
    .stats-grid > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Generous tap targets on touch screens */
@media (max-width: 991.98px) {
    .btn, .page-link, .sidebar-menu a {
        min-height: 40px;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c7c9d1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ============================================
   UNIFORM COLOUR OVERRIDES
   Every summary card, header, button and icon
   uses the same palette on every page. Only
   real status signals (in/low/out of stock,
   paid/owing, delete) keep green/amber/red.
   ============================================ */

/* Summary cards: one colour everywhere (beats inline gradients + bg-* classes) */
.stat-card,
.stat-card[class*="bg-"],
.stat-card[style] {
    background: var(--primary) !important;
    color: #fff !important;
}

/* Report summary cards (bg-primary/success/info/warning/secondary text-white) */
.card.bg-primary, .card.bg-success, .card.bg-info,
.card.bg-warning, .card.bg-secondary {
    background: var(--primary) !important;
    color: #fff !important;
}

/* Coloured card headers -> soft neutral header */
.card-header.bg-warning, .card-header.bg-success,
.card-header.bg-info, .card-header.bg-secondary {
    background: var(--primary-soft) !important;
    color: var(--primary-dark) !important;
}
.card-header.bg-primary {
    background: var(--primary) !important;
    color: #fff !important;
}

/* Icons / figures coloured with Bootstrap text utilities inside cards */
.card i.text-info, .card i.text-warning, .card i.text-primary, .card i.text-success {
    color: var(--primary) !important;
}
.text-primary { color: var(--primary) !important; }
.text-info    { color: var(--primary) !important; }

/* Buttons: one accent colour. Destructive stays red. */
.btn-success, .btn-info, .btn-warning {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-success:hover, .btn-info:hover, .btn-warning:hover,
.btn-success:focus, .btn-info:focus, .btn-warning:focus,
.btn-success:active, .btn-info:active, .btn-warning:active {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    color: #fff !important;
}
.btn-secondary {
    background: #374151;
    border-color: #374151;
    color: #fff;
}
.btn-secondary:hover { background: #1f2937; border-color: #1f2937; color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover, .btn-check:checked + .btn-outline-primary {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn-outline-secondary { color: #374151; border-color: #d1d5db; }
.btn-outline-secondary:hover { background: #374151; border-color: #374151; color: #fff; }

/* Badges: neutral/accent ones unified (status badges keep their meaning) */
.badge.bg-primary, .badge.bg-info {
    background-color: var(--primary) !important;
    color: #fff !important;
}
.badge.bg-secondary { background-color: #6b7280 !important; }
.badge.bg-warning   { color: #fff !important; }

/* Form focus + misc accents */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(22, 163, 74, 0.15);
}
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.page-item.active .page-link { background-color: var(--primary); border-color: var(--primary); }
.page-link { color: var(--primary); }
.nav-pills .nav-link.active, .nav-tabs .nav-link.active { color: var(--primary); }
.nav-pills .nav-link.active { background: var(--primary); color: #fff; }
.spinner-border.text-primary { color: var(--primary) !important; }
.progress-bar { background-color: var(--primary); }
.table > thead { --bs-table-bg: #f9fafb; }
.card { border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06); }
