/* ============================================================
   SIS Mini ERP - Main Stylesheet
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #1e40af;
    --primary-dark: #0f172a;
    --primary-light: #dbeafe;
    --accent: #d97706;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #d97706;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Login ─────────────────────────────────────────── */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.login-card {
    background: white; border-radius: 16px; padding: 48px 40px; max-width: 420px;
    width: 90%; box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { font-size: 3em; margin-bottom: 8px; }
.login-card h2 { color: var(--primary); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 0.9em; }

/* ── Header ────────────────────────────────────────── */
.sticky-header {
    position: sticky; top: 0; z-index: 1000; background: white;
    box-shadow: var(--shadow);
}
.header-bar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white; padding: 16px 24px; display: flex;
    justify-content: space-between; align-items: center;
    border-bottom: 3px solid var(--accent);
}
.header-left h1 { font-size: 1.5em; font-weight: 700; }
.header-right { display: flex; gap: 8px; align-items: center; }
.user-badge {
    background: rgba(255,255,255,0.15); padding: 4px 14px; border-radius: 20px;
    font-size: 0.85em; font-weight: 600;
}

/* ── Navigation ────────────────────────────────────── */
.main-nav {
    display: flex; gap: 2px; padding: 0 16px; overflow-x: auto;
    background: white; border-bottom: 1px solid var(--border);
}
.nav-tab {
    padding: 12px 18px; border: none; background: none; cursor: pointer;
    font-size: 0.88em; font-weight: 600; color: var(--text-muted);
    border-bottom: 3px solid transparent; transition: all 0.2s;
    white-space: nowrap;
}
.nav-tab:hover { color: var(--primary); background: var(--primary-light); }
.nav-tab.active {
    color: var(--primary); border-bottom-color: var(--primary);
    background: var(--primary-light);
}
.nav-tab[style*="display: none"] { display: none !important; }

/* ── Page Container ────────────────────────────────── */
.page-container { max-width: 1400px; margin: 0 auto; padding: 20px; min-height: 70vh; }

/* ── Cards ─────────────────────────────────────────── */
.card {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 16px; overflow-x: auto;
}
.card-header { font-size: 1.1em; font-weight: 700; color: var(--text); margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }

/* ── KPI Cards ─────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi-card {
    background: white; border-radius: var(--radius); padding: 14px 12px; text-align: center;
    box-shadow: var(--shadow); border-top: 3px solid var(--primary);
}
.kpi-value { font-size: 1.5em; font-weight: 800; margin-bottom: 2px; }
.kpi-label { font-size: 0.8em; color: var(--text-muted); }

/* ── Tables ────────────────────────────────────────── */
table {
    width: 100%; border-collapse: collapse; font-size: 0.9em;
    border: 1px solid #cbd5e1; border-radius: 6px; overflow: hidden;
}
th {
    background: var(--primary); color: #fff; font-weight: 600;
    padding: 10px 14px; text-align: left;
    border: 1px solid rgba(255,255,255,0.15);
    position: sticky; top: 0; font-size: 0.88em; letter-spacing: 0.02em;
    white-space: nowrap;
}
td {
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}
tbody tr { transition: background 0.15s ease; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover td { background: #eff6ff; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Table scroll wrapper - auto wrap tables on small screens */
.page-container > div { overflow-x: auto; }

/* ── Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 0.88em; margin-bottom: 4px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.95em; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius); cursor: pointer;
    font-size: 0.9em; font-weight: 600; transition: all 0.2s; display: inline-flex;
    align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1e3a8a; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 0.82em; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Badges ────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 0.8em; font-weight: 700;
}
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────── */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: 0.9em; font-weight: 500;
}
.alert-success { background: #dcfce7; color: var(--success); border-left: 4px solid var(--success); }
.alert-danger { background: #fee2e2; color: var(--danger); border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3c7; color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info { background: var(--primary-light); color: var(--primary); border-left: 4px solid var(--primary); }

/* ── Modals ────────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 5000; display: flex;
    justify-content: center; align-items: center;
}
.modal-content {
    background: white; border-radius: 12px; padding: 32px; max-width: 700px;
    width: 90%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.3em; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.5em; cursor: pointer; color: var(--text-muted); }

/* ── Change Password Modal ────────────────────────── */
.cpw-modal {
    background: white; border-radius: 16px; padding: 0; width: 420px; max-width: 92vw;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3); animation: cpwSlideIn 0.3s ease;
    overflow: hidden;
}
@keyframes cpwSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.cpw-header {
    text-align: center; padding: 28px 28px 20px; background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: white;
}
.cpw-icon {
    width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,0.2);
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.cpw-header h2 { font-size: 1.25em; font-weight: 700; margin: 0 0 4px; color: white; }
.cpw-header p { font-size: 0.85em; opacity: 0.85; margin: 0; }
#changePwForm { padding: 24px 28px 28px; }
.cpw-field { margin-bottom: 18px; }
.cpw-field label {
    display: block; font-size: 0.82em; font-weight: 600; color: var(--text);
    margin-bottom: 6px; letter-spacing: 0.02em;
}
.cpw-input-wrap {
    position: relative; display: flex; align-items: center;
    border: 1.5px solid #d1d5db; border-radius: 10px; transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}
.cpw-input-wrap:focus-within {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); background: white;
}
.cpw-input-wrap input {
    flex: 1; border: none; background: transparent; padding: 11px 14px; font-size: 0.95em;
    outline: none; border-radius: 10px; width: 100%;
}
.cpw-eye {
    position: absolute; right: 8px; background: none; border: none; cursor: pointer;
    color: #9ca3af; padding: 6px; display: flex; align-items: center; transition: color 0.2s;
}
.cpw-eye:hover { color: var(--primary); }
.cpw-strength { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.cpw-str-track { flex: 1; height: 4px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.cpw-str-fill { height: 100%; border-radius: 4px; transition: width 0.3s, background 0.3s; }
.cpw-error {
    background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 8px;
    padding: 10px 14px; font-size: 0.85em; margin-bottom: 16px; text-align: center;
}
.cpw-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.cpw-cancel {
    background: #f3f4f6; color: var(--text); border: 1px solid #d1d5db; border-radius: 10px;
    padding: 10px 22px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.cpw-cancel:hover { background: #e5e7eb; }
.cpw-submit { border-radius: 10px !important; padding: 10px 24px !important; font-weight: 600; }
.cpw-toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; border-radius: 12px;
    padding: 14px 24px; display: flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); font-weight: 600; font-size: 0.9em;
    z-index: 9999; animation: cpwSlideIn 0.3s ease; transition: opacity 0.3s;
}
#changePwModal { transition: opacity 0.2s; }
@media (max-width: 480px) {
    .cpw-modal { width: 95vw; border-radius: 12px; }
    .cpw-header { padding: 20px 20px 16px; }
    #changePwForm { padding: 18px 20px 22px; }
}

/* ── Status Colors ─────────────────────────────────── */
.status-active { color: var(--success); }
.status-inactive { color: var(--danger); }

/* ── Shop Code Badge ───────────────────────────────── */
.shop-code {
    font-family: 'Courier New', monospace; font-weight: 700;
    background: var(--primary-light); color: var(--primary);
    padding: 2px 8px; border-radius: 4px; font-size: 0.9em;
}

/* ── Upload Zone ───────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border); border-radius: 12px; padding: 48px;
    text-align: center; cursor: pointer; transition: all 0.3s;
    background: var(--bg);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .icon { font-size: 3em; margin-bottom: 12px; }

/* ── Progress Bar ──────────────────────────────────── */
.progress-bar {
    height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
}
.progress-fill {
    height: 100%; border-radius: 4px; transition: width 0.3s;
}

/* ── Chart Container ───────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-card {
    background: white; border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); position: relative;
    max-height: 320px; overflow: hidden;
}
.chart-card canvas { max-height: 240px !important; width: 100% !important; }
.chart-card h4 { margin-bottom: 8px; color: var(--text); font-size: 0.95em; }
.chart-card-full { max-height: 260px; }
.chart-card-full canvas { max-height: 180px !important; }

/* ── Receivables Cards ─────────────────────────────── */
.recv-card {
    background: white; border-radius: 8px; border: 1px solid #e2e8f0;
    margin-bottom: 12px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.recv-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
    background: #f8fafc; flex-wrap: wrap; gap: 8px;
}
.recv-shop-info { display: flex; align-items: center; gap: 10px; }
.recv-amounts {
    display: flex; gap: 16px; align-items: center; font-size: 0.88em; flex-wrap: wrap;
}
.recv-amounts > span { display: flex; align-items: center; gap: 4px; }
.recv-actions { display: flex; gap: 4px; }
.recv-batch {
    display: grid; grid-template-columns: 1fr auto;
    align-items: center; gap: 12px;
    padding: 10px 16px; border-bottom: 1px solid #f1f5f9;
}
.recv-batch:last-child { border-bottom: none; }
.recv-batch-info { font-size: 0.88em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recv-batch-amounts { font-size: 0.88em; text-align: right; white-space: nowrap; }
.recv-collection-form {
    display: flex; gap: 6px; align-items: center; padding: 8px 16px 12px;
    background: #fafbfc; border-top: 1px dashed #e2e8f0; flex-wrap: wrap;
}
.recv-collection-form input, .recv-collection-form select {
    padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 0.85em; background: white;
}
.recv-collection-form input:focus, .recv-collection-form select:focus {
    border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(30,64,175,0.1);
}
.recv-border-paid { border-left: 4px solid var(--success); }
.recv-border-partial { border-left: 4px solid var(--warning); }
.recv-border-pending { border-left: 4px solid var(--danger); }

/* ── Toolbar ───────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9em;
}

/* ── Footer ────────────────────────────────────────── */
.app-footer {
    text-align: center; padding: 20px; color: var(--text-muted);
    font-size: 0.85em; border-top: 1px solid var(--border); margin-top: 40px;
}
.vr-brand { font-weight: 800; color: var(--primary); }

/* ── Responsive ────────────────────────────────────── */

/* Large desktop (1200px+) — default styles above handle this */

/* Medium desktop / small laptop (max 1200px) */
@media (max-width: 1200px) {
    .page-container { max-width: 100%; padding: 16px; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .kpi-value { font-size: 1.35em; }
    .chart-card { max-height: 300px; }
    .chart-card canvas { max-height: 220px !important; }
}

/* Tablet landscape (max 1024px) */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .kpi-card { padding: 12px 10px; }
    .kpi-value { font-size: 1.25em; }
    .kpi-label { font-size: 0.75em; }
    .chart-grid { gap: 12px; }
    .chart-card { max-height: 280px; padding: 14px; }
    .chart-card canvas { max-height: 200px !important; }
    .chart-card-full { max-height: 240px; }
    .chart-card-full canvas { max-height: 160px !important; }
    .header-left h1 { font-size: 1.3em; }
}

/* Tablet portrait (max 768px) */
@media (max-width: 768px) {
    .header-bar { padding: 12px 16px; }
    .header-left h1 { font-size: 1.1em; }
    .header-right { gap: 4px; }
    .main-nav { gap: 0; padding: 0 8px; }
    .nav-tab { padding: 10px 10px; font-size: 0.78em; }
    .page-container { padding: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: 1fr; gap: 10px; }
    .chart-card { max-height: 260px; padding: 12px; }
    .chart-card canvas { max-height: 180px !important; }
    .chart-card-full { max-height: 220px; }
    .chart-card-full canvas { max-height: 150px !important; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .kpi-card { padding: 10px 8px; }
    .kpi-value { font-size: 1.2em; }
    .kpi-label { font-size: 0.72em; }
    .card { padding: 14px; margin-bottom: 10px; }
    .card-header { font-size: 1em; margin-bottom: 12px; }
    .modal-content { padding: 20px; width: 95%; }
}

/* Mobile (max 480px) */
@media (max-width: 480px) {
    .header-bar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
    .header-left h1 { font-size: 1em; }
    .user-badge { font-size: 0.75em; padding: 3px 10px; }
    .main-nav { padding: 0 4px; }
    .nav-tab { padding: 8px 8px; font-size: 0.72em; }
    .page-container { padding: 8px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .kpi-card { padding: 8px 6px; border-top-width: 2px; }
    .kpi-value { font-size: 1.05em; }
    .kpi-label { font-size: 0.68em; }
    .chart-card { max-height: 230px; padding: 10px; }
    .chart-card canvas { max-height: 160px !important; }
    .chart-card h4 { font-size: 0.85em; margin-bottom: 6px; }
    .chart-card-full { max-height: 200px; }
    .chart-card-full canvas { max-height: 140px !important; }
    .card { padding: 10px; margin-bottom: 8px; }
    .btn { padding: 8px 14px; font-size: 0.82em; }
    .btn-sm { padding: 4px 8px; font-size: 0.75em; }
    table { font-size: 0.78em; }
    th { padding: 5px 7px; font-size: 0.82em; }
    td { padding: 5px 7px; }
    .modal-content { padding: 16px; border-radius: 8px; max-height: 90vh; }
    .login-card { padding: 32px 24px; }
}

/* Very small mobile (max 360px) */
@media (max-width: 360px) {
    .header-left h1 { font-size: 0.9em; }
    .header-right .btn-sm span { display: none; }
    .kpi-value { font-size: 0.95em; }
    .kpi-label { font-size: 0.65em; }
    .chart-card { max-height: 200px; padding: 8px; }
    .chart-card canvas { max-height: 140px !important; }
    .nav-tab { padding: 8px 6px; font-size: 0.68em; }
}

/* ============================================================
   Dashboard — Interactive Account Receivable Dashboard
   ============================================================ */

/* Dashboard Header */
.dash-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.dash-title h2 { font-size: 1.25em; font-weight: 800; color: var(--primary-dark); }
.dash-subtitle { font-size: 0.8em; color: var(--text-muted); }
.dash-actions { display: flex; gap: 6px; }

/* Dashboard Loading */
.dash-loading {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 60px; color: var(--text-muted); font-size: 1.1em;
}
.dash-spinner {
    width: 24px; height: 24px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: dashSpin 0.6s linear infinite;
}
@keyframes dashSpin { to { transform: rotate(360deg); } }

/* Dashboard KPI Row */
.dash-kpi-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px;
}
.dash-kpi {
    background: white; border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.dash-kpi:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.dash-kpi-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 1.2em; flex-shrink: 0;
}
.dash-kpi-body { flex: 1; min-width: 0; }
.dash-kpi-value { font-size: 1.3em; font-weight: 800; line-height: 1.2; }
.dash-kpi-label { font-size: 0.75em; color: var(--text-muted); }
.dash-kpi-badge {
    position: absolute; top: 8px; right: 10px;
    font-size: 0.65em; font-weight: 600; color: var(--text-muted);
    background: var(--bg); padding: 2px 8px; border-radius: 10px;
}

/* Secondary KPI Row */
.dash-kpi-secondary {
    display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
    justify-content: center;
}
.dash-kpi-mini {
    background: white; border-radius: 6px; padding: 8px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); text-align: center;
    flex: 1; min-width: 100px;
}
.dash-kpi-mini-val { font-size: 1.15em; font-weight: 800; display: block; }
.dash-kpi-mini-lbl { font-size: 0.68em; color: var(--text-muted); }

/* Dashboard Main Chart */
.dash-chart-main {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; margin-bottom: 16px;
}
.dash-chart-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.dash-chart-header h4 { font-size: 0.92em; font-weight: 700; color: var(--text); }
.dash-chart-body { height: 220px; position: relative; }

/* 4-Column Chart Grid */
.dash-grid-4 {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
.dash-grid-3 {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
}

/* Small Chart Cards */
.dash-chart-sm {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px; cursor: pointer; transition: all 0.2s;
}
.dash-chart-sm:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.dash-chart-sm h4 { font-size: 0.82em; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.dash-chart-body-sm { height: 180px; position: relative; }

/* Small Table Cards */
.dash-table-sm {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px; display: flex; flex-direction: column;
}
.dash-table-sm h4 { font-size: 0.82em; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* Full-width Table */
.dash-table-full {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; margin-bottom: 16px;
}

/* Dashboard Table Scroll */
.dash-table-scroll { overflow-x: auto; overflow-y: auto; max-height: 250px; flex: 1; }

/* Dashboard Mini Table */
.dash-mini-table { width: 100%; border-collapse: collapse; font-size: 0.82em; border: 1px solid #e2e8f0; }
.dash-mini-table th {
    background: var(--primary); color: #fff; font-weight: 600;
    padding: 7px 10px; text-align: left; border: 1px solid rgba(255,255,255,0.15);
    position: sticky; top: 0; font-size: 0.88em; z-index: 1; white-space: nowrap;
}
.dash-mini-table td { padding: 6px 10px; border: 1px solid #e2e8f0; }
.dash-mini-table tbody tr:nth-child(even) { background: #f8fafc; }
.dash-mini-table tr:hover td { background: #eff6ff; }
.dash-clickable { cursor: pointer; }
.dash-clickable:hover td { background: var(--primary-light) !important; }

/* Dashboard Empty State */
.dash-empty {
    text-align: center; padding: 24px; color: var(--text-muted); font-size: 0.85em;
}

/* Dashboard Drilldown Panel */
.dash-drilldown {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary); margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}
.dash-drill-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    background: var(--primary-light); border-radius: var(--radius) var(--radius) 0 0;
}
.dash-drill-header h4 { font-size: 0.95em; font-weight: 700; color: var(--primary); }
.dash-drill-body { padding: 16px 18px; max-height: 400px; overflow-y: auto; }

/* Drilldown KPI Row */
.dash-drill-kpis {
    display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
    padding: 12px; background: var(--bg); border-radius: 6px;
}
.dash-drill-kpis > div { text-align: center; min-width: 100px; }
.dash-drill-kpis strong { font-size: 1.1em; display: block; }

/* Efficiency Grid */
.dash-eff-grid { display: flex; flex-direction: column; gap: 8px; }
.dash-eff-item { display: flex; align-items: center; gap: 10px; font-size: 0.9em; }
.dash-eff-bar { height: 20px; border-radius: 4px; min-width: 20px; }

/* ── Dashboard Responsive ─────────────────────────── */
@media (max-width: 1200px) {
    .dash-kpi-row { grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .dash-kpi-value { font-size: 1.15em; }
    .dash-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .dash-chart-body { height: 200px; }
    .dash-chart-body-sm { height: 160px; }
}

@media (max-width: 1024px) {
    .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .dash-kpi-value { font-size: 1.1em; }
    .dash-kpi-icon { width: 36px; height: 36px; font-size: 1em; }
    .dash-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .dash-grid-3 { grid-template-columns: 1fr 1fr; }
    .dash-chart-body { height: 180px; }
    .dash-chart-body-sm { height: 150px; }
    .dash-kpi-secondary { gap: 6px; }
    .dash-kpi-mini { padding: 6px 10px; min-width: 80px; }
    .dash-kpi-mini-val { font-size: 1em; }
}

@media (max-width: 768px) {
    .dash-kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .dash-kpi { padding: 10px 12px; }
    .dash-kpi-value { font-size: 1em; }
    .dash-kpi-icon { width: 32px; height: 32px; font-size: 0.9em; }
    .dash-kpi-badge { font-size: 0.6em; top: 4px; right: 6px; }
    .dash-kpi-secondary { gap: 4px; }
    .dash-kpi-mini { padding: 6px 8px; min-width: 70px; }
    .dash-kpi-mini-val { font-size: 0.9em; }
    .dash-kpi-mini-lbl { font-size: 0.62em; }
    .dash-grid-4, .dash-grid-3 { grid-template-columns: 1fr; }
    .dash-chart-body { height: 180px; }
    .dash-chart-body-sm { height: 160px; }
    .dash-chart-main { padding: 12px; }
    .dash-chart-sm, .dash-table-sm { padding: 10px; }
    .dash-drill-body { padding: 12px; }
    .dash-drill-kpis { gap: 10px; }
    .dash-drill-kpis > div { min-width: 70px; }
    .dash-drill-kpis strong { font-size: 0.95em; }
    .dash-table-scroll { max-height: 200px; }
}

@media (max-width: 480px) {
    .dash-title h2 { font-size: 1.05em; }
    .dash-kpi-row { grid-template-columns: 1fr 1fr; gap: 6px; }
    .dash-kpi { padding: 8px 10px; gap: 8px; }
    .dash-kpi-icon { width: 28px; height: 28px; font-size: 0.8em; border-radius: 6px; }
    .dash-kpi-value { font-size: 0.9em; }
    .dash-kpi-label { font-size: 0.65em; }
    .dash-kpi-badge { display: none; }
    .dash-kpi-secondary { gap: 4px; justify-content: space-between; }
    .dash-kpi-mini { min-width: 55px; padding: 4px 6px; }
    .dash-kpi-mini-val { font-size: 0.85em; }
    .dash-kpi-mini-lbl { font-size: 0.58em; }
    .dash-chart-body { height: 160px; }
    .dash-chart-body-sm { height: 140px; }
    .dash-chart-sm h4, .dash-table-sm h4 { font-size: 0.75em; }
    .dash-mini-table { font-size: 0.75em; }
    .dash-mini-table th, .dash-mini-table td { padding: 4px 5px; }
}

/* ── Animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }
