/* ────────────────────────────────────────────────
   Equipment Checkliste – Themes & Layout
   Light / Dark über <html data-theme="…">
──────────────────────────────────────────────── */

:root,
:root[data-theme="light"] {
  --bg: #eef0f1;
  --bg-grad-a: #f4f5f6;
  --bg-grad-b: #e7eaec;
  --panel: rgba(255, 255, 255, .92);
  --panel-soft: #f7f8f9;
  --text: #17191b;
  --muted: #676d73;
  --line: #dcdfe3;
  --accent: #1c1e21;
  --accent-contrast: #ffffff;
  --accent-soft: #e8eaec;
  --tally: #e2483d;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --link: #2050c8;
  --shadow: 0 20px 55px rgba(20, 24, 28, .10);
  --radius: 20px;

  --pill-cat-bg: #ecebf6; --pill-cat-fg: #453a75; --pill-cat-line: #dcd8ef;
  --cond-ex-bg: #dcfce7; --cond-ex-fg: #166534; --cond-ex-line: #bbf7d0;
  --cond-good-bg: #fef3c7; --cond-good-fg: #854d0e; --cond-good-line: #fde68a;
  --cond-fair-bg: #f1f5f9; --cond-fair-fg: #475569; --cond-fair-line: #e2e8f0;
  --cond-rep-bg: #ffedd5; --cond-rep-fg: #9a3412; --cond-rep-line: #fed7aa;
  --toast-bg: #dcfce7; --toast-fg: #166534; --toast-line: #bbf7d0;
  --row-missing: #fff5f4;
}

:root[data-theme="dark"] {
  --bg: #121417;
  --bg-grad-a: #16181c;
  --bg-grad-b: #0e1013;
  --panel: rgba(28, 31, 35, .92);
  --panel-soft: #22262b;
  --text: #e8eaec;
  --muted: #9aa1a8;
  --line: #33383f;
  --accent: #e8eaec;
  --accent-contrast: #121417;
  --accent-soft: #2b2f35;
  --tally: #ff5a4e;
  --danger: #f97066;
  --danger-soft: #3b1a17;
  --link: #7ba2ff;
  --shadow: 0 20px 55px rgba(0, 0, 0, .45);

  --pill-cat-bg: #2b2841; --pill-cat-fg: #c6bcf2; --pill-cat-line: #3d3860;
  --cond-ex-bg: #143323; --cond-ex-fg: #6ee7a0; --cond-ex-line: #1e4d33;
  --cond-good-bg: #3a2e10; --cond-good-fg: #f5cf6b; --cond-good-line: #57451a;
  --cond-fair-bg: #262c33; --cond-fair-fg: #aab6c2; --cond-fair-line: #37404a;
  --cond-rep-bg: #3d2413; --cond-rep-fg: #ffb383; --cond-rep-line: #5c3620;
  --toast-bg: #14331f; --toast-fg: #7ee2a2; --toast-line: #1e4d30;
  --row-missing: #33201e;
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, var(--bg-grad-a), transparent 40rem),
    linear-gradient(150deg, var(--bg-grad-a) 0%, var(--bg-grad-b) 100%);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 6px;
  font-family: Archivo, Inter, sans-serif;
  font-size: clamp(1.7rem, 4vw, 3.2rem);
  font-weight: 850;
  font-stretch: 90%;
  letter-spacing: -0.04em;
  line-height: .98;
  text-transform: uppercase;
}
h2 { font-family: Archivo, Inter, sans-serif; margin-bottom: 6px; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
h3 { margin: 22px 0 10px; font-size: .95rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.subline, .panel-head p, .empty { color: var(--muted); margin-bottom: 0; }
.empty a { color: var(--link); }

.eyebrow {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .16em; font-size: .72rem; font-weight: 800; margin-bottom: 10px;
}
.tally {
  width: 9px; height: 9px; border-radius: 999px; background: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 22%, transparent);
  animation: tally 2.4s ease-in-out infinite;
}
@keyframes tally { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .tally { animation: none; } }

/* ── Header ── */
.app-header {
  max-width: 1440px; margin: 0 auto;
  padding: 28px 24px 16px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-logo {
  max-height: 64px; max-width: 150px; object-fit: contain;
  border-radius: 12px; background: var(--panel); padding: 6px;
  border: 1px solid var(--line);
}
.header-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.theme-toggle {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 999px;
  width: 42px; height: 42px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
html[data-theme="light"] .theme-icon.light { display: none; }
html[data-theme="dark"]  .theme-icon.dark  { display: none; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tabs a, .button, button, input, select, textarea { font: inherit; }
.tabs a {
  text-decoration: none; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 14px; font-weight: 700;
}
.tabs a.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* ── Grundlayout ── */
.layout { max-width: 1440px; margin: 0 auto; padding: 0 24px calc(54px + env(safe-area-inset-bottom)); }
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.card { padding: 20px; }
.metric span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.metric strong { font-family: Archivo, Inter, sans-serif; font-size: 2rem; font-weight: 850; letter-spacing: -0.04em; }
.metric.warn strong { color: var(--danger); }

.panel { padding: 22px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.button {
  appearance: none; border: 1px solid var(--accent); border-radius: 13px;
  padding: 11px 16px; cursor: pointer; font-weight: 800; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
}
.button.primary { background: var(--accent); color: var(--accent-contrast); }
.button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.link { border: 0; background: transparent; color: var(--link); padding: 6px 0; cursor: pointer; font-weight: 800; }
.link.danger, .danger { color: var(--danger); }

/* ── Formulare ── */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.inventory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--muted); font-size: .82rem; font-weight: 800; }
label.wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-soft); color: var(--text);
  padding: 11px 12px; outline: none; min-height: 44px;
}
input[type="file"] { padding: 9px 12px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 18%, transparent);
}
textarea { min-height: 86px; resize: vertical; }
code { background: var(--accent-soft); padding: 2px 6px; border-radius: 8px; }
.inline-check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; }
.inline-check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--tally); }

.inventory-editor {
  background: var(--panel-soft); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; margin-bottom: 18px;
}
.logo-preview { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.logo-preview img { max-height: 80px; max-width: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }

/* ── Tabellen ── */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 14px 0 18px; flex-wrap: wrap; }
.toolbar input { max-width: 420px; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-soft); }
.data-table { width: 100%; border-collapse: collapse; min-width: 940px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.data-table th {
  color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  background: var(--panel-soft); position: sticky; top: 0; z-index: 1;
}
.data-table td { font-size: .91rem; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table small { display: block; color: var(--muted); margin-top: 4px; font-size: .78rem; }
.data-table strong { font-weight: 800; }
.data-table .qty { width: 76px; padding: 8px 9px; min-height: 0; }
.data-table input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--tally); }
.data-table select, .data-table input { padding: 8px 9px; border-radius: 10px; min-height: 0; }
.check { text-align: center !important; }
.qty-cell { white-space: nowrap; }
.row-missing td { background: var(--row-missing); }
.row-actions { display: flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }

.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 4px 9px; font-size: .75rem; font-weight: 800; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.category { background: var(--pill-cat-bg); color: var(--pill-cat-fg); border-color: var(--pill-cat-line); }
.pill.condition.excellent { background: var(--cond-ex-bg); color: var(--cond-ex-fg); border-color: var(--cond-ex-line); }
.pill.condition.good { background: var(--cond-good-bg); color: var(--cond-good-fg); border-color: var(--cond-good-line); }
.pill.condition.fair { background: var(--cond-fair-bg); color: var(--cond-fair-fg); border-color: var(--cond-fair-line); }
.pill.condition.needs_repair { background: var(--cond-rep-bg); color: var(--cond-rep-fg); border-color: var(--cond-rep-line); }
.pill.condition.defect, .pill.condition.missing { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ── Projektlisten ── */
.project-list { display: grid; gap: 10px; }
.project-card {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  text-decoration: none; color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; padding: 15px 16px;
  background: var(--panel-soft);
  transition: transform .12s ease, border-color .12s ease;
}
.project-card:hover { border-color: var(--muted); transform: translateY(-1px); }
.project-card span { display: block; color: var(--muted); margin-top: 4px; font-size: .9rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badges em { font-style: normal; background: var(--accent-soft); border-radius: 999px; padding: 6px 9px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.badges em.red { color: var(--danger); background: var(--danger-soft); }

.toast { background: var(--toast-bg); color: var(--toast-fg); border: 1px solid var(--toast-line); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-weight: 800; }
.toast.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.toast code { background: transparent; padding: 0; }

.category-block + .category-block { margin-top: 14px; }
.sticky-actions { position: sticky; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; margin-top: 18px; pointer-events: none; }
.sticky-actions .button { pointer-events: all; box-shadow: 0 12px 28px rgba(0,0,0,.28); }
.delete-project { text-align: right; margin: 12px 6px 0; }

.print-title { display: none; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .app-header { flex-direction: column; align-items: stretch; padding: 20px 16px 12px; }
  .header-side { flex-direction: row-reverse; align-items: center; justify-content: space-between; }
  .tabs { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tabs a { white-space: nowrap; }
  .layout { padding-left: 16px; padding-right: 16px; }
  .cards, .form-grid, .inventory-grid, .settings-grid, .signature-block { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .project-card { align-items: flex-start; flex-direction: column; }
  .badges { justify-content: flex-start; }
  .brand { gap: 12px; }
  .brand-logo { max-height: 48px; }
}

/* ── Unterschriften ── */
.signature-block { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 22px; }
.signature-block div { border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 82px; background: var(--panel-soft); }
.signature-block span { display: block; color: var(--muted); font-size: .8rem; font-weight: 800; margin-bottom: 20px; }
.signature-block strong { display: block; border-bottom: 1px solid var(--muted); min-height: 24px; }

/* ────────────────────────────────────────────────
   Druck: immer DIN A4 hochkant, weißer Hintergrund
──────────────────────────────────────────────── */
@page { size: A4 portrait; margin: 12mm; }

@media print {
  html, body {
    width: 210mm;
    background: #fff !important;
    color: #111 !important;
  }
  body { font-size: 9.5pt; font-family: Inter, Arial, sans-serif; }
  * { box-shadow: none !important; text-shadow: none !important; }

  .no-print, .app-header, .toast, .sticky-actions, .delete-project, .toolbar { display: none !important; }
  .layout { max-width: none; padding: 0; margin: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; margin: 0; border-radius: 0; background: #fff !important; }

  .print-title {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    border-bottom: 2px solid #222; padding-bottom: 10px; margin-bottom: 14px;
  }
  .print-brand { display: flex; align-items: center; gap: 12px; }
  .print-brand img { max-height: 18mm; max-width: 45mm; object-fit: contain; }
  .print-title h2 { margin-bottom: 2px; font-size: 1.4rem; color: #111; }
  .print-title p, .print-title .eyebrow { color: #444 !important; }
  .print-meta { text-align: right; border: 1px solid #222; padding: 8px 12px; min-width: 110px; color: #111; }
  .print-meta span { display: block; font-size: .7rem; text-transform: uppercase; color: #555; }

  .print-table-wrap, .table-wrap { overflow: visible; border: 0; border-radius: 0; background: #fff !important; }
  .data-table { min-width: 0; width: 100%; table-layout: fixed; font-size: 8.2pt; }
  .data-table th, .data-table td {
    border: 1px solid #999; padding: 4px 5px;
    background: #fff !important; color: #111 !important;
  }
  .data-table th { position: static; text-transform: none; letter-spacing: 0; font-size: 7.5pt; }
  .data-table small { color: #333 !important; font-size: 7pt; }
  .data-table tr { break-inside: avoid; }
  .row-missing td { background: #f3f3f3 !important; }

  .data-table input, .data-table select {
    border: 0; background: transparent !important; color: #111 !important;
    padding: 0; font-size: 8pt; appearance: none; -webkit-appearance: none; min-height: 0;
  }
  .data-table input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 4.5mm; height: 4.5mm; border: 1.2px solid #111;
    vertical-align: middle; position: relative; accent-color: #111;
  }
  .data-table input[type="checkbox"]:checked::after {
    content: "✓"; position: absolute; inset: -2px 0 0 1px;
    font-size: 12pt; font-weight: 900; color: #111;
  }
  .data-table .qty { width: 22px; text-align: center; }

  .checklist-table th:nth-child(1), .checklist-table td:nth-child(1) { width: 15%; }
  .checklist-table th:nth-child(2), .checklist-table td:nth-child(2) { width: 24%; }
  .checklist-table th:nth-child(3), .checklist-table td:nth-child(3) { width: 8%; }
  .checklist-table th:nth-child(4), .checklist-table td:nth-child(4),
  .checklist-table th:nth-child(5), .checklist-table td:nth-child(5),
  .checklist-table th:nth-child(6), .checklist-table td:nth-child(6) { width: 7%; text-align: center; }
  .checklist-table th:nth-child(7), .checklist-table td:nth-child(7),
  .checklist-table th:nth-child(8), .checklist-table td:nth-child(8) { width: 11%; }
  .checklist-table th:nth-child(9), .checklist-table td:nth-child(9) { width: 15%; }

  .pill { border: 1px solid #999 !important; background: #fff !important; color: #111 !important; }

  .signature-block { grid-template-columns: repeat(3, 1fr); gap: 8px; break-inside: avoid; margin-top: 10mm; }
  .signature-block div { border: 1px solid #222; border-radius: 0; min-height: 22mm; padding: 7px; background: #fff !important; }
  .signature-block span { margin-bottom: 10mm; font-size: 8pt; color: #444 !important; }
  .signature-block strong { border-bottom: 1px solid #666; color: #111 !important; }

  a { color: #111 !important; text-decoration: none; }
}
