:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-alt: #eef1f5;
    --text: #1b2330;
    --muted: #5f6b7a;
    --border: #dde2e9;
    --primary: #1f4e79;
    --primary-hover: #173c5e;
    --primary-soft: #e6eef6;
    --ok: #1e7a4c;
    --ok-soft: #e3f3ea;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1.5em; }
p { margin: 0 0 1em; }
code { background: var(--surface-alt); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.plain { list-style: none; margin: 0; padding: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.narrow { width: 100%; max-width: 400px; padding: 32px 28px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: .6em 1.1em; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: .35em .75em; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Forms */
.stack > * + * { margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
.field > span { color: var(--text); }
input, select, textarea { width: 100%; font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .55em .75em; min-height: 42px; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--primary); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: .5em; font-size: .95rem; }
.field-error { color: var(--danger); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.inline-form input { flex: 1 1 240px; width: auto; }
.input-row { display: flex; gap: 8px; }
.search { max-width: 260px; }

@media (max-width: 680px) {
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .form-actions .btn { width: 100%; }
}

/* Flash messages */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #b7e0c8; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c2bd; }

/* Badges */
.badge { display: inline-block; padding: .15em .6em; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-muted { background: var(--surface-alt); color: var(--muted); }
.count { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: center; vertical-align: middle; }

/* Center pages (login / error) */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.brand-mark { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); margin: 0 0 8px; }
.error-card { text-align: center; }
.install-card { width: 100%; max-width: 520px; padding: 32px 28px; }
.checks { list-style: none; margin: 0 0 24px; padding: 0; border: 1px solid var(--border); border-radius: 8px; }
.checks li { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.checks li:last-child { border-bottom: 0; }
.check-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: #fff; }
.check-ok .check-icon { background: var(--ok); }
.check-fail .check-icon { background: var(--danger); }
.check-warn .check-icon { background: #b54708; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--border); margin: 0; }

/* ---------- Public page ---------- */
.site-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.site-title { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; }
.site-nav a:hover { background: var(--surface-alt); color: var(--text); }

.hero { background: linear-gradient(180deg, var(--primary-soft), var(--bg)); padding: 56px 0 32px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); max-width: 22ch; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 65ch; }

.section { padding: 40px 0; }
.section-alt { background: var(--surface-alt); }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.details { margin: 0; padding: 8px 24px; }
.details > div { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.details > div:last-child { border-bottom: 0; }
.details dt { color: var(--muted); font-size: .92rem; }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 520px) { .details > div { grid-template-columns: 1fr; gap: 2px; } }

.contact { padding: 20px 24px; }
.contact h3 { margin-top: 0; }
.contact li { display: flex; flex-direction: column; padding: 8px 0; overflow-wrap: anywhere; }
.contact li .muted { font-size: .82rem; }

.members { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.member { padding: 18px 20px; }
.member p { margin: 0; }
.member-name { font-weight: 700; font-size: 1.05rem; }
.member-position { color: var(--primary); font-weight: 600; margin-bottom: 6px !important; }

.year-group + .year-group { margin-top: 28px; }
.year-group h3 { margin-top: 0; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.doc { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.doc:hover { border-color: var(--primary); box-shadow: var(--shadow); color: var(--text); }
.doc-ext { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: .72rem; font-weight: 800; }
.doc-body { display: flex; flex-direction: column; min-width: 0; }
.doc-title { font-weight: 600; overflow-wrap: anywhere; }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0; font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Admin ---------- */
.admin-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.admin-header .brand-mark { margin: 0 8px 0 0; }
.admin-company { font-size: 1rem; }
.brand-link { color: var(--text); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover, .tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.admin-main { padding-top: 24px; padding-bottom: 64px; }
.panel { padding: 24px; margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h1, .panel-head h2 { margin: 0; }
.danger-zone { border-color: #f5c2bd; }

.table-wrap { overflow-x: auto; margin: 0 -24px 8px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover td { background: #fafbfc; }
.edit-row td { background: var(--surface-alt) !important; padding: 16px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline-block; margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-actions { display: flex; gap: 4px; }
.list-actions form { margin: 0; }

.upload-box { margin-bottom: 24px; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--bg); text-align: center; cursor: pointer; margin-bottom: 16px; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.dropzone-file { font-weight: 600; color: var(--primary); overflow-wrap: anywhere; }
