/* KiloLog – Digitales Fahrtenbuch */

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #e9efee;
  --text: #1c2b2a;
  --text-muted: #5b6d6b;
  --accent: #0f766e;
  --accent-strong: #0b5a54;
  --accent-contrast: #ffffff;
  --secondary: #d97706;
  --border: #d3dddb;
  --danger: #b3261e;
  --warning-bg: #fdf3e3;
  --warning-text: #8a5a00;
  --error-bg: #fbe9e7;
  --shadow: 0 1px 3px rgba(16, 42, 40, 0.1), 0 4px 14px rgba(16, 42, 40, 0.06);
  --radius: 10px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Archivo", "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101817;
    --surface: #182422;
    --surface-alt: #1f2e2c;
    --text: #e4ecea;
    --text-muted: #93a5a2;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-contrast: #06302c;
    --secondary: #fbbf24;
    --border: #2c3d3a;
    --danger: #f2846d;
    --warning-bg: #33290f;
    --warning-text: #f0c674;
    --error-bg: #3a1f1b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: var(--font-head);
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

/* ---------- Header ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.4rem;
  max-width: 60rem;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand h1 { font-size: 1.25rem; margin: 0; }
.brand-sub { margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.brand-icon { flex-shrink: 0; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1rem;
  max-width: 60rem;
  margin: 0 auto;
  overflow-x: auto;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Layout ---------- */
.app-main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tab-panel { display: none; flex-direction: column; gap: 1rem; }
.tab-panel.is-active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.2rem;
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.25rem; }

label { font-size: 0.85rem; font-weight: 600; }
.req-hint { font-weight: 400; color: var(--text-muted); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  min-width: 0;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.distance-line { margin: 0.8rem 0 0.2rem; font-size: 0.95rem; }

.form-message {
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.form-message.is-error { background: var(--error-bg); color: var(--danger); }
.form-message.is-warning { background: var(--warning-bg); color: var(--warning-text); }
.form-message.is-success { background: var(--surface-alt); color: var(--accent-strong); }

.form-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: filter 120ms ease;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.07); }

.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.btn-premium {
  background: transparent;
  color: var(--secondary);
  border-color: var(--secondary);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }

.linklike {
  appearance: none;
  background: none;
  border: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.file-btn { display: inline-block; text-align: center; }

/* ---------- Fahrtenliste ---------- */
.list-head { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; }
.filter span { font-weight: 600; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 46rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.data-table td.num { text-align: right; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text);
}
.badge-geschaeftlich { background: var(--accent); color: var(--accent-contrast); }
.badge-arbeitsweg { background: var(--secondary); color: #fff; }

.modified-note { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

.row-actions { display: flex; gap: 0.35rem; }

.muted { color: var(--text-muted); }
.hint { font-size: 0.8rem; color: var(--text-muted); margin: 0.8rem 0 0; }

/* ---------- Fahrzeuge ---------- */
.vehicle-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }

.vehicle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  flex-wrap: wrap;
}

.vehicle-plate { font-weight: 700; font-family: var(--font-head); }
.vehicle-meta { font-size: 0.82rem; color: var(--text-muted); }

/* ---------- Auswertung ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-accent { border-color: var(--accent); }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; }
.stat-accent .stat-value { color: var(--accent); }

.calc-block { margin-bottom: 1rem; }
.calc-block p { margin: 0.25rem 0; }
.calc-total { font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 0.75rem; margin: 0; }

/* ---------- Export ---------- */
.export-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }

.disclaimer-card { border-left: 4px solid var(--secondary); }

/* ---------- Ad-Slot ---------- */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.8rem 1rem;
  text-align: center;
}

.ad-label {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.ad-placeholder { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Footer ---------- */
.app-footer {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.app-footer p { margin: 0.3rem 0; }
.footer-disclaimer { font-size: 0.75rem; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 19, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 28rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.25rem 1.4rem 1.4rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.premium-list { padding-left: 1.2rem; margin: 0.5rem 0 0.8rem; }
.premium-list li { margin: 0.25rem 0; }

/* ---------- Druck ---------- */
@media print {
  .app-header, .app-footer, .ad-slot, .tab-panel, .modal-backdrop { display: none !important; }
  body { background: #fff; color: #000; }
}

#print-area { display: none; }

@media print {
  #print-area { display: block; }
  #print-area h1 { font-size: 16pt; margin: 0 0 4pt; }
  #print-area h2 { font-size: 12pt; margin: 12pt 0 4pt; }
  #print-area .print-vehicle { page-break-after: always; }
  #print-area .print-vehicle:last-child { page-break-after: auto; }
  #print-area table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
  #print-area th, #print-area td { border: 1pt solid #000; padding: 3pt 4pt; text-align: left; vertical-align: top; }
  #print-area .print-meta { font-size: 9pt; margin: 2pt 0; }
  #print-area .print-footer { font-size: 8pt; margin-top: 10pt; }
}

/* ---------- Erste-Schritte-Hilfe ---------- */
.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.help-btn {
  inline-size: 2rem; block-size: 2rem; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1;
  cursor: pointer; flex: 0 0 auto;
}
.help-btn:hover, .help-btn:focus-visible { color: var(--accent); border-color: var(--accent); }

.tour-intro { color: var(--text-muted); }
.tour-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.6rem; }
.tour-steps li strong { color: var(--accent-strong); }

.know-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.know-box h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.know-box ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.4rem; }
.know-box li { font-size: 0.9rem; color: var(--text-muted); }
