:root {
    --primary: #0f766e;
    --primary-dark: #0a5b55;
    --primary-soft: #e7f5f2;
    --gold: #d6a928;
    --ink: #17202a;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #ffffff;
    --background: #f4f7f6;
    --danger: #b42318;
    --warning: #b54708;
    --success: #067647;
    --shadow: 0 12px 30px rgba(17, 39, 35, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--background); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.45rem, 2vw, 2rem); line-height: 1.18; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.eyebrow { display: inline-block; color: var(--primary); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 276px; padding: 22px 18px; display: flex; flex-direction: column; background: #0b2927; color: #fff; box-shadow: 12px 0 30px rgba(0,0,0,.12); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand:hover { color: #fff; }
.brand img { width: 54px; height: 54px; flex: 0 0 54px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 2px; color: #a9c7c3; font-size: .73rem; }
.sidebar-nav { display: grid; gap: 6px; margin-top: 22px; }
.nav-link { display: flex; align-items: center; gap: 13px; padding: 11px 13px; color: #bfd3d0; font-weight: 650; border-radius: 11px; transition: .18s ease; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link.active { color: #0a3b37; background: #e8c761; }
.nav-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:first-child svg { fill: currentColor; stroke: none; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.12); }
.admin-mini { display: flex; gap: 10px; align-items: center; margin-bottom: 13px; color: #fff; }
.admin-mini:hover { color: #fff; }
.admin-mini img, .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar { display: inline-grid; place-items: center; color: #0b2927; background: #e8c761; font-weight: 800; }
.admin-mini strong, .admin-mini small { display: block; }
.admin-mini strong { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.admin-mini small { color: #9cbab6; font-size: .73rem; }
.main-content { min-height: 100vh; margin-left: 276px; display: flex; flex-direction: column; }
.topbar { min-height: 88px; padding: 18px clamp(20px, 3vw, 42px); display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.topbar-profile { margin-left: auto; padding: 9px 14px; font-size: .86rem; font-weight: 700; color: var(--ink); background: var(--primary-soft); border-radius: 999px; }
.menu-button { display: none; }
.icon-button { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); background: #fff; border-radius: 10px; }
.menu-button span { display: block; width: 18px; height: 2px; margin: 4px auto; background: var(--ink); }
.content-area { width: 100%; max-width: 1600px; margin: 0 auto; padding: clamp(22px, 3vw, 42px); flex: 1; }
.app-footer { padding: 20px clamp(22px, 3vw, 42px); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--line); }
.sidebar-backdrop { display: none; }

.page-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-actions h2 { margin-bottom: 4px; }
.action-group { display: flex; flex-wrap: wrap; gap: 9px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(17,39,35,.035); }
.card-header { padding: 20px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-header h2, .card-header h3 { margin-bottom: 3px; }
.card-body { padding: 22px; }
.card-footer { padding: 16px 22px; border-top: 1px solid var(--line); }
.stat-card { position: relative; padding: 22px; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; right: -24px; bottom: -30px; width: 95px; height: 95px; background: var(--primary-soft); border-radius: 50%; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { margin: 7px 0 2px; font-size: 2rem; font-weight: 850; letter-spacing: -.04em; }
.stat-note { color: var(--muted); font-size: .78rem; }
.stat-accent { color: var(--primary); }

.btn { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px; font-size: .86rem; font-weight: 750; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { color: #fff; filter: brightness(.92); }
.btn-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.btn-secondary:hover { color: var(--primary); border-color: var(--primary); }
.btn-danger { color: var(--danger); background: #fff; border-color: #f4c7c3; }
.btn-ghost { color: #c6d9d6; background: transparent; border-color: rgba(255,255,255,.18); }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,.07); }
.btn-lg { min-height: 48px; padding: 11px 18px; }
.btn-sm { min-height: 31px; padding: 5px 10px; font-size: .76rem; border-radius: 8px; }
.btn-block { width: 100%; }
.link-danger { color: var(--danger); }

.alert { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 11px; font-size: .88rem; }
.alert-success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }
.alert-danger { color: #912018; background: #fef3f2; border-color: #fecdca; }
.alert-warning { color: #93370d; background: #fffaeb; border-color: #fedf89; }
.alert-info { color: #175cd3; background: #eff8ff; border-color: #b2ddff; }

.stack-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #344054; font-size: .83rem; font-weight: 720; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #d0d5dd; border-radius: 9px; outline: none; transition: .15s ease; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-span-2 { grid-column: span 2; }
.field-span-3 { grid-column: span 3; }
.form-actions { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.form-note { margin: -5px 0 0; color: var(--muted); font-size: .76rem; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 58px; }
.password-field button { position: absolute; right: 5px; top: 5px; height: 32px; padding: 0 9px; color: var(--primary); border: 0; background: transparent; font-size: .76rem; font-weight: 750; }
.filter-bar { padding: 16px; display: grid; grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(140px, 1fr)) auto; gap: 10px; align-items: end; background: #fff; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.inline-form label { min-width: 140px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .82rem; vertical-align: middle; }
th { color: #475467; background: #f8faf9; font-size: .72rem; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
tbody tr:hover { background: #fbfdfc; }
tbody tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 7px; justify-content: flex-end; white-space: nowrap; }
.table-name { font-weight: 780; color: var(--ink); }
.table-subtext { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding-top: 20px; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 8px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; }
.pagination .active { color: #fff; background: var(--primary); border-color: var(--primary); }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 780; white-space: nowrap; }
.badge-success, .badge-present, .badge-published, .badge-active { color: #05603a; background: #dcfae6; }
.badge-warning, .badge-late, .badge-draft, .badge-high { color: #93370d; background: #fef0c7; }
.badge-danger, .badge-absent, .badge-archived, .badge-urgent { color: #912018; background: #fee4e2; }
.badge-info, .badge-excused, .badge-normal { color: #175cd3; background: #d1e9ff; }
.badge-neutral, .badge-moved, .badge-deceased { color: #344054; background: #eaecf0; }

.bar-list { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 75px 1fr 42px; align-items: center; gap: 10px; font-size: .8rem; }
.bar-track { height: 9px; background: #edf1f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #43a99d); border-radius: inherit; }
.activity-list, .announcement-list { display: grid; }
.list-item { padding: 14px 0; display: flex; gap: 12px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-dot { width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--gold); flex: 0 0 9px; }
.list-item strong { display: block; font-size: .86rem; }
.list-item p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }

.document-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.document-card { padding: 15px; display: flex; align-items: center; gap: 11px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.document-icon { width: 40px; height: 46px; display: grid; place-items: center; color: #175cd3; background: #eff8ff; border-radius: 8px; font-size: .68rem; font-weight: 850; }
.document-card strong, .document-card small { display: block; }
.document-card strong { font-size: .82rem; }
.document-card small { color: var(--muted); font-size: .7rem; }
.document-card a { margin-left: auto; font-size: .76rem; font-weight: 750; }

.profile-hero { display: flex; align-items: center; gap: 18px; }
.profile-photo { width: 90px; height: 90px; border-radius: 18px; object-fit: cover; background: var(--primary-soft); }
.profile-placeholder { display: grid; place-items: center; color: #fff; background: var(--primary); font-size: 2rem; font-weight: 850; }
.profile-meta h2 { margin-bottom: 4px; }
.profile-meta p { margin-bottom: 2px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.detail-item { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.detail-item span { display: block; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .045em; }
.detail-item strong { display: block; margin-top: 3px; font-size: .87rem; overflow-wrap: anywhere; }
.qr-card { text-align: center; }
.qr-card img { width: 190px; height: 190px; image-rendering: pixelated; }
.qr-code-box { min-height: 210px; display: grid; place-items: center; }
.id-card { max-width: 650px; margin: auto; overflow: hidden; border: 2px solid var(--primary); border-radius: 18px; background: #fff; }
.id-card-head { padding: 15px 20px; display: flex; align-items: center; gap: 12px; color: #fff; background: var(--primary); }
.id-card-head img { width: 52px; height: 52px; }
.id-card-head strong, .id-card-head span { display: block; }
.id-card-head span { color: #d5efeb; font-size: .72rem; }
.id-card-body { padding: 20px; display: grid; grid-template-columns: 96px 1fr 130px; gap: 18px; align-items: center; }
.id-card-body .profile-photo { width: 96px; height: 112px; border-radius: 8px; }

.attendance-tools { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f8faf9; border-bottom: 1px solid var(--line); }
.attendance-tools .action-group { justify-content: flex-end; }
.attendance-status { min-width: 108px; }
.report-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.report-type { position: relative; }
.report-type input { position: absolute; opacity: 0; pointer-events: none; }
.report-type span { min-height: 105px; padding: 18px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.report-type span strong { display: block; color: var(--ink); }
.report-type input:checked + span { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }

.auth-page { min-height: 100vh; padding: 34px; display: grid; place-items: center; background: radial-gradient(circle at top left, #d9f1ed, transparent 36%), #eef3f1; }
.auth-card { width: min(960px, 100%); min-height: 590px; display: grid; grid-template-columns: .95fr 1.05fr; overflow: hidden; background: #fff; border-radius: 26px; box-shadow: 0 28px 80px rgba(11,41,39,.18); }
.auth-brand { position: relative; padding: 48px; display: flex; flex-direction: column; justify-content: center; color: #fff; background: linear-gradient(145deg, #0b2927, #0f766e); overflow: hidden; }
.auth-brand::after { content: ''; position: absolute; width: 310px; height: 310px; right: -150px; bottom: -130px; border: 42px solid rgba(255,255,255,.07); border-radius: 50%; }
.auth-brand img { width: 116px; margin-bottom: 25px; filter: drop-shadow(0 8px 18px rgba(0,0,0,.22)); }
.auth-brand .eyebrow { color: #f0cf69; }
.auth-brand h1 { margin: 10px 0 12px; font-size: 2.35rem; }
.auth-brand p { max-width: 360px; color: #c1dcd8; }
.auth-location { position: absolute; left: 48px; bottom: 36px; color: #b0cfca; font-size: .78rem; }
.auth-form-panel { padding: 48px; display: grid; place-items: center; }
.auth-form-wrap { width: min(380px, 100%); }
.auth-form-wrap h2 { margin-bottom: 7px; font-size: 1.65rem; }
.credential-note { margin-top: 22px; padding: 11px 13px; color: #475467; background: #f8faf9; border: 1px dashed #c7d0cd; border-radius: 9px; font-size: .76rem; }
.install-link { text-align: center; margin: 14px 0 0; font-size: .82rem; }

.setup-page { min-height: 100vh; padding: 30px; display: grid; place-items: center; background: linear-gradient(145deg, #e4f3f0, #f7f8f7); }
.setup-card { width: min(600px, 100%); padding: 38px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.setup-logo { width: 100px; margin-bottom: 12px; }
.setup-summary { margin: 22px 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); text-align: left; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.setup-summary div { padding: 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.setup-summary div:nth-child(2n) { border-right: 0; }
.setup-summary div:nth-last-child(-n+2) { border-bottom: 0; }
.setup-summary strong, .setup-summary span { display: block; }
.setup-summary strong { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.setup-summary span { margin-top: 3px; font-size: .87rem; }

@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .document-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.45); }
    .sidebar-open .sidebar-backdrop { display: block; }
    .main-content { margin-left: 0; }
    .menu-button { display: block; }
    .grid-3, .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .filter-bar { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .auth-card { grid-template-columns: 1fr; }
    .auth-brand { min-height: 300px; padding: 34px; }
    .auth-brand img { width: 82px; margin-bottom: 12px; }
    .auth-brand h1 { font-size: 1.8rem; }
    .auth-location { left: 34px; bottom: 20px; }
}

@media (max-width: 650px) {
    .content-area { padding: 20px 14px; }
    .topbar { padding: 13px 14px; min-height: 72px; }
    .topbar p, .topbar-profile { display: none; }
    .page-actions, .app-footer { flex-direction: column; }
    .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3, .detail-grid, .report-type-grid { grid-template-columns: 1fr; }
    .span-2, .field-span-2, .field-span-3 { grid-column: auto; }
    .filter-bar { grid-template-columns: 1fr; }
    .document-grid { grid-template-columns: 1fr; }
    .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
    th, td { padding: 10px; }
    .auth-page { padding: 14px; }
    .auth-brand { display: none; }
    .auth-form-panel { padding: 34px 22px; }
    .auth-card { min-height: 0; }
    .id-card-body { grid-template-columns: 80px 1fr; }
    .id-card-body .qr-mini { grid-column: span 2; }
}

@media print {
    .sidebar, .topbar, .app-footer, .no-print, .sidebar-backdrop { display: none !important; }
    .main-content { margin: 0; }
    .content-area { max-width: none; padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}
