/* ========== Reset & base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --sb-w: 240px;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;

    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e5e7eb;

    --text: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;

    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --info: #0ea5e9;

    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sb-w);
    height: 100vh;
    background:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.18) 0%, transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.10) 0%, transparent 50%),
        linear-gradient(180deg, #0f172a 0%, #111827 60%, #0b1120 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform .25s ease;
    border-right: 1px solid rgba(255,255,255,.06);
}

.side-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.5px;
    box-shadow: 0 6px 18px -4px rgba(99, 102, 241, 0.55), inset 0 1px 0 rgba(255,255,255,0.2);
    position: relative;
}

.logo:not(:has(img))::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99,102,241,0.35), transparent);
    z-index: -1;
    filter: blur(8px);
}

.brand { line-height: 1.2; }
.brand-name {
    font-weight: 700;
    color: #fff;
    font-size: 1rem;
    letter-spacing: -0.2px;
    background: linear-gradient(90deg, #fff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.brand-tag {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-top: 2px;
}

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(6px);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px -2px rgba(139, 92, 246, 0.5);
    border: 2px solid rgba(255,255,255,0.1);
}

.who { min-width: 0; flex: 1; }
.who-name { font-weight: 600; color: #f1f5f9; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role {
    display: inline-block;
    margin-top: 3px;
    padding: 2px 8px;
    background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(34,197,94,0.18));
    color: #6ee7b7;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid rgba(16,185,129,0.25);
}

.menu {
    flex: 1;
    padding: 6px 10px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-section {
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 14px 14px 6px;
}
.menu-section:first-child { padding-top: 6px; }

.menu a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px 9px 14px;
    border-radius: 9px;
    color: #94a3b8;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background .18s, color .18s, transform .18s;
}

.menu a::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
    transition: background .18s, transform .18s, box-shadow .18s;
}

.menu a:hover {
    background: rgba(255,255,255,.05);
    color: #f1f5f9;
}
.menu a:hover::before {
    background: var(--accent, #818cf8);
    transform: scale(1.4);
}

.menu a.on {
    background: linear-gradient(90deg, var(--accent, #6366f1) 0%, color-mix(in srgb, var(--accent, #6366f1) 70%, #1e1b4b) 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px -6px var(--accent, #6366f1);
}
.menu a.on::before {
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
    transform: scale(1.2);
}

.menu a.on::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--accent, #818cf8);
    box-shadow: 0 0 12px var(--accent, #818cf8);
}

.side-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 14px 18px;
    padding: 11px 14px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.10);
    color: #fca5a5;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.18);
    transition: background .15s, color .15s, border-color .15s;
}

.side-logout::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

.side-logout:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border-color: transparent;
}
.side-logout:hover::before {
    background: #fff;
    box-shadow: 0 0 8px #fff;
}

.menu::-webkit-scrollbar { width: 6px; }
.menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.menu::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ========== Mobile menu button ========== */
.menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 1100;
    box-shadow: var(--shadow-md);
}

.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 800;
}
.backdrop.on { display: block; }

/* ========== Main ========== */
.main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body.app .main { margin-left: var(--sb-w); }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px;
    width: 100%;
    flex: 1;
}

.container > h2:first-child {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    letter-spacing: -0.4px;
}

/* ========== Cards ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
    font-size: 0.82rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-light); }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-group textarea { resize: vertical; min-height: 90px; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.87rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-info { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-info:hover { background: #f9fafb; border-color: #d1d5db; }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

/* ========== Tables ========== */
.table-responsive {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

table th, table td {
    padding: 12px 18px;
    text-align: left;
    font-size: 0.87rem;
}

table th {
    background: #f9fafb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    border-bottom: 1px solid var(--border);
}

table td { border-bottom: 1px solid var(--border); color: var(--text); }
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #fafafa; }

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-pending       { background: var(--warning-soft); color: #92400e; }
.badge-approved      { background: var(--success-soft); color: #065f46; }
.badge-needs-details { background: var(--danger-soft);  color: #991b1b; }

/* ========== Alerts ========== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.87rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: var(--danger-soft);  color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }
.alert-info    { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

/* ========== Stats ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.stat-card p {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
}

/* ========== Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1200;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal h3 {
    margin-bottom: 18px;
    color: var(--text);
    font-size: 1.1rem;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* ========== Filter bar ========== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 16px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ========== Remarks ========== */
.remarks-box {
    background: var(--warning-soft);
    border-left: 3px solid var(--warning);
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 0.83rem;
    color: #78350f;
}

.hidden { display: none; }

/* ========== Auth / Login ========== */
body.auth {
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.auth .main { display: block; min-height: auto; width: 100%; max-width: 420px; }
body.auth .container { padding: 0; max-width: none; }

.login-wrapper { width: 100%; }

.login-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

.login-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    padding: 0;
    border: none;
}

.login-card h2::after {
    content: "Sign in to your account";
    display: block;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 4px;
    margin-bottom: 20px;
}

/* ========== Responsive ========== */
@media (max-width: 960px) {
    body.app .main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .menu-btn { display: flex; align-items: center; justify-content: center; }
    .container { padding: 68px 20px 20px; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card h3 { font-size: 1.35rem; }
    .card { padding: 18px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-group { min-width: 0; }
}
