:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #172033;
    --muted: #67728a;
    --line: #e3e8f1;
    --navy: #10192c;
    --blue: #315efb;
    --blue-dark: #2347cf;
    --green: #16845b;
    --orange: #d97706;
    --red: #dc3f4f;
    --shadow: 0 12px 32px rgba(19, 34, 68, .07);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; font-weight: 800; background: linear-gradient(145deg, #3f6cff, #7447e8); box-shadow: 0 8px 22px rgba(49, 94, 251, .35); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { color: #9ba8c1; margin-top: 2px; }
.nav { display: grid; gap: 7px; margin-top: 40px; }
.nav a { color: #aeb8cd; padding: 12px 14px; border-radius: 10px; font-weight: 650; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer span, .sidebar-footer small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer small { margin: 4px 0 14px; color: #98a5bd; }

.main { padding: 34px 42px 56px; min-width: 0; }
.topbar, .page-intro, .panel-heading, .actions, .filter-form, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.topbar { margin-bottom: 30px; }
.topbar h1, .page-intro h2 { margin: 2px 0 0; }
h1 { font-size: 28px; letter-spacing: -.035em; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.015em; }
h3 { margin: 0; }
.eyebrow { margin: 0; color: var(--blue); text-transform: uppercase; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.muted, .page-intro p { color: var(--muted); }
.live-pill { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; }
.live-pill span { width: 8px; height: 8px; border-radius: 50%; background: #22b983; box-shadow: 0 0 0 4px #dff8ef; }
.page-intro { margin-bottom: 22px; }
.page-intro p { margin: 4px 0 0; }

.button { display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.button-primary { background: var(--blue); color: #fff; box-shadow: 0 7px 18px rgba(49,94,251,.2); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { background: #eaf0ff; color: #284ecc; border-color: #d9e2ff; }
.button-ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.sidebar .button-ghost { border-color: rgba(255,255,255,.16); color: #cbd4e5; }
.button-block { width: 100%; }

.alert { padding: 13px 16px; margin: 0 0 20px; border-radius: 10px; border: 1px solid; }
.alert-success { color: #126746; background: #eafaf4; border-color: #bfecdc; }
.alert-error { color: #a32c38; background: #fff0f2; border-color: #f7cdd2; }
.alert ul { margin-bottom: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { position: relative; overflow: hidden; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--blue); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 5px; font-size: 30px; }
.stat-card small { font-size: 12px; }
.accent-green::before { background: var(--green); }.accent-orange::before { background: var(--orange); }.accent-red::before { background: var(--red); }

.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.panel-wide { grid-column: 1 / -1; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.panel-heading { margin-bottom: 18px; }
.panel-heading h2 { margin-top: 3px; }
.attendance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.person-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface-soft); }
.person-row small, table small { display: block; margin-top: 3px; color: var(--muted); }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--blue); background: #eaf0ff; font-weight: 800; }
.avatar-muted { color: var(--muted); background: #ebeff5; }
.badge { display: inline-flex; width: fit-content; padding: 5px 8px; border-radius: 999px; background: #edf1f7; color: #59657a; font-size: 11px; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.badge-success { background: #dff7ee; color: #137250; }.badge-danger { background: #fee8eb; color: #bc3341; }.badge-warning { background: #fff3d8; color: #98620a; }.badge-muted { color: #697386; }
.list-stack { display: grid; gap: 10px; }
.list-item { position: relative; padding: 13px 88px 13px 14px; border: 1px solid var(--line); border-radius: 10px; }
.list-item p { margin: 5px 0 0; color: var(--muted); }
.list-item .badge { position: absolute; right: 12px; top: 12px; }
.list-item.warning { padding-right: 14px; border-color: #f6ddb0; background: #fffbf1; }
.empty-state { padding: 22px; color: var(--muted); text-align: center; border: 1px dashed #d8dfeb; border-radius: 10px; }

.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
td { font-size: 14px; }
.table-action { text-align: right; font-weight: 750; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.pagination { display: flex; justify-content: space-between; padding: 15px 18px; color: var(--muted); font-size: 13px; }

.form-panel { max-width: 850px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-stack { display: grid; gap: 17px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #414c61; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #ccd5e3; border-radius: 9px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,94,251,.1); }
.field-span-2 { grid-column: span 2; }
.toggle-row { display: flex; align-items: flex-start; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.toggle-row input, .check-row input { width: 17px; min-height: 17px; margin-top: 2px; }
.toggle-row strong, .toggle-row small { display: block; }.toggle-row small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 9px; }
.form-actions { justify-content: flex-end; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line); }
.filter-panel { margin-bottom: 18px; }
.filter-form { justify-content: flex-start; align-items: end; flex-wrap: wrap; }
.filter-form label { min-width: 200px; }

.report-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; margin-bottom: 20px; }
.raw-report { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.72; font: 14px/1.7 Inter, ui-sans-serif, sans-serif; }
.report-side { display: grid; gap: 20px; align-content: start; }
.meta-list { margin: 0; }.meta-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }.meta-list div:last-child { border: 0; }.meta-list dt { color: var(--muted); }.meta-list dd { margin: 0; text-align: right; font-weight: 700; }
.project-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.project-card { padding: 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.project-card > div:first-child { display: flex; justify-content: space-between; gap: 12px; }
.project-card ul, .detail-list { margin: 14px 0 0; padding-left: 19px; line-height: 1.6; }.project-card p { line-height: 1.6; color: #445067; }
.pre-line { white-space: pre-line; }.link-list { display: flex; gap: 10px; margin-top: 12px; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, #e5ebff, transparent 35%), radial-gradient(circle at 90% 90%, #e9ddff, transparent 34%), var(--bg); }
.auth-card { width: min(440px, 100%); padding: 38px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 70px rgba(27,41,75,.13); }
.auth-brand { margin-bottom: 42px; }.auth-card h1 { margin: 8px 0 7px; font-size: 32px; }.auth-card .muted { line-height: 1.6; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .three-columns { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 17px; }
    .sidebar .brand, .sidebar-footer { display: none; }
    .nav { margin: 0; grid-template-columns: repeat(3, 1fr); }.nav a { text-align: center; padding: 10px 7px; font-size: 13px; }
    .main { padding: 24px 16px 40px; }
    .topbar, .page-intro { align-items: flex-start; }.topbar h1 { font-size: 24px; }.live-pill { display: none; }
    .page-intro, .actions { flex-wrap: wrap; }
    .stats-grid, .content-grid, .attendance-grid, .form-grid, .report-grid, .project-cards { grid-template-columns: 1fr; }
    .field-span-2, .panel-wide { grid-column: auto; }
    .panel { padding: 17px; }
    .actions form, .actions .button, .actions button { width: 100%; }
    .auth-card { padding: 28px 22px; }
}
