.rt {
  --text: #222529;
  --muted: #6b7178;
  --line: #e2e5e8;
  --bg: #fff;
  --soft: #f4f6f8;
  --brand: #b50018;
  --brand-dark: #8c0013;
  --danger: #b3261e;
  --warn: #8a5a00;
  --map-bg: #fff;
  --map-fill: #c2414c;
  --map-fill-hover: #a92f3a;
  --map-fill-sel: #6e0a14;
  --map-line: #fff;
  --map-county: rgba(255, 255, 255, 0.25);
  --map-empty: #ecc9cd;
  --hatch: #dc9aa1;
  --font: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-head: Poppins, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.rt, .rt * { box-sizing: border-box; }
.rt [hidden] { display: none !important; }
.rt { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
.rt button, .rt input, .rt select { font: inherit; color: inherit; }
.rt button { cursor: pointer; }
.rt a { color: var(--brand); }
.rt :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Neutralize the host theme (Bootstrap/Porto) inside the map */
.rt h1, .rt h2, .rt h3 { font-family: var(--font-head); color: var(--text); letter-spacing: normal; text-transform: none; line-height: 1.25; }
.rt label { margin: 0; font-family: inherit; font-size: inherit; font-weight: 400; color: inherit; }
.rt ul { margin: 0; }
.rt .btn { display: inline-flex; align-items: center; justify-content: center; font-family: inherit; font-weight: 600; letter-spacing: normal; text-transform: none; line-height: 1; box-shadow: none; transition: background-color .15s, border-color .15s; }
.rt .row { margin: 0; }
.rt .toast { opacity: 1; font-size: 15px; box-shadow: none; border: 0; }
.rt .vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.rt .page { max-width: 1280px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 40px; }
.rt .page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rt .page-head h1 { margin: 0; font-size: 26px; font-weight: 700; }
.rt .page-head p { margin: 4px 0 0; color: var(--muted); }
.rt .admin-entry { display: flex; gap: 8px; flex-wrap: wrap; }
.rt .admin-entry form { margin: 0; }

.rt .finder { position: relative; display: flex; gap: 8px; max-width: 560px; margin: 18px 0 20px; }
.rt .finder input { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #bbb; border-radius: 3px; background: #fff; }
.rt .finder input:focus { border-color: var(--brand); outline: none; }
.rt .suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid #bbb; max-height: 300px; overflow-y: auto; }
.rt .suggest li { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.rt .suggest li[aria-selected="true"], .rt .suggest li:hover { background: var(--soft); }
.rt .suggest .muted { color: var(--muted); font-size: 13px; white-space: nowrap; }

.rt .btn { height: 40px; padding: 0 16px; border: 1px solid #bbb; border-radius: 3px; background: #fff; white-space: nowrap; }
.rt .btn:hover { background: var(--soft); }
.rt .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.rt .btn-primary:hover { background: var(--brand-dark); }
.rt .btn-sm { height: 32px; padding: 0 12px; font-size: 14px; }
.rt .btn-link { border: 0; background: none; padding: 0; height: auto; color: var(--brand); text-decoration: underline; }
.rt .btn-link:hover { background: none; }
.rt .btn-danger { color: var(--danger); }
.rt .btn[aria-pressed="true"] { background: var(--soft); border-color: var(--brand); }
.rt .btn:disabled { opacity: .5; cursor: not-allowed; }

.rt .layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .rt .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

.rt .map-box { position: relative; aspect-ratio: 975 / 610; max-height: 78vh; width: 100%; max-width: 100%; background: var(--map-bg); touch-action: none; }
.rt .map-box svg { display: block; width: 100%; height: 100%; }
.rt .map-box.paint svg { cursor: crosshair; }
.rt .map-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

.rt .county { fill: var(--map-fill); stroke: var(--map-county); stroke-linejoin: round; }
.rt .county.un { fill: url(#hatch); }
.rt .county.no-data { fill: var(--map-empty); }
.rt .county.in { fill: var(--map-fill-sel); }
.rt .county.hover { fill: var(--map-fill-hover); }
.rt .county.in.hover { fill: var(--map-fill-sel); }
.rt .county.picked { stroke: var(--map-line); }
.rt .b-territory { fill: none; stroke: var(--map-line); stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.rt .b-selected { fill: none; stroke: var(--map-line); stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.rt .hatch-bg { fill: var(--map-empty); }
.rt .hatch-line { stroke: var(--hatch); stroke-width: 1.4; }
.rt .lbl { font-family: var(--font); font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(64, 8, 14, .7); stroke-linejoin: round; pointer-events: none; text-anchor: middle; dominant-baseline: central; }

.rt .map-tools { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; gap: 4px; }
.rt .map-tools button { width: 30px; height: 30px; border: 1px solid #bbb; border-radius: 3px; background: #fff; font-size: 17px; line-height: 1; display: grid; place-items: center; }
.rt .map-tools button:hover { background: var(--soft); }
.rt .map-wrap { position: relative; min-width: 0; }
.rt .chips { position: absolute; right: 0; top: 30%; display: grid; grid-template-columns: repeat(2, 44px); gap: 7px; }
.rt .chips button { height: 28px; border: 0; border-radius: 6px; background: var(--map-fill); color: #fff; font-weight: 700; font-size: 13px; }
.rt .chips button:hover, .rt .chips button[aria-pressed="true"] { background: var(--map-fill-sel); }
.rt .city-dot { fill: #3a070d; stroke: #fff; pointer-events: none; }
.rt .city-lbl { font-family: var(--font); font-weight: 600; fill: #fff; paint-order: stroke; stroke: rgba(64, 8, 14, .7); stroke-linejoin: round; dominant-baseline: central; pointer-events: none; }
.rt .paint-banner { position: absolute; left: 40px; top: 0; right: 100px; padding: 6px 10px; background: var(--brand); color: #fff; font-size: 14px; }

.rt .tip { position: fixed; z-index: 30; display: block; margin: 0; border-radius: 0; vertical-align: baseline; pointer-events: none; padding: 6px 9px; background: #fff; color: var(--text); text-align: left; text-transform: none; letter-spacing: normal; line-height: 1.4; font-family: var(--font); border: 1px solid #bbb; font-size: 13px; max-width: 260px; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.rt .tip b { display: block; color: var(--text); font-weight: 700; }
.rt .tip::before { content: none; }

.rt .side { display: grid; gap: 24px; min-width: 0; }
.rt .side h2 { margin: 0 0 4px; font-size: 20px; }
.rt .side h3 { margin: 16px 0 6px; font-size: 15px; }
.rt .side p { margin: 0 0 8px; }
.rt .where { color: var(--muted); font-size: 14px; }
.rt .rep { padding: 10px 0; border-top: 1px solid var(--line); line-height: 1.6; }
.rt .rep:first-of-type, .rt .rep-label + .rep { border-top: 0; padding-top: 2px; }
.rt .rep > span { display: block; color: var(--muted); font-size: 15px; }
.rt .rep > .rep-name { color: var(--brand); font-size: 16px; }
.rt .rep a { text-decoration: none; overflow-wrap: anywhere; }
.rt .rep a:hover { text-decoration: underline; }
.rt .rep-label { margin: 18px 0 6px; font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.rt .browse { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 6px; }
.rt .browse label { font-size: 14px; color: var(--muted); }
.rt .browse select, .rt .field input, .rt .field select { width: 100%; height: 36px; padding: 0 8px; border: 1px solid #bbb; border-radius: 3px; background: #fff; min-width: 0; }

.rt .admin { display: grid; gap: 20px; border-top: 2px solid var(--brand); padding-top: 16px; }
.rt .admin section { display: grid; gap: 10px; }
.rt .admin section + section { border-top: 1px solid var(--line); padding-top: 16px; }
.rt .admin h3 { margin: 0; }
.rt .admin .hint { color: var(--muted); font-size: 14px; margin: 0; }
.rt .field { display: grid; gap: 3px; }
.rt .field label { font-size: 13px; color: var(--muted); }
.rt .field input[aria-invalid="true"] { border-color: var(--danger); }
.rt .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .rt .grid2 { grid-template-columns: 1fr; } }
.rt .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rt .row.end { justify-content: flex-end; }
.rt .rep-edit { display: grid; gap: 8px; padding: 10px; background: var(--soft); }
.rt .county-list { display: flex; flex-wrap: wrap; gap: 4px; max-height: 170px; overflow-y: auto; }
.rt .county-list button { border: 1px solid var(--line); background: #fff; border-radius: 3px; padding: 1px 7px; font-size: 13px; }
.rt .county-list button:hover { border-color: var(--brand); }

.rt .savebar { position: sticky; bottom: 0; z-index: 15; margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line); }
.rt .save-state.dirty { color: var(--warn); font-weight: 700; }
.rt .toast { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; background: #333; color: #fff; padding: 8px 14px; border-radius: 3px; max-width: calc(100% - 32px); }

.rt .login { min-height: 100vh; display: grid; place-items: center; padding-inline: 16px; padding-block: 32px; }
.rt .login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.rt .login-logo { display: block; width: 185px; max-width: 70%; height: auto; margin: 0 0 20px; }
.rt .login-card h1 { margin: 0 0 4px; font-size: 22px; }
.rt .login-card .btn { width: 100%; }
.rt .notice { margin: 0; padding: 8px 10px; background: #fdf1e0; color: var(--warn); font-size: 14px; }
.rt .suggest li.group { font-weight: 700; }
.rt .rep .btn-link { font-size: 16px; font-weight: 700; text-align: left; }
.rt .hint { color: var(--muted); font-size: 14px; margin: 0; }

@media (max-width: 600px) {
  .rt { font-size: 17px; }
  .rt .page { padding-block: 16px 32px; }
  .rt .page-head h1 { font-size: 23px; line-height: 1.25; }
  .rt .page-head p { font-size: 16px; }
  .rt .finder { margin: 14px 0 16px; }
  .rt .finder input, .rt .finder .btn { height: 48px; font-size: 17px; }
  .rt .suggest li { padding: 12px 10px; font-size: 16px; }
  .rt .suggest .muted { font-size: 14px; }
  .rt .map-box { margin-bottom: 42px; }
  .rt .map-tools { top: auto; left: auto; right: 0; bottom: -40px; flex-direction: row; gap: 5px; }
  .rt .map-tools button { width: 34px; height: 34px; font-size: 18px; }
  .rt .chips { position: static; display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 5px; margin-top: 2px; }
  .rt .chips button { flex: 0 1 38px; min-width: 34px; height: 28px; font-size: 12px; border-radius: 5px; }
  .rt .side h2 { font-size: 23px; }
  .rt .side h3 { font-size: 17px; }
  .rt .where { font-size: 16px; }
  .rt .rep-label { font-size: 15px; }
  .rt .rep > span { font-size: 17px; }
  .rt .rep > .rep-name { font-size: 19px; }
  .rt .rep a { display: inline-block; padding-block: 4px; }
  .rt .rep .btn-link { font-size: 18px; }
  .rt .browse label { font-size: 16px; }
  .rt .browse select, .rt .field input, .rt .field select { height: 46px; font-size: 16px; }
  .rt .btn { height: 46px; }
  .rt .btn-sm { height: 40px; font-size: 15px; }
  .rt .savebar .row { width: 100%; }
  .rt .savebar .btn { flex: 1; }
  .rt .tip { display: none; }
}

/* Touch screens: 16px text keeps iOS from zooming the page when a field is focused */
@media (hover: none) and (pointer: coarse) {
  .rt input, .rt select, .rt textarea { font-size: 16px; }
}
