:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --border: #e2e8f0;
  --shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 40%, #f8fafc 100%);
  color: var(--text);
}

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

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: 8px 12px;
  border-radius: 999px;
}

nav a:hover {
  background: #e0e7ff;
  color: #1e40af;
}

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

main {
  max-width: 1120px;
  margin: 24px auto 80px;
  padding: 0 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.12);
}

.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.02em;
}

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: 16px;
  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: 999px;
  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: 12px;
  font-family: inherit;
  background: #f8fafc;
}

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: 12px;
  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: #dc2626;
  color: #fff;
  box-shadow: none;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  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: 14px;
  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: 12px;
  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) {
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  nav .links {
    gap: 10px;
  }

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

  .row-actions {
    justify-content: flex-start;
  }
}
