:root {
    --ink: #1a2b3c;
    --muted: #687786;
    --line: #dbe1e6;
    --soft: #f3f5f6;
    --paper: #ffffff;
    --accent: #b8d548;
    --danger: #a33a3a;
    --shadow: 0 12px 32px rgba(26, 43, 60, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }

.public-page { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--paper); }
.public-header, .public-footer { width: min(1120px, calc(100% - 40px)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.public-header { padding: 28px 0; border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-size: 1.15rem; font-weight: 750; letter-spacing: -.02em; text-decoration: none; }
.quiet-link { color: var(--muted); font-size: .9rem; text-decoration: none; }
.public-main { width: min(880px, calc(100% - 40px)); margin: auto; padding: 80px 0; }
.eyebrow { margin: 0 0 14px; color: var(--muted); font-size: .75rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.public-main h1 { max-width: 780px; margin: 0; font-size: clamp(2.8rem, 8vw, 6.6rem); line-height: .96; letter-spacing: -.065em; }
.public-intro { max-width: 570px; margin: 30px 0 42px; color: var(--muted); font-size: 1.08rem; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.contact-card { display: flex; min-height: 128px; padding: 24px; border: 1px solid var(--line); border-radius: 10px; flex-direction: column; justify-content: space-between; text-decoration: none; transition: border-color .15s, transform .15s; }
.contact-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.contact-card span { color: var(--muted); font-size: .84rem; }
.contact-card strong { font-size: clamp(1rem, 2.8vw, 1.35rem); font-weight: 650; overflow-wrap: anywhere; }
.public-footer { padding: 22px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.public-footer a { color: var(--muted); }

.admin-body { min-height: 100vh; }
.admin-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.admin-header-inner { width: min(1320px, calc(100% - 32px)); margin: 0 auto; display: flex; min-height: 64px; align-items: center; gap: 26px; }
.admin-nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.admin-nav a { padding: 8px 10px; border-radius: 6px; color: var(--muted); font-size: .88rem; text-decoration: none; }
.admin-nav a:hover, .admin-nav a.active { color: var(--ink); background: var(--soft); }
.admin-account { display: flex; gap: 12px; color: var(--muted); font-size: .82rem; }
.admin-main { width: min(1320px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 5px; font-size: clamp(1.65rem, 4vw, 2.35rem); letter-spacing: -.04em; }
.page-head p { margin: 0; color: var(--muted); }
.button { display: inline-flex; min-height: 40px; padding: 8px 14px; border: 1px solid var(--ink); border-radius: 7px; align-items: center; justify-content: center; gap: 7px; color: var(--paper); background: var(--ink); font-weight: 650; font-size: .9rem; text-decoration: none; }
.button:hover { opacity: .9; }
.button.secondary { color: var(--ink); background: var(--paper); border-color: var(--line); }
.button.danger { color: var(--danger); background: var(--paper); border-color: #e7caca; }
.button.small { min-height: 32px; padding: 5px 9px; font-size: .8rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.stat strong { display: block; font-size: 1.6rem; line-height: 1; }
.stat span { display: block; margin-top: 7px; color: var(--muted); font-size: .78rem; }

.panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; padding: 16px 18px; border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; gap: 16px; }
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-body { padding: 20px; }
.panel-body > form { display: grid; gap: 14px; }
.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)); gap: 10px; }
.field { display: grid; gap: 6px; }
.field label, .label { color: var(--muted); font-size: .76rem; font-weight: 700; }
.field input, .field select, .field textarea, .filters input, .filters select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--paper); outline: none; }
.field textarea { min-height: 98px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(26,43,60,.08); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field.wide { grid-column: 1 / -1; }
.check-list { display: flex; flex-wrap: wrap; gap: 9px 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: .9rem; }
.check input { width: 17px; height: 17px; margin: 0; }
.form-actions { display: flex; margin-top: 22px; align-items: center; justify-content: space-between; gap: 12px; }
.action-group { display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: #fafbfb; font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }
td { font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.table-name { font-weight: 700; text-decoration: none; }
.table-note { max-width: 340px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; margin: 1px 3px 1px 0; padding: 3px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: .72rem; white-space: nowrap; }
.badge.grant { color: #6b5200; background: #fff2c7; }
.badge.action { color: #1e5a2d; background: #dff2e2; }
.priority { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; background: var(--ink); color: white; font-size: .75rem; font-weight: 750; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.flash { margin-bottom: 18px; padding: 12px 15px; border: 1px solid #b8d8bd; border-radius: 8px; color: #23572b; background: #edf8ef; }
.flash.error { border-color: #e4baba; color: #7e2c2c; background: #fff1f1; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 18px; align-items: start; }
.timeline { display: grid; gap: 14px; }
.timeline-item { padding-left: 15px; border-left: 2px solid var(--line); }
.timeline-meta { margin-bottom: 3px; color: var(--muted); font-size: .76rem; }
.timeline-item p { margin: 0; }
.next-action { margin-top: 8px; padding: 9px 11px; border-radius: 7px; background: var(--soft); font-size: .84rem; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-card { width: min(420px, 100%); padding: 30px; border-radius: 12px; background: var(--paper); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.login-card h1 { margin: 8px 0; letter-spacing: -.04em; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card .button { width: 100%; margin-top: 16px; }
.hidden { display: none !important; }

@media (max-width: 920px) {
    .admin-header-inner { align-items: flex-start; flex-wrap: wrap; gap: 8px; padding: 13px 0; }
    .admin-nav { order: 3; width: 100%; overflow-x: auto; }
    .admin-account { margin-left: auto; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .filters, .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .field.wide { grid-column: auto; }
}

@media (max-width: 620px) {
    .public-header, .public-footer, .public-main, .admin-header-inner, .admin-main { width: min(100% - 24px, 1320px); }
    .public-main { padding: 54px 0; }
    .contact-grid { grid-template-columns: 1fr; }
    .public-footer, .page-head, .form-actions { align-items: flex-start; flex-direction: column; }
    .stats { grid-template-columns: 1fr 1fr; }
    .page-head .button { width: 100%; }
}
