:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --error: #ef4444;
    --success: #10b981;
    --info: #3b82f6;
    --radius: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

.ml-2 { margin-left: 0.5rem; }
.mt-3 { margin-top: 1rem; }

/* Global Sidebar Navigation Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar-nav-global {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.2rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    overflow: hidden;
}

.sidebar-nav-global .sidebar-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--surface-border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sidebar-nav-global .brand-logo {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.25rem;
    text-decoration: none;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.sidebar-nav-global .nav-links {
    display: flex;
    flex-direction: column;
    list-style: none;
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0 4px 0 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}

.sidebar-nav-global .nav-links::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav-global .nav-links::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
    border-radius: 6px;
}

.sidebar-nav-global .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar-nav-global .nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.sidebar-nav-global .nav-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    padding: 0.85rem 0.75rem 0.35rem;
    margin-top: 0.15rem;
    list-style: none;
}

.sidebar-nav-global .nav-group-label:first-child {
    margin-top: 0;
    padding-top: 0;
}

.sidebar-nav-global .nav-subgroup-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #a8b4c4;
    padding: 0.5rem 0.75rem 0.2rem 1.35rem;
    list-style: none;
}

.sidebar-nav-global .nav-sublink {
    padding: 0.55rem 1rem 0.55rem 1.35rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-nav-global .nav-sublink-deep {
    padding-left: 2.1rem;
    font-size: 0.86rem;
}

.sidebar-nav-global .nav-group-spacer {
    flex: 1;
    min-height: 0.5rem;
    list-style: none;
}

.main-wrapper {
    flex: 1;
    margin-left: 250px; /* Offset for sidebar */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 250px);
    min-width: 0;
}

.main-wrapper.full-width {
    margin-left: 0;
    width: 100%;
}

.app-wrapper.no-sidebar .main-content {
    align-items: center;
}

/* Layout elements */
.main-content {
    flex: 1;
    max-width: 100%; /* Take full available width inside main-wrapper */
    min-width: 0;
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.app-wrapper:not(.no-sidebar) .main-content > .glass-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--surface-border);
    background: var(--surface);
    margin-top: auto;
    font-size: 0.85rem;
}

/* Glassmorphism -> Solid Cards Panels */
.glass-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.table-scroll-panel {
    overflow: hidden;
}
.table-scroll-panel .data-table-container,
.table-scroll-panel .enhanced-table-shell {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    font-size: 0.95rem;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    color: white;
}

.btn-secondary {
    background: #f8fafc;
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #f87171;
}

.btn-danger:hover {
    background: #fecaca;
    color: #b91c1c;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 2rem;
    width: 100%;
}

.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    animation: slideInDown 0.4s ease;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* Forms (Auth) - Left aligned */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 180px);
    width: 100%;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    animation: fadeInUp 0.5s ease;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.auth-header {
    text-align: left; /* Pulled to left */
    margin-bottom: 2rem;
}

.auth-header p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-align: left;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
}

.form-control, .input-container input {
    width: 100%;
    padding: 0.65rem 1rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}

.input-container input {
    padding-left: 2.5rem;
}

.form-control:focus, .input-container input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
    text-align: left;
}

.auth-footer {
    margin-top: 2rem;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Dashboard ─────────────────────────────────────────────────────── */
/* KPI Cards */
.kpi-card {
    transition: var(--transition);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px -6px rgba(0,0,0,0.10);
}

.kpi-value {
    line-height: 1;
    margin-bottom: 0;
    font-variant-numeric: tabular-nums;
}

/* Responsive: collapse from 4→2→1 col */
@media (max-width: 820px) {
    #dashboard-content > div:first-child {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    #dashboard-content > div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }
}
@media (max-width: 540px) {
    #dashboard-content > div:first-child {
        grid-template-columns: 1fr !important;
    }
}


/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Masters Layout & Tables - Left aligned structure */
.masters-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
    flex-direction: column; /* Stack so content doesn't get squished */
}
@media (min-width: 900px) {
    .masters-layout { flex-direction: row; }
}

.sidebar {
    width: 100%;
    max-width: 280px;
    flex-shrink: 0;
    padding: 1.5rem 0;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
}

.sidebar-title {
    padding: 0 1.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: 1rem;
    text-align: left;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    gap: 1rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-link i {
    width: 20px;
}

.sidebar-link:hover, .sidebar-link.active {
    background: #f1f5f9;
    color: var(--primary);
    border-left-color: var(--primary);
}

.masters-content {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    overflow: hidden;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    width: 100%;
    box-sizing: border-box;
}

.content-header #btn-add-record {
    flex-shrink: 0;
}

.data-table-container {
    padding: 0;
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
}

#data-table-wrapper,
#data-table-wrapper .enhanced-table-shell {
    max-width: 100%;
    overflow-x: auto;
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--surface-border);
}
.data-table th.text-end,
.data-table td.text-end,
.data-table .text-end {
    text-align: right;
}
.data-table th.text-center,
.data-table td.text-center,
.data-table .text-center {
    text-align: center;
}
.data-table .enhanced-subtotal-num {
    text-align: right;
}

#master-table {
    width: 100%;
    table-layout: auto;
}
#master-table th,
#master-table td {
    text-align: left !important;
    padding: 0.45rem 0.55rem;
    white-space: normal;
    vertical-align: middle;
    word-break: break-word;
}
#master-table th {
    line-height: 1.25;
    max-width: 110px;
}
#master-table .enhanced-subtotal-num {
    text-align: left !important;
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    background: #f8fafc;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: #f1f5f9;
}

/* ── Enhanced table toolbar (search / filter / sort / subtotal) ── */
.enhanced-table-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}

.enhanced-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
}

.enhanced-table-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
    max-width: 420px;
}

.enhanced-table-search-icon {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.enhanced-global-search {
    flex: 1;
    min-width: 160px;
    padding: 6px 10px;
    font-size: 0.875rem;
}

.enhanced-table-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.enhanced-row-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.enhanced-filter-row th {
    padding: 6px 8px !important;
    background: #f1f5f9 !important;
    vertical-align: middle;
}

.enhanced-col-filter {
    width: 100%;
    min-width: 60px;
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.enhanced-col-filter-date {
    min-width: 148px;
    width: 100%;
    padding: 4px 8px !important;
}

#addRecordModal input[type="date"] {
    min-width: 140px;
    pointer-events: auto;
}

#addRecordModal .data-table input[type="date"] {
    position: relative;
    z-index: 2;
}

.enhanced-filter-muted {
    color: #cbd5e1;
    font-size: 0.75rem;
}

.enhanced-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.enhanced-sortable:hover {
    background: #e2e8f0 !important;
    color: var(--primary);
}

.enhanced-sortable.enhanced-sorted {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08) !important;
}

.enhanced-sort-icon {
    margin-left: 6px;
    opacity: 0.45;
    font-size: 0.7rem;
}

.enhanced-sortable.enhanced-sorted .enhanced-sort-icon {
    opacity: 1;
}

tr.enhanced-subtotal-row {
    background: rgba(99, 102, 241, 0.07);
    border-top: 2px solid rgba(99, 102, 241, 0.2);
    font-weight: 700;
}

tr.enhanced-subtotal-row td {
    padding: 0.75rem 1.5rem;
    font-size: 0.85rem;
}

.enhanced-subtotal-label {
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.enhanced-subtotal-num {
    text-align: right;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

@media print {
    .enhanced-table-toolbar,
    .enhanced-filter-row,
    tr.enhanced-subtotal-row {
        display: none !important;
    }
}

.text-center { text-align: center; }
.text-danger { color: var(--error); }
.text-muted { color: var(--text-secondary) !important; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.bg-light { background-color: #f1f5f9 !important; border-color: #e2e8f0 !important; cursor: not-allowed; }
.bg-success { background-color: #ecfdf5 !important; border-color: #10b981 !important; color: #065f46 !important;}
.font-weight-bold { font-weight: 700 !important; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    padding: 16px;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

#tally-dump-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#tally-dump-overlay.active {
    display: flex;
}
.tally-dump-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 32px;
    width: min(420px, 100%);
    text-align: center;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.tally-dump-card .tally-dump-spin {
    font-size: 2.2rem;
    color: #4f46e5;
    margin-bottom: 12px;
}
.tally-dump-card #tally-dump-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}
.tally-dump-card #tally-dump-detail {
    margin-top: 6px;
    font-size: 0.88rem;
    color: #64748b;
    min-height: 1.3em;
}
.tally-dump-progress {
    margin-top: 16px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.tally-dump-progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #4f46e5, #6366f1);
    transition: width 0.25s ease;
}
.tally-dump-progress.indeterminate > span {
    width: 38%;
    border-radius: 99px;
    animation: tally-dump-indeterminate 1.15s ease-in-out infinite;
    transition: none;
}
@keyframes tally-dump-indeterminate {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(280%); }
}

.stock-lot-grade-wrap {
    overflow-x: auto;
}
.stock-lot-grade-table {
    width: 100%;
    border-collapse: collapse;
}
.stock-lot-grade-table th,
.stock-lot-grade-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 10px;
    vertical-align: middle;
}
.stock-lot-grade-table thead th {
    background: #4f46e5;
    color: #fff;
    text-align: center;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    font-weight: 700;
}
.stock-lot-grade-table tbody td:first-child,
.stock-lot-grade-table tfoot td:first-child {
    font-weight: 700;
    width: 130px;
    background: #f8fafc;
}
.stock-lot-grade-table tbody td:not(:first-child):not(.stock-lot-grade-actions) {
    min-width: 110px;
}
.stock-lot-grade-table .form-control {
    width: 100%;
    margin: 0;
}
.stock-lot-grade-table .stock-lot-grade-total td {
    background: #eef2ff;
    font-weight: 700;
}
.stock-lot-grade-table .stock-lot-grade-total input {
    background: #f8fafc;
    font-weight: 700;
}
.stock-lot-grade-table .stock-lot-grade-actions {
    width: 44px;
    text-align: center;
    padding: 4px;
}
.stock-lot-add-grade {
    margin-top: 10px;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;           /* never taller than viewport */
    display: flex;
    flex-direction: column;     /* header / body / footer stacked */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--surface-border);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close-btn:hover {
    color: var(--error);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;           /* scroll when content is taller than modal */
    flex: 1 1 auto;             /* grow to fill remaining space */
    scrollbar-width: thin;
    scrollbar-color: rgba(79,70,229,0.3) transparent;
}
.modal-body::-webkit-scrollbar       { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(79,70,229,0.3); border-radius: 4px; }

/* Trip Entry Layout specifics to keep it left bound */
.transaction-container {
    width: 100%;
    max-width: 1000px; /* Constrain width */
    margin: 0; /* Keep it left aligned instead of auto margins centering it */
}

/* Ensure wide cards in trip entry stack neatly */
.transaction-form .row {
    flex-direction: column; /* Force single column on left for forms */
}
.transaction-form .col-md-6, .transaction-form .col-md-12, .transaction-form .col-6, .transaction-form .col-4, .transaction-form .col-md-3, .transaction-form .col-md-4, .transaction-form .col-md-2 {
    width: 100% !important;
    max-width: 100% !important;
}

.card-header { margin-bottom: 10px; }
.card-header h4 { margin: 0; font-size: 1.1rem; color: var(--primary); }

.highlight-panel {
    background-color: #fff1f2 !important;
    border-color: #fce7f3;
}
.highlight-panel h4 { color: #e11d48; }

.hired-card {
    background-color: #f0f9ff !important;
    border-color: #e0f2fe;
}
.hired-card h4 { color: #0284c7; }

/* Generic Flex and Grid Utilities */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.w-100 { width: 100%; }
.p-4 { padding: 1.5rem; }
.p-3 { padding: 1rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.text-end { text-align: right; }
.fw-bold { font-weight: 700 !important; }
.small { font-size: 0.82rem; }

/* Grid system (simple 12-col) */
.row { display: flex; flex-wrap: wrap; gap: 1rem; width: 100%; }
.col-12, .col-md-12 { flex: 0 0 100%; max-width: 100%; }
.col-6, .col-md-6  { flex: 0 0 calc(50% - 0.5rem); max-width: calc(50% - 0.5rem); }
.col-4, .col-md-4  { flex: 0 0 calc(33.333% - 0.667rem); max-width: calc(33.333% - 0.667rem); }
.col-3, .col-md-3  { flex: 0 0 calc(25% - 0.75rem); max-width: calc(25% - 0.75rem); }
.col-8, .col-md-8  { flex: 0 0 calc(66.666% - 0.333rem); max-width: calc(66.666% - 0.333rem); }

@media (max-width: 700px) {
    .col-md-6, .col-md-4, .col-md-3, .col-md-8 {
        flex: 0 0 100%; max-width: 100%;
    }
}

/* ── Tab Navigation ──────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--background);
    border: 1px solid var(--surface-border);
    border-radius: calc(var(--radius) + 2px);
    width: fit-content;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 20px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ── Badge ───────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red   { background: #fee2e2; color: #991b1b; }

/* ── Stat / KPI card (used in reports) ──────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    flex: 1 1 200px;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

/* ── Section header divider ──────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--surface-border);
    font-weight: 600;
    font-size: 0.95rem;
}

.section-header i { color: var(--primary); margin-right: 8px; }

/* ── Page Header strip ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.page-header h2 { margin: 0; }
