/* ============================================================
   Petrol Log — design tokens & shared styles
   Palette: petrol teal + fuel amber, inspired by a fuel gauge
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* --- Light theme (default) --- */
  --bg: #F3F7F6;
  --bg-alt: #E7EFED;
  --surface: #FFFFFF;
  --surface-2: #F0F5F4;
  --border: #DCE6E3;
  --text: #16232B;
  --text-muted: #5C7570;
  --text-faint: #8AA29D;

  --primary: #146C64;
  --primary-strong: #0E4F49;
  --primary-soft: #DCEFEC;
  --accent: #F2A93B;
  --accent-strong: #D68C1E;
  --accent-soft: #FCEACB;
  --coral: #E4572E;
  --coral-soft: #FBE0D6;

  --shadow-sm: 0 1px 2px rgba(15, 40, 37, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 40, 37, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 40, 37, 0.14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  /* Kept intentionally light-ish, not near-black */
  --bg: #1B2B31;
  --bg-alt: #22353C;
  --surface: #24383F;
  --surface-2: #2B4048;
  --border: #3A5058;
  --text: #EAF2F0;
  --text-muted: #A9C2BD;
  --text-faint: #7E9994;

  --primary: #4FC3B4;
  --primary-strong: #7FDCCF;
  --primary-soft: #2C4A47;
  --accent: #F5BE5C;
  --accent-strong: #FFD27F;
  --accent-soft: #3E3520;
  --coral: #F0805A;
  --coral-soft: #402A22;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.36);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
  background-image:
    radial-gradient(circle at 8% 0%, var(--bg-alt) 0%, transparent 45%),
    radial-gradient(circle at 100% 20%, var(--bg-alt) 0%, transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

a { color: inherit; }

button { font-family: inherit; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------- Layout shell ---------------- */

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 4px 18px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-mark svg { width: 20px; height: 20px; stroke: white; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-pills {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-pill svg { width: 15px; height: 15px; }

.nav-pill.active {
  background: var(--primary);
  color: white;
}
.nav-pill:not(.active):hover {
  background: var(--surface-2);
  color: var(--text);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform 0.2s ease, background 0.2s ease;
}
.theme-toggle:hover { transform: rotate(-12deg); background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ---------------- Hero / gauge ---------------- */

.hero {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 8px 4px 30px;
  flex-wrap: wrap;
}

.hero-text h1 {
  font-size: 30px;
  margin: 0 0 6px;
  font-weight: 700;
}
.hero-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 40ch;
}

.gauge-wrap { flex-shrink: 0; }

/* ---------------- Cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.form-card {
  padding: 30px;
}

@media (max-width: 560px) {
  .form-card { padding: 22px; }
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.field label svg { width: 14px; height: 14px; stroke: var(--primary); }

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15.5px;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus {
  border-color: var(--primary);
  background: var(--surface);
  outline: none;
}

.input-group {
  position: relative;
}
.input-group .prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
}
.input-group input { padding-left: 34px; }
.input-group .suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-weight: 600;
  font-size: 13px;
  pointer-events: none;
}

.rate-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-soft);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 22px;
  font-size: 13.5px;
  color: var(--primary-strong);
  font-weight: 600;
}
[data-theme="dark"] .rate-line { color: var(--primary-strong); }

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #3A2705;
  box-shadow: 0 8px 20px rgba(214, 140, 30, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--primary-strong);
  color: white;
  padding: 13px 22px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(.2,.8,.3,1.3), opacity 0.3s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast svg { width: 16px; height: 16px; }

/* ---------------- Recent list (home) ---------------- */

.recent {
  margin-top: 28px;
}
.recent h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 12px;
  font-weight: 700;
}
.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.recent-row:last-child { border-bottom: none; }
.recent-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.recent-icon svg { width: 16px; height: 16px; stroke: var(--accent-strong); }
.recent-main { flex: 1; }
.recent-date { color: var(--text-muted); font-size: 12.5px; }
.recent-amt { font-weight: 700; font-family: var(--font-display); }
.recent-litres { color: var(--text-muted); font-size: 12.5px; }

.empty-note {
  color: var(--text-faint);
  font-size: 13.5px;
  padding: 10px 4px;
}

/* ---------------- Stats grid (history) ---------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}

.stat-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-ring svg { width: 21px; height: 21px; }
.ring-teal { background: var(--primary-soft); }
.ring-teal svg { stroke: var(--primary); }
.ring-amber { background: var(--accent-soft); }
.ring-amber svg { stroke: var(--accent-strong); }
.ring-coral { background: var(--coral-soft); }
.ring-coral svg { stroke: var(--coral); }

.stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------------- Filters ---------------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-row select,
.filter-row input[type="month"] {
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
}

/* ---------------- Charts ---------------- */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 760px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-card {
  padding: 20px 20px 12px;
}
.chart-card h3 {
  font-size: 14px;
  margin: 0 0 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}
.chart-card h3 svg { width: 15px; height: 15px; stroke: var(--primary); }
.chart-canvas-wrap { height: 220px; position: relative; }

/* ---------------- Table ---------------- */

.log-card { padding: 8px 0; }
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 4px;
}
.log-header h3 {
  font-size: 14px;
  margin: 0;
  font-weight: 700;
}
.log-count {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
}

table.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.log-table thead th {
  text-align: left;
  padding: 10px 20px;
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.log-table tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.log-table tbody tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover { background: var(--surface-2); }
.log-table .num { font-weight: 700; font-family: var(--font-display); }
.log-table .del-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-faint);
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
}
.log-table .del-btn svg { width: 15px; height: 15px; }
.log-table .del-btn:hover { background: var(--coral-soft); color: var(--coral); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-faint);
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--text-faint); margin-bottom: 10px; }
.empty-state p { margin: 4px 0 0; font-size: 13.5px; }

footer.foot {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 34px;
}
