:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --muted: #6b7280;
  --text: #0f172a;
  --border: #e5e7eb;
  --accent: #1f6feb;
  --accent-strong: #144bb8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

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

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #eef2ff 0, transparent 28%),
              radial-gradient(circle at 80% 0%, #e0f2fe 0, transparent 30%),
              var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  background: var(--surface);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  gap: 12px;
}
body[data-tab="landing"] .topbar {
  display: none;
}

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

.brand .dot {
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: 50%;
  display: inline-block;
}

.title {
  font-weight: 700;
  font-size: 18px;
}

.tabs {
  display: inline-flex;
  gap: 6px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
}

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

button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

button:hover {
  background: #eef2ff;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: #f8fafc;
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #e2e8f0;
}

.status.saving { background: #fde68a; color: #92400e; }
.status.error { background: #fecdd3; color: #991b1b; }
.status.ok { background: #bbf7d0; color: #166534; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 8px; }

.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.trip {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
  cursor: pointer;
  transition: border 0.2s;
}

.trip.active {
  border-color: var(--accent);
  background: #eef2ff;
}

.two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 16px;
  margin-top: 8px;
}

.col { min-width: 0; }
.map-col { position: sticky; top: 90px; height: calc(100vh - 140px); }

#map {
  width: 100%;
  height: 70vh;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid #e5e7eb;
}

.timeline li {
  margin-left: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  margin-bottom: 8px;
  position: relative;
  cursor: grab;
}

.timeline li.selected {
  border-color: var(--accent);
  background: #eef2ff;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 16px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.timeline .handle {
  position: absolute;
  left: -6px;
  top: 8px;
  font-size: 16px;
  color: var(--muted);
  cursor: grab;
}

.order-input {
  position: absolute;
  left: -56px;
  top: 30px;
  width: 44px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}

.tab-section { display: none; }
.tab-section.active { display: block; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.hero {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
.hero-wide {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: stretch;
  background: linear-gradient(120deg, rgba(31,111,235,0.16), rgba(255,255,255,0.92));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.hero-left { display: flex; flex-direction: column; gap: 12px; }
.hero-sub { margin: 0; color: var(--muted); }
.hero-counts { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-pill {
  min-width: 120px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.hero-pill .label { font-size: 12px; color: var(--muted); }
.hero-pill .value { font-size: 18px; font-weight: 700; color: var(--text); }
.pill { background: #eef2ff; border: 1px solid #dbeafe; }
.pill .value { font-size: 16px; font-weight: 700; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-right { position: relative; }
.hero-img {
  width: 100%;
  height: 360px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 18px 4px 6px;
}
.gallery img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(15,23,42,0.08);
}

.mini-gallery {
  display: none;
}

.bg-rotator {
  position: fixed;
  inset: 0;
  background-size: 140% 100%;
  background-position: 0% 50%;
  filter: blur(4px);
  opacity: 0.16;
  z-index: -1;
  transition: background-image 2s ease, opacity 0.8s ease;
  animation: pan 120s linear infinite;
}

@keyframes pan {
  0% { background-position: 0% 50%; }
  100% { background-position: -120% 50%; }
}

.route-details {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.route-leg {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.route-leg .leg-title { font-weight: 600; }
.route-leg .leg-meta { color: var(--muted); font-size: 12px; }
.route-leg .leg-badge {
  background: #eef2ff;
  color: #1d4ed8;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.timeline-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15,23,42,0.05);
}
.timeline-bar {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f6feb, #60a5fa);
  margin: 6px 0;
}
.timeline-info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.cost-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.card.light {
  background: #f8fafc;
}

.big {
  font-size: 28px;
  font-weight: 700;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.landing-block {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}

#map {
  width: 100%;
  height: 70vh;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.timeline .meta { color: var(--muted); font-size: 12px; }
.timeline .actions { display: flex; gap: 6px; margin-top: 8px; }
.timeline .conflict { border-color: var(--warning); }
.timeline .badge-order {
  position: absolute;
  left: -32px;
  top: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

label {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

input, textarea, select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 14px;
}

textarea { resize: vertical; }

.full { grid-column: 1 / -1; }

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list .item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  margin-bottom: 8px;
}

.list .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.table .row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.table .row.head {
  font-weight: 700;
  background: #f8fafc;
  border-radius: 10px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
}

.overlay.hidden { display: none; }

.panel {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  width: min(360px, 90vw);
  box-shadow: var(--shadow);
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  grid-column: 1 / -1;
}

.conflicts .item {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.badge.small { font-size: 11px; padding: 4px 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #dbeafe;
}

@media (max-width: 960px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .two-col { grid-template-columns: 1fr; }
  .map-col { position: relative; height: auto; }
  #map { height: 320px; }
}

@media (max-width: 600px) {
  .top-actions { width: 100%; }
  #app { padding: 12px; }
}
