:root {
  --tl-blue: #0080FF;
  --tl-blue-hover: #0066cc;
  --tl-bg: #000000;
  --tl-text: #ffffff;
  --tl-muted: #9ca3af;
  --tl-muted-dark: #6b7280;
  --tl-label: #d1d5db;
  --tl-card: #111827;
  --tl-card-border: #1f2937;
  --tl-input-bg: #1f2937;
  --tl-input-border: #374151;
  --tl-accent: #f97316;
  --tl-error-bg: #7f1d1d;
  --tl-error-border: #b91c1c;
  --tl-error-text: #fca5a5;
  --radius: 0.5rem;
  --radius-panel: 0.75rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--tl-text);
  background-color: var(--tl-bg);
  min-height: 100vh;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #121212;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--tl-blue);
}

.transloop-blue {
  color: var(--tl-blue);
}

.nav {
  background-color: var(--tl-bg);
  border-bottom: 1px solid var(--tl-card-border);
  margin-bottom: 2rem;
}

.nav-inner {
  max-width: 67.5rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  padding: 1.5rem 0;
  text-decoration: none;
  color: inherit;
}

.brand-link img {
  height: 40px;
}

.brand-badge {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  color: var(--tl-blue);
  align-self: flex-start;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-contact {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tl-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}

.nav-contact:hover {
  color: var(--tl-text);
}

.badge-preview {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tl-muted);
  border: 1px solid var(--tl-input-border);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

.shell {
  max-width: 67.5rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.shell-narrow {
  max-width: 28rem;
}

.page-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
}

.page-header {
  text-align: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.page-header .subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--tl-muted);
}

/* ── Card ── */

.card {
  background: var(--tl-card);
  border: 1px solid var(--tl-card-border);
  border-radius: var(--radius-panel);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  padding: 2rem 2rem 1.5rem;
}

.card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tl-text);
}

.card .subtitle {
  margin: 0 0 1.75rem;
  color: var(--tl-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* ── Form primitives ── */

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tl-muted);
  letter-spacing: 0.01em;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  margin-bottom: 0.375rem;
}

input,
select,
textarea {
  font: inherit;
  font-size: 0.875rem;
  min-height: 3rem;
  padding: 0.625rem 0.75rem;
  background: var(--tl-input-bg);
  border: 1px solid var(--tl-input-border);
  border-radius: var(--radius);
  color: var(--tl-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--tl-muted-dark);
}

input::placeholder {
  color: var(--tl-muted-dark);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--tl-blue);
  box-shadow: 0 0 0 2px rgba(0, 128, 255, 0.25);
}

select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* ── Required field markers ── */

.label-text {
  display: inline;
}

/* ── Form grid (login + generic) ── */

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* ── Lane section: origin → destination ── */

.lane-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.lane-block {
  border: 1px solid var(--tl-input-border);
  border-radius: var(--radius-panel);
  padding: 1.5rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 0.2s ease;
}

.lane-block:focus-within {
  border-color: var(--tl-muted-dark);
}

.lane-block legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--tl-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.25rem;
}

.lane-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lane-dot--origin {
  background: var(--tl-blue);
}

.lane-dot--dest {
  background: var(--tl-accent);
}

.lane-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.lane-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--tl-muted-dark);
}

.lane-arrow svg {
  width: 18px;
  height: 18px;
}

/* ── Load details ── */

.load-details {
  margin: 0;
}

/* ── Actions ── */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Buttons ── */

.btn {
  font: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.6875rem 1.25rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--tl-blue-hover);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background-color: #005bb5;
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-primary:focus-visible {
  outline: 2px solid rgba(0, 128, 255, 0.5);
  outline-offset: 2px;
}

.btn-neutral {
  background: transparent;
  border-color: var(--tl-input-border);
  color: var(--tl-label);
}

.btn-neutral:hover:not(:disabled) {
  border-color: var(--tl-muted-dark);
  color: var(--tl-text);
}

.btn-cta {
  position: relative;
  padding: 0.75rem 1.75rem;
  min-width: 9.5rem;
}

.btn-small {
  min-height: 2.25rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* HTMX loading state */

.btn-spinner {
  display: none;
}

.btn-cta.htmx-request .btn-label {
  visibility: hidden;
}

.btn-cta.htmx-request .btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary.htmx-request {
  pointer-events: none;
}

/* ── Utilities ── */

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

.no-margin {
  margin: 0;
}

.mt-4 {
  margin-top: 1rem;
}

.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;
}

/* ── Result panel ── */

#quote-result:empty {
  display: none;
}

.quote-result-wrap {
  margin-top: 1.5rem;
}

.result-divider {
  border-top: 1px solid var(--tl-card-border);
  margin-bottom: 1.5rem;
}

.result-panel {
  border-radius: var(--radius-panel);
  padding: 1.5rem;
}

.rate-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-panel .quote-id {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tl-muted);
}

.result-panel.rate {
  background: rgba(0, 128, 255, 0.04);
  border: 1px solid rgba(0, 128, 255, 0.15);
}

.result-panel.rate h2 {
  color: var(--tl-blue);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
}

.rate-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.rate-summary-heading {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rate-disclaimer {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tl-muted);
  line-height: 1.4;
}

.rate-value {
  color: var(--tl-text);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-details {
  margin: 0;
  padding-top: 0.875rem;
  border-top: 1px solid rgba(0, 128, 255, 0.12);
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.25rem;
  row-gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.preview-details dt {
  margin: 0;
  color: var(--tl-muted);
  font-weight: 500;
}

.preview-details dd {
  margin: 0;
  color: var(--tl-text);
}

.field-hint {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
  color: var(--tl-muted-dark);
}

.field-error {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
  color: var(--tl-error-text);
}

.field-error[hidden] {
  display: none;
}

.field--invalid input,
.field--invalid select {
  border-color: var(--tl-error-border);
}

/* ── Error banner ── */

.error-banner {
  background: var(--tl-error-bg);
  border: 1px solid var(--tl-error-border);
  color: var(--tl-error-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

/* ── Nav links (in-page navigation) ── */

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
  justify-content: center;
}

.nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tl-muted);
  text-decoration: none;
  letter-spacing: 0.01em;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  color: var(--tl-text);
}

.nav-link--active {
  color: var(--tl-text);
  border-bottom-color: var(--tl-blue);
}

/* ── Admin / data tables ── */

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.admin-filter-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.admin-filter-field {
  min-width: 14rem;
}

.quote-history-search-field {
  width: min(100%, 30rem);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tl-label);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tl-card-border);
  background: rgba(255, 255, 255, 0.02);
}

.quote-history-sort-form {
  margin: 0;
}

.quote-history-sort-button {
  font: inherit;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.quote-history-sort-button:hover {
  color: var(--tl-text);
}

.quote-history-sort-button:focus-visible {
  outline: 2px solid rgba(0, 128, 255, 0.5);
  outline-offset: 2px;
}

.quote-history-sort-button--active {
  color: var(--tl-text);
}

.quote-history-sort-indicator {
  font-size: 0.6875rem;
}

.data-table-actions-head {
  width: 1%;
}

.data-table tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--tl-card-border);
  color: var(--tl-text);
  vertical-align: middle;
}

.data-table-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table-empty {
  text-align: center;
  color: var(--tl-muted);
  padding: 1.5rem 1rem;
  font-style: italic;
}

/* ── Data-table cell utilities (reusable across admin tables) ── */

.data-table thead th.data-table-num,
.data-table tbody td.data-table-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody td.data-table-num--prominent {
  font-weight: 600;
  color: var(--tl-text);
}

.data-table tbody td.data-table-cell--muted {
  color: var(--tl-muted);
}

.data-table tbody td.data-table-cell--muted-soft {
  color: var(--tl-label);
}

.quote-history-sort-button--align-end {
  justify-content: flex-end;
  width: 100%;
}

/* ── Lane cell (used in quote-history table and quote-detail subtitle) ── */

.lane-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lane-cell-city {
  white-space: nowrap;
}

.lane-arrow {
  color: var(--tl-muted);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ── Quote-history result count line ── */

.quote-history-count {
  margin: 0;
  color: var(--tl-muted);
  font-size: 0.8125rem;
}

/* ── Loading dim during HTMX swaps (search input + sort form point hx-indicator here) ── */

#quote-history-table.htmx-request {
  opacity: 0.6;
  transition: opacity 0.15s ease-out;
}

.status-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1;
}

.status-badge--inactive {
  color: var(--tl-muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--tl-card-border);
}

.status-badge--active {
  color: var(--tl-blue);
  background: rgba(0, 128, 255, 0.08);
  border-color: rgba(0, 128, 255, 0.25);
}

.status-badge--pending {
  color: var(--tl-label);
  background: rgba(209, 213, 219, 0.06);
  border-color: var(--tl-input-border);
}

/* ── Footer ── */

.footer {
  margin-top: 4rem;
  border-top: 1px solid var(--tl-card-border);
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--tl-muted-dark);
  font-size: 0.75rem;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--tl-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer a:hover {
  color: var(--tl-blue);
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .nav-inner {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding-bottom: 0.75rem;
  }

  .brand-link {
    padding: 1rem 0 0.5rem;
  }

  .nav-links {
    order: 3;
    flex: 1 0 100%;
    justify-content: flex-start;
    gap: 1rem;
  }

  .nav-right {
    margin-left: auto;
  }

  .lane-section {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .lane-arrow {
    margin: 0;
    transform: rotate(90deg);
  }

  .lane-fields {
    grid-template-columns: 1fr;
  }

  .admin-filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-filter-field {
    min-width: 0;
  }

  .nav-links {
    gap: 0.875rem;
  }

  .card {
    padding: 1.5rem 1rem;
  }

  .rate-summary {
    flex-direction: column;
    gap: 0.5rem;
  }

  .rate-value {
    font-size: 1.625rem;
  }

  .preview-details {
    grid-template-columns: 1fr;
    row-gap: 0.375rem;
  }

  .preview-details dd {
    margin-bottom: 0.75rem;
  }

}

@media (max-width: 480px) {
  .nav-right {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .result-panel {
    padding: 1.25rem 1rem;
  }
}

/* ── Required field marker ── */

.required-star {
  color: var(--tl-blue);
  margin-left: 0.125rem;
}

/* ── Table toolbar (reusable for any admin data-table screen) ── */

.table-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
}

.table-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tl-text);
}

.table-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--tl-muted);
  letter-spacing: 0.02em;
}

.table-toolbar-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.table-toolbar .admin-filter-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.table-toolbar .admin-filter-field label {
  margin: 0;
  white-space: nowrap;
}

.table-toolbar .admin-filter-field select {
  min-height: 2.5rem;
  padding-top: 0.4375rem;
  padding-bottom: 0.4375rem;
}

/* ── Admin dialog (reusable for any admin add/edit) ── */

.admin-dialog {
  background: var(--tl-card);
  color: var(--tl-text);
  border: 1px solid var(--tl-card-border);
  border-radius: var(--radius-panel);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  padding: 0;
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.admin-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--tl-card-border);
}

.admin-dialog-heading {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.admin-dialog-heading h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tl-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-dialog-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--tl-muted);
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.admin-dialog-close:hover {
  color: var(--tl-text);
  border-color: var(--tl-input-border);
  background: rgba(255, 255, 255, 0.04);
}

.admin-dialog-close:focus-visible {
  outline: 2px solid rgba(0, 128, 255, 0.5);
  outline-offset: 2px;
}

.admin-dialog-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 14rem);
  overflow-y: auto;
}

.admin-dialog-body .error-banner {
  margin-bottom: 0;
}

.admin-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--tl-card-border);
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  bottom: 0;
}

/* ── Toast (reusable for any HX-Trigger success message) ── */

.toast-region {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--tl-card);
  border: 1px solid rgba(0, 128, 255, 0.4);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--tl-text);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success .toast-icon {
  color: var(--tl-blue);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

/* ── Responsive overrides for table toolbar + admin dialog ── */

@media (max-width: 768px) {
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-toolbar-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .table-toolbar .admin-filter-field {
    flex-direction: column;
    align-items: stretch;
  }

  .table-toolbar .admin-filter-field label {
    margin-bottom: 0.375rem;
  }

  .admin-dialog {
    width: calc(100vw - 1.5rem);
  }

  .admin-dialog-footer {
    flex-direction: column-reverse;
  }

  .admin-dialog-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .toast-region {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
  }

  .toast {
    width: 100%;
    justify-content: flex-start;
  }
}
