:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--primary-dark);
  text-decoration: none;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 20px;
  margin: 4px 0 0;
}
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-wa { background: #25d366; color: #fff; }

.card-grid {
  display: grid;
  gap: 12px;
}
.trip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.trip-card.closed { opacity: 0.6; }
.trip-card-top { display: flex; justify-content: space-between; align-items: center; }
.trip-card-top h3 { margin: 0; font-size: 16px; }
.trip-card-stats {
  display: flex;
  gap: 18px;
  margin-top: 10px;
}
.trip-card-stats .label { display: block; font-size: 11px; color: var(--muted); }
.trip-card-stats strong { font-size: 14px; }
.margin { color: var(--primary-dark); }

.badge {
  background: #eef2f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-box.highlight { border-color: var(--primary); }
.stat-box .label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.stat-box strong { font-size: 16px; }

.status-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--pill-color) 15%, white);
  color: var(--pill-color);
}

.section-title { font-size: 15px; color: var(--muted); margin: 20px 0 10px; }

.customer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.customer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.customer-head h3 { margin: 0 0 2px; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }
.customer-actions { display: flex; gap: 6px; }

.order-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.order-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.order-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.thumb {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.inline-form { display: inline; }
.status-btn {
  border: 1px solid var(--pill-color);
  color: var(--pill-color);
  background: transparent;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.status-btn.done {
  background: color-mix(in srgb, var(--pill-color) 15%, white);
  cursor: default;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.modal input, .modal select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.calc-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px;
}
.calc-preview span { display: block; font-size: 10px; color: var(--muted); }
.calc-preview strong { font-size: 13px; }
