:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --secondary-dark: #6d28d9;
    --accent: #8b5cf6;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --background: #f1f5f9;
    --text: #172033;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 18px 45px rgba(30, 41, 59, .10);
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 18px;
    background:
        radial-gradient(circle at 12% 18%, rgba(37, 99, 235, .22), transparent 30%),
        radial-gradient(circle at 88% 82%, rgba(124, 58, 237, .22), transparent 34%),
        linear-gradient(135deg, #eff6ff 0%, #f5f3ff 52%, #faf5ff 100%);
}

.auth-shell { width: min(100%, 440px); }
.auth-brand { margin-bottom: 20px; text-align: center; }
.auth-logo, .brand-mark {
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 10px 25px rgba(93, 68, 220, .28);
    font-weight: 800;
}
.auth-logo { width: 58px; height: 58px; border-radius: 18px; font-size: 20px; }
.auth-brand h1 { margin: 12px 0 4px; font-size: 24px; }
.auth-brand p, .auth-footer { color: var(--muted); font-size: 14px; }
.auth-card {
    padding: 30px;
    border: 1px solid rgba(255,255,255,.85);
    border-radius: 22px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}
.auth-card h2 { margin: 0 0 6px; font-size: 22px; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); }
.auth-footer { margin-top: 18px; text-align: center; }
.auth-footer a, .text-link { color: var(--secondary); font-weight: 700; }
.auth-footer a:hover, .text-link:hover { color: var(--primary); }

.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }
.form-control {
    width: 100%;
    min-height: 45px;
    padding: 10px 13px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
textarea.form-control { min-height: 105px; resize: vertical; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124,58,237,.11); }
.form-error { margin-top: 6px; color: var(--danger); font-size: 13px; }
.form-hint { margin-top: 6px; color: var(--muted); font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 2px 0 20px; color: var(--muted); font-size: 14px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--secondary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 43px;
    padding: 10px 17px;
    border: 0;
    border-radius: 11px;
    font-weight: 750;
    transition: transform .2s, box-shadow .2s, opacity .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 10px 20px rgba(80, 70, 210, .22); }
.btn-secondary { color: var(--secondary); background: #f3e8ff; }
.btn-danger { color: var(--danger); background: #fef2f2; }
.btn-block { width: 100%; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    padding: 22px 16px;
    overflow-y: auto;
    color: #e0e7ff;
    background: linear-gradient(180deg, #172554 0%, #312e81 48%, #581c87 100%);
    box-shadow: 8px 0 32px rgba(30,41,59,.13);
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; }
.brand strong { display: block; color: #fff; font-size: 16px; }
.brand small { color: #a5b4fc; }
.nav-label { padding: 24px 12px 9px; color: #a5b4fc; font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 12px; margin: 4px 0; padding: 12px 13px; border-radius: 12px; color: #dbeafe; font-size: 14px; font-weight: 650; transition: background .2s, color .2s; }
.nav-link:hover, .nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(59,130,246,.65), rgba(139,92,246,.62)); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.sidebar-note { margin-top: 28px; padding: 15px; border: 1px solid rgba(255,255,255,.13); border-radius: 14px; background: rgba(255,255,255,.08); }
.sidebar-note strong { display: block; color: #fff; font-size: 13px; }
.sidebar-note span { display: block; margin-top: 4px; color: #c7d2fe; font-size: 12px; line-height: 1.5; }

.app-area { min-height: 100vh; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); }
.topbar-title strong { display: block; font-size: 17px; }
.topbar-title span { color: var(--muted); font-size: 13px; }
.mobile-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.profile-menu { position: relative; }
.profile-menu summary { display: flex; align-items: center; gap: 10px; list-style: none; }
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-name { text-align: right; }
.profile-name strong { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-name span { color: var(--muted); font-size: 11px; }
.profile-avatar { width: 42px; height: 42px; display: grid; place-items: center; border: 3px solid #ede9fe; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); font-weight: 800; box-shadow: 0 7px 18px rgba(93,68,220,.22); }
.dropdown { position: absolute; top: calc(100% + 12px); right: 0; width: 220px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.dropdown::before { content: ""; position: absolute; top: -6px; right: 16px; width: 11px; height: 11px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: #fff; transform: rotate(45deg); }
.dropdown a, .dropdown button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 0; border-radius: 9px; color: #334155; background: transparent; text-align: left; font-size: 13px; }
.dropdown a:hover, .dropdown button:hover { background: #f5f3ff; color: var(--secondary); }
.dropdown-divider { height: 1px; margin: 6px 3px; background: var(--border); }

.main-content { width: 100%; max-width: 1500px; flex: 1; margin: 0 auto; padding: 28px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 5px; font-size: clamp(24px, 3vw, 31px); letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card, .panel { border: 1px solid var(--border); background: var(--surface); box-shadow: 0 10px 30px rgba(30,41,59,.055); }
.stat-card { position: relative; padding: 21px; overflow: hidden; border-radius: 16px; }
.stat-card::after { content: ""; position: absolute; right: -24px; bottom: -30px; width: 90px; height: 90px; border-radius: 50%; background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(124,58,237,.16)); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat-value { margin-top: 10px; font-size: 28px; font-weight: 800; }
.stat-note { margin-top: 4px; color: var(--success); font-size: 12px; }

.content-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(440px, 1.4fr); gap: 22px; align-items: start; }
.panel { border-radius: 17px; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 21px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 17px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 21px; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th, .data-table td { padding: 13px 15px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.data-table th { color: var(--muted); background: var(--surface-muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.data-table tbody tr:hover { background: #fafaff; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge-success { color: #047857; background: #d1fae5; }
.badge-info { color: #1d4ed8; background: #dbeafe; }
.badge-purple { color: #6d28d9; background: #ede9fe; }

.app-footer { padding: 20px 28px 25px; color: var(--muted); text-align: center; font-size: 13px; }
.profile-card { display: grid; grid-template-columns: 90px 1fr; gap: 22px; align-items: center; }
.profile-large { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 24px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); font-size: 28px; font-weight: 800; }
.profile-details h2 { margin: 0 0 5px; }
.profile-details p { margin: 0; color: var(--muted); }

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .app-area { margin-left: 0; }
    .mobile-toggle { display: inline-grid; place-items: center; }
    .topbar { padding: 0 16px; }
    .topbar-title { display: none; }
    .main-content { padding: 21px 16px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .profile-name { display: none; }
}

@media (max-width: 520px) {
    .auth-card { padding: 24px 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .profile-card { grid-template-columns: 1fr; }
}
