:root {
  --ink: #17111b;
  --muted: #6f6873;
  --paper: #fbf9f5;
  --white: #fff;
  --purple: #38164d;
  --purple-2: #5a2475;
  --gold: #cba84d;
  --gold-soft: #f2e6bd;
  --line: #e3ddd3;
  --green: #146b4c;
  --red: #a13737;
  --shadow: 0 18px 50px rgba(24, 12, 30, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }

.county-bar { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem clamp(1rem, 4vw, 4rem); color: #f7efd3; background: #1d1022; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; }
.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 82px; padding: .7rem clamp(1rem, 4vw, 4rem); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand img { width: 60px; height: 60px; object-fit: contain; }
.brand span { display: grid; }
.brand b { color: var(--purple); font-family: Georgia, serif; font-size: 1.35rem; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.site-header nav { display: flex; align-items: center; gap: 1.2rem; }
.site-header nav a { color: #382f3a; font-size: .92rem; font-weight: 700; text-decoration: none; }
.site-header nav a:hover { color: var(--purple-2); }
.site-header .nav-signin { padding: .72rem 1rem; color: var(--white); background: var(--purple); border-radius: 999px; }
.menu-toggle { display: none; border: 1px solid var(--line); border-radius: .6rem; background: #fff; padding: .55rem .8rem; }

.wrap { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }
.narrow { width: min(760px, calc(100% - 2rem)); margin-inline: auto; }
.section { padding: clamp(3rem, 7vw, 6.5rem) 0; }
.section.alt { background: #f1ece4; }
.eyebrow { margin: 0 0 .75rem; color: var(--purple-2); font-size: .76rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.05; }
h1 { margin: 0; font-size: clamp(2.6rem, 7vw, 6rem); }
h2 { margin: 0 0 1rem; font-size: clamp(2rem, 4vw, 3.4rem); }
h3 { margin: 0 0 .6rem; font-size: 1.4rem; }
p { line-height: 1.7; }
.lede { max-width: 720px; color: #4f4651; font-size: clamp(1rem, 2vw, 1.2rem); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.section-head > div { max-width: 720px; }

.hero { position: relative; min-height: 690px; display: grid; align-items: center; overflow: hidden; color: #fff; background: radial-gradient(circle at 70% 25%, #733b88 0, #33143f 35%, #180d20 80%); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(18,8,22,.95) 0%, rgba(18,8,22,.7) 50%, rgba(18,8,22,.12) 100%); }
.hero .hero-seal { position: absolute; right: clamp(-90px, 2vw, 4rem); bottom: -16%; width: min(58vw, 760px); opacity: .78; filter: drop-shadow(0 30px 50px rgba(0,0,0,.35)); }
.hero-content { position: relative; z-index: 2; width: min(1180px, calc(100% - 2rem)); margin: auto; padding: 6rem 0; }
.hero h1 span { display: block; color: #f3d77f; }
.hero .lede { color: #eee3f0; }
.actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.7rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .75rem 1.1rem; border: 1px solid transparent; border-radius: .55rem; color: #fff; background: var(--purple); font-weight: 800; text-decoration: none; }
.button:hover { background: var(--purple-2); }
.button.gold { color: #221424; background: var(--gold); }
.button.outline { color: var(--purple); border-color: var(--purple); background: transparent; }
.button.light { color: #fff; border-color: rgba(255,255,255,.65); background: rgba(255,255,255,.07); }
.button.danger { background: var(--red); }
.button.small { min-height: 36px; padding: .45rem .75rem; font-size: .85rem; }

.stat-row { position: relative; z-index: 3; margin-top: -48px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 1.5rem; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat b { display: block; color: var(--purple); font-family: Georgia, serif; font-size: 1.75rem; }
.stat span { color: var(--muted); font-size: .86rem; }

.grid { display: grid; gap: 1.2rem; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: .9rem; box-shadow: 0 8px 30px rgba(24,12,30,.05); }
.card p { color: var(--muted); }
.department-card { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 1rem; min-height: 180px; }
.department-card img { width: 110px; height: 110px; object-fit: contain; }
.department-card a, .app-card a { color: var(--purple-2); font-weight: 800; }
.app-card { display: flex; flex-direction: column; }
.app-card .tag { align-self: start; margin-bottom: 1rem; }
.app-card .button { margin-top: auto; align-self: start; }
.tag, .status { display: inline-flex; align-items: center; padding: .28rem .55rem; border-radius: 999px; background: var(--gold-soft); color: #5b4614; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.status.active, .status.approved, .status.completed, .status.verified, .status.registered { color: #0e5a3e; background: #d8f0e4; }
.status.denied, .status.failed, .status.suspended, .status.revoked { color: #8d2828; background: #f4dddd; }
.status.submitted, .status.queued, .status.pending, .status.under_review { color: #70540c; background: #f6e9b9; }

.page-hero { padding: clamp(3rem, 8vw, 6rem) 0; color: #fff; background: linear-gradient(120deg, #1d0e24, #4b1e60); }
.page-hero h1 { font-size: clamp(2.5rem, 6vw, 5rem); }
.page-hero .lede { color: #e9dfea; }

.form-shell { padding: 1.5rem; background: #fff; border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
form { margin: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: .4rem; }
.field.full { grid-column: 1 / -1; }
label { font-size: .86rem; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 46px; padding: .7rem .8rem; color: var(--ink); background: #fff; border: 1px solid #cfc7cf; border-radius: .5rem; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(90,36,117,.15); border-color: var(--purple-2); }
.help, .muted { color: var(--muted); font-size: .85rem; }
.error-text { color: var(--red); font-size: .85rem; }
.flash { width: min(1180px, calc(100% - 2rem)); margin: 1rem auto; padding: .85rem 1rem; border-radius: .55rem; background: #e8edf4; }
.flash.success { color: #0e5a3e; background: #d8f0e4; }
.flash.error { color: #8d2828; background: #f4dddd; }

.portal-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; align-items: start; padding: 2rem 0 5rem; }
.portal-nav { position: sticky; top: 105px; display: grid; gap: .25rem; padding: .8rem; background: #211028; border-radius: .8rem; }
.portal-nav b { padding: .65rem .7rem; color: #f1d986; font-family: Georgia, serif; font-size: 1.1rem; }
.portal-nav a { padding: .65rem .7rem; color: #e8dfea; border-radius: .4rem; text-decoration: none; }
.portal-nav a:hover, .portal-nav a.active { color: #25142b; background: #f1d986; }
.portal-main > h1 { font-size: clamp(2.2rem, 5vw, 4rem); }
.portal-main .section-head { margin-top: 2rem; }
.record { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.record:last-child { border-bottom: 0; }
.record h3 { font-family: inherit; font-size: 1rem; }
.record p { margin: .25rem 0; }
.record-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.empty { padding: 2rem; color: var(--muted); text-align: center; border: 1px dashed #cfc7cf; border-radius: .7rem; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: .8rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--purple); background: #f5f0f6; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.review-note { white-space: pre-wrap; }
.public-copy { color: #403743; font-size: 1.06rem; }
.public-copy p { margin: 0 0 1.25rem; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.media-card { min-width: 0; }
.media-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; padding: .5rem; background: #eee8ef; border-radius: .55rem; }
.media-card code { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: .72rem; }

.join-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.5rem; }
.join-step { padding: .8rem; color: var(--muted); background: #eee8ef; border-radius: .55rem; font-size: .82rem; font-weight: 800; }
.join-step.active { color: #fff; background: var(--purple); }
.join-panel[hidden] { display: none; }
.code-display { padding: 1rem; color: var(--purple); background: #f3ebf5; border: 1px dashed var(--purple-2); border-radius: .6rem; font: 700 1.2rem ui-monospace, monospace; text-align: center; letter-spacing: .15em; }

.cta { display: grid; grid-template-columns: 1.5fr 1fr; gap: 2rem; align-items: center; padding: clamp(2rem, 5vw, 4rem); color: #fff; background: linear-gradient(130deg, #24102b, #5a2475); border-radius: 1.2rem; }
.cta img { max-height: 260px; margin: auto; object-fit: contain; }

.site-footer { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; padding: 3rem clamp(1rem, 4vw, 4rem); color: #dcd2de; background: #160c1a; }
.site-footer > div:not(.footer-brand) { display: grid; align-content: start; gap: .45rem; }
.site-footer a { color: #dcd2de; text-decoration: none; }
.footer-brand { display: flex; align-items: center; gap: 1rem; }
.footer-brand img { width: 90px; height: 90px; object-fit: contain; }
.footer-brand div { display: grid; }
.footer-brand b { color: #f1d986; font-family: Georgia, serif; font-size: 1.5rem; }
.site-footer small { grid-column: 1 / -1; padding-top: 1.5rem; color: #9d929f; border-top: 1px solid #392e3d; }

@media (max-width: 1120px) {
  .menu-toggle { display: block; }
  .site-header nav { position: absolute; top: 100%; left: 0; right: 0; display: none; padding: 1rem; background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .site-header nav.open { display: grid; }
  .hero { min-height: 620px; }
  .hero .hero-seal { right: -160px; width: 720px; opacity: .35; }
  .grid.three { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .portal-layout { grid-template-columns: 1fr; }
  .portal-nav { position: static; grid-template-columns: repeat(3, 1fr); }
  .portal-nav b { grid-column: 1 / -1; }
  .join-steps { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .county-bar span:last-child { display: none; }
  .brand img { width: 48px; height: 48px; }
  .brand b { font-size: 1.08rem; }
  .brand small { display: none; }
  .hero { min-height: 570px; }
  .stat-row { margin-top: -24px; }
  .grid.three, .grid.two, .fields, .cta, .site-footer, .media-grid { grid-template-columns: 1fr; }
  .department-card { grid-template-columns: 80px 1fr; }
  .department-card img { width: 80px; height: 80px; }
  .section-head { align-items: start; flex-direction: column; }
  .portal-nav { grid-template-columns: repeat(2, 1fr); }
  .record { flex-direction: column; }
  .record-actions { justify-content: flex-start; }
}
