:root {
    color-scheme: light;
    --ink: #15243b;
    --muted: #4f6179;
    --line: #dce5f0;
    --paper: #f3f6fb;
    --white: #fff;
    --navy: #12223e;
    --navy-soft: #223757;
    --accent: #1e51cc;
    --accent-dark: #183fa1;
    --soft-blue: #edf3ff;
    --focus: #3d74f3;
    --radius: .85rem;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 system-ui, sans-serif; }
a { color: var(--accent); text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
input, select, textarea, button { font: inherit; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.65rem); line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 1.22rem; line-height: 1.3; }
h3 { font-size: 1.02rem; }
small, .muted, .intro, .field-help { color: var(--muted); }
.intro { max-width: 64ch; }
.field-help { font-size: .9rem; }
.eyebrow { color: var(--accent); font-size: .78rem; font-weight: 750; letter-spacing: .06em; }
.skip-link { position: fixed; inset: .65rem auto auto .65rem; background: var(--white); padding: .75rem; border-radius: .45rem; z-index: 5; }
.skip-link:not(:focus) { clip-path: inset(50%); }

.app-shell { display: grid; grid-template-columns: 14.75rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2rem; padding: 1.45rem 1rem 1rem; background: var(--navy); color: var(--white); }
.brand { display: inline-flex; align-items: center; gap: .7rem; padding: .3rem; color: inherit; font-size: 1.38rem; line-height: 1.1; font-weight: 800; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: 0 0 2.55rem; width: 2.55rem; height: 2.55rem; border-radius: .72rem; background: #3975f6; color: var(--white); }
.brand small { display: block; margin-top: .28rem; color: #c0cfe6; font-size: .75rem; font-weight: 500; }
.app-nav { display: grid; gap: .32rem; }
.app-nav a { display: flex; align-items: center; min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid transparent; border-radius: .55rem; color: #dbe7f9; text-decoration: none; font-weight: 600; }
.app-nav a:hover { background: var(--navy-soft); }
.app-nav a[aria-current="page"] { color: var(--white); background: var(--navy-soft); border-color: #405b8d; }
.sidebar-foot { display: grid; gap: .65rem; margin-top: auto; }
.sidebar-status { display: flex; align-items: center; gap: .5rem; padding: .65rem .7rem; border: 1px solid #405275; border-radius: .55rem; color: #dbe7f9; font-size: .78rem; }
.status-dot { flex: 0 0 .5rem; height: .5rem; border-radius: 50%; background: #f7c977; }
.status-on { background: #77dda6; }
.sidebar-logout { width: 100%; color: #e6efff; background: transparent; border-color: #405275; }
.sidebar-logout:hover { background: var(--navy-soft); }
.workspace { display: grid; align-content: start; gap: 1.25rem; min-width: 0; width: min(100%, 82rem); margin: 0 auto; padding: clamp(1rem, 3.4vw, 3rem); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.15rem; }
.login-frame { width: min(100%, 55rem); display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 1.1rem; overflow: hidden; background: var(--white); }
.login-story, .login-panel { padding: clamp(1.4rem, 5vw, 3.25rem); }
.login-story { display: grid; gap: 3rem; align-content: space-between; background: var(--navy); color: var(--white); }
.login-story .eyebrow { color: #aac6ff; margin-bottom: .55rem; }
.login-story h2 { margin-bottom: .6rem; font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
.login-story p:not(.eyebrow) { color: #d3e0f5; }
.login-panel { display: grid; gap: .9rem; align-content: center; }
.login-panel form { margin-top: .4rem; }
.login-panel button { width: 100%; }

.section-heading, .section-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.section-heading > div { display: grid; gap: .45rem; min-width: 0; }
.section-header h2 { margin: 0; }
.section-header > div { display: grid; gap: .22rem; }
.page-heading { display: grid; gap: .5rem; }
.card { min-width: 0; padding: clamp(.95rem, 2vw, 1.3rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); overflow-wrap: anywhere; }
.card > h2 + form { margin-top: .8rem; }
.stack, .list { display: grid; gap: .8rem; min-width: 0; }
.row, .actions, .card-meta { display: flex; align-items: center; gap: .55rem .85rem; flex-wrap: wrap; min-width: 0; }
.row { justify-content: space-between; }
.card-meta { color: var(--muted); font-size: .9rem; }
.grid, .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .8rem; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 1rem; }
.dashboard-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card, .metric-value, .metric-label { margin: 0; }
.metric-card { display: grid; gap: .4rem; }
.metric-card dt, .metric-label { color: var(--muted); font-size: .88rem; font-weight: 600; }
.dashboard-metrics dd, .metrics strong, .metric-value { display: block; font-size: 1.65rem; font-weight: 780; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-card a { font-size: .88rem; }
.queue-number { font-size: 2rem; line-height: 1.1; }
.data-list, .workflow { list-style: none; padding: 0; margin: 0; }
.data-row { padding: .8rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.data-row:last-child { padding-bottom: 0; }
.data-row .text-error { margin-top: .25rem; font-size: .9rem; }
.workflow { display: grid; gap: .6rem; }
.workflow li { position: relative; padding: .6rem .75rem .6rem 2.9rem; border: 1px solid var(--line); border-radius: .6rem; }
.workflow .workflow-number { position: absolute; top: .68rem; left: .7rem; display: grid; place-items: center; width: 1.55rem; height: 1.55rem; border-radius: 50%; background: var(--soft-blue); color: var(--accent); font-weight: 750; }
.workflow a { font-weight: 700; }
.workflow span { display: block; color: var(--muted); font-size: .88rem; }
.empty-state { display: grid; gap: .55rem; padding: .9rem; border: 1px dashed #aebed4; border-radius: .65rem; background: var(--paper); color: var(--muted); }

label { display: grid; gap: .3rem; font-weight: 640; min-width: 0; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; }
input[type=checkbox] { accent-color: var(--accent); }
input:not([type=checkbox]), select, textarea { width: 100%; min-width: 0; min-height: 2.75rem; padding: .5rem .68rem; border: 1px solid #a8b8ce; border-radius: .48rem; background: var(--white); color: var(--ink); }
textarea { min-height: 7rem; resize: vertical; }
button, .button-link { justify-self: start; display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .52rem .86rem; border: 1px solid var(--accent); border-radius: .5rem; background: var(--accent); color: var(--white); font-weight: 690; text-decoration: none; cursor: pointer; }
button:hover, .button-link:hover { background: var(--accent-dark); }
button.secondary, .button-link.secondary { background: var(--white); color: var(--accent); border-color: #b6c8ee; }
button.secondary:hover, .button-link.secondary:hover { background: var(--soft-blue); }
.small-button { font-size: .88rem; }
button:disabled { color: var(--muted); background: var(--paper); border-color: var(--line); cursor: default; }
.badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 1rem; padding: .16rem .66rem; background: #eaf0f8; color: #3b4d69; font-size: .82rem; font-weight: 670; }
.badge-done, .badge-positive { color: #0d5c42; background: #e0f4e9; }
.badge-queued, .badge-warning { color: #76410e; background: #fef3d7; }
.badge-running { color: #1e3a8a; background: #dbeafe; }
.badge-failed, .badge-danger { color: #991b1b; background: #fee2e2; }
.badge-neutral { color: #3b4d69; background: #eaf0f8; }
.notice { padding: .75rem 1rem; border: 1px solid var(--line); border-left: .25rem solid var(--accent); border-radius: .45rem; background: var(--soft-blue); }
.notice-success { background: #e8f7ee; border-left-color: #178456; color: #14513d; }
.notice-error { background: #fff0ef; border-left-color: #bf342d; color: #852323; }
.notice-warning { background: #fff6e3; border-left-color: #b47119; color: #704210; }
.text-error { color: #982621; }
.message { white-space: pre-wrap; }
summary { cursor: pointer; min-height: 2.75rem; padding: .6rem 0; font-weight: 650; color: var(--accent); }
.section-nav, .contact-pagination, .contact-meta, .contact-sources, .contact-enrollments { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem .95rem; }
.section-nav a, .contact-pagination a { display: inline-flex; align-items: center; min-height: 2.75rem; }
.form-details, .contact-advanced, .contact-review { min-width: 0; }
.contact-review[open] > summary, .form-details[open] > summary { margin-bottom: .55rem; }
.contact-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.contact-metric { display: grid; gap: .25rem; text-decoration: none; color: var(--ink); }
.contact-metric[aria-current="page"], .contact-metric:hover { background: var(--soft-blue); border-color: #a4bbed; }
.contact-meta, .contact-enrollments { color: var(--muted); font-size: .88rem; }

@media (max-width: 67rem) {
    .dashboard-metrics, .contact-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 56rem) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .65rem 1rem; }
    .app-nav { order: 3; display: flex; flex-wrap: wrap; width: 100%; gap: .25rem; }
    .app-nav a { padding-inline: .6rem; font-size: .88rem; }
    .sidebar-foot { display: flex; align-items: center; margin: 0 0 0 auto; }
    .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 34rem) {
    .login-frame { grid-template-columns: minmax(0, 1fr); }
    .login-story { gap: 1.05rem; }
    .sidebar-status { display: none; }
    .app-nav { column-gap: .14rem; }
    .workspace { gap: 1rem; }
    .section-heading { align-items: start; }
}
