:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #60707b;
  --line: #d8e0e5;
  --paper: #f8fafb;
  --panel: #ffffff;
  --accent: #0c6b5a;
  --accent-dark: #084a3f;
  --warm: #b86125;
  --blue: #315c96;
  --soft-green: #e8f4ef;
  --soft-blue: #e9f0f8;
  --shadow: 0 18px 45px rgba(30, 45, 55, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 63px, rgba(49, 92, 150, 0.08) 64px),
    repeating-linear-gradient(90deg, transparent 0 63px, rgba(12, 107, 90, 0.08) 64px),
    #edf3f5;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.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-shell {
  display: grid;
  grid-template-columns: minmax(560px, 1.15fr) minmax(420px, 0.85fr);
  gap: 22px;
  height: 100vh;
  min-height: 100vh;
  padding: 28px;
}

.public-shell {
  grid-template-columns: minmax(0, 980px);
  justify-content: center;
  height: auto;
}

.lookup-panel,
.database-panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(216, 224, 229, 0.95);
  box-shadow: var(--shadow);
}

.lookup-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow: auto;
  padding: 28px;
}

.database-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 22px;
}

.brand-row,
.panel-heading,
.match-heading,
.breakdown-row,
.rate-line,
.detail-row {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
}

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 8px;
  background: var(--soft-green);
  border: 1px solid #c5dfd5;
}

.mark span {
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  position: relative;
}

.mark span::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-row p,
.panel-heading p,
.empty-state p,
.record-meta,
.confidence-note {
  color: var(--muted);
}

.lookup-form {
  display: grid;
  gap: 8px;
}

label,
.filter-label {
  color: #40515c;
  font-size: 13px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.address-combobox {
  position: relative;
  min-width: 0;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12, 107, 90, 0.16);
}

#addressInput {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  font-size: 16px;
}

.address-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10;
  overflow: auto;
  max-height: 278px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.address-suggestions[hidden] {
  display: none;
}

.address-suggestion {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 11px 13px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.address-suggestion:hover,
.address-suggestion[aria-selected="true"] {
  background: var(--soft-green);
  color: var(--ink);
}

.address-suggestion + .address-suggestion {
  border-top: 1px solid #edf2f4;
}

.address-suggestion strong,
.address-suggestion span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.address-suggestion strong {
  font-size: 14px;
  line-height: 1.25;
}

.address-suggestion span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

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

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-row button,
#exportButton {
  min-height: 36px;
  background: #fff;
  color: var(--accent-dark);
  border-color: #b9d8cf;
  font-size: 13px;
}

.example-row button:hover,
#exportButton:hover {
  background: var(--soft-green);
}

.result-card {
  flex: 0 0 auto;
  display: flex;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: visible;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  width: 100%;
  padding: 30px;
  text-align: center;
}

.empty-state h2 {
  max-width: 460px;
  font-size: 21px;
}

.map-preview {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #cad7df;
  border-radius: 8px;
  background:
    linear-gradient(35deg, transparent 0 44%, rgba(184, 97, 37, 0.14) 45% 53%, transparent 54%),
    linear-gradient(120deg, rgba(49, 92, 150, 0.12), rgba(12, 107, 90, 0.1)),
    #eef4f6;
}

.grid-lines {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 32px, rgba(23, 32, 38, 0.08) 33px),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(23, 32, 38, 0.08) 43px);
}

.route {
  position: absolute;
  height: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(49, 92, 150, 0.22);
  transform-origin: left center;
}

.route-a {
  left: -20px;
  top: 42%;
  width: 115%;
  transform: rotate(-9deg);
}

.route-b {
  left: 38%;
  top: -10px;
  width: 95%;
  transform: rotate(76deg);
}

.pin {
  position: absolute;
  left: 53%;
  top: 42%;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  background: var(--warm);
  border: 4px solid #fff;
  box-shadow: 0 8px 18px rgba(23, 32, 38, 0.18);
  transform: rotate(-45deg);
}

.pin::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #fff;
}

.match-result {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  width: 100%;
}

.match-top {
  padding: 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.match-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.match-heading h2 {
  font-size: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.rate-line {
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.rate-number {
  font-size: clamp(42px, 8vw, 76px);
  line-height: 0.95;
  font-weight: 900;
  color: var(--accent-dark);
}

.rate-label {
  color: var(--muted);
  font-weight: 700;
}

.match-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.detail-block {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.detail-block:last-child {
  border-right: 0;
}

.detail-block span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-block strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.breakdown {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.breakdown h3 {
  margin: 0;
  font-size: 16px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(150px, 230px) minmax(120px, 1fr) minmax(52px, max-content);
  align-items: center;
  gap: 12px;
}

.bar {
  width: 100%;
  min-width: 0;
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebef;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.breakdown-row:nth-of-type(2) .bar span {
  background: var(--blue);
}

.breakdown-row:nth-of-type(3) .bar span {
  background: var(--warm);
}

.breakdown-row:nth-of-type(4) .bar span {
  background: #6d4c9a;
}

.breakdown-row strong {
  min-width: 0;
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.breakdown-row em {
  justify-self: end;
  width: auto;
  color: var(--muted);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.confidence-note {
  margin-top: 6px;
  font-size: 13px;
}

.business-source {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.business-choice-panel {
  display: grid;
  gap: 18px;
  width: 100%;
  padding: 24px;
}

.choice-heading {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.choice-heading h2 {
  font-size: 24px;
}

.choice-heading p {
  color: var(--muted);
  line-height: 1.45;
}

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

.business-choice {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 0;
  padding: 15px;
  border-color: var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.business-choice:hover {
  border-color: #b9d8cf;
  background: var(--soft-green);
}

.business-choice strong,
.business-choice span,
.business-choice em {
  min-width: 0;
  overflow-wrap: anywhere;
}

.business-choice strong {
  font-size: 15px;
}

.business-choice span,
.business-choice em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 22px;
}

.filter-input {
  width: 100%;
  min-height: 42px;
  margin: 8px 0 14px;
  padding: 0 12px;
}

.table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f6;
  color: #41525d;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfcfd;
}

.place-name {
  font-weight: 850;
}

.record-meta {
  margin-top: 3px;
  font-size: 12px;
}

.rate-cell {
  font-weight: 900;
  color: var(--accent-dark);
}

.notice {
  padding: 22px;
  width: 100%;
}

.notice h2 {
  margin-bottom: 8px;
}

.notice p {
  color: var(--muted);
  line-height: 1.5;
}

.address-popup[hidden] {
  display: none;
}

.address-popup {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 38, 0.46);
}

.address-popup__card {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.address-popup__card h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.address-popup__card p {
  color: var(--muted);
  line-height: 1.5;
}

.address-popup__card button {
  width: 100%;
  margin-top: 18px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    padding: 18px;
  }

  .public-shell {
    grid-template-columns: 1fr;
  }

  .lookup-panel,
  .database-panel {
    overflow: visible;
  }

  .table-wrap {
    max-height: 70vh;
  }
}

@media (max-width: 640px) {
  .lookup-panel,
  .database-panel {
    padding: 18px;
  }

  .app-shell {
    overflow-x: hidden;
  }

  .example-row button {
    flex: 1 1 calc(50% - 8px);
    padding: 0 10px;
  }

  .input-row,
  .match-details {
    grid-template-columns: 1fr;
  }

  .address-suggestions {
    max-height: 240px;
  }

  .detail-block {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-block:last-child {
    border-bottom: 0;
  }

  .match-heading,
  .rate-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .breakdown-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .breakdown-row strong {
    flex: none;
    width: auto;
  }

  .breakdown-row .bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .result-card {
    min-height: 360px;
  }
}

.records-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 28px;
}

.records-header,
.records-panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(216, 224, 229, 0.95);
  box-shadow: var(--shadow);
}

.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.back-link {
  color: var(--accent-dark);
  font-weight: 850;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.records-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.65fr) auto;
  gap: 14px;
  align-items: end;
}

.token-form,
.records-filter {
  display: grid;
  gap: 8px;
}

.token-row {
  display: flex;
  gap: 8px;
}

.token-row input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
}

.records-actions {
  display: flex;
  gap: 8px;
}

#clearTokenButton {
  background: #fff;
  color: var(--accent-dark);
  border-color: #b9d8cf;
}

#clearTokenButton:hover {
  background: var(--soft-green);
}

.records-status {
  margin: 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-weight: 750;
}

.records-status[data-tone="ready"] {
  background: var(--soft-green);
  border-color: #c5dfd5;
  color: var(--accent-dark);
}

.records-status[data-tone="error"] {
  background: #fff1ed;
  border-color: #f0c5b7;
  color: #8a3218;
}

.records-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.records-table {
  min-width: 1320px;
}

.records-table td {
  font-size: 13px;
  line-height: 1.35;
}

.records-table td:nth-child(1),
.records-table td:nth-child(2),
.records-table td:nth-child(5),
.records-table td:nth-child(10) {
  overflow-wrap: anywhere;
}

.time-date {
  display: block;
  font-size: 14px;
}

.time-clock {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.table-subtle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.empty-table {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .records-shell {
    padding: 18px;
  }

  .records-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .records-toolbar {
    grid-template-columns: 1fr;
  }

  .records-actions {
    flex-wrap: wrap;
  }
}
