:root {
  --bg: #0b1220;
  --bg-soft: #101a2f;
  --surface: #13213a;
  --surface-2: #182945;
  --border: #31507a;
  --text: #f8fbff;
  --muted: #b4c4dd;
  --primary: #ff8a1a;
  --primary-soft: rgba(255, 138, 26, 0.16);
  --success: #32d074;
  --danger: #ef4444;
  --warning: #f5b746;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --safe-top: max(10px, env(safe-area-inset-top));
  --safe-bottom: max(22px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  font-family: 'Chivo', system-ui, sans-serif;
}
body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
  color: inherit;
  background: none;
}
img { max-width: 100%; display: block; }

.app-shell {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at top right, rgba(255,138,26,0.12), transparent 30%),
    linear-gradient(180deg, #101a2f, #08101d 58%);
}
.mobile-frame {
  width: min(100%, 460px);
  min-height: 100dvh;
  background: transparent;
  position: relative;
}
.page {
  padding: 18px 16px calc(102px + var(--safe-bottom));
}
.page-tight {
  padding: 0 0 calc(88px + var(--safe-bottom));
}
.header {
  position: sticky;
  top: 0;
  z-index: 12;
  background: rgba(11, 18, 32, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(49, 80, 122, 0.7);
  padding: calc(12px + var(--safe-top)) 16px 16px;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-title {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.header-subtitle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}
.header-grow { flex: 1; }
.icon-btn {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: none;
}
.icon-btn.round { border-radius: 999px; }
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.card {
  background: rgba(19, 33, 58, 0.98);
  border: 2px solid rgba(63, 101, 153, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric-card {
  padding: 16px;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d5e0f1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}
.metric-value.primary { color: var(--primary); }
.metric-value.success { color: var(--success); }
.muted { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(255,255,255,0.08);
}
.badge.primary { color: var(--primary); background: rgba(249,115,22,0.12); border-color: rgba(249,115,22,0.24); }
.badge.success { color: var(--success); background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.24); }
.badge.warning { color: #fbbf24; background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.24); }
.badge.slate { color: var(--text); background: rgba(51,65,85,0.65); }
.section-title {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.route-card,
.pipeline-card,
.detail-card {
  background: rgba(19, 33, 58, 0.98);
  border: 2px solid rgba(63, 101, 153, 0.72);
  border-radius: 14px;
}
.route-card {
  display: flex;
  align-items: stretch;
  min-height: 88px;
  overflow: hidden;
  text-align: left;
  width: 100%;
  color: var(--text);
  background: rgba(19, 33, 58, 0.98);
}
.route-accent {
  width: 5px;
  background: var(--primary);
}
.route-content {
  display: flex;
  gap: 14px;
  flex: 1;
  padding: 14px;
  align-items: center;
}
.route-time {
  min-width: 70px;
  padding-right: 12px;
  border-right: 2px solid var(--border);
}
.route-time strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  line-height: 1;
}
.route-body { min-width: 0; flex: 1; }
.route-title {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.route-sub {
  margin-top: 6px;
  color: #d7e3f6;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-tabs {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}
.pipeline-tabs::-webkit-scrollbar { display: none; }
.pipeline-tab {
  padding: 14px 0 12px;
  color: var(--muted);
  background: transparent;
  border-bottom: 4px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}
.pipeline-tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.pipeline-card {
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.pipeline-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary);
  opacity: 0;
}
.pipeline-card.highlight::before { opacity: 1; }
.pipeline-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.pipeline-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}
.pipeline-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  min-height: 50px;
  border-radius: 12px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-soft { background: #334155; color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 2px dashed var(--border);
}
.btn-full { width: 100%; }
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(86px + var(--safe-bottom));
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 26px rgba(249, 115, 22, 0.35);
  z-index: 25;
}
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 460px);
  z-index: 24;
  background: rgba(15, 23, 42, 0.98);
  border-top: 2px solid var(--border);
  display: flex;
  padding: 10px 12px calc(8px + var(--safe-bottom));
  gap: 8px;
}
.bottom-nav a {
  flex: 1;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.bottom-nav a.active { color: var(--primary); }
.hero-map {
  position: relative;
  height: 188px;
  overflow: hidden;
  border-bottom: 2px solid var(--border);
  background: linear-gradient(135deg, #334155, #0f172a);
}
.hero-map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
.hero-map::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11,18,32,0.12), rgba(11,18,32,0.88));
}
.hero-meta {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
}
.utility-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 0;
}
.detail-card { padding: 16px; }
.detail-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.info-block { background: var(--bg-soft); border: 2px solid var(--border); border-radius: 12px; padding: 12px; }
.checklist { display: flex; flex-direction: column; gap: 12px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.check-indicator {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 2px solid var(--muted);
  color: transparent;
  flex: 0 0 auto;
}
.check-item.done { opacity: 0.72; }
.check-item.done .check-indicator {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.photo-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.photo-thumb,
.photo-add {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-soft);
}
.photo-add {
  border-style: dashed;
  display: grid;
  place-items: center;
  color: var(--primary);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.quote-total-block {
  padding: 22px 16px;
  text-align: center;
  background: rgba(16, 26, 47, 0.72);
  border-bottom: 2px solid var(--border);
}
.quote-total-label {
  color: #d5e0f1;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.quote-total {
  margin-top: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(38px, 8vw, 54px);
  color: var(--primary);
  font-weight: 700;
  letter-spacing: -0.05em;
}
.line-items {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.line-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
}
.line-item-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.signature-box {
  height: 132px;
  border-radius: 14px;
  border: 2px dashed var(--border);
  background: var(--bg-soft);
  position: relative;
  overflow: hidden;
}
.signature-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.signature-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #d7e3f6;
  font-size: 13px;
  pointer-events: none;
}
.pill-toggle {
  display: flex;
  gap: 10px;
}
.pill-option {
  flex: 1;
  border-radius: 14px;
  min-height: 66px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 700;
}
.pill-option.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.input,
.textarea,
.select {
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.textarea {
  min-height: 112px;
  padding: 14px;
  resize: vertical;
}
.label {
  margin-bottom: 8px;
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-transform: uppercase;
}
.form-group { display: flex; flex-direction: column; gap: 8px; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: min(100%, 460px);
  margin: 0 auto;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(16px + var(--safe-bottom));
}
.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 16px;
}
.sheet-title {
  margin: 0 0 4px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
}
.sheet-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.empty-state {
  padding: 26px 18px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.mt-8 { margin-top: 8px; }

.profile-list { display: flex; flex-direction: column; gap: 10px; }
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}
.kpi strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  margin-top: 6px;
}
.spacer-8 { height: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

@media (max-width: 360px) {
  .pipeline-actions { flex-direction: column; }
  .grid-2 { grid-template-columns: 1fr; }
}


.header-title { text-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.icon-btn:hover, .btn:hover { filter: brightness(1.04); }
.route-title, .pipeline-name, .detail-title, .section-title { color: var(--text); }
.bottom-nav { background: rgba(11, 18, 32, 0.98); }
.bottom-nav a { color: #c7d5ea; }
.input, .textarea, .select, .info-block, .check-item, .pill-option, .line-item, .profile-row, .kpi, .sheet, .empty-state { border-color: rgba(63, 101, 153, 0.72); }
