:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --line: #e6edf5;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { background: #101828; color: #fff; padding: 26px; }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 36px; }
.brand-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(135deg, #60a5fa, #2563eb); font-weight: 900; }
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: #a8b3c7; font-size: 12px; margin-top: 4px; }
.nav-link { display: block; padding: 13px 14px; border-radius: 14px; color: #cbd5e1; }
.nav-link.active, .nav-link:hover { background: rgba(255,255,255,.10); color: #fff; }

.dashboard-page { padding: 30px; }
.home-card { margin: 40px; padding: 34px; background: #fff; border-radius: 22px; box-shadow: var(--shadow); }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; margin-bottom: 26px; }
.eyebrow { display: inline-flex; color: var(--primary); background: #eaf1ff; font-size: 12px; font-weight: 800; padding: 6px 10px; border-radius: 999px; margin-bottom: 10px; }
.dashboard-header h1 { margin: 0; font-size: 32px; font-weight: 900; }
.dashboard-header p { margin: 8px 0 0; color: var(--muted); }

.refresh-btn { border: 0; background: var(--primary); color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 800; cursor: pointer; box-shadow: 0 10px 24px rgba(37,99,235,.25); }
.refresh-btn:hover { background: var(--primary-dark); }
.refresh-btn:disabled { opacity: .65; cursor: not-allowed; }

.alert-box, .loading-box { background: #fff; padding: 28px; border-radius: 22px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.alert-box { border: 1px solid #fecaca; color: #991b1b; flex-direction: column; align-items: flex-start; }
.loader { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #dbeafe; border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 18px; margin-bottom: 22px; }
.kpi-card { background: linear-gradient(135deg, #fff, #f8fbff); border: 1px solid var(--line); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-card.primary { background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff; }
.kpi-card span { color: var(--muted); font-size: 14px; font-weight: 800; }
.kpi-card.primary span, .kpi-card.primary small { color: #dbeafe; }
.kpi-card h3 { margin: 14px 0 4px; font-size: 34px; font-weight: 950; color: var(--primary); }
.kpi-card.primary h3 { color: #fff; }
.kpi-card small { color: #7b8797; }

.charts-grid, .tables-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-title h2 { margin: 0; font-size: 19px; font-weight: 900; }
.panel-title p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.modern-table { width: 100%; border-collapse: collapse; }
.modern-table thead { background: #f8fafc; }
.modern-table th { padding: 14px; text-align: right; color: #475569; font-size: 14px; border-bottom: 1px solid var(--line); }
.modern-table td { padding: 14px; border-bottom: 1px solid #eef2f7; color: #1f2937; }
.modern-table.compact td, .modern-table.compact th { padding: 11px 12px; font-size: 13px; }
.modern-table tbody tr:hover { background: #f8fafc; }
.badge { display: inline-block; background: #e0ecff; color: var(--primary-dark); padding: 5px 12px; border-radius: 999px; font-weight: 900; }

@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: flex; justify-content: space-between; align-items: center; padding: 18px; }
    .brand { margin-bottom: 0; }
    .kpi-grid, .charts-grid, .tables-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .dashboard-page { padding: 16px; }
    .dashboard-header { flex-direction: column; }
    .kpi-grid, .charts-grid, .tables-grid { grid-template-columns: 1fr; }
    .sidebar { flex-direction: column; align-items: flex-start; gap: 16px; }
}
