
/* ============================================================
   Sunglow Enterprise Design System — v2 (Full Scale)
   ============================================================ */
:root {
    /* Color Palette */
    --primary:          #0D6B4F;
    --primary-hover:    #0A5540;
    --primary-light:    #E8F5F1;
    --secondary:        #475569;
    --accent:           #F4B942;
    --accent-strong:    #A96A0B;
    --accent-soft:      rgba(244, 185, 66, 0.16);
    --bg:               #F1F5F9;
    --surface:          #FFFFFF;
    --border:           #E2E8F0;
    --text-primary:     #0F172A;
    --text:             #0F172A;
    --text-muted:       #64748B;

    /* Semantic Colors */
    --success:          #10B981;
    --success-light:    #ECFDF5;
    --warning:          #F59E0B;
    --warning-light:    #FFFBEB;
    --danger:           #EF4444;
    --danger-light:     #FEF2F2;
    --info:             #3B82F6;
    --info-light:       #EFF6FF;

    /* Borders & Radii */
    --radius:           10px;
    --radius-sm:        7px;
    --radius-lg:        14px;

    /* Typography */
    --font: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Layout Dimensions — enterprise scale */
    --sidebar-width:    280px;
    --topbar-height:    68px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --shadow:     0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.06);
    --shadow-md:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

/* ============================================================
   Dark Mode Token Overrides
   ============================================================ */
[data-theme="dark"] {
    --primary:          #34D399;
    --primary-hover:    #10B981;
    --primary-light:    rgba(52, 211, 153, 0.12);
    --accent:           #FBBF24;
    --accent-strong:    #F59E0B;
    --accent-soft:      rgba(251, 191, 36, 0.14);
    --bg:               #0F172A;
    --surface:          #1E293B;
    --border:           #334155;
    --text-primary:     #F1F5F9;
    --text:             #F1F5F9;
    --text-muted:       #94A3B8;
    --success-light:    rgba(16, 185, 129, 0.15);
    --warning-light:    rgba(245, 158, 11, 0.15);
    --danger-light:     rgba(239, 68, 68, 0.15);
    --info-light:       rgba(59, 130, 246, 0.15);
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow:     0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-md:  0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.3);
}

/* Dark mode body & background */
[data-theme="dark"] body {
    background: var(--bg);
}

/* Smooth theme transitions */
body, .topbar, .card, .stat-card, .table-wrapper,
.modal-content, .modal-header, .modal-footer,
.form-input, select.form-input, textarea.form-input,
.pos-cart-panel, .pos-product-card, .pos-summary-section,
.badge, .alert, .btn-secondary, .btn-ghost,
.page-link, .pagination li a, .pagination li span {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

/* Dark mode component overrides */
[data-theme="dark"] body {
    color: var(--text-primary);
}

[data-theme="dark"] .topbar {
    background: var(--surface);
    border-bottom-color: var(--border);
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .card-header {
    border-bottom-color: var(--border);
    background: transparent;
}

[data-theme="dark"] .table-wrapper {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .table th {
    background: #0F172A;
    color: #94A3B8;
    border-bottom-color: var(--border);
}

[data-theme="dark"] .table td {
    border-bottom-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .table tr:hover td {
    background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] select.form-input,
[data-theme="dark"] textarea.form-input {
    background: #0F172A;
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .form-input::placeholder {
    color: #475569;
}

[data-theme="dark"] .form-label {
    color: #CBD5E1;
}

[data-theme="dark"] .btn-secondary {
    background: #1E293B;
    border-color: var(--border);
    color: #CBD5E1;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #334155;
    color: #F1F5F9;
}

[data-theme="dark"] .btn-ghost {
    border-color: var(--border);
    color: #94A3B8;
}

[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .badge-secondary {
    background: #1E293B;
    color: #94A3B8;
    border-color: var(--border);
}

[data-theme="dark"] .badge-success {
    background: var(--success-light);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.25);
}

[data-theme="dark"] .badge-warning {
    background: var(--warning-light);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .badge-danger {
    background: var(--danger-light);
    color: #F87171;
    border-color: rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .badge-info {
    background: var(--info-light);
    color: #60A5FA;
    border-color: rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .badge-primary {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(52, 211, 153, 0.25);
}

[data-theme="dark"] .alert-success {
    background: var(--success-light);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.3);
}

[data-theme="dark"] .alert-danger {
    background: var(--danger-light);
    color: #F87171;
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .alert-warning {
    background: var(--warning-light);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .alert-info {
    background: var(--info-light);
    color: #60A5FA;
    border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .modal-content {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: #0F172A;
    border-color: var(--border);
}

[data-theme="dark"] .pos-cart-panel {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .pos-product-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .pos-summary-section {
    background: #0F172A;
    border-color: var(--border);
}

[data-theme="dark"] .pos-summary-row.total {
    border-top-color: var(--border);
}

[data-theme="dark"] .page-link,
[data-theme="dark"] .pagination li a,
[data-theme="dark"] .pagination li span {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .page-link:hover,
[data-theme="dark"] .pagination li a:hover {
    background: #334155;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ============================================================
   Brand & Visual Enhancements
   ============================================================ */
.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 8px 18px rgba(15,23,42,0.12);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-mark.brand-mark-large {
    width: 76px;
    height: 76px;
    border-radius: 22px;
}

body {
    background: linear-gradient(135deg, #f8fafc 0%, #eef6f2 52%, #fff8e9 100%);
}

/* ============================================================
   Base Reset & Globals
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;    /* enterprise base — was 14px */
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[x-cloak] {
    display: none !important;
}

/* Typography Scale */
h1 { font-size: 1.875rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: 1.5rem;   font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
h3 { font-size: 1.2rem;   font-weight: 600; color: var(--text-primary); }
h4 { font-size: 1rem;     font-weight: 600; color: var(--text-primary); }
p  { color: var(--text-muted); line-height: 1.65; }
a  { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); }

/* Scrollbars */
::-webkit-scrollbar            { width: 7px; height: 7px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover{ background: #94A3B8; }

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #001B36 0%, #002A54 100%); /* Premium Oxford Navy match to logo */
    color: #F8F8FC;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    overflow: hidden;
    transform: translateX(0);
    transition: width 0.25s ease, transform 0.25s ease;
}

@media (min-width: 1025px) {
    .app-shell.sidebar-collapsed .sidebar {
        width: 88px;
    }

    .app-shell.sidebar-collapsed .sidebar-brand {
        justify-content: center;
    }
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .branch-badge,
.app-shell.sidebar-collapsed .nav-section-label,
.app-shell.sidebar-collapsed .nav-group-caret,
.app-shell.sidebar-collapsed .sidebar-footer .user-meta,
.app-shell.sidebar-collapsed .sidebar-footer .btn-logout {
    display: none;
}

.app-shell.sidebar-collapsed .nav-item {
    justify-content: center;
    padding-left: 0;
    width: 100%;
}

.app-shell.sidebar-collapsed .nav-item .nav-icon {
    margin-right: 0;
}

.app-shell.sidebar-collapsed .nav-item span:not(.nav-icon) {
    display: none;
}

.app-shell.sidebar-collapsed .nav-group-items {
    display: none !important;
}

.app-shell.sidebar-collapsed .sidebar-nav {
    padding-left: 0;
}

.app-shell.sidebar-collapsed .sidebar-footer {
    padding: 12px 0 16px;
}

.app-shell.sidebar-collapsed .sidebar-brand {
    padding: 0 12px;
}

/* Brand */
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.brand-icon {
    font-size: 1.7rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(16,185,129,0.3));
}

.brand-text h2 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #FFFFFF;
    line-height: 1;
    background: linear-gradient(135deg, #FFFFFF 0%, #34D399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.72rem;
    color: #64748B;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Branch Badge */
.branch-badge {
    margin: 14px 16px 8px;
    padding: 10px 12px;
    background: rgba(16, 185, 129, 0.06);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(16, 185, 129, 0.15);
    flex-shrink: 0;
}

.branch-label {
    display: block;
    font-size: 0.62rem;
    color: rgba(52, 211, 153, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
    font-weight: 700;
}

.branch-name {
    font-weight: 700;
    font-size: 0.83rem;
    color: #FFFFFF;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

/* Custom Scrollbar for Sidebar Nav */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.nav-section-label {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    margin: 16px 8px 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94A3B8;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: all 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #FFFFFF;
    padding-left: 15px; /* micro-interaction slide */
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(234, 179, 53, 0.15) 0%, rgba(234, 179, 53, 0.02) 100%);
    color: #FBBF24; /* Adjusted gold to match standard alert colors */
    border-left: 3px solid #FBBF24;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-weight: 600;
    padding-left: 14px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.nav-group-caret {
    margin-left: auto;
    font-size: 1rem;
    color: currentColor;
}

.nav-group-items {
    display: block;
    padding-left: 18px;
    margin-top: 4px;
}

.nav-group-items .nav-item {
    padding-left: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    border-left: 3px solid transparent;
}

.nav-group-items .nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    padding-left: 33px;
}

.nav-group-items .nav-item.active {
    background: linear-gradient(90deg, rgba(234, 179, 53, 0.12) 0%, rgba(234, 179, 53, 0.01) 100%);
    color: #FBBF24;
    border-left: 3px solid #FBBF24;
}

.nav-icon {
    font-size: 1.22rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 999px;
    color: #FFFFFF;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s ease, background 0.2s ease;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

@media (max-width: 1024px) {
    .sidebar {
        width: min(92vw, 280px);
        transform: translateX(-110%);
        box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
    }

    .sidebar.sidebar-visible {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .mobile-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        z-index: 90;
    }

    .main-content {
        margin-left: 0;
    }

    .app-shell.sidebar-collapsed .main-content {
        margin-left: 0;
    }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #10B981);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.83rem;
    flex-shrink: 0;
}

.user-meta { line-height: 1.25; }

.user-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #F1F5F9;
}

.user-role {
    font-size: 0.68rem;
    color: #64748B;
}

.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94A3B8;
    padding: 7px 12px;
    font-size: 0.78rem;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
}

.btn-logout:hover {
    background: #EF4444;
    border-color: #EF4444;
    color: #FFFFFF;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.app-shell.sidebar-collapsed .main-content {
    margin-left: 88px;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Page Content */
.page-content {
    padding: 32px;
    flex: 1;
}

/* Flash Zone */
.flash-zone {
    padding: 20px 32px 0;
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dark-mode-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
}

.dark-mode-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
    transform: rotate(12deg) scale(1.08);
    box-shadow: 0 0 0 4px var(--primary-light);
}

[data-theme="dark"] .dark-mode-toggle {
    background: #1E293B;
    border-color: #334155;
    color: #FBBF24;
}

[data-theme="dark"] .dark-mode-toggle:hover {
    background: #FBBF24;
    border-color: #FBBF24;
    color: #0F172A;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
}


/* ============================================================
   Components
   ============================================================ */

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.card + .card {
    margin-top: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.25;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(13,107,79,0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: #FFFFFF;
    box-shadow: 0 4px 8px rgba(13,107,79,0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #F1F5F9;
    border-color: #E2E8F0;
    color: #334155;
}
.btn-secondary:hover {
    background: #E2E8F0;
    color: #1E293B;
}

.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
}
.btn-danger:hover {
    background: #DC2626;
    color: #FFFFFF;
}

.btn-warning {
    background: var(--warning);
    color: #FFFFFF;
}
.btn-warning:hover {
    background: #D97706;
    color: #FFFFFF;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--bg);
    color: var(--text-primary);
    border-color: #CBD5E1;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input,
select.form-input,
textarea.form-input {
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition: all 0.15s ease;
    width: 100%;
    line-height: 1.5;
}

.form-input:focus,
select.form-input:focus,
textarea.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,107,79,0.12);
}

.form-input::placeholder { color: #CBD5E1; }

.form-input.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    font-weight: 500;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Tables --- */
.table-wrapper {
    display: block;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
    table-layout: auto;
}

.table th,
.table td {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}

@media (max-width: 992px) {
    .table {
        min-width: 700px;
        display: table;
    }

    .table-wrapper {
        overflow-x: auto;
    }
    .table th,
    .table td {
        white-space: nowrap;
        word-break: normal;
        overflow-wrap: normal;
    }
}

/* --- Pagination --- */

/* Bootstrap 5 nav wrapper rendered by ->links() */
.pagination-wrapper nav,
nav[role="navigation"] {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* The ul.pagination row */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Each li is a simple list item — NOT a flex container */
.page-item {
    display: list-item;
    list-style: none;
    margin: 0;
}

/* The link / span inside each li */
.page-link,
.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
}

.page-link:hover,
.pagination li a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Active page */
.page-item.active .page-link,
.pagination li.active span,
.pagination li.active a {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
    font-weight: 700;
}

/* Disabled (prev/next when on first/last page) */
.page-item.disabled .page-link,
.pagination li.disabled span,
.pagination li.disabled a {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* "Showing X to Y of Z results" info text from Bootstrap 5 paginator */
.pagination-info,
.d-none.flex-sm-fill .small.text-muted,
nav .small.text-muted {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.83rem;
    margin-top: 0;
}

/* Bootstrap 5 flex utility classes used inside paginator nav */
.d-flex { display: flex !important; }
.justify-items-center { justify-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-sm-center { align-items: center !important; }
.flex-fill { flex: 1 1 auto !important; }
.fw-semibold { font-weight: 600 !important; }

@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-flex { display: flex !important; }
    .flex-sm-fill { flex: 1 1 auto !important; }
    .justify-content-sm-between { justify-content: space-between !important; }
}

@media (max-width: 575px) {
    .d-none { display: none !important; }
    .pagination {
        justify-content: center;
    }
}

.pagination-info {
    justify-content: flex-start;
    color: var(--text-muted);
    font-size: 0.83rem;
}

@media (max-width: 768px) {
    .pagination {
        justify-content: center;
    }
    .pagination-info {
        justify-content: center;
    }
}


.table th {
    padding: 13px 18px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.92rem;
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--bg);
}

.table tbody tr {
    transition: background 0.1s;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 9999px;
    line-height: 1;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: #065F46;  border: 1px solid rgba(16,185,129,0.25); }
.badge-warning { background: var(--warning-light); color: #92400E;  border: 1px solid rgba(245,158,11,0.25); }
.badge-danger  { background: var(--danger-light);  color: #991B1B;  border: 1px solid rgba(239,68,68,0.25);  }
.badge-primary { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(13,107,79,0.25); }
.badge-info    { background: var(--info-light);    color: #1D4ED8;  border: 1px solid rgba(59,130,246,0.25); }
.badge-secondary{ background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* --- Alerts --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.55;
}

.alert-success {
    background: var(--success-light);
    border-color: rgba(16,185,129,0.3);
    color: #065F46;
}
.alert-danger {
    background: var(--danger-light);
    border-color: rgba(239,68,68,0.3);
    color: #991B1B;
}
.alert-warning {
    background: var(--warning-light);
    border-color: rgba(245,158,11,0.3);
    color: #92400E;
}
.alert-info {
    background: var(--info-light);
    border-color: rgba(59,130,246,0.3);
    color: #1D4ED8;
}

/* ============================================================
   Layout Utilities
   ============================================================ */
.d-flex         { display: flex; }
.flex-column    { flex-direction: column; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 18px; }
.gap-5  { gap: 24px; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.text-muted  { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.d-block     { display: block; }
.w-100       { width: 100%; }
.mb-0        { margin-bottom: 0 !important; }
.mt-2        { margin-top: 8px; }
.mt-3        { margin-top: 12px; }
.mt-4        { margin-top: 18px; }

/* Page section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.35rem;
}

/* ============================================================
   Point of Sale Layout
   ============================================================ */
.pos-container {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 22px;
    height: calc(100vh - var(--topbar-height) - 64px);
    overflow: hidden;
}

.pos-catalog-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.pos-cart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pos-search-bar {
    margin-bottom: 18px;
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.pos-product-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
}

.pos-product-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.pos-product-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 5px;
    line-height: 1.3;
}

.pos-product-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pos-product-price {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.1rem;
    margin-top: 10px;
}

.pos-cart-header {
    padding: 18px 20px;
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.pos-cart-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.pos-cart-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pos-summary-section {
    padding: 18px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.pos-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.pos-summary-row.total {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px dashed var(--border);
}

.pos-actions {
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* ============================================================
   Modal / Dialog
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 26px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    color: var(--text-primary);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: 26px;
    color: var(--text-primary);
}

.modal-footer {
    padding: 18px 26px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg);
}

/* ============================================================
   POS Page Layout – natural growth (cart grows, page scrolls)
   ============================================================ */
.pos-active-layout {
    padding: 16px !important;
    /* allow page to scroll naturally as cart grows */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: calc(100vh - var(--topbar-height)) !important;
}

.pos-active-layout .pos-container {
    height: auto !important;
    margin-bottom: 16px !important;
}

.pos-active-layout .pos-product-grid {
    overflow-y: auto !important;
}

/* Responsive utilities for audit logs, sidebar, and mobile layout */
.audit-filter-grid {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.audit-filter-field {
    margin-bottom: 0;
    flex: 1 1 220px;
    min-width: 0;
}

.audit-filter-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    flex: 1 1 100%;
    justify-content: flex-start;
}

.audit-filter-actions .btn {
    min-width: 120px;
}

@media (max-width: 768px) {
    .audit-filter-grid {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .audit-filter-field,
    .audit-filter-actions {
        width: 100%;
    }

    .audit-filter-actions {
        justify-content: stretch;
        margin-top: 8px;
    }

    .audit-filter-actions .btn {
        width: 100%;
    }
}

.table th,
.table td {
    word-break: break-word;
}

.mobile-menu-btn,
.mobile-overlay {
    display: none;
}

@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 90vw);
        max-width: 320px;
        height: 100vh;
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        z-index: 1100;
        box-shadow: 2px 0 18px rgba(15, 23, 42, 0.16);
        background: linear-gradient(180deg, #001B36 0%, #002A54 100%);
    }

    .sidebar-visible {
        transform: translateX(0) !important;
        visibility: visible;
    }

    .mobile-menu-btn {
        position: fixed;
        top: 18px;
        left: 18px;
        z-index: 1200;
        width: 44px;
        height: 44px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        background: rgba(15, 23, 42, 0.9);
        color: #FFFFFF;
        font-size: 1.3rem;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: var(--shadow-sm);
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1080;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-expanded .mobile-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
        min-height: 100vh;
    }

    .topbar {
        padding: 16px 20px 16px 88px;
        flex-wrap: wrap;
        row-gap: 12px;
    }

    .topbar-title {
        width: 100%;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-content {
        padding: 24px 20px;
    }

    .card {
        padding: 24px;
        width: 100%;
        max-width: 100%;
        overflow-wrap: break-word;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (min-width: 993px) {
    .mobile-menu-btn,
    .mobile-overlay {
        display: none !important;
    }
}

@media (max-width: 992px) {
    .form-input,
    .badge {
        font-size: 0.9rem;
    }

    .table-wrapper {
        overflow-x: auto;
    }

    .table th,
    .table td {
        padding: 12px 12px;
        white-space: nowrap;
    }

    .btn {
        padding: 10px 16px;
    }

    .card,
    .stat-card,
    .page-content,
    .table-wrapper {
        width: 100%;
        max-width: 100%;
    }

    .card {
        padding: 18px;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .stats-grid,
    .grid-2,
    .grid-3,
    .pos-container,
    .pos-product-grid {
        grid-template-columns: 1fr;
    }

    .pos-container {
        height: auto;
    }

    .pos-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 14px 16px 14px 88px;
    }

    .page-content {
        padding: 18px 16px;
    }

    .card {
        padding: 18px;
        width: 100%;
        max-width: 100%;
    }

    .table-wrapper {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    .table th,
    .table td {
        padding: 10px 10px;
        white-space: nowrap;
    }

    .audit-filter-actions {
        width: 100%;
        justify-content: stretch;
    }

    .audit-filter-actions .btn {
        flex: 1 1 0;
        width: 100%;
    }

    .nav-item {
        padding: 10px 14px;
        font-size: 0.88rem;
    }

    .sidebar {
        border-right: none;
    }

    .pos-product-card {
        min-height: auto;
    }

    .pos-cart-item {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .page-content,
    .card,
    .table-wrapper,
    .stats-grid,
    .pos-cart-panel,
    .pos-product-grid {
        width: 100%;
        max-width: 100%;
    }

    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions > * {
        width: 100%;
    }

    .topbar {
        justify-content: space-between;
    }

    .table {
        display: table;
        width: 100%;
    }

    .stats-grid,
    .grid-2,
    .grid-3,
    .pos-container,
    .pos-product-grid {
        grid-template-columns: 1fr;
    }
}


/* Pagination container layout — used by pages that wrap ->links() in .pagination-container */
.pagination-container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 16px 0 4px;
}

.pagination-container nav {
    order: 2;
}

.pagination-container .pagination-info {
    order: 1;
}

@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .pagination-container nav,
    .pagination-container .pagination-info {
        width: 100%;
        text-align: center;
    }
}
