:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #687385;
  --border: #d7dde6;
  --accent: #1f5d8f;
  --accent-dark: #17486f;
  --danger: #a63a3a;
  --ok: #26734d;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

.app-header {
  align-items: center;
  background: #182233;
  color: #fff;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 16px 28px;
}

.app-header h1 {
  font-size: 20px;
  line-height: 1.1;
  margin: 0;
}

.app-header p {
  color: #b9c3d2;
  margin: 4px 0 0;
}

.app-header nav {
  display: flex;
  gap: 8px;
}

.app-header a {
  border-radius: 6px;
  color: #dce5f2;
  padding: 8px 12px;
  text-decoration: none;
}

.app-header a.active,
.app-header a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.section-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head h2,
.panel h3,
.county-group h3 {
  margin: 0;
}

.section-head p {
  color: var(--muted);
  margin: 4px 0 0;
}

.flash {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash div {
  background: #eef6ff;
  border: 1px solid #c7def7;
  border-radius: 6px;
  color: #17486f;
  padding: 10px 12px;
}

.county-list {
  display: grid;
  gap: 10px;
}

.county-group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.county-group > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 16px;
}

.county-group > summary::-webkit-details-marker {
  display: none;
}

.county-group > summary::after {
  color: var(--muted);
  content: "Open";
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.county-group[open] > summary::after {
  content: "Close";
}

.county-group > summary strong {
  font-size: 16px;
}

.county-group > summary small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.record-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.top-list {
  padding: 0;
}

.record,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.record summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  list-style: none;
  padding: 14px 16px;
}

.record summary::-webkit-details-marker {
  display: none;
}

.record summary small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.status {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  white-space: nowrap;
}

.status.on {
  background: #e7f5ed;
  color: var(--ok);
}

.status.off {
  background: #f5eaea;
  color: var(--danger);
}

.grid-form {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 600;
  gap: 5px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #c7ced8;
  border-radius: 6px;
  color: var(--text);
  font: 14px "Segoe UI", Arial, sans-serif;
  min-height: 34px;
  padding: 7px 9px;
  width: 100%;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.search-select-source {
  display: none;
}

.combo-select {
  position: relative;
  width: 100%;
}

.combo-input {
  padding-right: 28px;
}

.combo-list {
  background: #fff;
  border: 1px solid #aeb8c5;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgb(15 23 42 / 14%);
  left: 0;
  max-height: 260px;
  overflow-y: auto;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
}

.combo-option,
.combo-empty {
  background: #fff;
  border: 0;
  color: var(--text);
  display: block;
  font: 14px "Segoe UI", Arial, sans-serif;
  min-height: 32px;
  padding: 7px 9px;
  text-align: left;
  width: 100%;
}

.combo-option:hover,
.combo-option:focus {
  background: #eef6ff;
  outline: none;
}

.combo-empty {
  color: var(--muted);
}

.wide {
  grid-column: span 2;
}

.check {
  align-content: end;
  display: flex;
  gap: 8px;
}

.check input {
  min-height: 0;
  width: auto;
}

.check-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 10px 12px 12px;
}

.check-group legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 0 5px;
}

.check-group label {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.check-group input[type="checkbox"],
.check-group input[type="radio"] {
  min-height: 0;
  width: auto;
}

.check-group .wide {
  align-items: stretch;
  flex-direction: column;
}

.form-actions {
  align-items: end;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

button,
.button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: 600 13px "Segoe UI", Arial, sans-serif;
  min-height: 34px;
  padding: 7px 12px;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

.ghost {
  background: #fff;
  color: var(--accent);
}

.ghost:hover {
  background: #eef6ff;
}

.danger {
  background: #fff;
  border-color: #d7b2b2;
  color: var(--danger);
}

.danger:hover {
  background: #f8eeee;
}

.subsection {
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
}

.subsection h4 {
  margin: 0 0 10px;
}

.inline-form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  margin-top: 8px;
}

.add-row {
  grid-template-columns: minmax(160px, 1fr) auto;
  max-width: 520px;
}

.empty {
  color: var(--muted);
  margin: 0 0 8px;
}

.empty-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
}

.detail-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 0 16px 16px;
}

.detail-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.detail-grid strong,
.detail-grid span {
  display: block;
}

.detail-grid strong {
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-grid span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.result-box {
  background: #111827;
  border-radius: 8px;
  color: #e5e7eb;
  margin: 0 16px 16px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.panel {
  margin-top: 22px;
  padding-top: 14px;
}

.panel h3 {
  padding: 0 16px 12px;
}

.panel-title-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 0 16px 12px;
}

.panel-title-row h3 {
  padding: 0;
}

.inline-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.selector-row {
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
}

.selector-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  padding: 7px 11px;
  text-decoration: none;
}

.selector-pill.selected,
.selector-pill:hover {
  background: #eef6ff;
  border-color: #a8c8ec;
  color: var(--accent);
}

.browser-toolbar {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 16px;
}

.file-browser {
  border-top: 1px solid var(--border);
  display: grid;
}

.browser-row {
  align-items: center;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) auto;
  padding: 10px 16px;
  text-decoration: none;
}

.browser-row.folder {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.browser-row:hover {
  background: #f8fafc;
}

.browser-row span {
  font-weight: 650;
}

.browser-row small {
  color: var(--muted);
}

.mapping-table {
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) 80px minmax(210px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr);
  overflow-x: auto;
}

.mapping-head,
.mapping-cell {
  border-bottom: 1px solid var(--border);
  min-width: 0;
  padding: 10px;
}

.mapping-head {
  background: #f3f5f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-name {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.mapping-empty {
  grid-column: 1 / -1;
  margin: 12px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
}

.output-list {
  border-top: 1px solid var(--border);
  display: grid;
}

.output-row {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 12px 16px;
}

.output-row small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .app-header,
  .section-head {
    display: grid;
  }

  .app-header nav {
    flex-wrap: wrap;
  }

  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mapping-table {
    grid-template-columns: 180px 70px 200px 160px 160px;
  }

  .browser-row,
  .browser-row.folder {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 14px;
  }

  .grid-form,
  .inline-form,
  .add-row {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }
}
