:root {
  --ink: #12233F;
  --ink-2: #1B3055;
  --paper: #F3F5F4;
  --card: #FFFFFF;
  --brass: #A8763A;
  --brass-dark: #86602E;
  --line: #DFE3E3;
  --text: #1B2430;
  --text-muted: #5C6672;
  --danger: #A5432F;
  --good: #2F6F4E;
  --radius: 10px;
  --focus: #2E5C8A;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0D1826;
    --ink-2: #142236;
    --paper: #0E1826;
    --card: #16233A;
    --brass: #CE9C5C;
    --brass-dark: #E3B473;
    --line: #2A3A52;
    --text: #E7EAEE;
    --text-muted: #93A0B3;
    --focus: #6FA1D8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell { display: grid; grid-template-columns: 340px 1fr; min-height: 100vh; }

.rail {
  background: linear-gradient(175deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #EDEFF2;
  padding: 44px 36px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.mark { display: flex; align-items: center; gap: 10px; margin-bottom: 46px; }
.mark .glyph {
  width: 34px; height: 34px;
  border: 1.5px solid var(--brass);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brass);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 17px;
  flex-shrink: 0;
}
.mark .name { font-size: 13.5px; letter-spacing: 0.06em; text-transform: uppercase; color: #C7CEDA; font-weight: 600; }
.brand-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.brand-card img { height: 20px; width: auto; display: block; }
.login-mark .brand-card { padding: 7px 12px; }
.login-mark .brand-card img { height: 22px; }
.rail h1 { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-size: 30px; line-height: 1.22; font-weight: 400; margin: 0 0 16px; text-wrap: balance; }
.rail .lede { font-size: 14.5px; line-height: 1.65; color: #AEB8C7; margin: 0 0 40px; max-width: 30ch; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.steps li { display: flex; align-items: baseline; gap: 14px; padding: 13px 4px; border-top: 1px solid rgba(255,255,255,0.09); font-size: 14px; color: #9BA6B8; }
.steps li:last-child { border-bottom: 1px solid rgba(255,255,255,0.09); }
.steps li .num { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--brass); width: 16px; }
.steps li.active { color: #F2F4F7; font-weight: 600; }
.steps li.active .num { color: var(--brass); }
.rail .foot-note { margin-top: auto; padding-top: 28px; font-size: 12.5px; color: #8592A5; line-height: 1.6; border-top: 1px solid rgba(255,255,255,0.09); }
.rail .foot-note strong { color: #C7CEDA; }

.main { padding: 56px 64px 120px; max-width: 760px; }
.top-meta { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.eyebrow { font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.time-pill { font-size: 12px; color: var(--text-muted); border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.main > h2 { font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: 27px; margin: 6px 0 40px; }

section.card, .panel-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 32px 32px; margin-bottom: 22px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.sec-head .idx { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--brass); }
.sec-head h3 { font-size: 16.5px; font-weight: 650; margin: 0; }
.sec-sub { font-size: 13.5px; color: var(--text-muted); margin: 6px 0 22px; line-height: 1.55; max-width: 58ch; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.grid .full { grid-column: 1 / -1; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
label .opt { font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
label .req { color: var(--brass-dark); }

input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="password"], select {
  width: 100%; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--paper); color: var(--text); font-size: 14.5px; font-family: inherit;
}
input.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.02em; }
input:focus, select:focus, .tag-input:focus-within { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
::placeholder { color: #9AA4B2; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

hr.div { border: none; border-top: 1px solid var(--line); margin: 26px 0; }

.radio-row { display: flex; gap: 12px; margin-bottom: 22px; }
.radio-card { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.radio-card input { margin-top: 2px; accent-color: var(--brass-dark); }
.radio-card.checked { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 7%, var(--card)); }
.radio-card .rt-title { font-weight: 600; display: block; }
.radio-card .rt-sub { color: var(--text-muted); font-size: 12px; }

.tag-input { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; background: var(--paper); }
.chip { display: inline-flex; align-items: center; gap: 7px; background: color-mix(in srgb, var(--brass) 16%, var(--card)); color: var(--text); border: 1px solid color-mix(in srgb, var(--brass) 40%, transparent); padding: 4px 6px 4px 11px; border-radius: 999px; font-size: 13px; }
.chip button { all: unset; cursor: pointer; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-muted); font-size: 13px; line-height: 1; }
.chip button:hover { background: rgba(0,0,0,0.1); color: var(--text); }
.tag-input input { flex: 1; min-width: 140px; border: none; background: transparent; padding: 4px; font-size: 14px; }
.tag-input input:focus { outline: none; box-shadow: none; }
.tag-hint { font-size: 12px; color: var(--text-muted); margin-top: 7px; }
#countyBlock[hidden] { display: none; }

.agree-row { display: flex; gap: 12px; padding: 14px 0; }
.agree-row + .agree-row { border-top: 1px solid var(--line); }
.agree-row input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brass-dark); flex-shrink: 0; }
.agree-row p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.agree-row a { color: var(--focus); text-decoration: underline; }

.submit-bar { display: flex; align-items: center; gap: 18px; margin-top: 8px; flex-wrap: wrap; }
button.submit, a.btn-primary, button.btn-primary {
  background: var(--brass-dark); color: #FBF4E9; border: none; padding: 13px 26px; border-radius: 8px;
  font-size: 14.5px; font-weight: 650; cursor: pointer; text-decoration: none; display: inline-block;
}
button.submit:hover, a.btn-primary:hover, button.btn-primary:hover { background: var(--brass); }
.submit-note { font-size: 12.5px; color: var(--text-muted); }

.btn-secondary { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 11px 20px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.btn-danger { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); padding: 11px 20px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; }

.approval-banner { max-width: 760px; margin: 0 0 28px; padding: 13px 18px; border: 1px dashed color-mix(in srgb, var(--brass) 55%, var(--line)); border-radius: 8px; font-size: 13px; color: var(--text-muted); background: color-mix(in srgb, var(--brass) 6%, transparent); }
.approval-banner strong { color: var(--text); }
.error-banner { max-width: 760px; margin: 0 0 20px; padding: 13px 18px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); border-radius: 8px; font-size: 13.5px; color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, transparent); }

/* ---- Admin ---- */
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 36px 28px 80px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-top .brand { display: flex; align-items: center; gap: 10px; font-family: Georgia, serif; font-size: 20px; }
.admin-top .brand .glyph { width: 30px; height: 30px; border: 1.5px solid var(--brass); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--brass); font-size: 15px; }
.admin-top .who { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 14px; }
.admin-top form { display: inline; }
.admin-top button { background: none; border: none; color: var(--focus); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }

.filter-row { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-pill { font-size: 12.5px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-muted); text-decoration: none; }
.filter-pill.active { background: var(--ink); color: #EDEFF2; border-color: var(--ink); }

table.firms-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.firms-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
table.firms-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.firms-table tr:last-child td { border-bottom: none; }
table.firms-table a { color: var(--text); text-decoration: none; font-weight: 600; }
table.firms-table a:hover { color: var(--focus); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pending { color: #8A6D1D; background: color-mix(in srgb, #8A6D1D 14%, transparent); }
.pill.approved { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.pill.active { color: var(--focus); background: color-mix(in srgb, var(--focus) 14%, transparent); }
.pill.denied { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.pill.terminated { color: var(--text-muted); background: color-mix(in srgb, var(--text-muted) 16%, transparent); }
.pill.verified { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.pill.invalid { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.pill.not_found { color: #8A6D1D; background: color-mix(in srgb, #8A6D1D 14%, transparent); }
.pill.unchecked { color: var(--text-muted); background: color-mix(in srgb, var(--text-muted) 16%, transparent); }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.audit-item { font-size: 12.5px; color: var(--text-muted); padding: 8px 0; border-top: 1px solid var(--line); }
.audit-item:first-child { border-top: none; }
.audit-item strong { color: var(--text); }
.chip-static { display: inline-flex; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; background: color-mix(in srgb, var(--brass) 12%, var(--card)); border: 1px solid var(--line); margin: 0 6px 6px 0; }
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; top: auto; padding: 22px 20px; flex-direction: row; align-items: center; justify-content: space-between; }
  .rail .lede, .rail .steps, .rail .foot-note, .rail h1 { display: none; }
  .mark { margin-bottom: 0; }
  .main { padding: 28px 18px 110px; }
  .grid { grid-template-columns: 1fr; }
  .radio-row { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  table.firms-table { display: block; overflow-x: auto; }
}
@media (max-width: 520px) {
  section.card, .panel-card { padding: 22px 18px 26px; }
  .main > h2 { font-size: 22px; }
  .admin-shell { padding: 22px 14px 60px; }
}
