:root {
  color-scheme: light;
  --ink: #25292d;
  --muted: #697078;
  --line: #dfe3e7;
  --soft: #f6f7f8;
  --green: #176b50;
  --green-soft: #eaf4ef;
  --red: #ad3434;
  --amber: #8a601e;
  --blue: #326785;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; color: var(--ink); background: var(--soft); font: 13px/1.45 "Segoe UI", system-ui, sans-serif; letter-spacing: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 16px; font-weight: 650; white-space: nowrap; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 12px; font-weight: 650; }
button, input, select { font: inherit; color: inherit; }
button, input, select { border: 1px solid #cfd5da; border-radius: 4px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 32px; padding: 5px 11px; background: #fff; font-size: 12px; font-weight: 550; cursor: pointer; }
button:hover:not(:disabled), .icon-button:hover { background: #eef1f3; }
button:disabled { opacity: .42; cursor: not-allowed; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:hover:not(:disabled) { background: #10583f; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid #3f8b72; outline-offset: 2px; }
svg { width: 16px; height: 16px; stroke-width: 1.7; flex: 0 0 auto; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-height: 32px; flex: 0 0 32px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); text-decoration: none; }
.icon-button.bordered { border-color: #cfd5da; background: #fff; }
.full-width { width: 100%; }
.subtle { color: var(--muted); font-size: 12px; }
.tabular, time { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 54px; padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; color: #fff; background: #293932; }
.brand-mark svg { width: 20px; height: 20px; }
.county { padding-left: 13px; margin-left: 3px; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.header-tools { display: flex; align-items: center; gap: 7px; }
.last-check { display: flex; gap: 7px; color: var(--muted); font-size: 11px; margin-right: 12px; }
.last-check time { color: var(--ink); }
.state-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; white-space: nowrap; border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; margin-right: 7px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #929aa1; flex: 0 0 6px; display: inline-block; }
.state-label.active { background: var(--green-soft); color: var(--green); border-color: #c8e0d3; }
.active .status-dot, .connected .status-dot { background: var(--green); }
.source-error .status-dot { background: var(--red); }
.console { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.search-region { display: flex; align-items: end; background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.mobile-search-toggle, .mobile-records, .mobile-nav, .mobile-sort { display: none; }
.toolbar { display: flex; align-items: end; flex: 1; min-width: 0; gap: 10px; padding: 12px 20px; background: #fff; }
.toolbar > label { display: grid; gap: 4px; width: 155px; min-width: 0; font-size: 11px; color: var(--muted); }
.toolbar > .scope-field { width: 192px; }
.toolbar > .interval-field { width: 115px; }
input:not([type=checkbox]), select { width: 100%; min-width: 0; height: 32px; padding: 0 9px; background: #fff; font-size: 12px; }
input:hover, select:hover { border-color: #9ca7b0; }
.toolbar-actions { display: flex; gap: 7px; padding: 12px 20px 12px 0; margin-left: auto; }
.toolbar-actions > button:not(.icon-button) { min-width: 94px; }
.view-bar { display: flex; justify-content: space-between; align-items: center; gap: 15px; height: 43px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.view-tabs { display: flex; align-self: stretch; gap: 21px; }
.view-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 0 1px; color: var(--muted); }
.view-tab[aria-selected=true] { border-bottom-color: var(--green); color: var(--ink); }
.view-tab:hover:not(:disabled) { background: transparent; color: var(--ink); }
.count { display: inline-grid; place-items: center; min-width: 18px; padding: 0 5px; height: 17px; background: #edf0f2; border-radius: 3px; color: #656e76; font-size: 10px; font-weight: 500; font-variant-numeric: tabular-nums; }
.error-count { color: var(--red); font-size: 10px; }
.schedule { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
#nextCheck { min-width: 82px; text-align: right; color: var(--ink); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; }
.view-content { display: flex; min-width: 0; min-height: 0; overflow: hidden; }
.records-view, .activity-view { display: flex; flex-direction: column; width: 100%; min-width: 0; min-height: 0; }
.status-line { display: flex; align-items: center; gap: 7px; min-height: 35px; padding: 7px 20px; background: #fbfcfc; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; flex-shrink: 0; flex-wrap: wrap; }
.status-icon { display: inline-flex; }
.status-icon svg { width: 13px; height: 13px; }
#statusText { color: #505a62; }
#statusMeta { overflow-wrap: anywhere; }
.status-line.error { background: #fff1f0; color: #8d3535; border-bottom-color: #efcecb; }
.status-line.error #statusText { color: var(--red); font-weight: 600; }
.status-line.alert .status-icon { color: var(--amber); }
.status-line.ok .status-icon { color: var(--green); }
.status-line.checking .status-icon, #checkNow.busy svg { animation: spin 1.3s linear infinite; }
.records-scroll { min-height: 0; overflow: auto; background: #fff; flex: 1; }
.records-table { width: 100%; min-width: 850px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12px; }
.name-col { width: 25%; }
.booking-col { width: 14%; }
.date-col { width: 21%; }
.status-col { width: 16%; }
.charges-col { width: 9%; }
.bond-col { width: 12%; }
.action-col { width: 36px; }
.records-table th { position: sticky; top: 0; z-index: 1; background: #f3f5f6; border-bottom: 1px solid #d9dfe3; height: 37px; padding: 0 12px; text-align: left; font-size: 11px; font-weight: 550; color: #5e6871; }
.records-table th:first-child, .records-table td:first-child { padding-left: 20px; }
.records-table th > button { border: 0; border-radius: 0; background: transparent; width: 100%; justify-content: flex-start; padding: 0; font-size: 11px; color: inherit; min-height: 36px; }
.records-table th > button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.records-table th svg { height: 12px; width: 12px; color: #89939b; }
.records-table th[aria-sort=ascending] svg, .records-table th[aria-sort=descending] svg { color: var(--green); }
.records-table td { height: 44px; padding: 7px 12px; border-bottom: 1px solid #e8ebed; vertical-align: middle; overflow-wrap: anywhere; }
.records-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.records-table th.numeric > button { justify-content: flex-end; }
.records-table .record-row { cursor: pointer; }
.record-row:hover { background: #f7f9fa; }
.record-row.selected { background: #eef5f2; }
.record-row.selected td:first-child { box-shadow: inset 3px 0 var(--green); }
.record-link { border: 0; border-radius: 0; background: transparent; color: #2c566e; padding: 0; min-height: 28px; text-align: left; justify-content: flex-start; font-weight: 550; max-width: 100%; overflow-wrap: anywhere; }
.record-link:hover:not(:disabled) { background: transparent; text-decoration: underline; }
.record-id { font-variant-numeric: tabular-nums; color: #58626b; }
.status-badge { display: inline-flex; padding: 2px 6px; border-radius: 3px; background: #eef1f4; color: #506477; font-size: 10px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.record-arrow { width: 13px; height: 13px; color: #85929b; }
.records-table .empty-cell, .activity-table .empty-cell { height: 78px; color: var(--muted); font-size: 12px; font-weight: 400; vertical-align: middle; text-align: left; }
.table-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 31px; align-items: center; padding: 6px 20px; background: #f9fafb; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; flex-shrink: 0; }
.activity-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 20px; min-height: 45px; background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.activity-actions { display: flex; gap: 8px; align-items: center; }
.activity-actions select { width: 156px; height: 28px; font-size: 11px; }
.activity-scroll { flex: 1; min-height: 0; overflow: auto; background: #fff; }
.activity-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: 12px; }
.activity-table th { background: #f3f5f6; font-weight: 550; color: #5e6871; font-size: 11px; position: sticky; top: 0; }
.activity-table th, .activity-table td { padding: 10px 20px; border-bottom: 1px solid var(--line); vertical-align: top; }
.activity-table td { overflow-wrap: anywhere; }
.activity-table th:first-child { width: 130px; }
.activity-table th:nth-child(2) { width: 280px; }
.activity-table time { color: var(--muted); white-space: nowrap; font-size: 11px; }
.activity-event { display: flex; align-items: flex-start; gap: 8px; }
.activity-event svg { margin-top: 1px; width: 14px; height: 14px; color: var(--muted); }
.activity-row.ok svg { color: var(--green); }
.activity-row.alert svg { color: var(--amber); }
.activity-row.error svg { color: var(--red); }
.activity-detail { color: var(--muted); }
.status-bar { display: flex; align-items: center; gap: 20px; min-height: 29px; padding: 5px 20px; border-top: 1px solid var(--line); background: #f1f3f5; font-size: 10px; color: var(--muted); flex-shrink: 0; }
#sourceHealth, .session-indicator { display: flex; align-items: center; gap: 6px; }
.session-indicator { margin-left: auto; }
.session-indicator svg { height: 12px; width: 12px; }
.detail-panel { position: fixed; inset: 0; margin: auto; padding: 0; width: min(780px, calc(100% - 40px)); height: fit-content; max-height: min(90dvh, 940px); max-width: none; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; box-shadow: 0 24px 80px #17221b33; }
.detail-panel::backdrop { background: #20282d80; }
.detail-panel[open] { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-head > div:first-child { min-width: 0; }
.panel-head h2 { overflow-wrap: anywhere; line-height: 1.35; }
.panel-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.panel-actions { display: flex; flex-shrink: 0; gap: 2px; }
.panel-body { padding: 16px; overflow: auto; flex: 1; min-height: 0; }
.panel-footer { padding: 9px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 10px; color: var(--muted); background: #fafbfc; border-top: 1px solid var(--line); flex-shrink: 0; }
.panel-footer > span { overflow-wrap: anywhere; }
.detail-navigator { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 4px 16px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); flex-shrink: 0; }
.detail-navigator > div { display: flex; }
.detail-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
.detail-heading p { font-size: 11px; color: var(--muted); }
.bond-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.bond-summary dt, .detail-grid dt, .charge-fields dt { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.bond-summary dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin: 0; }
.detail-grid dd, .charge-fields dd { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.detail-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-section h3 { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.holds { display: flex; gap: 6px; flex-wrap: wrap; }
.hold { padding: 3px 7px; border-radius: 3px; background: #fcf4e8; color: var(--amber); font-size: 11px; overflow-wrap: anywhere; }
.charge-item + .charge-item { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.charge-title { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.charge-statute { font-size: 11px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.charge-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0 0; }
.preview-note { padding: 8px 10px; background: #eef4f8; border-left: 2px solid #8faebf; color: var(--blue); font-size: 11px; margin-bottom: 16px; }
.settings-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: 360px; max-width: 100%; height: 100dvh; max-height: none; padding: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0; color: var(--ink); }
.settings-drawer[open] { display: flex; flex-direction: column; }
.settings-drawer::backdrop { background: #20272d38; }
.settings-drawer .panel-head { align-items: center; min-height: 55px; }
.settings-section + .settings-section { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 22px; }
.settings-section h3 { margin-bottom: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 48px; cursor: pointer; font-size: 12px; }
.toggle-row small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.switch { appearance: none; width: 30px; height: 18px; flex: 0 0 30px; border: 1px solid transparent; border-radius: 20px; background: #d0d6da; margin: 0; position: relative; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(12px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
#testAlert { margin-top: 9px; }
.session-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 24px; font-size: 11px; color: var(--muted); }
.session-note svg { width: 14px; height: 14px; margin-top: 1px; }
.toast { position: fixed; bottom: 42px; left: 50%; transform: translateX(-50%); padding: 10px 15px; max-width: calc(100% - 24px); width: max-content; background: #293932; color: #fff; border-radius: 4px; font-size: 12px; z-index: 5; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1150px) {
  .last-check { display: none; }
}
@media (max-width: 760px), (max-width: 1000px) and (pointer: coarse) {
  body { height: 100dvh; min-height: 0; overflow: hidden; }
  .app-header { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; min-height: 58px; gap: 8px; }
  .brand { gap: 9px; }
  h1 { font-size: 16px; }
  .county, .header-tools > a, #openSettings { display: none; }
  .header-tools { gap: 0; }
  .state-label { font-size: 11px; padding: 5px 8px; margin: 0; }
  .search-region { display: block; padding: 14px 16px; flex-shrink: 0; max-height: 45dvh; overflow-y: auto; }
  .mobile-search-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; border: 0; padding: 0; min-height: 44px; background: transparent; text-align: left; }
  .mobile-search-toggle strong { display: block; font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
  .mobile-search-toggle small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
  .mobile-search-toggle > svg { width: 20px; height: 20px; color: var(--muted); }
  .toolbar { display: none; padding: 0; margin-top: 14px; }
  .search-region.expanded .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .toolbar > label, .toolbar > .scope-field, .toolbar > .interval-field { width: 100%; font-size: 12px; gap: 6px; }
  input:not([type=checkbox]), select { height: 44px; font-size: 16px; }
  button, .icon-button { min-height: 44px; }
  .icon-button { width: 44px; height: 44px; flex-basis: 44px; }
  .toolbar-actions { width: 100%; gap: 10px; padding: 0; margin: 14px 0 0; }
  .toolbar-actions > button:not(.icon-button) { flex: 1; font-size: 14px; }
  .view-bar { padding: 0 16px; height: 52px; gap: 10px; background: #f4f6f8; }
  .view-tabs { display: none; }
  .schedule { gap: 5px; font-size: 11px; flex-wrap: wrap; }
  #nextCheck { min-width: 0; text-align: left; }
  .mobile-sort { display: block; min-width: 0; width: 154px; }
  .mobile-sort select { font-size: 13px; height: 36px; background: transparent; border-color: transparent; }
  .status-line { padding: 9px 16px; font-size: 12px; }
  .records-scroll { background: #f4f6f8; }
  .records-table { display: none; }
  .mobile-records { display: grid; gap: 12px; padding: 12px; }
  .mobile-empty { color: var(--muted); padding: 14px 4px; font-size: 13px; overflow-wrap: anywhere; }
  .mobile-record { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 15px; width: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: left; font-weight: 400; }
  .mobile-record.selected { border-color: #81ac9c; background: #f9fcfa; }
  .mobile-record-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .mobile-record-heading strong { font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
  .mobile-record-heading .status-badge { flex-shrink: 0; max-width: 40%; }
  .mobile-record-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .mobile-record-fields > span { display: grid; gap: 4px; }
  .mobile-record-fields small { color: var(--muted); font-size: 11px; }
  .mobile-record-fields span span { font-size: 13px; overflow-wrap: anywhere; }
  .mobile-record-fields strong { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .mobile-record-link { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--green); font-weight: 550; }
  .table-footer { padding: 7px 16px; font-size: 10px; min-height: 32px; background: #f4f6f8; }
  .status-bar { display: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px 8px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; flex-shrink: 0; }
  .mobile-nav button { display: flex; flex-direction: column; gap: 4px; min-height: 52px; border: 0; padding: 5px 0; background: transparent; color: var(--muted); font-size: 11px; }
  .mobile-nav svg { width: 21px; height: 21px; }
  .mobile-nav button.active { color: var(--green); }
  .mobile-nav .count { height: 15px; font-size: 9px; min-width: 16px; padding: 0 3px; }
  .activity-toolbar { padding: 6px 12px; gap: 4px; }
  .activity-actions { gap: 2px; }
  .activity-actions select { height: 40px; font-size: 13px; width: 130px; }
  .activity-table, .activity-table tbody { display: block; width: 100%; }
  .activity-table thead { display: none; }
  .activity-table tr { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .activity-table td { border: 0; padding: 0; font-size: 12px; min-width: 0; }
  .activity-table td:first-child { grid-column: 2; grid-row: 1; }
  .activity-table td:nth-child(2) { grid-column: 1; grid-row: 1; }
  .activity-table td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
  .activity-table time { font-size: 10px; white-space: nowrap; }
  .activity-table .empty-cell { grid-column: 1 / -1 !important; height: auto; }
  .detail-panel { inset: 0; margin: 0; width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .detail-panel .panel-head { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .panel-head h2 { font-size: 17px; }
  .panel-label { font-size: 11px; }
  .panel-footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .detail-grid, .charge-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid dd, .charge-fields dd, .charge-title { font-size: 14px; }
  .detail-grid dt, .charge-fields dt { font-size: 12px; }
  .settings-drawer { width: 100%; }
  .settings-drawer .panel-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .toggle-row { min-height: 58px; font-size: 14px; }
  .settings-section h3 { font-size: 14px; }
  .switch { width: 40px; height: 24px; flex-basis: 40px; }
  .switch::after { width: 18px; height: 18px; }
  .switch:checked::after { transform: translateX(16px); }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
@media print {
  html, body { display: block; height: auto; min-height: 0; background: white; }
  body > :not(.console), .console > :not(.workspace), .workspace > :not(.detail-panel) { display: none !important; }
  .console, .workspace, .workspace.has-details { display: block; }
  .detail-panel[open] { position: static; display: block; width: 100%; height: auto; max-height: none; border: 0; overflow: visible; }
  .detail-panel::backdrop { background: transparent; }
  .panel-body { overflow: visible; }
  .panel-actions, .panel-footer button, .detail-navigator { display: none; }
  .charge-item { break-inside: avoid; }
}
