:root {
    --bg: #f5f7fb; --surface: #fff; --text: #495057; --head: #212529; --muted: #8a94a6; --line: #e9ecef;
    --brand: #3b7ddd; --brand-dark: #2f6bc4; --brand-soft: #e7effb;
    --side: #222e3c; --side-dark: #1b2430; --side-text: #a5b0c0; --side-active: #2b3947;
    --ok: #1cbb8c; --warn: #fcb92c; --bad: #dc3545;
    --radius: 6px; --shadow: 0 1px 2px rgba(20, 30, 50, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 Poppins, "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { color: var(--head); font-weight: 600; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; }
.muted-copy, .lead { color: var(--muted); margin: 0 0 1.25rem; }

/* Shell */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.app-anon { grid-template-columns: 1fr; }
.sidebar { background: var(--side); color: var(--side-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 0 0 1.5rem; scrollbar-width: thin; scrollbar-color: #3a4a5c transparent; }
.logo { display: flex; align-items: center; gap: .7rem; color: #fff; font-weight: 600; font-size: 1.15rem; padding: 1.25rem 1.4rem; }
.logo-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 700; }
.nav-group { text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; color: #6f7d90; padding: 1.1rem 1.4rem .4rem; }
.side-nav a { display: block; padding: .6rem 1.4rem; color: var(--side-text); font-weight: 400; border-left: 3px solid transparent; transition: background .15s, color .15s; }
.side-nav a:hover { color: #fff; background: var(--side-dark); }
.side-nav a.active { color: #fff; background: var(--side-active); border-left-color: var(--brand); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.5rem; background: #fff; box-shadow: 0 0 2rem rgba(33, 37, 41, .06); position: sticky; top: 0; z-index: 5; }
.page-title { margin: 0; font-size: 1.05rem; flex: 1; font-weight: 600; }
.top-actions form { display: flex; align-items: center; gap: .6rem; margin: 0; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 600; }
.user-name { font-weight: 500; color: var(--head); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; background: #fff; color: var(--head); border: 1px solid var(--line); border-radius: var(--radius); font-size: 1.2rem; padding: .25rem .6rem; cursor: pointer; }
.scrim { display: none; }
.page-shell { padding: 1.75rem 1.75rem 3rem; max-width: 1500px; width: 100%; margin: 0 auto; }

/* Cards */
.card, .hero-copy, .hero-panel, .error-shell { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; overflow-x: auto; }
.hero-shell { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1.5rem; }
.hero-shell > * { margin-bottom: 0; }
.hero-copy h1 { font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.15; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; color: var(--brand); font-size: .72rem; font-weight: 600; margin: 0 0 .5rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.metric, .status-card { padding: 1rem; border-radius: var(--radius); background: var(--bg); }
.metric span, .status-label { display: block; color: var(--muted); font-size: .8rem; }
.metric strong { font-size: 1.5rem; color: var(--head); }
.hero-panel { display: flex; flex-direction: column; gap: 1rem; }
.status-card { display: flex; align-items: center; gap: .8rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 5px rgba(28, 187, 140, .18); }
.dashboard-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.dashboard-links a { padding: .65rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); transition: all .15s; }
.dashboard-links a:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.dashboard-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.dashboard-sections .card { margin: 0; }

/* Buttons */
button, .btn { font: inherit; font-weight: 500; cursor: pointer; border: 1px solid var(--brand); border-radius: 4px; padding: .5rem 1.1rem; background: var(--brand); color: #fff; transition: background .15s; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #fff; color: var(--head); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg); }
.signout { background: #fff !important; color: var(--head) !important; border: 1px solid var(--line) !important; padding: .35rem .85rem !important; }
.signout:hover { background: var(--bg) !important; }

/* Forms */
label { display: flex; flex-direction: column; gap: .35rem; margin: 0; font-weight: 500; font-size: .82rem; color: var(--head); }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; padding: .45rem .8rem; font: inherit; color: var(--text); background: #fff; border: 1px solid #ced4da; border-radius: 4px; transition: border-color .15s, box-shadow .15s; }
input:not([type=checkbox]):not([type=radio]), select { height: 38px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #9fbeed; box-shadow: 0 0 0 3px rgba(59, 125, 221, .15); }
input[type=checkbox], input[type=radio] { width: 1rem; height: 1rem; accent-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
main form[method=get] { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
main form[method=get] > input:not([type=checkbox]), main form[method=get] > select { flex: 1 1 220px; width: auto; }
main form[method=post] { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.25rem; align-items: start; }
main form[method=post] > button, main form[method=post] > table, main form[method=post] > h2, main form[method=post] > h3, main form[method=post] > p, main form[method=post] > div.full { grid-column: 1 / -1; }
main form[method=post] > button { justify-self: start; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
fieldset { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: .1rem .5rem; align-content: start; margin: 0; min-width: 0; max-height: 300px; overflow-y: auto; padding: .5rem 1rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fafbfd; }
fieldset > legend { padding: 0 .5rem; font-weight: 600; color: var(--head); }
fieldset > label { flex-direction: row; align-items: center; gap: .5rem; padding: .3rem .5rem; border-radius: 4px; font-size: .84rem; font-weight: 400; color: var(--text); cursor: pointer; }
fieldset > label:hover { background: var(--brand-soft); }
.text-danger, .field-validation-error { color: var(--bad); font-size: .8rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-weight: 600; color: var(--head); padding: .7rem .9rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: #f8fafd; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
    .menu-btn { display: inline-block; }
    .hero-shell { grid-template-columns: 1fr; }
    .user-name { display: none; }
    .page-shell { padding: 1rem; }
}

/* Filter forms */
main form[method=get] { align-items: flex-start; }
main form[method=get] > .dashboard-links { flex: 1 1 100%; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; align-items: start; }
main form[method=get] > .dashboard-links > label { border: 0; padding: 0; }
label > select, label > input { flex: 0 0 auto; }
select[multiple] { height: 120px !important; padding: .3rem; }
select[multiple] option { padding: .25rem .5rem; border-radius: 3px; }
main form[method=get] > button { flex: 0 0 auto; width: auto; align-self: flex-start; }