:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --primary: #1d4ed8;
    --primary-dark: #1a44be;
    --accent: #059669;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-900: #0f172a;
    --radius: 0.5rem;
    --sidebar: #0f172a;
    --amber: #b45309;
    --rose: #e11d48;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    min-height: 100vh;
}
h1, h2, h3, h4, .font-heading { font-family: "Manrope", system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .login-wrap { grid-template-columns: 1fr 1fr; } }
.login-hero {
    display: none; position: relative; flex-direction: column; justify-content: space-between;
    padding: 48px; color: #fff; overflow: hidden;
    background: linear-gradient(135deg, rgba(29,78,216,0.92), rgba(16,44,110,0.94)),
        url('https://images.pexels.com/photos/37320179/pexels-photo-37320179.jpeg') center/cover;
}
@media (min-width: 1024px) { .login-hero { display: flex; } }
.login-hero h2 { font-size: 40px; font-weight: 800; line-height: 1.1; margin: 0; }
.login-hero p.lead { margin-top: 16px; color: rgba(255,255,255,0.85); line-height: 1.6; max-width: 30rem; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-logo { display: grid; place-items: center; height: 44px; width: 44px; border-radius: 12px; background: rgba(255,255,255,0.15); backdrop-filter: blur(6px); overflow: hidden; }
.login-logo img { height: 100%; width: 100%; object-fit: contain; }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 22rem; }
.login-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em; color: rgba(255,255,255,0.7); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 256px; background: var(--sidebar);
    color: #e2e8f0; display: flex; flex-direction: column; transition: transform 0.3s ease;
}
.sidebar-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); position: relative; }
.sidebar-logo { display: grid; place-items: center; height: 64px; width: 64px; border-radius: 12px; background: var(--primary); overflow: hidden; }
.sidebar-logo img { height: 100%; width: 100%; object-fit: contain; }
.sidebar-org { text-align: center; }
.sidebar-org .name { font-family: "Manrope"; font-weight: 800; font-size: 14px; }
.sidebar-org .sub { font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: #94a3b8; margin-top: 2px; }
.nav { flex: 1; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; border-radius: var(--radius); padding: 10px 12px; font-size: 14px; font-weight: 500; color: #cbd5e1; transition: background-color 0.15s ease, color 0.15s ease; }
.nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a svg { width: 18px; height: 18px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,0.1); padding: 16px; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar { display: grid; place-items: center; height: 36px; width: 36px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.logout-btn { margin-top: 12px; width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #cbd5e1; padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }
.logout-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.main { flex: 1; margin-left: 0; display: flex; flex-direction: column; min-width: 0; }
@media (min-width: 1024px) { .main { margin-left: 256px; } }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; height: 64px; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.8); backdrop-filter: blur(8px); padding: 0 16px; }
@media (min-width: 1024px) { .topbar { padding: 0 32px; } }
.topbar .org-name { margin-left: auto; font-size: 12px; color: var(--muted); }
.content { flex: 1; padding: 16px; max-width: 1500px; width: 100%; }
@media (min-width: 1024px) { .content { padding: 32px; } }
.menu-toggle { display: inline-flex; background: none; border: 0; }
@media (min-width: 1024px) { .menu-toggle { display: none; } }
.sidebar.closed { transform: translateX(-100%); }
@media (min-width: 1024px) { .sidebar.closed { transform: none; } }
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.4); }
@media (min-width: 1024px) { .overlay { display: none; } }

/* ---------- Page header ---------- */
.page-head { margin-bottom: 24px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
@media (min-width: 640px) { .page-head h1 { font-size: 36px; } }
.page-head .subtitle { margin-top: 4px; font-size: 14px; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); background: none; border: 0; margin-bottom: 16px; }
.back-link:hover { color: var(--primary); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card.hoverable { transition: box-shadow 0.2s ease; }
.card.hoverable:hover { box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.card-title { font-family: "Manrope"; font-size: 18px; font-weight: 700; margin: 0; }
.card-body { padding: 20px; }

/* Stat cards */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(1, 1fr); }
@media (min-width: 640px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 20px; }
.stat-icon { display: grid; place-items: center; height: 40px; width: 40px; border-radius: var(--radius); }
.stat-label { margin-top: 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--muted); }
.stat-value { margin-top: 4px; font-family: "Manrope"; font-size: 24px; font-weight: 800; }
.stat-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.tone-blue { background: #eff6ff; color: #1d4ed8; }
.tone-emerald { background: #ecfdf5; color: #047857; }
.tone-amber { background: #fffbeb; color: #b45309; }
.tone-violet { background: #f5f3ff; color: #6d28d9; }
.tone-rose { background: #fff1f2; color: #be123c; }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl thead { background: var(--slate-50); }
table.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: #475569; padding: 12px 16px; white-space: nowrap; }
table.tbl td { padding: 12px 16px; font-size: 14px; border-top: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr.zebra { background: rgba(248,250,252,0.6); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--border); padding: 2px 10px; font-size: 12px; font-weight: 500; }
.badge-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.b-emerald { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.b-slate { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.b-amber { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.b-rose { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.b-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.b-violet { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }

/* ---------- Forms ---------- */
label.lbl { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
label.lbl.up { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.input, .select, textarea.input {
    width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0 12px; font-size: 14px; background: #fff; color: var(--text); outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea.input { height: auto; padding: 10px 12px; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,0.12); }
.field { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.col-span-2 { grid-column: 1 / -1; }
.input-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon + .input { padding-left: 36px; }
.pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius); font-size: 14px; font-weight: 600; border: 1px solid transparent; transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: rgba(29,78,216,0.4); }
.btn-ghost { background: none; color: var(--text); }
.btn-ghost:hover { background: var(--slate-100); }
.btn-danger { color: var(--rose); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; height: 34px; width: 34px; border-radius: var(--radius); background: none; border: 0; color: var(--text); }
.icon-btn:hover { background: var(--slate-100); }
.icon-btn.danger { color: var(--rose); }
.full { width: 100%; }
.h11 { height: 44px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,0.5); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade 0.15s ease; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 32rem; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.2); animation: pop 0.15s ease; }
.modal.wide { max-width: 42rem; }
.modal-head { padding: 20px 24px 8px; }
.modal-title { font-family: "Manrope"; font-size: 18px; font-weight: 700; margin: 0; }
.modal-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.modal-body { padding: 12px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--slate-100); padding: 4px; border-radius: var(--radius); }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; padding: 12px 16px; box-shadow: var(--shadow-sm); font-size: 14px; min-width: 240px; animation: slidein 0.2s ease; }
.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--rose); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- Misc ---------- */
.spinner { width: 28px; height: 28px; border: 3px solid rgba(29,78,216,0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-box { display: grid; place-items: center; min-height: 16rem; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); padding: 40px 0; text-align: center; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none; }
.dl-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.dl-row:first-child { border-top: 0; }
.metric { padding: 16px; }
.metric .m-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--muted); }
.metric .m-value { margin-top: 4px; font-family: "Manrope"; font-size: 18px; font-weight: 700; }
.hero-book { background: var(--primary); color: #fff; }
.doc-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; transition: border-color 0.15s ease; }
.doc-item:hover { border-color: rgba(29,78,216,0.4); }
.doc-icon { display: grid; place-items: center; height: 40px; width: 40px; border-radius: 6px; background: var(--slate-100); color: #64748b; flex-shrink: 0; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; border-top: 1px solid var(--border); }
.check-row:first-child { border-top: 0; }
.check-row:hover { background: var(--slate-50); }
.chart-box { position: relative; height: 320px; }
.foto-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
@media (min-width: 640px) { .foto-grid { grid-template-columns: repeat(4,1fr); } }
.foto-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--slate-100); }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-label { display: inline-flex; align-items: center; gap: 8px; border-radius: var(--radius); background: var(--primary); color: #fff; padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.upload-label.outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.filters { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .filters { grid-template-columns: repeat(2,1fr); } }
@media (min-width: 1024px) { .filters { grid-template-columns: repeat(5,1fr); } }
