:root {
    --navy: #1B3A5C;
    --navy-deep: #102538;
    --gold: #D9A441;
    --gold-light: #F0CC7F;
    --cream: #F7F5F0;
    --cream-deep: #EFEBE0;
    --line: #DDE1E6;
    --ink: #1F2430;
    --ink-soft: #5C6470;
    --danger: #C0392B;
    --danger-bg: #FBEAE8;
    --success: #1F9D55;
    --success-bg: #E8F8EE;
    --font-mono: 'IBM Plex Mono', monospace;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 37, 56, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--cream);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}
h1, h2, h3 { font-family: 'Sora', 'Inter', sans-serif; margin: 0; color: var(--ink); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex: none; background: var(--navy-deep); color: #E9EEF3;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand .logo-row { display: flex; align-items: center; gap: 10px; }
.sidebar-brand img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #fff; }
.sidebar-brand .name { font-weight: 700; font-size: .92rem; line-height: 1.3; }
.sidebar-brand .tag { font-size: .68rem; color: var(--gold-light); letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.sidebar nav { padding: 14px 10px; flex: 1; }
.section-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7D8CA0; padding: 14px 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; font-size: .87rem; font-weight: 500; color: #C9D3DF; margin-bottom: 2px; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--gold); color: #241A08; font-weight: 700; }
.sidebar-bottom { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.sidebar-bottom a { color: #C9D3DF; font-weight: 600; }
.sidebar-bottom a:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 1.35rem; }
.topbar .who { display: flex; align-items: center; gap: 10px; }
.topbar .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: #241A08; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 26px 28px 60px; }

/* ---------- Panels & forms ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 1.02rem; }
.panel-body { padding: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 180px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=number], input[type=file], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: .92rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; padding: 10px 18px; font-weight: 700; font-size: .87rem; cursor: pointer; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-gold { background: var(--gold); color: #241A08; }
.btn-gold:hover { background: #C99326; }
.btn-outline { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f5d9d5; }
.btn-sm { padding: 6px 11px; font-size: .78rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .87rem; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: var(--cream); }
tr:last-child td { border-bottom: none; }
.mono { font-family: var(--font-mono); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--cream-deep); color: var(--ink-soft); }

.alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); color: #146A38; border: 1px solid #b9e6c8; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c3bd; }
.alert-info { background: var(--cream-deep); color: var(--ink); border: 1px solid var(--line); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.stat-card .num { font-family: 'Sora', sans-serif; font-size: 1.7rem; font-weight: 700; margin-top: 6px; }

/* ---------- Login / Setup page ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), var(--navy-deep)); padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px 32px; max-width: 400px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card img { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; }
.auth-card h1 { font-size: 1.2rem; text-align: center; margin-bottom: 4px; }
.auth-card p.sub { text-align: center; color: var(--ink-soft); font-size: .85rem; margin-bottom: 20px; }

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .content { padding: 20px 16px 50px; }
    .topbar { padding: 14px 16px; }
}
