:root {
    --navy: #0f2544;
    --navy-700: #16325c;
    --charcoal: #1f2937;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --blue: #2563eb;
    --blue-600: #1d4ed8;
    --blue-50: #eff6ff;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e9f2;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(15, 37, 68, .04), 0 8px 24px rgba(15, 37, 68, .06);
    --shadow-sm: 0 1px 2px rgba(15, 37, 68, .06);
    --sidebar-w: 252px;
    --font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--charcoal);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: #dbe4f3;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar__logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #22c55e);
    display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .5px;
}
.sidebar__title { font-weight: 700; color: #fff; font-size: 16px; }
.sidebar__subtitle { font-size: 11px; color: #93a4c4; }

.sidebar__nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: #c4d2ea; font-weight: 500; text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; }
.nav-link svg { width: 19px; height: 19px; flex: none; }

.sidebar__foot { padding: 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 11px; color: #8ea0c0; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 64px; background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: 14px; }
.topbar__title { font-size: 18px; font-weight: 700; color: var(--navy); }
.topbar__user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--blue-50); color: var(--blue);
    display: grid; place-items: center; font-weight: 700;
}

.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    width: 40px; height: 40px; border-radius: 8px; color: var(--navy);
}
.hamburger:hover { background: var(--bg); }

.content { padding: 26px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------------- Cards / grid ---------------- */
.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card__body { padding: 20px 22px; }
.card__head {
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card__title { font-weight: 700; color: var(--navy); font-size: 16px; }

.stat {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 6px;
}
.stat__label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat__value { font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat__icon {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    margin-bottom: 4px;
}
.stat__icon svg { width: 22px; height: 22px; }
.ic-blue { background: var(--blue-50); color: var(--blue); }
.ic-green { background: var(--green-bg); color: var(--green); }
.ic-red { background: var(--red-bg); color: var(--red); }
.ic-amber { background: var(--amber-bg); color: var(--amber); }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; white-space: nowrap; }
table.data thead th {
    background: #f8fafc; color: var(--muted); font-weight: 600;
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfe; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge--active { background: var(--green-bg); color: var(--green); }
.badge--expired { background: var(--red-bg); color: var(--red); }
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-600); color: #fff; }
.btn--light { background: #fff; color: var(--navy); border-color: var(--border); }
.btn--light:hover { background: #f8fafc; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--bg); color: var(--navy); }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: #b91c1c; color: #fff; }
.btn--sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn--block { width: 100%; }

.actions { display: inline-flex; gap: 6px; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
    border: 1px solid var(--border); background: #fff; color: var(--muted); cursor: pointer;
    transition: .15s;
}
.icon-btn:hover { color: var(--navy); background: #f8fafc; text-decoration: none; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn--danger:hover { color: var(--red); border-color: #fecaca; background: var(--red-bg); }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field--full { grid-column: 1 / -1; }
label.lbl { font-size: 13px; font-weight: 600; color: var(--charcoal); }
label.lbl .req { color: var(--red); }
.control {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
    font-size: 14px; font-family: inherit; color: var(--charcoal); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.control[readonly] { background: #f8fafc; color: var(--muted); font-weight: 600; }
select.control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--red); font-weight: 500; }
.control.is-invalid { border-color: var(--red); }

.photo-drop {
    border: 1.5px dashed var(--border); border-radius: 12px; padding: 18px;
    display: flex; align-items: center; gap: 16px; background: #fbfcfe;
}
.photo-preview {
    width: 76px; height: 76px; border-radius: 10px; object-fit: cover;
    border: 1px solid var(--border); background: #f1f5f9;
}

/* ---------------- Alerts ---------------- */
.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border-radius: 12px; font-size: 14px; margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert--success { background: var(--green-bg); color: #14532d; border-color: #bbf7d0; }
.alert--error { background: var(--red-bg); color: #7f1d1d; border-color: #fecaca; }
.alert--warn { background: var(--amber-bg); color: #78350f; border-color: #fde68a; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------- Page header ---------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; color: var(--navy); font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- Filter bar ---------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { gap: 5px; }
.search-input { position: relative; flex: 1 1 240px; min-width: 200px; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted-2); }
.search-input .control { padding-left: 38px; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; margin: 18px 0 0; justify-content: flex-end; }
.pagination a, .pagination span {
    min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: #fff; color: var(--charcoal); font-size: 13px;
}
.pagination a:hover { background: #f8fafc; text-decoration: none; }
.pagination .active span { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination .disabled span { color: var(--muted-2); background: #f8fafc; }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: var(--muted-2); margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; color: var(--navy); }

/* ---------------- Detail / preview ---------------- */
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.info-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); font-size: 13px; }
.info-row .v { font-weight: 600; color: var(--navy); text-align: right; }
.applicant-photo {
    width: 100%; max-width: 220px; aspect-ratio: 3/4; object-fit: cover;
    border-radius: 12px; border: 1px solid var(--border); background: #f1f5f9;
}
.qr-box { text-align: center; }
.qr-box svg, .qr-box img { width: 220px; max-width: 100%; height: auto; }
.qr-url { font-size: 12px; color: var(--muted); word-break: break-all; margin-top: 10px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 37, 68, .5);
    display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: 16px; max-width: 420px; width: 100%;
    padding: 26px; box-shadow: var(--shadow); text-align: center;
}
.modal__icon { width: 54px; height: 54px; border-radius: 50%; background: var(--red-bg); color: var(--red); display: grid; place-items: center; margin: 0 auto 14px; }
.modal__icon svg { width: 26px; height: 26px; }
.modal h3 { margin: 0 0 8px; color: var(--navy); }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.modal__actions { display: flex; gap: 10px; justify-content: center; }

/* ---------------- Utilities ---------------- */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-muted { color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: none; }
.no-print { }

.overlay-scrim { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-100%); width: 252px; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .main { margin-left: 0; }
    .hamburger { display: grid; place-items: center; }
    .overlay-scrim.open { display: block; position: fixed; inset: 0; background: rgba(15,37,68,.4); z-index: 39; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .topbar { padding: 0 16px; }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .topbar__user span.uname { display: none; }
    .page-head { align-items: flex-start; }
}

/* ---------------- Print ---------------- */
@media print {
    .sidebar, .topbar, .no-print, .overlay-scrim, .modal-overlay { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border-color: #d1d5db !important; break-inside: avoid; }
    .detail-grid { grid-template-columns: 1.6fr 1fr !important; }
    a[href]:after { content: ""; }
}
