:root {
    --primary: #1e40af;
    --primary-600: #2563eb;
    --primary-dark: #172554;
    --accent: #c8a24a;
    --accent-soft: #fff7df;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #047857;
    --warning: #b45309;
    --danger: #b91c1c;
    --info: #0369a1;
    --success-bg: #ecfdf5;
    --warning-bg: #fffbeb;
    --danger-bg: #fef2f2;
    --info-bg: #eff6ff;
    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-width: 288px;
    --topbar-height: 78px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(30, 64, 175, 0.09), transparent 32rem),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #eef3f9 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary-600); text-decoration: none; transition: color .18s ease, background .18s ease, border .18s ease, transform .18s ease; }
a:hover { color: var(--primary); text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #071638 0%, #0b1f49 52%, #102a5c 100%);
    color: #e2e8f0;
    position: fixed;
    inset: 0 auto 0 0;
    padding: 22px 18px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 16px 0 42px rgba(15, 23, 42, .18);
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 999px; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 24px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    margin-bottom: 18px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), #f8dd8e);
    display: grid;
    place-items: center;
    font-size: 24px;
    box-shadow: 0 14px 30px rgba(200, 162, 74, .22);
}

.brand strong { display: block; color: #fff; font-size: 17px; letter-spacing: -.01em; }
.brand small { display: block; color: #a8b8d8; margin-top: 2px; font-size: 12px; }

.sidebar-section {
    color: #8ea6ce;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    margin: 18px 12px 8px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 14px;
    color: #cbd5e1;
    font-weight: 650;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(2px); }
.sidebar-nav a.active {
    background: linear-gradient(90deg, rgba(37,99,235,.98), rgba(30,64,175,.68));
    color: #fff;
    box-shadow: 0 12px 25px rgba(37, 99, 235, .28);
}
.sidebar-nav a.active::before {
    content: "";
    position: absolute;
    left: -18px;
    width: 4px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent);
}
.nav-icon { width: 26px; height: 26px; display: grid; place-items: center; font-size: 17px; }
.sidebar-backdrop { display: none; }

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(226, 232, 240, .88);
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 30px;
}

.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 14px;
    cursor: pointer;
    font-size: 20px;
    color: var(--text);
}

.top-search {
    flex: 1;
    max-width: 650px;
    height: 48px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}
.top-search input { width: 100%; border: 0; background: transparent; outline: none; font-size: 14px; color: var(--text); }
.top-search input::placeholder { color: #94a3b8; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.icon-btn:hover { transform: translateY(-1px); border-color: #bfdbfe; }

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px 7px 7px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.user-box strong { display: block; font-size: 13px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-dark));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
}
.logout-btn {
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 800;
    border: 1px solid #fecaca;
}
.logout-btn:hover { background: #fee2e2; color: #991b1b; }

/* Content */
.content {
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 30px) 30px 42px;
    width: calc(100% - var(--sidebar-width));
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.page-title h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.045em; color: #0f172a; }
.page-title p { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Cards and panels */
.cardx, .card, .panel, .box {
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(226,232,240,.96);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.cardx h5, .card h5 { margin: 0 0 16px; font-size: 17px; letter-spacing: -.01em; }
.card-header {
    margin: -22px -22px 18px;
    padding: 17px 22px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(180deg, #fff, #f8fafc);
    font-weight: 800;
}

/* Tables */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 16px; }
table, .table { width: 100%; border-collapse: collapse; }
table th, .table th {
    text-align: left;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    white-space: nowrap;
}
table td, .table td { padding: 14px 12px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
table tr:hover td { background: #f8fbff; }
table tr:last-child td { border-bottom: 0; }
.text-muted { color: var(--muted) !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }

/* Forms */
form { margin: 0; }
label { display: block; font-weight: 800; color: #334155; margin-bottom: 7px; font-size: 13px; }
input, select, textarea, .form-control, .form-select {
    width: 100%;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: .18s ease;
}
input:hover, select:hover, textarea:hover, .form-control:hover, .form-select:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus, .form-control:focus, .form-select:focus {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
textarea { min-height: 120px; resize: vertical; }
.form-group { margin-bottom: 16px; }

/* Grid helpers */
.row { display: flex; flex-wrap: wrap; margin: -8px; }
.row > * { padding: 8px; }
.g-3 > * { padding: 8px; }
.col-12 { width: 100%; }
.col-md-2 { width: 16.666%; }
.col-md-3 { width: 25%; }
.col-md-4 { width: 33.333%; }
.col-md-5 { width: 41.666%; }
.col-md-6 { width: 50%; }
.col-md-7 { width: 58.333%; }
.col-md-8 { width: 66.666%; }
.col-md-10 { width: 83.333%; }
.col-lg-3 { width: 25%; }
.col-lg-4 { width: 33.333%; }
.col-lg-5 { width: 41.666%; }
.col-lg-6 { width: 50%; }
.col-lg-7 { width: 58.333%; }
.col-lg-8 { width: 66.666%; }

/* Buttons */
button, .btn {
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    transition: .18s ease;
}
.btn:hover, button:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary-600), var(--primary)); color: #fff; box-shadow: 0 10px 22px rgba(37,99,235,.22); }
.btn-primary:hover { color: #fff; background: linear-gradient(135deg, #1d4ed8, #172554); }
.btn-secondary { background: #eef2f7; color: #334155; }
.btn-success { background: #059669; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-outline-primary { background: #fff; color: var(--primary-600); border: 1px solid #bfdbfe; }
.btn-outline-warning { background: #fff; color: var(--warning); border: 1px solid #fde68a; }
.btn-outline-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-outline-secondary { background: #fff; color: #475569; border: 1px solid var(--border); }
.btn-sm { padding: 8px 11px; font-size: 12px; border-radius: 11px; }
.w-100 { width: 100%; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 22px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }

/* Alerts */
.alert { padding: 14px 16px; border-radius: 15px; margin-bottom: 18px; font-weight: 650; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #bfdbfe; }

/* Badges */
.badge-soft, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.badge-soft.success, .badge-success { background: var(--success-bg); color: var(--success); }
.badge-soft.warning, .badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-soft.danger, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-soft.secondary, .badge-secondary { background: #f1f5f9; color: #475569; }

/* Dashboard */
.dashboard-hero {
    display: grid;
    grid-template-columns: 1.4fr .8fr;
    gap: 18px;
    margin-bottom: 20px;
}
.hero-card {
    padding: 28px;
    border-radius: 24px;
    background: linear-gradient(135deg, #0b1f49 0%, #1e40af 64%, #2563eb 100%);
    color: #fff;
    box-shadow: 0 22px 55px rgba(30,64,175,.25);
    position: relative;
    overflow: hidden;
}
.hero-card::after {
    content: "";
    position: absolute;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    right: -70px;
    top: -80px;
}
.hero-card h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.05em; position: relative; z-index: 1; }
.hero-card p { margin: 10px 0 0; color: #dbeafe; max-width: 720px; position: relative; z-index: 1; }
.hero-actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; position: relative; z-index: 1; }
.hero-actions .btn { background: #fff; color: var(--primary); }
.hero-actions .btn-secondary { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.24); }
.today-card { padding: 24px; border-radius: 24px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); }
.today-card small { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.today-card h3 { margin: 8px 0 6px; font-size: 24px; }
.today-card p { margin: 0; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); padding: 22px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; inset: auto -35px -45px auto; width: 115px; height: 115px; border-radius: 999px; background: rgba(37,99,235,.08); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--info-bg); font-size: 20px; margin-bottom: 14px; }
.stat-card small { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-card h2 { margin: 4px 0 0; font-size: 34px; letter-spacing: -.04em; }

/* Authentication */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 470px;
    background:
        radial-gradient(circle at 18% 20%, rgba(200,162,74,.26), transparent 28rem),
        linear-gradient(135deg, #071638 0%, #102a5c 45%, #f8fafc 45.2%, #eef4fb 100%);
}
.auth-panel {
    color: #fff;
    padding: 58px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-logo { display: flex; align-items: center; gap: 13px; font-weight: 900; font-size: 20px; }
.auth-logo span { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #f8dd8e); }
.auth-copy h1 { font-size: clamp(38px, 5vw, 62px); line-height: .95; letter-spacing: -.06em; margin: 0 0 18px; }
.auth-copy p { color: #cbd5e1; max-width: 560px; font-size: 16px; }
.auth-card-wrap { display: grid; place-items: center; padding: 28px; }
.auth-card {
    width: min(430px, 94vw);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(226,232,240,.96);
    border-radius: 26px;
    padding: 34px;
    box-shadow: 0 28px 70px rgba(15,23,42,.16);
}
.auth-card h3 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.03em; }
.auth-card p { margin: 0 0 24px; color: var(--muted); }
.auth-card .default-login { margin-top: 18px; padding: 13px; border-radius: 14px; background: #f8fafc; border: 1px dashed #cbd5e1; color: #64748b; font-size: 13px; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 7px 9px; border-radius: 10px; background: #f1f5f9; color: #334155; font-size: 12px; }

/* Footer */
.app-footer { margin-top: 28px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 1100px) {
    .sidebar { transform: translateX(-105%); transition: transform .25s ease; }
    .sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.48); z-index: 95; }
    .topbar { left: 0; }
    .content { margin-left: 0; width: 100%; }
    .sidebar-toggle { display: inline-grid; place-items: center; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-hero { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .auth-page { grid-template-columns: 1fr; background: linear-gradient(180deg, #071638 0%, #102a5c 34%, #eef4fb 34.2%, #eef4fb 100%); }
    .auth-panel { padding: 30px 24px 12px; min-height: 300px; }
    .auth-copy h1 { font-size: 38px; }
    .top-search { display: none; }
}

@media (max-width: 720px) {
    .content { padding: calc(var(--topbar-height) + 20px) 16px 30px; }
    .topbar { padding: 0 14px; }
    .user-box div:not(.avatar) { display: none; }
    .logout-btn { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-10,
    .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8 { width: 100%; }
    .stat-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 26px; }
}
