:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --ok: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --sidebar: #0f172a;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.5;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
}
.brand {
    display: flex; gap: 12px; align-items: center;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.brand-name { color: #fff; font-weight: 700; }
.brand-sub { font-size: 11.5px; color: #94a3b8; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav a {
    color: #cbd5e1; text-decoration: none;
    padding: 9px 12px; border-radius: 8px;
    transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 40;
    background: #2b3240;
    border-bottom: 1px solid #1f2530;
    color: #e6ebf2;
    padding: 12px 22px;
    display: flex; align-items: center; gap: 14px;
}
.topbar .page-title { color: #fff; }
.topbar .who small { color: #9aa5b5; }
.topbar .pop-foot { background: #343d4d; }
.brand-mini { display: flex; align-items: center; gap: 9px; padding-right: 14px; border-right: 1px solid #454f60; }
.bm-name { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; font-size: 14px; color: #fff; }
.bm-name small { font-weight: 500; color: #9aa5b5; font-size: 11px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.burger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.burger span { display: block; width: 20px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; }

.imp-banner { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; }
.imp-banner a { color: #92400e; font-weight: 600; margin-left: 8px; }

.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 7px; font-weight: 500; }
.pop > summary::-webkit-details-marker { display: none; }
.pill { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.who small { color: var(--muted); font-size: 11px; }
.pop-panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--card); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 12px 30px rgba(15,23,42,.12);
    width: 300px; overflow: hidden; z-index: 60;
}
.notif-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; }
.notif-item.unread { background: #eef2ff; }
.notif-item time { color: var(--muted); font-size: 11px; }
.pad { padding: 12px 14px; }
.pop-foot { display: block; text-align: center; padding: 10px; background: #f8fafc; color: var(--primary); font-weight: 600; text-decoration: none; border-top: 1px solid var(--border); }
.user-pop .pop-panel { width: 230px; }

.apps-pop { position: relative; }
.apps-btn {
    width: 42px; height: 42px; border-radius: 10px;
    background: #7c3aed; color: #fff; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(124,58,237,.35);
    transition: background .15s, transform .1s;
}
.apps-btn:hover, .apps-pop.open .apps-btn { background: #6d28d9; }
.apps-btn:active { transform: scale(.95); }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.5px; width: 17px; height: 17px; }
.apps-grid i { background: #e9e4f8; border-radius: 2px; display: block; }
.apps-panel {
    position: absolute; left: 0; top: calc(100% + 10px);
    background: #2b3240; border: 1px solid #414a5a;
    border-radius: 12px; box-shadow: 0 14px 34px rgba(15,23,42,.28);
    width: min(440px, calc(100vw - 40px)); max-height: calc(100vh - 110px); overflow-y: auto;
    padding: 12px; display: none; grid-template-columns: repeat(2, 1fr); gap: 7px; z-index: 70;
}
@media (hover: hover) {
    .apps-pop:hover .apps-panel { display: grid; }
}
.apps-pop.open .apps-panel { display: grid; }
.apps-item {
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 13px 8px; border-radius: 9px; border: 1px solid #454f60;
    background: #343d4d; color: #e6ebf2;
    font-weight: 600; font-size: 13px; text-decoration: none; line-height: 1.25;
    transition: background .12s, border-color .12s, color .12s;
}
.apps-item:hover { background: #7c3aed; border-color: #7c3aed; color: #fff; box-shadow: 0 4px 10px rgba(124,58,237,.35); }
.apps-item:hover { background: #7c3aed; border-color: #7c3aed; color: #fff; box-shadow: 0 4px 10px rgba(124,58,237,.35); }
.apps-item.active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

.content { padding: 22px; width: 100%; }

.alert {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500;
}
.alert-success { background: #dcfce7; color: #14532d; }
.alert-error { background: #fee2e2; color: #7f1d1d; }
.alert-info { background: #e0e7ff; color: #312e81; }
.alert-x { background: none; border: none; font-size: 17px; cursor: pointer; color: inherit; opacity: .6; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 18px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    box-shadow: 0 1px 2px rgba(15,23,42,.05);
    transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: 0 10px 26px rgba(15,23,42,.09); }

.kpi { display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #64748b, #94a3b8); }
.kpi.primary::before { background: linear-gradient(90deg, #4f46e5, #818cf8); }
.kpi.ok::before { background: linear-gradient(90deg, #059669, #34d399); }
.kpi.warn::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.kpi.bad::before { background: linear-gradient(90deg, #dc2626, #f87171); }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.kpi .value { font-size: 29px; font-weight: 800; line-height: 1.2; }
.kpi .sub { color: var(--muted); font-size: 12.5px; }
.kpi.primary .value { color: var(--primary); }
.kpi.ok .value { color: var(--ok); }
.kpi.bad .value { color: var(--bad); }
.kpi.warn .value { color: var(--warn); }

.hero {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: linear-gradient(120deg, #4338ca, #7c3aed);
    color: #fff; border-radius: var(--radius);
    padding: 20px 24px; margin-bottom: 18px;
    box-shadow: 0 10px 24px rgba(79,70,229,.25);
}
.hero h2 { margin: 0; font-size: 19px; }
.hero p { margin: 5px 0 0; opacity: .85; font-size: 13.5px; }
.hero .hero-date { text-align: right; font-size: 13px; opacity: .9; white-space: nowrap; text-transform: capitalize; }

h2.section { font-size: 15px; font-weight: 700; margin: 22px 0 12px; }
.card h3 { font-size: 14px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }

table.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.04); }
.table-wrap { overflow-x: auto; border-radius: 14px; }
.table th, .table td { text-align: left; padding: 12px 16px; vertical-align: middle; }
.table th { background: #f4f6fa; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7a8699; font-weight: 700; border-bottom: 1px solid #eef1f6; }
.table td { border-bottom: 1px solid #f2f5f9; font-size: 13.5px; color: #334155; }
.table tbody tr { transition: background .13s ease; }
.table tbody tr:nth-child(even) { background: #fbfcfe; }
.table tbody tr:hover { background: #f7f5ff; }
.table tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 8px;
    padding: 8px 14px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--ok); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 700; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #e2e8f0; color: #475569; }

form.form, .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: #334155; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font-size: 14px; font-family: inherit;
    background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.checks label { display: flex; gap: 5px; align-items: center; font-weight: 400; font-size: 13px; }
.inline-form { display: inline; }

.tabs-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: #fff; border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 13px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.progress { background: #e2e8f0; border-radius: 999px; height: 8px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.bad > span { background: var(--bad); }

details.course { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
details.course > summary { cursor: pointer; padding: 14px 18px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
details.course .course-body { padding: 0 18px 18px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e1b4b, #312e81 55%, #4338ca); padding: 20px; }
.login-box { background: #fff; border-radius: 16px; padding: 30px; width: 100%; max-width: 420px; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.login-box .brand-logo { width: 64px; height: 64px; border-radius: 16px; font-size: 25px; margin: 0 auto 14px; }
.login-box .login-title { font-size: 27px; }
.login-title { font-size: 21px; font-weight: 800; margin-bottom: 4px; text-align: center; }
.login-sub { color: var(--muted); margin-bottom: 18px; font-size: 13.5px; text-align: center; }
.login-field { margin-bottom: 12px; }
.login-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 14px; cursor: pointer; user-select: none; }
.login-check input { width: auto; accent-color: var(--primary); }
.login-link { display: block; text-align: center; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--primary); text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-home { display: block; text-align: center; margin-top: 10px; font-size: 13px; color: var(--muted); text-decoration: none; }
.login-home:hover { color: var(--primary); }
.login-copyright { text-align: center; margin-top: 20px; font-size: 11.5px; color: var(--muted); opacity: .7; }
.reset-info { background: #f5f3ff; border: 1px solid #ddd6fe; color: #4c1d95; border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.reset-info code { display: block; margin-top: 6px; word-break: break-all; background: #ede9fe; border-radius: 6px; padding: 6px 8px; font-size: 12px; }

.doc-sheet { background: #fff; max-width: 800px; margin: 0 auto; padding: 40px; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--text); padding-bottom: 14px; margin-bottom: 20px; }
.doc-title { font-size: 19px; font-weight: 800; text-transform: uppercase; }
.print-hide { }
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .print-hide, .alert { display: none !important; }
    .main { margin-left: 0; }
    .doc-sheet { border: none; }
}

.sidebar-overlay { display: none; }

@media (max-width: 900px) {
    .bm-name { display: none; }
}

@media print {
    .apps-pop, .topbar, .sidebar, .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
}
