:root {
    --primary: #2952a3;
    --primary-dark: #1c3a7a;
    --primary-light: #eaf0fb;
    --accent: #f2a900;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1e2532;
    --muted: #6b7688;
    --border: #e6e9f0;
    --danger: #e0483f;
    --danger-bg: #fdeceb;
    --success: #1e9e6b;
    --success-bg: #e9f9f1;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(20, 30, 60, 0.06);
    --shadow-md: 0 6px 18px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ===================== SHELL / SIDEBAR ===================== */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.brand-mark {
    width: 38px; height: 38px;
    background: var(--accent);
    color: var(--primary-dark);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.brand-text span { display: block; font-weight: 400; font-size: 0.72rem; opacity: 0.7; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-nav a svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.12);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-size: 0.83rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: rgba(255,255,255,0.6); text-transform: capitalize; }
.sidebar-logout {
    color: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 7px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.12); color: #fff; }

.content-area { flex: 1; min-width: 0; }
.app-main { padding: 28px 34px; max-width: 1180px; margin: 0 auto; width: 100%; }
.app-main-bare { max-width: none; padding: 0; }

/* ===================== HEADINGS ===================== */
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 20px; color: var(--text); letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 16px; color: var(--primary-dark); }

/* ===================== CARDS ===================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}

/* ===================== LOGIN ===================== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(255,255,255,0.08) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(242,169,0,0.15) 0%, transparent 45%),
        linear-gradient(135deg, var(--primary-dark), var(--primary));
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
}
.login-card {
    background: #fff;
    padding: 40px 38px 34px;
    border-radius: 16px;
    width: 380px;
    box-shadow: 0 20px 50px rgba(10, 20, 50, 0.35);
}
.login-card .login-mark {
    width: 48px; height: 48px; margin: 0 auto 18px;
    background: var(--accent); color: var(--primary-dark);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem;
}
.login-card h1 { text-align: center; color: var(--primary-dark); font-size: 1.25rem; margin-bottom: 4px; }
.login-card .brand-sub { text-align: center; color: var(--muted); margin-bottom: 26px; font-size: 0.85rem; }

/* ===================== FORM ELEMENTS ===================== */
label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 14px;
    background: #fbfcfe;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--primary-light);
}
input:disabled, select:disabled {
    background: #f1f3f7;
    color: var(--muted);
    cursor: not-allowed;
}
textarea { resize: vertical; min-height: 72px; }

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { background: #c3cad8; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-full { width: 100%; }
.btn-secondary { background: #eef0f5; color: var(--text); box-shadow: none; }
.btn-secondary:hover { background: #e2e5ed; box-shadow: none; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c73a32; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #17805a; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ===================== ALERTS ===================== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.87rem; font-weight: 500; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f6c9c5; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b9ecd3; }

/* ===================== TABLES ===================== */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { background: #fafbfd; color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f7f9fd; }

.tag { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 0.73rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.tag-active { background: var(--success-bg); color: var(--success); }
.tag-inactive { background: var(--danger-bg); color: var(--danger); }

/* ===================== LAYOUT HELPERS ===================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 16px; }
.checkbox-group label { display: flex; align-items: center; gap: 7px; font-weight: 500; margin: 0; color: var(--text); }
.checkbox-group input { width: auto; margin: 0; accent-color: var(--primary); }

.repeat-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.repeat-row > div { flex: 1; }
.small-note { color: var(--muted); font-size: 0.79rem; margin-top: -8px; margin-bottom: 14px; line-height: 1.4; }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 26px; }
.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.dash-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}
.dash-card .num { font-size: 2rem; font-weight: 800; color: var(--primary-dark); letter-spacing: -0.02em; }
.dash-card .label { color: var(--muted); font-size: 0.83rem; margin-top: 4px; font-weight: 500; }

.top-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.actions-cell { display: flex; gap: 8px; }
