:root {
    --navy: #102a43;
    --navy-2: #243b53;
    --primary: #1f4e79;
    --primary-soft: #e8eef4;
    --accent: #c49335;
    --accent-soft: #f7edd6;
    --slate: #52667a;
    --bg: #f3f5f7;
    --card: #ffffff;
    --line: #dfe7f5;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Arial, sans-serif; background: var(--bg); color: var(--navy-2); }
a { text-decoration: none; }
body { overflow-x: hidden; }

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 260px;
    background: var(--navy);
    color: white;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.06);
}

.brand-box {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    padding-bottom: 1rem;
}

.brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--accent);
    color: white; display: grid; place-items: center; font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 8px 16px rgba(196, 147, 53, 0.18);
}

.brand-name { font-size: 1.15rem; font-weight: 700; }
.brand-logo { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; flex: 0 0 44px; }

.nav-item {
    display: block; padding: 0.8rem 0.9rem; border-radius: 10px; color: rgba(255,255,255,0.8);
    margin-bottom: 0.3rem; transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.08); color: white; border-left: 3px solid var(--accent);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.sidebar-footer {
    margin-top: auto; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 1rem;
}
.user-chip, .user-pill {
    display: inline-flex; align-items: center; padding: 0.35rem 0.7rem; border-radius: 999px;
    background: rgba(255,255,255,0.12); color: white; font-size: 0.8rem;
}
.logout-link { color: var(--accent-soft); display: inline-block; margin-top: 0.75rem; }

.main-panel {
    flex: 1; padding: 2rem; min-width: 0;
}
.topbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
    gap: 1rem;
}
.topbar-left {
    display: flex; align-items: center; gap: 0.75rem;
}
.page-title { margin: 0; font-size: clamp(1.5rem, 2vw, 2rem); color: var(--navy); }
.topbar-actions { display: flex; gap: 0.75rem; }
.user-pill { background: var(--navy); color: white; }
.mobile-nav-toggle {
    display: none; border: 1px solid var(--line); background: white; color: var(--navy); border-radius: 9px; width: 42px; height: 42px; cursor: pointer; font-size: 1.1rem;
}

.page-section { display: flex; flex-direction: column; gap: 1.25rem; }
.section-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.eyebrow { display: inline-block; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-size: 0.72rem; font-weight: 700; }
.section-header h2 { margin: 0.4rem 0 0; font-size: 1.75rem; color: var(--navy); }

.stats-grid {
    display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 1rem;
}
.stat-card, .panel-card, .table-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem; box-shadow: 0 8px 20px rgba(15,23,42,0.04);
}
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
    content: ''; position: absolute; inset: 0 auto auto 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--accent), var(--primary));
}
.stat-label { color: var(--slate); font-size: 0.8rem; }
.stat-value { font-size: 2rem; font-weight: 700; margin-top: 0.4rem; }

.panel-grid {
    display: grid; grid-template-columns: repeat(2, minmax(260px,1fr)); gap: 1rem;
}
.panel-card h3 { margin-top: 0; }
.activity-list { padding-left: 1.1rem; margin: 0; color: var(--slate); line-height: 1.8; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
    padding: 0.72rem 1.1rem; border-radius: 10px; border: none; font-weight: 600; cursor: pointer; transition: 0.2s ease; display: inline-block;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 8px 16px rgba(16, 42, 67, 0.14); }
.btn-secondary { background: var(--primary-soft); color: var(--navy); }
.btn-danger { background: var(--danger); color: white; }

.form-grid {
    display: grid; grid-template-columns: repeat(2, minmax(240px,1fr)); gap: 1rem;
}
label { display: block; margin-bottom: 0.35rem; font-weight: 600; font-size: 0.85rem; color: var(--slate); }
input, select, textarea {
    width: 100%; padding: 0.75rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 0.95rem;
}
textarea { min-height: 120px; resize: vertical; }

.table-card {
    overflow-x: auto;
}
table {
    width: 100%; border-collapse: collapse; margin-top: 1rem; min-width: 720px;
}
th, td { padding: 0.85rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: var(--navy); }
.badge {
    display: inline-flex; padding: 0.35rem 0.7rem; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 0.72rem; font-weight: 700; text-transform: capitalize;
}
.table-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.table-actions a { font-size: 0.85rem; color: var(--navy); }

.auth-page {
    min-height: 100vh; display: grid; place-items: center; background: #eef2f5;
    padding: 2rem;
}
.auth-card {
    width: min(480px, 100%); background: rgba(255,255,255,0.96); border: 1px solid rgba(148,163,184,0.3); border-radius: 26px; padding: 2rem; box-shadow: 0 24px 60px rgba(15,23,42,0.2);
}
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-brand { margin: 0 auto 1rem; }
.login-brand-logo { display: block; max-width: 190px; max-height: 72px; object-fit: contain; margin: 0 auto 1rem; }
.auth-header h2 { margin: 0; font-size: 2rem; }
.auth-header p { color: var(--slate); }
.auth-footer { margin-top: 1rem; text-align: center; color: var(--slate); font-size: 0.8rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.w-full { width: 100%; }
.alert {
    padding: 0.9rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600;
}
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
    .app-shell { flex-direction: column; }
    .main-panel { padding: 1rem; }
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .mobile-nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .stats-grid, .panel-grid, .form-grid { grid-template-columns: 1fr; }
    .topbar, .section-header { align-items: flex-start; }
}

@media (max-width: 640px) {
    .auth-page { padding: 1rem; }
    .auth-card { padding: 1.25rem; }
    .section-header h2 { font-size: 1.35rem; }
    .btn { width: 100%; text-align: center; }
    .table-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
}
