/* ============================================================
   rechno – Design System
   ============================================================ */

:root {
  --bg:           #f0f2f5;
  --card-bg:      #ffffff;
  --text:         #1a1a2e;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --danger:       #dc2626;
  --success-bg:   #dcfce7;
  --success-text: #166534;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --font:         'Segoe UI', system-ui, Arial, sans-serif;
}

html.dark {
  --bg:          #0f172a;
  --card-bg:     #1e293b;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --border:      #334155;
  --shadow:      0 2px 12px rgba(0,0,0,0.4);
  --success-bg:  #14532d;
  --success-text:#bbf7d0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ── Privacy Banner ── */
#datenschutz-hinweis {
  background: var(--success-bg);
  color: var(--success-text);
  padding: 10px 16px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── App Header ── */
.app-header {
  text-align: center;
  padding: 28px 16px 4px;
  position: relative;
}
.btn-darkmode {
  position: absolute;
  top: 28px;
  right: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.btn-darkmode:hover { background: var(--border); }
.app-header h1 {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.04em;
}
.app-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Main wrapper ── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

/* ── Card ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ── Section headings ── */
.card h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 18px;
}

/* ── Grid layouts ── */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.three-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Form groups ── */
.form-group { margin-bottom: 12px; }

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  text-align: left;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.18s, box-shadow 0.18s;
  min-height: 44px;
  box-sizing: border-box;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: var(--card-bg);
}
input[readonly] {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ── Buttons (base reset) ── */
button { font-family: var(--font); cursor: pointer; transition: all 0.18s; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 50px;
  letter-spacing: 0.02em;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37,99,235,0.25); }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 44px;
}
.btn-secondary:hover { background: var(--primary); color: #fff; }

.btn-reset {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 50px;
}
.btn-reset:hover { background: var(--danger); color: #fff; }
.btn-reset--confirm { background: var(--danger); color: #fff; }

/* ── Action buttons area ── */
.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0 36px;
}

/* ── Zielgruppen Toggle ── */
.zielgruppen-toggle {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.toggle-btn {
  flex: 1;
  padding: 14px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  min-height: 68px;
  width: 100%;
}
.toggle-btn small {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 3px;
}
.toggle-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.toggle-btn:not(.active):hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Info hint ── */
.info-hinweis {
  display: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 4px solid var(--primary);
  background: rgba(37,99,235,0.07);
  color: #1e40af;
}
.info-hinweis.visible { display: block; }
.info-hinweis.warn {
  border-left-color: #f59e0b;
  background: rgba(245,158,11,0.08);
  color: #92400e;
}
html.dark .info-hinweis { color: #93c5fd; background: rgba(37,99,235,0.15); }
html.dark .info-hinweis.warn { color: #fcd34d; background: rgba(245,158,11,0.15); }

/* ── Positions table ── */
.position-header,
.position-zeile {
  display: grid;
  grid-template-columns: 1fr 90px 90px 100px 100px 40px;
  gap: 8px;
  align-items: end;
}
.festpreis-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
}
.festpreis-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}
.position-header {
  margin-bottom: 6px;
  align-items: center;
}
.position-header span {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.position-zeile { margin-bottom: 8px; }
.btn-del {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 44px;
  padding: 0;
  width: 100%;
}
.btn-del:hover { background: var(--danger); color: #fff; }

/* ── Summen box ── */
.summen-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.summen-zeile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}
.summen-zeile:last-child { border-bottom: none; }
.summen-brutto {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  padding-top: 12px;
}

/* ── Checkboxes ── */
.checkboxen {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  min-height: 32px;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.checkbox-label.disabled { opacity: 0.4; pointer-events: none; }

/* ── Pflichtfeld-Styles ── */
.pflicht { color: var(--danger); font-weight: 700; }

.pflicht-note {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.pflicht-legende {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin: -10px 0 20px;
}

/* Optional fields – hidden by default */
.optional-field {
  display: none;
}

.btn-optional-toggle {
  background: none;
  border: 1px dashed var(--border);
  color: var(--primary);
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 4px;
  width: 100%;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.btn-optional-toggle:hover {
  background: var(--bg);
  border-color: var(--primary);
}

/* ── Profil Export / Import ── */
.profil-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-profil {
  flex: 1;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}

.btn-profil:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg);
}

input.input-error,
textarea.input-error,
select.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.15) !important;
  background: rgba(220,38,38,0.04) !important;
}

/* ── Validation summary ── */
#validation-summary {
  display: none;
  background: #fef2f2;
  border: 1.5px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 16px;
  color: #991b1b;
  font-size: 0.9rem;
}
#validation-summary strong { display: block; margin-bottom: 6px; }
#validation-summary ul { margin: 0; padding-left: 18px; }
#validation-summary li { margin-bottom: 3px; }
html.dark #validation-summary { background: rgba(220,38,38,0.12); color: #fca5a5; }
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}

/* ── Logo area ── */
#logo-bereich { text-align: center; }
#logo-bereich input[type="file"] {
  display: block;
  margin: 0 auto 12px;
  min-height: 0;
  border: 1.5px dashed var(--border);
  background: var(--bg);
  padding: 8px;
  font-size: 0.85rem;
}
#rechnungsbild-vorschau {
  max-width: 220px;
  max-height: 80px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
}
.btn-logo-loeschen {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-logo-loeschen:hover {
  background: var(--danger);
  color: #fff;
}

/* ── PWA Banner ── */
#pwa-banner {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
#pwa-banner > div {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg);
  color: var(--text);
  padding: 32px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.25);
  text-align: center;
  min-width: 260px;
  max-width: 90vw;
}
#pwa-banner img { width: 64px; height: 64px; margin-bottom: 16px; }
#pwa-banner .pwa-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 18px; }
#pwa-banner .pwa-btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
#pwa-install-btn {
  padding: 10px 20px; font-size: 1rem; background: var(--primary);
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 600;
}
#pwa-cancel-btn {
  padding: 10px 20px; font-size: 1rem; background: var(--border);
  color: var(--text); border: none; border-radius: 8px; cursor: pointer;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { text-decoration: underline; }