:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #687386;
  --accent: #0f766e;
  --accent-2: #0284c7;
  --border: #dce3e8;
  --surface: #eef7f5;
  --danger: #dc2626;
  --shadow: 0 10px 22px rgba(17, 24, 39, 0.07);
  --shadow-soft: 0 5px 14px rgba(17, 24, 39, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  padding-top: env(safe-area-inset-top);
}

nav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
}

nav a:hover {
  background: var(--surface);
  color: #0f766e;
}

nav .links {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

main {
  max-width: 1120px;
  margin: 24px auto 80px;
  padding: 0 24px calc(24px + env(safe-area-inset-bottom));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

h1, h2, h3 {
  margin: 0 0 12px;
  letter-spacing: 0;
}

small {
  color: var(--muted);
}

.muted-text {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
}

.table tbody tr:hover {
  background: #f1f5f9;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
  box-shadow: var(--shadow-soft);
}

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

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
}

.history-pair {
  display: grid;
  gap: 4px;
}

.history-key {
  font-size: 0.8rem;
  color: var(--muted);
}

.history-value {
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #0f172a;
}

.chip.fuel { background: #fde68a; color: #92400e; }
.chip.charging { background: #bae6fd; color: #0c4a6e; }
.chip.service { background: #c7d2fe; color: #3730a3; }
.chip.parking { background: #fecdd3; color: #9f1239; }
.chip.toll { background: #bbf7d0; color: #166534; }
.chip.insurance { background: #e9d5ff; color: #6b21a8; }
.chip.tax { background: #fed7aa; color: #9a3412; }
.chip.other { background: #e2e8f0; color: #0f172a; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table th {
  white-space: nowrap;
}

.table td {
  white-space: nowrap;
}

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

.action-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: #fbfdfe;
  min-height: 44px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: none;
}

button.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

.button.secondary {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: none;
}

.inline-form {
  margin: 0;
}

.trip-kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trip-kpi-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.action-link {
  padding: 8px 12px;
}

.trip-table td {
  vertical-align: top;
}

.message {
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  color: #065f46;
}

@media (max-width: 900px) {
  nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  main {
    padding: 0 16px;
  }

  .card {
    padding: 16px;
  }

  .trip-kpi-grid {
    grid-template-columns: 1fr;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    background: #fff;
  }

  nav {
    padding: 10px 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  nav .links {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  nav a {
    text-align: center;
    padding: 9px 6px;
    font-size: 0.86rem;
    background: #f3f6f7;
  }

  main {
    margin-top: 14px;
    margin-bottom: 24px;
    padding: 0 12px calc(18px + env(safe-area-inset-bottom));
  }

  .card {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
    margin-left: -12px;
    margin-right: -12px;
  }

  .action-row,
  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .action-row > *,
  .row-actions > *,
  .button,
  button {
    width: 100%;
    text-align: center;
  }

  .history-grid {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
.chip.car_wash { background: #ccfbf1; color: #115e59; }
