/* ─── VARIABLES ─────────────────────────────────────────────── */
:root {
  --bg: #0e0d14;
  --surface: #16141f;
  --surface2: #1e1b2a;
  --surface3: #252235;
  --border: #2c2840;
  --border2: #38334f;
  --accent: #8b7fff;
  --accent2: #6B5BFF;
  --accent-dim: #6B5BFF28;
  --accent-text: #b3aaff;
  --muted: #6b6680;
  --muted2: #8a8499;
  --text: #edeaf5;
  --text2: #c8c4d8;
  --danger: #f87171;
  --danger-dim: #ef444420;
  --amber: #fbbf24;
  --amber-dim: #f59e0b20;
  --blue: #60a5fa;
  --blue-dim: #3b82f620;
  --radius: 10px;
  --radius-lg: 16px;
}

/* ─── RESET ─────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ─── HEADER ────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot { color: var(--text2); font-weight: 400; }

nav {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--muted2);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-btn:hover { color: var(--text); background: var(--surface3); }

.nav-btn.active {
  background: var(--surface3);
  color: var(--accent-text);
  border: 1px solid var(--border2);
}

/* ─── LAYOUT ────────────────────────────────────────────────── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.page { display: none; }
.page.active { display: block; }

/* ─── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

/* ─── STATS GRID ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.4;
}

.stat-card.amber::before { background: var(--amber); }
.stat-card.blue::before  { background: var(--blue); }
.stat-card.danger::before { background: var(--danger); }

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.stat-unit {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 2px;
}

/* ─── FORMS ─────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 1.2rem;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select option { background: var(--surface2); }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 22px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--accent2); color: #ffffff; }
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: var(--surface2);
  color: var(--muted2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { color: var(--text); background: var(--surface3); }

.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { border-color: var(--danger); }

.btn-amber { background: var(--amber-dim); color: var(--amber); border: 1px solid transparent; }
.btn-amber:hover { border-color: var(--amber); }

/* ─── TABLES ────────────────────────────────────────────────── */
.log-table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); color: var(--text); }

/* ─── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
}

.badge-trip { background: var(--blue-dim);  color: var(--blue); }
.badge-fuel { background: var(--amber-dim); color: var(--amber); }
.badge-partial { background: var(--surface3); color: var(--muted2); margin-left: 6px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent); }

/* ─── CHARTS ────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 200px; margin-top: 0.5rem; }

/* ─── EMPTY STATE ───────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; }
.empty h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted2);
  margin-bottom: 0.4rem;
}
.empty p { font-size: 13px; }

/* ─── TOGGLE ────────────────────────────────────────────────── */
.toggle-row { display: flex; gap: 8px; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; }

.toggle-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted2);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.toggle-btn.active {
  background: var(--accent-dim);
  color: var(--accent-text);
  border-color: var(--accent2);
}

/* ─── SWITCH ────────────────────────────────────────────────── */
.switch-label { display: flex; gap: 8px; align-items: center; cursor: pointer; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; }

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 22px;
  transition: all 0.2s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--muted2);
  transition: all 0.2s;
}

.switch input:checked + .slider {
  background: var(--accent-dim);
  border-color: var(--accent2);
}

.switch input:checked + .slider::before {
  background: var(--accent);
  transform: translateX(16px);
}

.smart-note {
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-dim);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 1rem;
}

/* ─── SECTION HEADS ─────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.section-head h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.section-head p { font-size: 13px; color: var(--muted2); margin-top: 2px; }

/* ─── EFFICIENCY BAR ────────────────────────────────────────── */
.eff-bar {
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.eff-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--danger) 0%, var(--amber) 50%, var(--accent) 100%);
  transition: width 0.5s ease;
}

/* ─── MISC ──────────────────────────────────────────────────── */
.delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.15s;
}
.delete-btn:hover { color: var(--danger); background: var(--danger-dim); }

.edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.15s;
}
.edit-btn:hover { color: var(--accent-text); background: var(--accent-dim); }

.row-actions { white-space: nowrap; }
.row-actions .edit-btn { margin-right: 4px; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.mono  { font-family: 'DM Mono', monospace; }
.text-accent { color: var(--accent-text); }
.text-amber  { color: var(--amber); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--muted2); }
.text-sm     { font-size: 12px; }

/* ─── IMPORT MODAL ──────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
}

.modal h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal p { font-size: 13px; color: var(--muted2); margin-bottom: 1.2rem; line-height: 1.6; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.5rem; }

.import-drop {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1rem;
}

.import-drop:hover, .import-drop.dragover {
  border-color: var(--accent2);
  color: var(--accent-text);
  background: var(--accent-dim);
}

.import-drop input[type="file"] { display: none; }

.import-preview {
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-dim);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 0.5rem;
  display: none;
}

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 0.8rem 1rem; flex-wrap: wrap; gap: 0.6rem; }
  main { padding: 1rem; }
  nav { overflow-x: visible; width: 100%; justify-content: stretch; }
  .nav-btn { font-size: 11px; padding: 5px 8px; flex: 1; text-align: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
}
