:root {
  --ink: #1a1210;
  --ink-muted: #6b5a54;
  --paper: #faf6f3;
  --surface: #ffffff;
  --line: #eadfd8;
  --primary: #c62828;
  --primary-dark: #9a1c1c;
  --primary-soft: #fdecea;
  --accent: #ffb300;
  --accent-soft: #fff6e0;
  --success: #2e7d32;
  --shadow: 0 18px 40px rgba(40, 18, 12, 0.08);
  --shadow-lg: 0 28px 60px rgba(40, 18, 12, 0.12);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  padding-bottom: var(--safe-bottom);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 28px;
  padding-top: var(--safe-top);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 243, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.25);
  flex-shrink: 0;
  background: #fff;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  letter-spacing: -0.03em;
  min-width: 0;
}

.brand-copy strong {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-copy span {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.nav-link {
  position: relative;
  height: 40px;
  border: 0;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover { background: var(--primary-soft); color: var(--primary); }
.nav-link.is-active {
  background: var(--primary);
  color: #fff;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 100%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.18);
}

main {
  flex: 1;
  padding: 36px 0 40px;
}

.page-view { display: none; animation: view-in 0.28s ease both; }
.page-view.is-visible { display: block; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(260px, 0.85fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 36px;
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro-badge img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.eyebrow-line {
  display: inline-block;
  width: 20px;
  height: 2px;
  background: var(--accent);
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 800;
}

h1 em {
  color: var(--primary);
  font-style: normal;
}

.hero-description {
  max-width: 440px;
  margin-bottom: 22px;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.6;
}

.origin-summary {
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(40, 18, 12, 0.04);
}

.origin-icon, .instruction-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.origin-icon svg, .instruction-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.origin-summary > div:nth-child(2) {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
  flex: 1;
}

.label {
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.origin-summary strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button, .link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.text-button { padding: 6px 0 6px 8px; }

.rate-card {
  position: relative;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(198, 40, 40, 0.28);
}

.rate-card::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  right: -50px;
  top: -50px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 100%;
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.04);
}

.rate-card-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
}

.mini-spark { font-size: 14px; }

.rate-value {
  position: relative;
  z-index: 1;
  margin: 14px 0 8px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.rate-value small {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.8;
}

.rate-card p {
  position: relative;
  z-index: 1;
  max-width: 200px;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  line-height: 1.45;
}

.card-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 22px;
  margin-bottom: 28px;
}

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

.section-heading h2 {
  margin: 6px 0 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.step-badge {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #9a6b00;
  font-size: 10px;
  font-weight: 800;
}

.calculator-card { padding: 24px; }

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.input-with-icon {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-muted);
  stroke-width: 1.8;
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffcfa;
  color: var(--ink);
  font-size: 14px;
  outline: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-icon input:focus {
  border-color: #e57373;
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.12);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(198, 40, 40, 0.25);
  transition: background 0.2s, transform 0.15s;
}

.primary-button:hover { background: var(--primary-dark); }
.primary-button:active { transform: scale(0.98); }
.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.soft-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.2s;
}

.rate-card .soft-button:hover { background: rgba(255, 255, 255, 0.28); }

.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s;
}

.outline-button:hover {
  border-color: #e0b4b0;
  color: var(--primary);
}

.map-instruction {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

.map-instruction p {
  margin: 0;
  flex: 1;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
}

.map-instruction strong { font-weight: 800; }

.map-wrap {
  position: relative;
  height: 340px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f0ebe7;
}

#map { width: 100%; height: 100%; }

.map-overlay-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 18, 16, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.hint-pin {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 450;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(250, 246, 243, 0.82);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.search-feedback {
  min-height: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

.result-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card { padding: 22px; }

.result-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.result-card-head h2 {
  margin: 6px 0 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.result-status {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.price-panel {
  text-align: center;
  padding: 18px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--primary-soft) 0%, #fff 100%);
  border: 1px solid #f5d0cd;
}

.price-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.price-panel strong {
  display: block;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--primary);
  line-height: 1.05;
}

.price-note {
  display: block;
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #fffcfa;
  border: 1px solid var(--line);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #9a6b00;
  font-size: 14px;
  font-weight: 800;
}

.metric small {
  display: block;
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 14px;
  font-weight: 800;
}

.calculation-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  background: #fffcfa;
  border: 1px dashed var(--line);
  font-size: 11px;
  color: var(--ink-muted);
}

.calculation-box strong {
  color: var(--ink);
  font-size: 13px;
}

.confirm-button {
  width: 100%;
  justify-content: center;
  margin: 10px 0 6px;
}

.quick-note {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid #f0e0b8;
}

.note-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1210;
  font-size: 13px;
  font-weight: 800;
}

.quick-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}

.history-card {
  padding: 24px;
  margin-bottom: 20px;
}

.history-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.history-heading h2 {
  margin: 6px 0 0;
  font-size: 20px;
}

.history-count {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.history-description {
  margin-bottom: 16px;
  color: var(--ink-muted);
  font-size: 13px;
}

.history-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.history-tools input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  background: #fffcfa;
}

.history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.history-summary span {
  padding: 7px 11px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.history-group { margin-bottom: 16px; }

.history-group-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-group-head b { color: var(--primary); }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffcfa;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.history-item:hover {
  border-color: #e8b4b0;
  background: var(--primary-soft);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-main strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-main span {
  color: var(--ink-muted);
  font-size: 11px;
}

.history-item-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--primary);
  font-size: 14px;
}

.history-del {
  border: 0;
  background: transparent;
  color: #b4a9a5;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

.history-del:hover { color: var(--primary); }

.history-more {
  width: 100%;
  margin-top: 6px;
}

.history-edited {
  color: var(--accent);
  font-weight: 800;
}

.settings-view { max-width: 960px; margin: 0 auto; }

.settings-intro { margin-bottom: 28px; }

.settings-intro h1 {
  font-size: clamp(28px, 4vw, 40px);
}

.settings-intro > p:last-child {
  max-width: 480px;
  margin-bottom: 0;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.55;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 20px;
}

.settings-card { padding: 26px; }

.settings-number {
  color: #c4b0a8;
  font-size: 12px;
  font-weight: 800;
}

.settings-form { margin-top: 24px; }

.field-group {
  display: block;
  margin-bottom: 18px;
}

.field-group > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-group input,
.field-group textarea,
.field-group select {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #fffcfa;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-group textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.45;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: #e57373;
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.12);
}

.field-group small {
  display: block;
  margin-top: 6px;
  color: var(--ink-muted);
  font-size: 11px;
}

.currency-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffcfa;
  overflow: hidden;
}

.currency-input span {
  padding: 0 0 0 14px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 800;
}

.currency-input input {
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 46px;
}

.currency-input:focus-within {
  border-color: #e57373;
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.12);
}

.currency-input input:focus { box-shadow: none; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  flex-wrap: wrap;
}

.ghost-button {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
}

.ghost-button:hover { color: var(--primary); }

.settings-feedback {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12px;
}

.settings-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-card, .backup-card {
  padding: 20px;
  border-radius: var(--radius-lg);
}

.info-card {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}

.info-card-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--accent);
  font-size: 16px;
}

.info-card h3, .backup-card h3 {
  margin-bottom: 8px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.info-card p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 1.55;
}

.backup-card {
  border: 1px solid var(--line);
  background: #fff;
}

.backup-card .section-kicker { color: #9a6b00; }

.backup-card p {
  margin-bottom: 14px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.backup-card .soft-button {
  background: var(--primary-soft);
  color: var(--primary);
}

.backup-card .soft-button:hover { background: #f8d5d2; }

.file-button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.fee-edit {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
}

.fee-edit label {
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.fee-edit-row .currency-input { flex: 1; }
.fee-edit-row input { width: 100%; }

.fee-edit small {
  color: var(--ink-muted);
  font-size: 10px;
}

.fee-edit .soft-button {
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
}

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(20, 10, 8, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] { display: none !important; }

.leaflet-div-icon {
  background: transparent !important;
  border: 0 !important;
}

.psb-pin {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin-color, #c62828);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 800;
}

.psb-pin span {
  transform: rotate(45deg);
}

@media (max-width: 900px) {
  .app-shell { padding: 0 18px; }
  .hero-grid { gap: 20px; }
  .workspace-grid,
  .settings-grid { grid-template-columns: 1fr; }
  .result-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .quick-note { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0 14px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .topbar {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
  }

  .brand-logo { width: 40px; height: 40px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy span { font-size: 10px; }

  .topnav {
    order: 3;
    width: 100%;
    height: auto;
    margin: 0;
    gap: 6px;
  }

  .nav-link {
    flex: 1;
    height: 40px;
    font-size: 12px;
    text-align: center;
  }

  .topbar-status {
    margin-left: auto;
    font-size: 10px;
  }

  main { padding: 22px 0 28px; }

  .hero-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 22px;
  }

  h1 { font-size: 30px; }
  .hero-description { font-size: 14px; margin-bottom: 16px; }

  .origin-summary {
    flex-wrap: wrap;
    padding: 12px;
  }

  .origin-summary strong {
    white-space: normal;
    font-size: 12px;
  }

  .rate-card { padding: 18px; }
  .rate-value { font-size: 32px; }

  .calculator-card,
  .settings-card,
  .history-card,
  .result-card {
    padding: 16px;
  }

  .search-row { flex-direction: column; }
  .search-row .primary-button { width: 100%; }

  .map-instruction {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .map-instruction p { min-width: calc(100% - 50px); }

  .link-button {
    margin-left: 0;
    width: 100%;
    text-align: left;
    padding: 4px 0 0 46px;
  }

  .map-wrap { height: 280px; }

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

  .price-panel strong { font-size: 36px; }

  .history-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .history-item-main { width: 100%; }
  .history-item-main strong { white-space: normal; }

  .history-item-value {
    width: 100%;
    justify-content: space-between;
    padding-left: 0;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .primary-button,
  .form-actions .ghost-button {
    width: 100%;
  }

  .footer {
    flex-direction: column;
    text-align: center;
    gap: 6px;
    padding-bottom: 20px;
  }

  .step-badge { display: none; }

  .confirm-button {
    min-height: 52px;
    font-size: 15px;
  }
}

@media (max-width: 380px) {
  h1 { font-size: 26px; }
  .price-panel strong { font-size: 32px; }
  .metrics-grid { grid-template-columns: 1fr; }
}

/* ---- Tipo de corrida (só ida / ida e volta) ---- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.return-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: #f3ebe6;
  border: 1px solid var(--line);
}

.return-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .12s ease;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.return-mode-btn:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
}

.return-mode-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.return-mode-btn.is-active {
  background: #fff;
  color: var(--ink);
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(198, 40, 40, 0.14);
}

.return-mode-btn[data-return="1"].is-active {
  background: linear-gradient(145deg, #fff8e6 0%, #fff 55%);
  border-color: #e6a000;
  box-shadow: 0 4px 16px rgba(230, 160, 0, 0.22);
  color: #6b4a00;
}

.return-mode-btn[data-return="1"].is-active .mode-icon {
  background: #ffb300;
  color: #3d2a00;
}

.mode-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #ebe0d8;
  color: var(--ink-muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  transition: background .18s, color .18s;
}

.return-mode-btn.is-active .mode-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.mode-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.mode-copy strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.mode-copy small {
  font-size: 11px;
  opacity: 0.85;
  line-height: 1.3;
}

/* Destaque do valor quando é ida e volta */
.price-panel {
  position: relative;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.price-panel.is-roundtrip {
  background: linear-gradient(180deg, #fff6e0 0%, #fffaf0 55%, #fff 100%);
  border-color: #f0c040;
  box-shadow: 0 8px 24px rgba(230, 160, 0, 0.12);
}

.price-panel.is-roundtrip .price-label {
  color: #9a6b00;
}

.price-panel.is-roundtrip strong {
  color: #b36b00;
}

.price-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffb300;
  color: #3d2a00;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(230, 160, 0, 0.35);
}

.price-badge::before {
  content: "⇄";
  font-size: 12px;
}

.history-roundtrip {
  display: inline-block;
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fff6e0;
  color: #9a6b00;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.rate-value {
  font-size: 28px !important;
}
.rate-value small { font-size: 13px; }

.tiers-block { margin-bottom: 22px; }
.tiers-help {
  margin: 6px 0 12px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}
.tiers-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffcfa;
}
.tiers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tiers-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
}
.tiers-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tiers-table tr:last-child td { border-bottom: 0; }
.tiers-table input {
  width: 100%;
  min-width: 72px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}
.tiers-table input:focus {
  outline: 0;
  border-color: #e57373;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, .12);
}
.tiers-remove {
  border: 0;
  background: transparent;
  color: #b4a9a5;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}
.tiers-remove:hover { color: var(--primary); }
.tiers-add {
  margin-top: 10px;
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}
.extra-km-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}
@media (max-width: 640px) {
  .extra-km-grid { grid-template-columns: 1fr; }
  .tiers-table th, .tiers-table td { padding: 8px 6px; }
  .tiers-table input { min-width: 58px; font-size: 12px; }
}


/* ---- Tabela de faixas, retorno e detalhe do preço ---- */
.return-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffcfa;
  cursor: pointer;
  user-select: none;
}
.return-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.return-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.return-toggle-text strong {
  font-size: 13px;
  font-weight: 800;
}
.return-toggle-text small {
  color: var(--ink-muted);
  font-size: 11px;
}
.return-toggle-ui { display: none; }

.price-breakdown {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid #f5d0cd;
}
.breakdown-head {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.price-breakdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.price-breakdown li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  font-size: 12px;
}
.bd-main {
  font-weight: 800;
  color: var(--ink);
}
.bd-detail {
  grid-column: 1;
  color: var(--ink-muted);
  font-size: 11px;
}
.bd-value {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.tiers-block { margin-bottom: 18px; }
.tiers-block > span,
.tiers-help {
  display: block;
}
.tiers-help {
  margin: 6px 0 12px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}
.tiers-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffcfa;
}
.tiers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tiers-table th {
  padding: 10px 8px;
  text-align: left;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid #f5d0cd;
}
.tiers-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tiers-table input {
  width: 100%;
  min-width: 64px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}
.tiers-table input:focus {
  outline: 0;
  border-color: #e57373;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}
.tiers-remove {
  border: 0;
  background: transparent;
  color: #b4a9a5;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}
.tiers-remove:hover { color: var(--primary); }
.tiers-add {
  margin-top: 10px;
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}
.extra-km-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}
@media (max-width: 640px) {
  .extra-km-grid { grid-template-columns: 1fr; }
  .price-breakdown li { grid-template-columns: 1fr; }
  .bd-value { grid-row: auto; }
}


/* ========== LAYOUT OPERACIONAL (rápido) ========== */
main { padding: 16px 0 28px; }

.ops-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(40, 18, 12, 0.04);
}

.origin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.origin-chip .label {
  flex-shrink: 0;
}

.origin-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  min-width: 0;
}

.ops-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ops-actions .soft-button {
  background: var(--primary-soft);
  color: var(--primary);
  min-height: 36px;
  font-size: 12px;
}

.ops-faturamento {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #7a5800;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.workspace-ops {
  margin-bottom: 16px;
}

.workspace-ops .calculator-card {
  padding: 16px;
}

.workspace-ops .section-heading { display: none; }

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}

.map-toolbar .link-button {
  padding: 0;
  font-size: 12px;
}

.map-toolbar-hint {
  color: var(--ink-muted);
  font-size: 11px;
}

.map-wrap-tall {
  height: min(52vh, 480px);
  min-height: 320px;
}

.workspace-ops .result-card {
  padding: 16px;
  position: sticky;
  top: 80px;
}

.workspace-ops .result-card-head h2 {
  font-size: 16px;
  margin-top: 4px;
}

.workspace-ops .price-panel {
  padding: 14px 10px;
  margin-bottom: 10px;
}

.workspace-ops .price-panel strong {
  font-size: 36px;
}

.workspace-ops .history-card {
  padding: 16px;
}

.workspace-ops .history-description { display: none; }

.history-heading h2 {
  font-size: 16px;
}

/* hide old hero if any residual */
.hero-grid, .intro-badge, .hero-description, .rate-card, .quick-note { display: none !important; }

@media (max-width: 900px) {
  .map-wrap-tall {
    height: 42vh;
    min-height: 260px;
  }
  .workspace-ops .result-card {
    position: static;
  }
}

@media (max-width: 640px) {
  main { padding: 12px 0 20px; }
  .ops-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }
  .ops-actions {
    justify-content: space-between;
  }
  .map-wrap-tall {
    height: 38vh;
    min-height: 240px;
  }
  .search-row { flex-direction: column; }
  .search-row .primary-button { width: 100%; }
}

/* Compact return mode on small screens */
@media (max-width: 420px) {
  .return-mode {
    gap: 6px;
    padding: 5px;
  }
  .return-mode-btn {
    padding: 10px 8px;
    gap: 8px;
  }
  .mode-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
    border-radius: 8px;
  }
  .mode-copy strong {
    font-size: 12px;
  }
  .mode-copy small {
    font-size: 10px;
  }
}

/* ---- Status de entrega ---- */
.history-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.status-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.status-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.status-chip:hover:not(.is-active) {
  border-color: #e0c8c4;
  color: var(--ink);
}

.history-summary .sum-pendente {
  background: #fff6e0 !important;
  color: #9a6b00 !important;
}

.history-summary .sum-rota {
  background: #e8f1ff !important;
  color: #1a4b9c !important;
}

.history-item {
  align-items: flex-start;
}

.history-item.is-status-pendente {
  border-left: 3px solid #ffb300;
}

.history-item.is-status-em_rota {
  border-left: 3px solid #2f6fed;
}

.history-item.is-status-entregue {
  border-left: 3px solid #2e7d32;
  opacity: 0.88;
}

.history-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  background: #ccc;
}

.history-status-dot.is-amber { background: #ffb300; box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.25); }
.history-status-dot.is-blue { background: #2f6fed; box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.2); }
.history-status-dot.is-green { background: #2e7d32; }

.history-status-label {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.history-status-label.is-amber { background: #fff6e0; color: #9a6b00; }
.history-status-label.is-blue { background: #e8f1ff; color: #1a4b9c; }
.history-status-label.is-green { background: #e8f5e9; color: #1b5e20; }

.history-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.history-price {
  font-size: 15px;
  color: var(--primary);
}

.history-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-advance {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  color: #fff;
  background: #ffb300;
}

.status-advance.is-amber { background: #e6a000; }
.status-advance.is-blue { background: #2f6fed; }
.status-advance:hover { filter: brightness(1.05); }

.status-done-badge {
  font-size: 11px;
  font-weight: 700;
  color: #2e7d32;
  padding: 4px 8px;
}

.history-wa {
  border: 1px solid #25d366;
  background: #e8f8ef;
  color: #128c7e;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.history-wa:hover {
  background: #25d366;
  color: #fff;
}

.history-item-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

/* ---- Tela do cliente (acompanhamento) ---- */
.track-view {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px 40px;
  background: linear-gradient(180deg, #fdecea 0%, var(--paper) 40%);
  display: grid;
  place-items: start center;
}

body.is-track-mode {
  background: var(--paper);
}

.track-card {
  width: 100%;
  max-width: 420px;
  margin-top: 12px;
  padding: 22px 20px 24px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.track-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.track-brand img {
  border-radius: 12px;
}

.track-brand strong {
  display: block;
  font-size: 15px;
}

.track-brand span {
  color: var(--ink-muted);
  font-size: 12px;
}

.track-status-pill {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.track-status-pill.is-amber { background: #fff6e0; color: #9a6b00; }
.track-status-pill.is-blue { background: #e8f1ff; color: #1a4b9c; }
.track-status-pill.is-green { background: #e8f5e9; color: #1b5e20; }

.track-timeline {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.track-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  position: relative;
  color: var(--ink-muted);
}

.track-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 28px;
  bottom: -2px;
  width: 2px;
  background: var(--line);
}

.track-step.is-done:not(:last-child)::before,
.track-step.is-current:not(:last-child)::before {
  background: #c8e6c9;
}

.track-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}

.track-step.is-done .track-dot {
  background: #2e7d32;
  border-color: #2e7d32;
}

.track-step.is-current .track-dot {
  background: #ffb300;
  border-color: #ffb300;
  box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.25);
}

.track-step.is-current {
  color: var(--ink);
}

.track-step.is-done {
  color: #2e7d32;
}

.track-step strong {
  display: block;
  font-size: 14px;
}

.track-step small {
  font-size: 11px;
  opacity: 0.85;
}

.track-details {
  padding: 14px;
  border-radius: 14px;
  background: #fffcfa;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.track-details span {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.track-details strong {
  font-size: 14px;
  line-height: 1.35;
}

.track-details-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.track-note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

@media (max-width: 640px) {
  .history-item-actions {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .history-action-row {
    margin-left: auto;
  }
}

/* Ao vivo no acompanhamento do cliente */
.track-brand {
  position: relative;
}

.track-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #e8f5e9;
  color: #1b5e20;
  align-self: flex-start;
}

.track-live.is-offline {
  background: #f3ebe6;
  color: var(--ink-muted);
}

.track-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2e7d32;
  box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.5);
  animation: livePulse 1.6s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(46, 125, 50, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
}

.track-status-pill.is-pulse {
  animation: statusFlash 0.8s ease;
}

@keyframes statusFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.track-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Motoboy drawer + topbar */
.track-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.track-topbar .track-brand {
  flex: 1;
  margin-bottom: 0;
}

.moto-menu-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.moto-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(320px, 88vw);
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  padding: 16px 12px 24px;
  overflow-y: auto;
}

.moto-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.moto-drawer-head button {
  border: 0;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
}

.moto-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffcfa;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font: inherit;
}

.moto-item.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.moto-item strong {
  font-size: 13px;
  line-height: 1.3;
}

.moto-item small {
  color: var(--ink-muted);
  font-size: 11px;
}

.moto-empty {
  color: var(--ink-muted);
  font-size: 13px;
  padding: 12px;
}

.moto-actions {
  margin-top: 14px;
}

.status-advance-lg {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
}

.status-advance-lg.is-amber { background: #e6a000; }
.status-advance-lg.is-blue { background: #2f6fed; }

#share-motoboy-btn {
  white-space: nowrap;
}

/* ===== Ida e volta — destaque forte (não perde cor) ===== */
.return-mode {
  margin: 0 0 12px;
  padding: 6px;
  background: #efe6df;
  border: 1px solid #e0d2c8;
  border-radius: 16px;
  gap: 6px;
}

.return-mode-btn {
  min-height: 56px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid transparent;
}

.return-mode-btn.is-active {
  background: #fff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 14px rgba(198, 40, 40, 0.16) !important;
  color: var(--ink) !important;
}

.return-mode-btn[data-return="1"].is-active {
  background: linear-gradient(145deg, #ffe9a8 0%, #fff8e6 55%, #fff 100%) !important;
  border-color: #e6a000 !important;
  box-shadow: 0 6px 18px rgba(230, 160, 0, 0.28) !important;
  color: #5c3d00 !important;
}

.return-mode-btn[data-return="1"].is-active .mode-icon {
  background: #ffb300 !important;
  color: #3d2a00 !important;
  transform: scale(1.05);
}

.return-mode-btn[data-return="1"].is-active .mode-copy strong {
  color: #6b4a00 !important;
}

.price-panel {
  transition: background .25s ease, border-color .25s ease, box-shadow .25s ease, transform .2s ease;
}

.price-panel #price-display {
  transition: color .25s ease, transform .2s ease;
}

.price-panel.is-roundtrip {
  background: linear-gradient(180deg, #ffe9a8 0%, #fff6e0 45%, #fffdf5 100%) !important;
  border: 2px solid #e6a000 !important;
  box-shadow: 0 10px 28px rgba(230, 160, 0, 0.22) !important;
}

.price-panel.is-roundtrip .price-label {
  color: #8a5a00 !important;
}

.price-panel.is-roundtrip #price-display,
.price-panel.is-roundtrip strong {
  color: #a65f00 !important;
}

.price-panel.is-roundtrip .price-note {
  color: #8a5a00 !important;
}

.price-badge {
  display: inline-flex !important;
  margin: 10px auto 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: #ffb300 !important;
  color: #3d2a00 !important;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(230, 160, 0, 0.4);
}

.price-badge[hidden] {
  display: none !important;
}

.price-panel.is-roundtrip #price-display {
  animation: pricePop .35s ease;
}

@keyframes pricePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Mobile — toque maior, menos cansaço */
@media (max-width: 640px) {
  .workspace-grid.workspace-ops {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .result-column {
    order: -1; /* resultado sobe no mobile: preço antes do mapa longo */
  }

  .result-card {
    position: sticky;
    top: 8px;
    z-index: 5;
  }

  .return-mode-btn {
    min-height: 64px;
    padding: 14px 10px;
  }

  .mode-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .mode-copy strong {
    font-size: 14px;
  }

  .mode-copy small {
    font-size: 11px;
  }

  .workspace-ops .price-panel strong,
  .price-panel #price-display {
    font-size: 40px !important;
  }

  .confirm-button {
    min-height: 52px;
    font-size: 16px;
  }

  .primary-button {
    min-height: 48px;
  }

  .history-action-row {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .status-advance {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .history-wa {
    min-height: 36px;
    min-width: 40px;
  }

  .ops-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .map-wrap-tall {
    height: 34vh;
    min-height: 220px;
  }
}

@media (max-width: 380px) {
  .return-mode {
    grid-template-columns: 1fr 1fr;
  }
  .mode-copy small {
    display: none;
  }
}

/* Link motoboy bem visível */
.moto-share-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #25d366;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

.moto-share-btn:hover {
  filter: brightness(1.05);
}

.moto-share-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e8f8ef 0%, #f0fff6 100%);
  border: 1px solid #b8ebc8;
}

.moto-share-banner strong {
  display: block;
  font-size: 13px;
  color: #0b6b3a;
}

.moto-share-banner span {
  font-size: 12px;
  color: #2f6b4a;
}

@media (max-width: 640px) {
  .moto-share-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .moto-share-banner .moto-share-btn {
    width: 100%;
    min-height: 48px;
  }
}

/* Fila do motoboy — logo abaixo do nome */
.moto-queue {
  margin: 0 0 14px;
}

.moto-queue-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #c8e0d0;
  background: linear-gradient(180deg, #f3fbf6 0%, #fff 100%);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
}

.moto-queue-toggle.is-open {
  border-color: #25d366;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.18);
}

.moto-queue-toggle-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.moto-queue-toggle-main strong {
  font-size: 14px;
  font-weight: 800;
}

.moto-queue-toggle-main small {
  font-size: 11px;
  color: var(--ink-muted);
}

.moto-queue-count {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #25d366;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.moto-queue-chevron {
  font-size: 14px;
  color: var(--ink-muted);
  transition: transform .2s ease;
}

.moto-queue-toggle.is-open .moto-queue-chevron {
  transform: rotate(180deg);
}

.moto-queue-panel {
  margin-top: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffcfa;
  max-height: 42vh;
  overflow-y: auto;
}

/* Código do pedido — fácil para o motoboy */
.history-code,
.track-code {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 8px;
  background: #1a1210;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-family: ui-monospace, monospace;
}

.track-code {
  font-size: 18px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #c62828;
}

.track-code-row {
  margin-bottom: 10px;
}

.track-code-row span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.moto-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Motoboy: tela fixa, sem rolar o fundo */
body.is-track-mode {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
}

.track-view {
  position: fixed;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #fdecea 0%, var(--paper) 36%);
}

.track-view .track-card {
  max-width: 440px;
  margin: 0 auto;
  max-height: calc(100dvh - 24px);
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.track-view .moto-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, #fff 28%);
  padding-top: 10px;
  margin-top: auto;
}

.track-view .status-advance-lg {
  min-height: 54px;
  font-size: 16px;
}

/* Status do banco nas configurações */
#db-status-card.is-online {
  background: linear-gradient(145deg, #e8f5e9 0%, #fff 70%);
  border: 1px solid #a5d6a7;
  color: #1b5e20;
}
#db-status-card.is-online h3 { color: #1b5e20; }
#db-status-card.is-offline {
  background: linear-gradient(145deg, #fdecea 0%, #fff 70%);
  border: 1px solid #f5c6c2;
}
.db-status-meta {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.db-status-meta strong {
  display: inline-block;
  min-width: 72px;
  color: var(--ink-muted);
  font-weight: 700;
}
.db-config-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.db-config-form .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-feedback.is-success {
  color: #1b5e20;
  font-size: 13px;
  margin-top: 8px;
}
#topbar-db-status .status-dot {
  background: #b4a9a5;
}

/* Mobile — tela principal mais ágil (desktop intacto) */
@media (max-width: 640px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
  }

  .ops-bar {
    position: sticky;
    top: 56px;
    z-index: 15;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .history-card {
    padding: 14px 12px;
  }

  .history-item {
    padding: 12px;
    gap: 10px;
  }

  .history-item-actions {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .history-action-row {
    gap: 8px;
  }

  .status-advance {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 13px;
  }

  .history-wa {
    min-height: 40px;
    min-width: 44px;
    font-size: 12px;
  }

  .moto-share-banner {
    padding: 12px;
  }

  .status-chip {
    min-height: 36px;
    padding: 8px 12px;
  }

  .confirm-button,
  .primary-button {
    min-height: 52px;
    font-size: 16px;
    border-radius: 14px;
  }

  .calculator-card {
    padding: 14px 12px;
  }

  .result-card {
    padding: 14px 12px;
  }
}

/* Links rápidos (configurações) */
.quick-links-card {
  border: 1px solid #c8e0d0;
  background: linear-gradient(180deg, #f3fbf6 0%, #fff 100%);
}
.quick-link-block {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quick-link-block label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quick-link-block input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  background: #fff;
}
.quick-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-link-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #0b6b3a;
  min-height: 1.2em;
}

.cliente-lookup label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink-muted);
}
.cliente-lookup-row {
  display: flex;
  gap: 8px;
}
.cliente-lookup-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Banner de alertas */
.notify-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, #fff6e0, #fff);
  border-bottom: 1px solid #f0c040;
  flex-wrap: wrap;
}
.notify-banner.is-visible,
.notify-banner:not([hidden]) {
  display: flex;
}
.notify-banner[hidden] {
  display: none !important;
}
.notify-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.notify-banner-copy strong {
  font-size: 13px;
  color: #6b4a00;
}
.notify-banner-copy span {
  font-size: 12px;
  color: var(--ink-muted);
}
.notify-banner .primary-button {
  min-height: 40px;
  padding: 8px 14px;
  white-space: nowrap;
  background: #e6a000;
  border: 0;
}
@media (max-width: 640px) {
  .notify-banner {
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .notify-banner .primary-button {
    width: 100%;
  }
}
.track-notify-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff6e0;
  border: 1px solid #f0c040;
  font-size: 12px;
  color: #6b4a00;
}
.track-notify-strip .soft-button {
  white-space: nowrap;
  background: #ffb300;
  color: #3d2a00;
  border: 0;
  font-weight: 800;
}

/* Barra de instalar app */
.install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #e8f5e9;
  border-bottom: 1px solid #81c784;
  font-size: 13px;
  color: #1b5e20;
}
.install-bar .soft-button {
  white-space: nowrap;
  background: #2e7d32;
  color: #fff;
  border: 0;
  font-weight: 800;
}
.install-bar .soft-button[hidden] { display: none; }

/* Ações de instalação e alertas no painel dedicado do entregador */
.track-notify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.track-notify-actions .soft-button { min-height: 42px; }
@media (max-width: 560px) {
  .track-notify-strip { align-items: stretch; }
  .track-notify-actions { width: 100%; }
  .track-notify-actions .soft-button { flex: 1 1 145px; }
}

/* Zona de ações destrutivas no painel de administração */
.danger-zone-card {
  border: 1px solid #e9b0ac;
  background: #fff8f7;
}
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: #b71c1c;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.danger-button:hover { background: #8e1515; }
.danger-button:disabled { opacity: .6; cursor: wait; }
.danger-zone-card .settings-feedback { margin-bottom: 0; }

.history-print{border:1px solid #cbd5e1;background:#fff;color:#334155;border-radius:8px;padding:7px 9px;font-weight:700;cursor:pointer;font-size:12px}.history-print:hover{background:#f1f5f9}
