/* ============================================================
   Phase 9.5.2 — Modern SaaS Admin Dashboard
   ============================================================ */

/* ---------- Design System ---------- */
:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --success: #16A34A;
    --success-dark: #15803D;
    --success-light: #DCFCE7;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-dark: #B91C1C;
    --danger-light: #FEE2E2;
    --info: #0891B2;
    --info-light: #CFFAFE;
    --surface: #FFFFFF;
    --bg: #F8FAFC;
    --text: #0F172A;
    --muted: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --font: 'Cairo', 'Tahoma', 'Arial', sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
}

/* ---------- Base ---------- */
html { font-size: 15px; }

body {
    font-family: var(--font);
    font-size: .933rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font);
    font-weight: 800;
    color: var(--text);
}

/* ---------- Layout Shell ---------- */
.erp-main {
    padding: var(--space-5) var(--space-6) var(--space-6);
    min-height: calc(100vh - 130px);
}

/* ---------- Sidebar ---------- */
.erp-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.08) transparent;
    transition: width .25s ease;
}

.erp-sidebar::-webkit-scrollbar { width: 3px; }
.erp-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.erp-logo {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid rgba(255,255,255,.05);
}

.erp-logo-circle {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.erp-logo-circle img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.erp-logo-title {
    margin-top: var(--space-2);
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: -.01em;
}

.erp-logo-sub {
    text-align: center;
    font-size: .7rem;
    margin-top: 2px;
    color: rgba(255,255,255,.45);
    font-weight: 600;
}

.erp-menu-title {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: var(--space-6) var(--space-5) var(--space-2);
    color: rgba(255,255,255,.35);
    border-top: 1px solid rgba(255,255,255,.06);
    margin-top: var(--space-2);
}

.erp-menu-title:first-of-type {
    border-top: none;
    margin-top: 0;
}

.erp-menu a,
.erp-menu summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--space-5);
    font-size: .8rem;
    font-weight: 700;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    cursor: pointer;
    list-style: none;
    border: none;
    background: none;
    width: 100%;
    box-sizing: border-box;
    transition: background .18s ease, color .18s ease, padding-right .18s ease, border-right .18s ease;
    border-radius: 0;
    border-right: 2px solid transparent;
}

.erp-menu a:hover,
.erp-menu summary:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
    padding-right: 28px;
    border-right-color: rgba(255,255,255,.12);
}

.erp-menu a:active,
.erp-menu summary:active {
    background: rgba(255,255,255,.1);
}

.active-menu {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: inset 3px 0 0 rgba(255,255,255,.25);
    font-weight: 800;
    border-right-color: var(--primary) !important;
}

.erp-sub a {
    padding-right: 52px;
    font-size: .77rem;
    padding-top: 8px;
    padding-bottom: 8px;
    background: rgba(255,255,255,.015);
}

.erp-sub details summary {
    padding-right: 52px;
    font-size: .77rem;
    padding-top: 8px;
    padding-bottom: 8px;
    font-weight: 700;
}

.erp-sub details .erp-sub a {
    padding-right: 70px;
    font-size: .74rem;
}

details summary::marker { display: none; }

.erp-menu > details {
    margin-bottom: 2px;
}

details summary::after {
    content: "⌄";
    margin-right: auto;
    font-size: .8rem;
    opacity: .35;
    transition: transform .22s ease, opacity .18s;
    line-height: 1;
}

details[open] > summary::after {
    transform: rotate(180deg);
    opacity: .6;
}

details[open] > .erp-sub {
    animation: slideDown .2s ease;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to   { opacity: 1; max-height: 2000px; }
}

.erp-icon {
    width: 22px;
    font-size: .92rem;
    flex-shrink: 0;
    text-align: center;
    line-height: 1;
}

/* ---------- Topbar ---------- */
.erp-topbar {
    height: 54px;
    padding: 0 var(--space-6);
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.erp-topbar-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.01em;
}

.erp-user {
    font-size: .8rem;
    padding: 5px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 40px;
    font-weight: 700;
}

.logout-btn {
    font-size: .75rem;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    transition: background .18s ease, transform .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.logout-btn:hover {
    background: var(--danger-dark);
    color: #fff;
    transform: translateY(-1px);
}

/* ============================================================
   DASHBOARD — Complete Redesign
   ============================================================ */

/* --- Top Action Bar --- */
.db-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    gap: var(--space-3);
}

.db-top-main {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.db-top-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -.02em;
}

.db-top-sub {
    font-size: .8rem;
    color: var(--muted);
    margin: 0;
    font-weight: 500;
}

.db-top-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.db-top-user {
    font-size: .78rem;
    padding: 5px 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 40px;
    font-weight: 700;
    white-space: nowrap;
}

.db-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    font-size: .8rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background .15s ease, transform .12s ease, box-shadow .15s ease, border-color .15s ease;
    white-space: nowrap;
    border: 1.5px solid transparent;
    cursor: pointer;
    font-family: var(--font);
    line-height: 1.3;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.db-btn:active {
    transform: scale(.97);
}

.db-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}

/* ----- Primary (Blue) ----- */
.db-btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.db-btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.db-btn-primary:active {
    background: #1E40AF;
    border-color: #1E40AF;
    box-shadow: 0 1px 4px rgba(37,99,235,.2);
}

/* ----- Outline (White / Secondary) ----- */
.db-btn-outline {
    background: var(--surface);
    color: var(--text);
    border-color: #CBD5E1;
    box-shadow: var(--shadow-sm);
}

.db-btn-outline:hover {
    background: #F1F5F9;
    border-color: #94A3B8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.db-btn-outline:active {
    background: #E2E8F0;
    border-color: #64748B;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    transform: scale(.97);
}

/* ----- Active / Tab State ----- */
.db-btn--active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37,99,235,.2);
}

.db-btn--active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

/* ----- Disabled ----- */
.db-btn[disabled],
.db-btn.disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

/* --- KPI Grid --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--space-5) var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transition: box-shadow .25s ease, transform .2s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.kpi-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-icon-wrap--blue { background: var(--primary-light); }
.kpi-icon-wrap--green { background: var(--success-light); }
.kpi-icon-wrap--red { background: var(--danger-light); }
.kpi-icon-wrap--cyan { background: var(--info-light); }
.kpi-icon-wrap--orange { background: var(--warning-light); }

.kpi-info {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: .73rem;
    font-weight: 600;
    color: var(--muted);
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    display: block;
    direction: ltr;
    text-align: left;
}

.kpi-value--blue { color: var(--primary); }
.kpi-value--green { color: var(--success); }
.kpi-value--red { color: var(--danger); }
.kpi-value--cyan { color: var(--info); }
.kpi-value--orange { color: var(--warning); }

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.4;
}

.kpi-trend--up { background: var(--success-light); color: var(--success); }
.kpi-trend--down { background: var(--danger-light); color: var(--danger); }

/* --- Date Filter Form --- */
.db-filter-form {
    margin-bottom: var(--space-5);
}

.db-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.db-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.db-filter-group label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--muted);
}

.db-filter-input {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    background: var(--surface);
    color: var(--text);
    direction: ltr;
}

.db-filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.db-filter-btn {
    padding: 8px 18px !important;
    font-size: .8rem !important;
}

.db-filter-reset {
    background: transparent !important;
    color: var(--muted) !important;
    border: 1.5px solid var(--border) !important;
}

.db-filter-reset:hover {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

@media(max-width:575.98px) {
    .db-filter-row { flex-direction: column; align-items: stretch; }
    .db-filter-input { width: 100%; }
}

/* --- Two Column Layout --- */
.db-cols {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-5);
}

/* --- Panel --- */
.db-panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
}

.db-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.db-panel-title {
    font-size: .93rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.db-panel-badge {
    font-size: .68rem;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

/* --- Chart.js Canvas Container --- */
.chart-container {
    width: 100%;
    height: 180px;
    position: relative;
}

.chart-container-lg {
    height: 220px;
}

/* --- Table --- */
.db-table-wrap {
    overflow-x: auto;
    margin: 0 calc(-1 * var(--space-5));
    padding: 0 var(--space-5);
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    min-width: 700px;
}

.db-table thead th {
    padding: 10px 12px;
    background: var(--bg);
    color: var(--muted);
    font-weight: 700;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1.5px solid var(--border);
    text-align: center;
    white-space: nowrap;
}

.db-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-align: center;
    vertical-align: middle;
}

.db-table tbody tr:hover td {
    background: var(--bg);
}

.db-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Status Badges --- */
.db-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    white-space: nowrap;
}

.db-status--success { background: var(--success-light); color: var(--success); }
.db-status--failed  { background: var(--danger-light); color: var(--danger); }
.db-status--pending { background: var(--warning-light); color: var(--warning); }
.db-status--process { background: var(--info-light); color: var(--info); }
.db-status--muted   { background: #F1F5F9; color: #475569; }

/* --- Sidebar List Items --- */
.db-side-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.db-side-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    gap: var(--space-2);
    transition: background .15s ease;
}

.db-side-item:hover {
    background: var(--primary-light);
}

.db-side-item-name {
    font-weight: 700;
    font-size: .78rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-side-item-meta {
    font-size: .68rem;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
    direction: ltr;
    text-align: left;
}

/* --- Provider Item --- */
.db-provider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    gap: var(--space-2);
}

.db-provider-name {
    font-weight: 700;
    font-size: .78rem;
    color: var(--text);
}

/* --- Shortcut Links --- */
.db-shortcut {
    display: block;
    padding: 9px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.db-shortcut:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* --- Analytics Grid (3 cols) --- */
.db-analytics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}

.db-analytics-title {
    font-size: .7rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: var(--space-2);
}

/* ========== Accordion Component ========== */
.accordion {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-3);
}
.accordion summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background .15s;
    user-select: none;
    font-weight: 700;
    color: var(--text);
    font-size: .85rem;
}
.accordion summary:hover {
    background: var(--bg);
}
.accordion summary::after {
    content: "⌄";
    margin-right: auto;
    font-size: .8rem;
    opacity: .35;
    transition: transform .22s;
    line-height: 1;
}
.accordion[open] > summary::after {
    transform: rotate(180deg);
    opacity: .6;
}
.accordion[open] > summary {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: 1px solid var(--border);
}
.accordion-body {
    padding: var(--space-3);
}
.accordion-badge {
    font-size: .7rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.accordion-hidden {
    display: none !important;
}
.accordion-empty {
    display: none;
}
.accordion-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}
.accordion-toolbar input {
    flex: 1;
    min-width: 120px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .75rem;
    background: var(--bg);
    color: var(--text);
}
.accordion-toolbar input:focus {
    outline: none;
    border-color: var(--primary);
}
.accordion-count {
    font-size: .75rem;
    color: var(--muted);
    white-space: nowrap;
}
.accordion-search {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}
.accordion-search input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    background: var(--bg);
    color: var(--text);
}
.accordion-search input:focus {
    outline: none;
    border-color: var(--primary);
}
.accordion-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.grp-header {
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
    padding: 8px 0 4px 0;
}

/* ========== Import Toolbar ========== */
.import-sep {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    margin: 0 6px;
    display: inline-block;
    vertical-align: middle;
}
.import-btn {
    padding: 6px 14px;
    font-size: .78rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity .15s, background .15s;
}
.import-btn:hover {
    opacity: .85;
}
.import-btn-primary {
    background: #0B4F83;
    color: white;
}
.import-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    font-weight: 600;
}
.import-btn-secondary:hover {
    background: #e5e7eb;
}

/* ============================================================
   FORMS
   ============================================================ */
input, select, textarea, .form-control {
    font-family: var(--font);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: .8rem;
    transition: border-color .18s ease, box-shadow .18s ease;
    background: var(--surface);
    color: var(--text);
}

input:focus, select:focus, textarea:focus, .form-control:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
    outline: none;
}

label, .form-group label, .form-label {
    font-size: .73rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
    display: block;
}

.form-group { margin-bottom: var(--space-4); }

/* ============================================================
   BUTTONS
   ============================================================ */
button, .btn, [class*="btn-"] {
    font-family: var(--font);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: .8rem;
    font-weight: 600;
    transition: background .18s ease, transform .15s ease, box-shadow .18s ease;
    cursor: pointer;
    border: 1.5px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    line-height: 1.3;
    user-select: none;
    -webkit-user-select: none;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

button:active, .btn:active {
    transform: scale(.97);
}

button:focus-visible, .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}

button[disabled], .btn[disabled],
button.disabled, .btn.disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

.submit-btn, .btn-primary {
    background: var(--primary);
    color: #fff;
}

.submit-btn:hover, .btn-primary:hover {
    background: var(--primary-dark);
}

.approve-btn { background: var(--success-light); color: var(--success); }
.reject-btn, .delete-btn { background: var(--danger-light); color: var(--danger); }
.edit-btn { background: var(--primary-light); color: var(--primary); }

/* ============================================================
   BADGES
   ============================================================ */
.badge, [class*="badge-"] {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    display: inline-block;
    line-height: 1.4;
}

.badge-green { background: var(--success-light); color: var(--success); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #F1F5F9; color: #475569; }

/* ============================================================
   GENERAL COMPONENTS
   ============================================================ */
.card {
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.table {
    font-size: .8rem;
}

.table th {
    font-size: .7rem;
    letter-spacing: .3px;
    padding: 10px 12px;
    background: var(--bg);
    border-bottom: 1.5px solid var(--border);
    color: var(--muted);
    font-weight: 700;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.footer {
    font-size: .75rem;
    padding: var(--space-4);
    color: var(--muted);
    text-align: center;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media(max-width:1199.98px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .kpi-value { font-size: 1.35rem; }
}

@media(max-width:991.98px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .db-cols { grid-template-columns: 1fr; }
    .db-analytics { grid-template-columns: repeat(3, 1fr); }
    .chart-container { height: 160px; }
    .chart-container-lg { height: 190px; }
}

@media(max-width:767.98px) {
    .erp-main { padding: var(--space-3) var(--space-4); }
    .db-top { flex-wrap: wrap; gap: var(--space-2); }
    .db-top-main { flex-wrap: wrap; }
    .db-top-title { font-size: 1.2rem; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
    .kpi-card { padding: var(--space-4) var(--space-3); }
    .kpi-icon-wrap { width: 40px; height: 40px; font-size: 1rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-label { font-size: .68rem; }
    .db-panel { padding: var(--space-4); }
    .db-analytics { grid-template-columns: 1fr; }
    .chart-container { height: 140px; }
    .chart-container-lg { height: 160px; }
}

@media(max-width:575.98px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .db-top-actions .db-btn { width: 100%; justify-content: center; }
}

/* ---------- Mobile Data Table ---------- */
@media(max-width:767.98px) {
    .erp-main {
        padding: var(--space-3) var(--space-3);
        overflow-x: hidden;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive .table {
        min-width: 600px;
    }

    .table-responsive table {
        min-width: 600px;
    }

    .card-body {
        padding: var(--space-3);
    }

    .container-fluid {
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }

    /* Mobile form improvements */
    form .row > div {
        margin-bottom: var(--space-3);
    }

    form .col-md-6,
    form .col-md-4,
    form .col-md-3,
    form .col-sm-6 {
        width: 100%;
    }

    /* Mobile button stacking */
    .btn-group {
        flex-wrap: wrap;
        gap: 4px;
    }

    .btn-group .btn {
        white-space: normal;
        font-size: .75rem;
        padding: 6px 10px;
    }

    .d-flex.gap-1,
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    .d-flex.gap-1 .btn,
    .d-flex.gap-2 .btn,
    .d-flex.gap-3 .btn {
        white-space: normal;
        font-size: .75rem;
    }
}
