:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #132b3b;
  background: #f1f6f6;
  font-synthesis: none;
  --surface: #fff;
  --muted: #546b76;
  --line: #dce7e7;
  --rail: #0c2835;
  --primary: #007c6c;
  --primary-dark: #006557;
  --ring: #0d9b89;
  --danger: #ae2634;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .64; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
a { color: inherit; }
h1, h2, p, dl, dd { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.layout { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { padding: 24px 16px; color: #f3fffe; background: var(--rail); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 4px 39px; text-decoration: none; font-size: 1.125rem; font-weight: 750; }
.brand small { display: block; margin-top: 3px; color: #b4d2d3; font-size: .8125rem; font-weight: 500; }
.brand-logo { display: block; width: 96px; height: auto; flex: none; }
.navigation a { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 13px; border-radius: 8px; text-decoration: none; font-weight: 650; font-size: .9375rem; }
.navigation [aria-current] { background: #1d414d; box-shadow: inset 3px 0 #81dfc5; }
.nav-icon { color: #a1f4dc; width: 20px; text-align: center; font-weight: 750; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 66px; gap: 12px; padding: 10px clamp(18px, 4vw, 47px); background: var(--surface); border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: .875rem; }
.breadcrumb strong { color: #132b3b; font-weight: 650; }
.content { width: min(100%, 1420px); margin-inline: auto; padding: 36px clamp(18px, 4vw, 47px) 56px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.page-header h1 { margin: 11px 0 5px; font-size: clamp(1.875rem, 4vw, 2.5rem); line-height: 1.12; }
.page-header p { color: var(--muted); line-height: 1.55; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 6px; color: #425c64; background: #e5eeee; font-size: .8125rem; font-weight: 650; }
.status-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-chip[data-mode="live"] { background: #d9f4e8; color: #085044; }
.status-chip[data-mode="preview"] { background: #fff2d0; color: #704d0c; }
.status-chip[data-mode="error"] { background: #fbe7e8; color: var(--danger); }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; font-size: .875rem; font-weight: 660; white-space: nowrap; }
.button-small { min-height: 36px; padding: 5px 11px; }
.button-light { border-color: #cddbdc; background: var(--surface); }
.button-light:hover:not(:disabled) { background: #eef5f4; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-primary span { line-height: 1; font-size: 1.25rem; }
.danger { color: #fff; background: var(--danger); }
.danger:hover:not(:disabled) { background: #90202a; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 26px 0 24px; }
.summary div { min-width: 0; padding: 16px 19px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.summary dt { color: var(--muted); font-size: .875rem; font-weight: 600; }
.summary dd { margin-top: 5px; color: #143b46; font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; padding: 17px 19px; }
h2 { font-size: 1.125rem; font-weight: 730; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters label { min-width: 0; }
input:not([type="checkbox"]), select { width: 100%; min-width: 0; padding: 9px 11px; min-height: 40px; border: 1px solid #cbdadb; border-radius: 7px; color: #193442; background: var(--surface); font-size: .875rem; }
input::placeholder { color: #627580; }
.filters select { min-width: 136px; width: 100%; }
.search-field { position: relative; }
.search-field input { padding-inline-start: 31px; }
.search-field::before { content: ''; position: absolute; top: 13px; left: 11px; width: 10px; height: 10px; border: 1.6px solid #637d83; border-radius: 50%; pointer-events: none; }
.search-field::after { content: ''; position: absolute; top: 22px; left: 19px; width: 5px; height: 1.6px; transform: rotate(45deg); background: #637d83; pointer-events: none; }
select { appearance: none; padding-inline-end: 32px; background-image: linear-gradient(45deg, transparent 50%, #315561 50%), linear-gradient(135deg, #315561 50%, transparent 50%); background-position: calc(100% - 15px) 18px, calc(100% - 10px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.table-scroll { width: 100%; overflow: auto; }
table { width: 100%; min-width: 705px; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 15px; border-block-start: 1px solid var(--line); }
th:first-child, td:first-child { padding-inline-start: 19px; }
th:last-child, td:last-child { padding-inline-end: 19px; }
th { background: #f1f7f6; font-size: .875rem; font-weight: 650; color: #294855; }
td { font-size: .9375rem; }
tbody tr:hover { background: #f8fbfa; }
.did-link { border: 0; padding: 2px 0; background: transparent; color: #00695d; font-variant-numeric: tabular-nums; font-weight: 720; }
.did-link:hover { text-decoration: underline; }
.cell-subtitle, .cell-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .8125rem; }
.cell-meta { margin-top: 0; }
.record-badge { display: inline-block; border-radius: 5px; padding: 3px 7px; background: #eef3f4; color: #415866; font-size: .8125rem; font-weight: 640; white-space: nowrap; }
.record-badge[data-enabled="true"] { color: #075646; background: #dff5eb; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.icon-button { min-height: 33px; border: 1px solid #d4e2e2; border-radius: 7px; background: var(--surface); padding: 5px 8px; color: #20414b; font-size: .875rem; }
.icon-button:hover:not(:disabled) { background: #eef6f4; }
.danger-quiet { color: var(--danger); }
.danger-quiet:hover:not(:disabled) { background: #fff0ef; }
.table-footer { border-top: 1px solid var(--line); padding: 12px 19px; color: var(--muted); font-size: .875rem; }
#route-selection { align-items: center; gap: 8px 12px; padding: 0 19px 12px; color: var(--muted); font-size: .875rem; }
.route-select-cell:first-child { width: 42px; padding-inline: 10px; text-align: center; }
.route-select-cell input { width: 17px; height: 17px; margin: 0; vertical-align: middle; accent-color: var(--primary); }
.empty-state { padding: 36px 19px; text-align: center; color: #234652; }
.empty-state p { margin-top: 6px; color: var(--muted); }
.message { padding: 10px 12px; margin-bottom: 12px; border-radius: 7px; background: #fff1f0; color: #87282d; border: 1px solid #f7cfcc; font-size: .875rem; line-height: 1.45; }

dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: inherit; box-shadow: 0 20px 60px rgb(7 33 39 / 22%); }
dialog::backdrop { background: rgb(9 31 41 / 52%); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.dialog-close { min-width: 34px; padding: 0; font-size: 1.25rem; }
.dialog-content { padding: 18px 20px; }
.dialog-content > p { line-height: 1.55; }
.delete-routes { max-height: min(34vh, 260px); overflow: auto; margin: 10px 0; padding-inline-start: 24px; line-height: 1.65; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; align-content: start; gap: 6px; font-size: .875rem; font-weight: 650; }
.form-grid .check-field { display: flex; align-self: end; align-items: center; gap: 8px; min-height: 40px; }
.check-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.wide { grid-column: 1 / -1; margin: 0; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; border-top: 1px solid var(--line); padding: 13px 20px; }
.toast { position: fixed; inset: auto 22px 20px auto; max-width: min(420px, calc(100vw - 44px)); z-index: 2; padding: 10px 14px; border-radius: 8px; background: #113a3d; color: #fff; box-shadow: 0 6px 24px rgb(7 33 39 / 19%); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 172px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { font-size: 1rem; }
  .brand-logo { width: 70px; }
}

@media (max-width: 660px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; }
  .brand { margin: 0; }
  .brand small { display: none; }
  .brand-logo { width: 64px; }
  .navigation a { min-height: 36px; padding-inline: 8px; font-size: .875rem; gap: 3px; }
  .topbar { min-height: 52px; }
  .content { padding-block-start: 22px; }
  .page-header { align-items: start; flex-direction: column; }
  .page-header .button { margin-top: 0; }
  .summary { gap: 7px; margin: 18px 0; }
  .summary div { padding: 10px; }
  .summary dd { font-size: 1.375rem; }
  .panel-header { padding: 13px; }
  .filters { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .search-field { grid-column: 1 / -1; }
  .filters select { min-width: 0; }
}

@media (max-width: 410px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
