/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sidebar: 220px;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --light: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --purple: #7c3aed;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar); height: 100vh; background: #0f172a; display: flex; flex-direction: column; z-index: 50; overflow-y: auto; }
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid #1e293b; display: flex; align-items: center; gap: 10px; }
.sidebar-logo .emoji { font-size: 22px; }
.sidebar-logo h1 { color: #f1f5f9; font-size: 14px; font-weight: 700; }
.sidebar-logo p { color: #64748b; font-size: 11px; margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 8px; }
.sidebar-group-label { font-size: 10px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .08em; padding: 12px 8px 4px; }
.sidebar-nav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: #94a3b8; text-decoration: none; font-size: 13px; margin-bottom: 1px; transition: all .15s; }
.sidebar-nav a:hover { color: #fff; background: #1e293b; }
.sidebar-nav a.active { color: #fff; background: var(--primary); font-weight: 600; }
.sidebar-nav a .icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid #1e293b; }
.sidebar-footer form button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: none; background: none; color: #64748b; cursor: pointer; font-size: 13px; border-radius: 8px; transition: color .15s; }
.sidebar-footer form button:hover { color: #ef4444; }

/* ── Main Layout ───────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.main { margin-left: var(--sidebar); flex: 1; min-height: 100vh; }
.page { padding: 24px; max-width: 1400px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px; }
.card-sm { padding: 14px 16px; }

/* ── Grid helpers ──────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media(max-width:1200px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-5 { grid-template-columns: repeat(3,1fr); } }
@media(max-width:768px) { .grid-2,.grid-3,.grid-4,.grid-5 { grid-template-columns: 1fr; } }

/* ── KPI Cards ─────────────────────────────────────────────────────────────── */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 800; margin: 6px 0 2px; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--light); }
.kpi-card .kpi-icon { position: absolute; right: 16px; top: 16px; font-size: 28px; opacity: .15; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--bg); color: var(--text); transition: border .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }
.badge-orange { background: #ffedd5; color: #ea580c; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }
.badge-gray   { background: #f1f5f9; color: #64748b; }
.badge-emerald{ background: #d1fae5; color: #059669; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-warning { background: #fefce8; color: #ca8a04; border: 1px solid #fde68a; }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Filters bar ─────────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--muted); text-decoration: none; transition: all .15s; }
.filter-tab.active, .filter-tab:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Status progress bar ─────────────────────────────────────────────────────── */
.bar-bg { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--light); padding: 4px; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #0f172a, #1e3a5f); display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 20px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 25px 80px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .emoji { font-size: 48px; }
.login-logo h1 { font-size: 24px; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--muted); font-size: 13px; }

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state .emoji { font-size: 40px; display: block; margin-bottom: 12px; }
