/* =========================================================
   Porsche 997 Tracker — dark theme (refined)
   Extends Bootstrap 5.3.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Palette */
  --bg:             #0f1115;
  --bg-surface:     #171a21;
  --bg-elevated:    #1e222b;
  --bg-input:       #13161d;

  --border:         #252a34;
  --border-strong:  #353b48;

  --text:           #e8ebf0;
  --text-muted:     #8f97a6;
  --text-dim:       #606775;

  --accent:         #ff4d4d;
  --accent-hover:   #ff6a6a;
  --accent-soft:    rgba(255, 77, 77, 0.12);

  --cyan:    #5ccbe5;
  --green:   #7dd87d;
  --amber:   #f5b461;
  --purple:  #a684d0;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
}

/* ---------- Base ---------- */
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: var(--font-sans);
  font-weight: 400;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grid overlay — softer than before */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at top, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at top, #000 20%, transparent 70%);
}
main, header, nav, footer { position: relative; z-index: 1; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 { font-weight: 500; letter-spacing: -0.01em; color: var(--text); }
code, pre, .mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted) !important; }
.text-dim   { color: var(--text-dim) !important; }
.text-accent { color: var(--accent) !important; }

/* ---------- Brand ---------- */
.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(255, 77, 77, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.5px;
}
.brand-badge-sm { width: 30px; height: 30px; font-size: 11px; border-radius: 6px; }

/* Porsche 911 silhouette wrapper */
.hero-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 0 0.5rem;
}
.hero-logo svg {
  width: 100%;
  max-width: 380px;
  height: auto;
  color: var(--text);
  opacity: 0.92;
}

/* ---------- Navbar ---------- */
.navbar {
  background: rgba(15, 17, 21, 0.88) !important;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border) !important;
  padding: 0.85rem 0;
}
.navbar-brand { color: var(--text) !important; font-weight: 500; font-size: 0.95rem; }
.navbar .nav-link {
  color: var(--text-muted) !important;
  font-size: 14px;
  padding: 0.45rem 0.95rem !important;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.navbar .nav-link:hover { color: var(--text) !important; background: var(--bg-elevated); }
.navbar .nav-link.active {
  color: var(--accent) !important;
  background: var(--accent-soft);
}
.navbar-toggler { border-color: var(--border); }
.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28232,235,240,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ---------- Page header ---------- */
.page-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 1.75rem 0;
  position: relative;
}
.page-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.35;
}

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 12px; }
.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  background: var(--bg);
}
.meta-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.meta-badge .dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.meta-badge .dot.red   { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
}
.card-title, .card-header-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 1rem;
}

/* Home nav cards */
.nav-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 1.25rem;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
  position: relative;
  display: block;
  overflow: hidden;
  text-decoration: none;
  height: 100%;
}
.nav-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.nav-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  color: var(--text);
}
.nav-card:hover::before { transform: scaleX(1); }
.nav-card .card-arrow {
  position: absolute;
  bottom: 16px; right: 18px;
  color: var(--text-dim);
  transition: color 0.15s ease, transform 0.15s ease;
  font-size: 14px;
}
.nav-card:hover .card-arrow { color: var(--accent); transform: translateX(4px); }
.nav-card h2 { font-size: 16px; font-weight: 500; margin: 0.85rem 0 0.25rem; color: var(--text); }
.nav-card p  { font-size: 13px; color: var(--text-muted); margin: 0; }

.nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.nav-icon-info    { background: rgba(92, 203, 229, 0.12); color: var(--cyan);   border: 1px solid rgba(92, 203, 229, 0.25); }
.nav-icon-warning { background: rgba(245, 180, 97, 0.12); color: var(--amber);  border: 1px solid rgba(245, 180, 97, 0.25); }
.nav-icon-danger  { background: var(--accent-soft);       color: var(--accent); border: 1px solid rgba(255, 77, 77, 0.3); }
.nav-icon-success { background: rgba(125, 216, 125, 0.12);color: var(--green);  border: 1px solid rgba(125, 216, 125, 0.25); }

/* ---------- Metric cards ---------- */
.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  height: 100%;
}
.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ---------- Filter pills ---------- */
.btn-filter {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-filter:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Porsche button ---------- */
.btn-porsche {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.btn-porsche:hover, .btn-porsche:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn-outline-muted {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 6px;
}
.btn-outline-muted:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ---------- Forms ---------- */
.form-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.form-control, .form-select, .input-group-text {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 14px;
  border-radius: 6px;
  padding: 9px 12px;
}
.form-control::placeholder { color: var(--text-dim); }
.form-control:focus, .form-select:focus {
  background: var(--bg-input) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
  color: var(--text) !important;
}
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238f97a6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") !important;
}
.form-text { color: var(--text-dim); font-size: 12px; }
.input-group-text { color: var(--text-muted); }
.form-check-input {
  background-color: var(--bg-input);
  border-color: var(--border-strong);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-label { color: var(--text-muted); }

/* Slider */
.form-range { height: 1.5rem; padding: 0; background: transparent; }
.form-range::-webkit-slider-runnable-track {
  background: var(--bg-input);
  border: 1px solid var(--border);
  height: 6px;
  border-radius: 3px;
}
.form-range::-moz-range-track {
  background: var(--bg-input);
  border: 1px solid var(--border);
  height: 6px;
  border-radius: 3px;
}
.form-range::-webkit-slider-thumb {
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px var(--accent-soft);
  margin-top: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
}
.form-range::-moz-range-thumb {
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px var(--accent-soft);
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

/* Big editable km display */
.km-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 18px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.km-display:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.km-input-big {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0;
  width: 100%;
  outline: none;
  letter-spacing: -0.01em;
  -moz-appearance: textfield;
}
.km-input-big::-webkit-outer-spin-button,
.km-input-big::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.km-unit {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
}
.km-delta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 4px;
  font-family: var(--font-mono);
}
.km-delta .positive { color: var(--green); }

/* ---------- Login ---------- */
.login-body {
  background: var(--bg);
  min-height: 100vh;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  opacity: 0.6;
}

/* ---------- Tables ---------- */
.table {
  color: var(--text);
  border-color: var(--border);
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--bg-elevated);
  --bs-table-hover-color: var(--text);
}
.table thead {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.table tbody td { font-size: 14px; vertical-align: middle; }
.table tbody td.num { font-family: var(--font-mono); }
.table > :not(caption) > * > * {
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom-color: var(--border);
  background: transparent;
  color: var(--text);
}

/* Category tag */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  white-space: nowrap;
}
.tag-red    { border-color: rgba(255,77,77,0.4);   color: var(--accent); background: var(--accent-soft); }
.tag-cyan   { border-color: rgba(92,203,229,0.4);  color: var(--cyan);   background: rgba(92,203,229,0.1); }
.tag-amber  { border-color: rgba(245,180,97,0.4);  color: var(--amber);  background: rgba(245,180,97,0.1); }
.tag-green  { border-color: rgba(125,216,125,0.4); color: var(--green);  background: rgba(125,216,125,0.1); }
.tag-purple { border-color: rgba(166,132,208,0.4); color: var(--purple); background: rgba(166,132,208,0.1); }

/* ---------- Charts ---------- */
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; }
.chart-wrap { position: relative; width: 100%; height: 240px; }

/* ---------- Section title (replaces nerdy `//` headings) ---------- */
.section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.75rem 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Footer ---------- */
footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border) !important;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Alerts ---------- */
.alert-danger {
  background: rgba(255, 77, 77, 0.08);
  border: 1px solid rgba(255, 77, 77, 0.3);
  color: var(--accent);
  font-size: 13px;
}

/* ---------- Helpers ---------- */
.text-feedback-success {
  color: var(--green);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.text-feedback-success::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.badge.text-bg-light {
  background: var(--bg-elevated) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  font-weight: 400;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Timeline / expense history rows */
.timeline-row {
  display: grid;
  grid-template-columns: 100px 120px 1fr 100px;
  gap: 16px;
  padding: 12px 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.timeline-row:last-child { border-bottom: none; }
.timeline-row .t-date { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.timeline-row .t-desc { color: var(--text); font-size: 14px; }
.timeline-row .t-amount { font-family: var(--font-mono); font-size: 14px; text-align: right; font-weight: 500; }
@media (max-width: 576px) {
  .timeline-row {
    grid-template-columns: 90px 1fr 90px;
    grid-template-areas:
      "date type amount"
      "date desc amount";
  }
  .timeline-row .t-date { grid-area: date; }
  .timeline-row .t-type { grid-area: type; }
  .timeline-row .t-desc { grid-area: desc; font-size: 13px; color: var(--text-muted); }
  .timeline-row .t-amount { grid-area: amount; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #454b5a; }

::selection { background: var(--accent-soft); color: var(--text); }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-link { text-decoration: none; }
a.text-danger:hover { color: var(--accent-hover) !important; }

/* Sortable drag states */
.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-soft) !important;
}
.drag-handle {
  cursor: grab;
  padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }

/* Modal dark overrides */
.modal-content { color: var(--text); }
.list-group-item { background: var(--bg-input); color: var(--text); border-color: var(--border); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }