:root {
    --navy: #1B3A5C;
    --navy-deep: #102538;
    --navy-mid: #234A70;
    --gold: #D9A441;
    --gold-light: #F0CC7F;
    --danger: #B23A2E;
    --success: #1E7A4C;
    --cream: #F7F5F0;
    --cream-deep: #EFEBE2;
    --line: #DDE1E6;
    --ink: #1F2430;
    --ink-soft: #5C6470;
    --white: #FFFFFF;
    --shadow-lift: 0 10px 26px rgba(16, 37, 56, .10);
    --font-display: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}
* { box-sizing: border-box; }
body {
    margin: 0; font-family: var(--font-body); background: var(--cream); color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 .4em; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 250px; background: var(--navy-deep); color: #cdd9e4; flex-shrink: 0;
    padding: 20px 0 30px; display: flex; flex-direction: column;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 18px; }
.sidebar .brand img { width: 40px; height: 40px; border-radius: 50%; }
.sidebar .brand .name { font-family: var(--font-display); font-weight: 700; font-size: .95rem; color: #fff; line-height: 1.25; }
.sidebar .brand .tag { font-size: .68rem; color: var(--gold-light); letter-spacing: .05em; text-transform: uppercase; }
.sidebar nav { padding: 0 10px; }
.sidebar .section-label { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #7C8CA0; padding: 16px 12px 6px; }
.nav-link { display: block; padding: 9px 12px; border-radius: 8px; font-size: .87rem; font-weight: 500; color: #cdd9e4; margin-bottom: 2px; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--gold); color: var(--navy-deep); font-weight: 700; }
.sidebar-bottom { margin-top: auto; padding: 14px 20px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-bottom a { font-size: .82rem; color: #cdd9e4; display: flex; align-items: center; gap: 6px; }

/* ---------- Topbar / content ---------- */
.content { flex: 1; min-width: 0; }
.topbar {
    background: #fff; border-bottom: 1px solid var(--line); padding: 14px 26px;
    display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 1.25rem; }
.topbar .user-pill { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.topbar .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--navy-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.page-body { padding: 26px 28px 50px; }

/* ---------- Flash / alerts ---------- */
.alert { padding: 12px 16px; border-radius: 9px; font-size: .88rem; margin-bottom: 18px; }
.alert-success { background: #E4F3EA; color: var(--success); border: 1px solid #BEE3CC; }
.alert-error { background: #FBEAE3; color: #8C2E1F; border: 1px solid #F0C3B3; }

/* ---------- Panels / cards ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 22px; overflow: hidden; }
.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; }

.stat-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; flex: 1 1 200px; min-width: 180px; }
.stat-card .label { font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.stat-card .value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.stat-card .sub { font-size: .78rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=month], input[type=file], select, textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 8px;
    font-size: .92rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 200px; }
.mono { font-family: var(--font-mono); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: .88rem;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: var(--cream); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F0C3B3; }
.btn-danger:hover { background: #FBEAE3; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }

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

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

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.badge-active { background: #E4F3EA; color: var(--success); }
.badge-disengaged { background: #F1F1EE; color: #7A7F70; }
.badge-pending { background: #FDF0DA; color: #8A5A0E; }
.badge-approved { background: #E4F3EA; color: var(--success); }
.badge-rejected { background: #FBEAE3; color: #8C2E1F; }

/* ---------- ID card (screen + print, mirrors demand-notice pattern) ---------- */
.id-card-wrap { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; padding: 20px 0; }
.id-card { width: 340px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lift); }
.id-card .head { background: linear-gradient(135deg, var(--navy), var(--navy-deep)); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.id-card .head img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold); }
.id-card .head .t1 { font-family: var(--font-display); font-weight: 700; font-size: .92rem; }
.id-card .head .t2 { font-size: .72rem; color: var(--gold-light); }
.id-card .photo-row { display: flex; gap: 14px; padding: 16px; }
.id-card .photo { width: 84px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--cream); }
.id-card .meta h3 { font-size: 1rem; margin-bottom: 4px; }
.id-card .meta div { font-size: .78rem; color: var(--ink-soft); margin-bottom: 2px; }
.id-card .code-strip { background: var(--gold); color: var(--navy-deep); text-align: center; font-family: var(--font-mono); font-weight: 700; padding: 6px; letter-spacing: .04em; }
.id-card .qr-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-top: 1px dashed var(--line); }
.id-card .qr-row .valid { font-size: 10.5px; color: var(--ink-soft); text-align: right; line-height: 1.5; }
.id-card .foot { background: var(--navy-deep); color: #cdd9e4; font-size: 10px; text-align: center; padding: 6px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
    .no-print { display: none !important; }
    .sidebar, .topbar { display: none !important; }
    body { background: var(--white); }
    .id-card { box-shadow: none; border: 1px solid #999; }
}

@media (max-width: 860px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 40; transition: left .2s; }
    .sidebar.open { left: 0; }
    .field-row { grid-template-columns: 1fr; }
}
