:root {
  color-scheme: light;
  font: 15px/1.45 "DM Sans", system-ui, sans-serif;
  --ink: #172741;
  --muted: #50617b;
  --line: #dce5ef;
  --surface: #fff;
  --canvas: #f3f6fa;
  --navy: #121f35;
  --blue: #1953ce;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); border-radius: 7px; min-height: 37px; padding: 6px 12px; background: white; cursor: pointer; font-weight: 650; }
button:hover { border-color: #9bb5df; background: #f3f7ff; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #3977e4; outline-offset: 2px; }
.primary { background: var(--blue); color: white; border-color: var(--blue); }
.primary:hover { background: #13429e; border-color: #13429e; }
.topbar { display: flex; gap: 14px; align-items: center; background: var(--navy); color: #eff4ff; min-height: 62px; padding: 8px clamp(12px, 3vw, 34px); }
.topbar a { flex: none; }
.topbar img { display: block; width: clamp(117px, 26vw, 157px); height: auto; }
#account { overflow: hidden; min-width: 0; text-overflow: ellipsis; white-space: nowrap; border-left: 1px solid #53657f; padding-left: 12px; font-size: .87rem; }
.sign-out { margin-left: auto; flex: none; border-color: #51617b; color: #eef4ff; background: transparent; font-size: .84rem; }
.sign-out:hover { color: var(--ink); }
.layout { display: grid; grid-template-columns: minmax(176px, 215px) minmax(0, 1fr); min-height: calc(100dvh - 62px); max-width: 1650px; margin: 0 auto; }
aside { padding: 18px 12px; border-right: 1px solid var(--line); background: #f9fbfd; }
nav { display: grid; gap: 4px; }
nav p { font-size: .73rem; font-weight: 760; margin: 9px 9px 2px; color: var(--muted); }
nav button { text-align: left; border-color: transparent; min-height: 36px; background: transparent; }
nav button[aria-current="page"] { color: #134498; background: #e8f0ff; border-color: #d1e1ff; }
.content { min-width: 0; padding: clamp(13px, 3vw, 32px); }
.page-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: clamp(1.6rem, 3vw, 2rem); letter-spacing: -.035em; }
h2 { font-size: 1.12rem; }
.page-head p, .muted, .login > p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list, .login { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.list-tools { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.list-tools label { width: min(100%, 260px); }
#search { display: flex; align-items: end; gap: 7px; }
label { display: grid; gap: 4px; min-width: 0; color: #3b506c; font-size: .84rem; font-weight: 650; }
input, select, textarea { min-width: 0; width: 100%; min-height: 37px; padding: 6px 9px; border: 1px solid #d1deec; border-radius: 6px; background: white; font-weight: 450; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 7px; }
.check input { width: 17px; min-height: 17px; }
.branch-grants { margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.branch-grants legend { padding: 0 5px; font-weight: 700; }
#branch-checklist { max-height: 220px; overflow: auto; display: grid; gap: 7px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .87rem; }
th { padding: 9px 11px; white-space: nowrap; background: #f5f8fc; color: #455974; }
th:has([data-sort]) { padding: 0; }
.sort-heading { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 37px; padding: 6px 11px; border: 0; border-radius: 0; background: transparent; text-align: left; font: inherit; font-weight: 700; }
.sort-heading:hover, th[aria-sort] .sort-heading { background: #e8f0ff; color: #134498; }
.sort-indicator { display: grid; gap: 2px; color: #667d9b; }
.sort-indicator::before, .sort-indicator::after { content: ''; border-inline: 4px solid transparent; }
.sort-indicator::before { border-bottom: 4px solid currentColor; }
.sort-indicator::after { border-top: 4px solid currentColor; }
.sort-indicator[data-direction="asc"]::after, .sort-indicator[data-direction="desc"]::before { visibility: hidden; }
td { padding: 10px 11px; border-top: 1px solid #e7edf5; color: #30455f; }
td:first-child { font-weight: 690; color: var(--ink); overflow-wrap: anywhere; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; }
td:first-child { background: var(--surface); font-variant-numeric: tabular-nums; }
td:last-child { text-align: right; white-space: nowrap; }
td button { min-height: 31px; font-size: .8rem; }
.company-link { padding: 2px 0; border: 0; background: transparent; color: #174da9; text-align: left; text-decoration: underline; overflow-wrap: anywhere; font-size: inherit; }
.company-link:hover { background: transparent; color: #0e367c; }
.company-detail-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 11px; }
.company-detail-heading h3 { margin: 0; font-size: 1rem; }
.company-branch { margin-bottom: 7px; border: 1px solid var(--line); border-radius: 8px; }
.company-branch summary { padding: 9px 11px; cursor: pointer; overflow-wrap: anywhere; }
.company-branch summary .muted { margin-inline: 5px; font-size: .8rem; white-space: nowrap; }
.company-branch ul { margin: 0; padding: 2px 12px 9px 33px; }
.company-branch p { padding: 0 11px 9px 24px; }
.record-id { display: inline-block; margin-inline: 3px; padding: 1px 5px; background: #edf3fa; border-radius: 4px; color: #435976; font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: .74rem; font-weight: 750; padding: 2px 7px; border-radius: 4px; background: #ecf2f9; color: #4c617b; white-space: nowrap; }
.tag.active { color: #126247; background: #e6f5ee; }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: end; padding: 8px 12px; border-top: 1px solid var(--line); }
.empty { color: var(--muted); margin: 14px; }
.login { width: min(420px, calc(100% - 28px)); margin: clamp(25px, 10vh, 95px) auto; padding: 23px; }
.login form { display: grid; gap: 12px; margin-top: 17px; }
.error { color: #9f2634; margin-top: 9px; overflow-wrap: anywhere; }
#feedback { margin-top: 10px; color: #154a78; }
dialog { width: min(calc(100% - 18px), 708px); max-height: 88dvh; border: 1px solid var(--line); border-radius: 12px; padding: 0; color: var(--ink); box-shadow: 0 14px 42px #10233a40; }
dialog::backdrop { background: #14253b85; }
.coverage-map { height: clamp(245px, 40dvh, 390px); margin-bottom: 8px; border: 1px solid var(--line); border-radius: 6px; z-index: 0; }
dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 9px; position: sticky; top: 0; z-index: 1; background: white; border-bottom: 1px solid var(--line); padding: 9px 13px; }
#dialog-content { padding: 13px; }
.form-grid, .quote-result { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.wide { grid-column: 1 / -1; }
.form-actions { margin-top: 14px; }
.field-help, .hint { display: block; margin: 3px 0 8px; color: var(--muted); font-size: .83rem; }
.quote-result { margin: 10px 0; }
.quote-result > div { padding: 8px; border-radius: 6px; background: #f3f7fc; color: var(--muted); }
.quote-result strong { display: block; color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
@media(max-width:720px) {
  .layout { display: block; }
  aside { padding: 7px; border: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; flex-wrap: wrap; gap: 4px; }
  nav p { display: none; }
  nav button { font-size: .78rem; padding: 5px 7px; min-height: 31px; }
}
@media(max-width:440px) {
  .topbar { gap: 8px; }
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .content { padding: 11px; }
  .page-head { margin-bottom: 11px; }
}
