/* Folienrechner – Gestaltung (Aufbau wie Textilrechner, Farben des Folienrechners)
   Akzent #1f5fae · Hintergrund #f5f7fa · Rand #c9ced6 · Text #1d2129 */

:root {
  --prim: #1f5fae;
  --prim-dark: #184b8a;
  --prim-soft: #e8eef8;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1d2129;
  --ink-2: #555b66;
  --line: #c9ced6;
  --line-2: #e3e6eb;
  --zusatz: #f3f7fd;
  --zusatz-rand: #b9cbe6;
  --error: #b3261e;
  --ok: #1e7a3c;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
small { color: var(--ink-2); font-weight: 400; }

/* ---------- Kopfleiste ---------- */
.topbar { background: var(--prim); color: #fff; margin-bottom: 24px; }
.topbar__in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.topbar__brand { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.topbar__title { display: block; font-size: 19px; font-weight: 600; }
.topbar__status { font-size: 13px; opacity: .85; }

/* ---------- Layout: Formular links, Ergebnis rechts ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; padding-bottom: 40px; }
.layout__side { position: sticky; top: 16px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout__side { position: static; }
}

.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

/* ---------- Felder ---------- */
.feld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.feld__label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=number], input[type=password], input[type=email], select {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--prim); box-shadow: 0 0 0 3px rgba(31, 95, 174, .18); }
.ausgabe { background: #eef2f7; font-weight: 600; text-align: right; }
.is-invalid { border-color: var(--error) !important; background: #fdecea !important; }
option:disabled { color: #aaa; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; border-radius: 6px; padding: 10px 18px; min-height: 42px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn--primary { background: var(--prim); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--prim-dark); }
.btn--primary:disabled { opacity: .55; cursor: wait; }
.btn--light { background: #e7eaf0; color: var(--ink); }
.btn--light:hover { background: #dce1e8; }
.btn--ghost { background: transparent; color: var(--prim); border: 1px dashed var(--prim); }
.btn--ghost:hover:not(:disabled) { background: var(--prim-soft); }
.btn--ghost:disabled { opacity: .4; cursor: not-allowed; }
.btn--danger { background: #fff; color: var(--error); border-color: #e3b7b3; }
.btn--danger:hover { background: #fdecea; }
.btn--block { width: 100%; margin-top: 10px; }
.btn--add { width: 100%; padding: 14px; }
.btn--add span { font-size: 20px; line-height: 1; }

/* ---------- Position (Zeile) ---------- */
.zeile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; animation: popIn .2s ease-out; }
@keyframes popIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.zeile__kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--prim); color: #fff; padding: 8px 16px; min-height: 44px; }
.zeile__kopf h2 { margin: 0; font-size: 16px; }
.zeile__weg { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; width: 30px; height: 30px; font-size: 18px; line-height: 1; cursor: pointer; }
.zeile__weg:hover { background: rgba(255,255,255,.15); }

.zeile.zusatz { background: var(--zusatz); border-color: var(--zusatz-rand); margin-left: 28px; margin-top: -8px; position: relative; overflow: visible; }
.zeile.zusatz::before { content: "↳"; position: absolute; left: -24px; top: 10px; color: var(--prim); font-size: 1.2rem; }
.zeile.zusatz .zeile__kopf { background: var(--prim-soft); color: var(--prim); border-radius: var(--radius) var(--radius) 0 0; min-height: 36px; }
.zeile.zusatz .zeile__kopf h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

.zeile__felder { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px 16px 4px; }
.feld--breit { grid-column: span 2; }
.zeile__ergebnis { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 16px 0; padding: 10px 0 14px; border-top: 1px dashed var(--line); }
.bahnen { font-size: 13px; color: var(--ink-2); flex: 1 1 160px; padding-bottom: 6px; }
.zeile__komm { flex: 2 1 220px; }
.zeile__preis { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 120px; }
.zeile__preis span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.zeile__preis output { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fehler { color: var(--error); font-size: 13px; margin: -6px 16px 12px; }
.fehler:empty { display: none; }

/* ---------- Ergebnis ---------- */
.summary { border-top: 5px solid var(--prim); }
.summary__title { margin: 0 0 12px; font-size: 17px; }
.totals { margin: 0; }
.totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals__check { border-bottom: 1px dotted var(--line); }
.totals__end { border-top: 2px solid var(--ink); border-bottom: 0 !important; margin-top: 6px; padding-top: 10px !important; font-size: 19px; font-weight: 700; }
.totals__end dt { color: var(--ink); }
.totals__end dd { color: var(--prim); }
.brutto { margin: 2px 0 0; text-align: right; font-size: 13px; color: var(--ink-2); }
.brutto strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.hint { margin: 14px 0 4px; font-size: 12.5px; color: var(--ink-2); background: var(--bg); border-left: 3px solid var(--prim); padding: 8px 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--prim); }

.notice { padding: 12px 16px; border-radius: 6px; margin: 0 0 16px; background: #fff; border-left: 4px solid var(--prim); }
.notice--error { border-left-color: var(--error); color: var(--error); background: #fdecea; }
.notice--ok { border-left-color: var(--ok); color: var(--ok); background: #e5f4ea; }
.notice--info { color: var(--prim); background: var(--prim-soft); }

.footer { text-align: center; font-size: 8px; line-height: 1.4; color: var(--ink-2); padding: 0 16px 12px; }

/* ---------- Kalkulation (Vorschau) ---------- */
#druck { position: fixed; inset: 0; z-index: 50; background: rgba(20,25,35,.55); overflow: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.druck-leiste { position: sticky; top: 0; z-index: 1; max-width: 860px; margin: 0 auto 12px; display: flex; gap: 10px; justify-content: flex-end; }
.druck-leiste .btn { box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.druck-leiste .btn--light { background: #fff; }
body.vorschau { overflow: hidden; }

.blatt { background: #fff; color: #000; max-width: 860px; margin: 0 auto; padding: 36px 40px; border-radius: 6px; box-shadow: 0 4px 20px rgba(0,0,0,.25); }
.blatt__kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 3px solid var(--prim); padding-bottom: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.blatt__firma { margin: 0 0 2px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--prim); font-weight: 600; }
.blatt h2 { font-size: 1.3rem; margin: 0; }
.blatt .datum { margin: 0; font-size: .9rem; color: #444; }
.blatt table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.blatt th, .blatt td { border-bottom: 1px solid #bbb; padding: 7px 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.blatt th { border-bottom: 2px solid #000; font-size: .85rem; }
.blatt .zahl { text-align: right; width: 1%; white-space: nowrap; }
.blatt .betrag { text-align: right; white-space: nowrap; }
.blatt tr.zusatz td { background: #f6f8fb; }
.blatt .zusatzhinweis { font-size: .8em; color: #555; }
.blatt tfoot td { border-bottom: none; }
.blatt tfoot tr:first-child td { border-top: 2px solid #000; }
.blatt tr.summe td { font-weight: 700; border-top: 2px solid #000; }
.blatt tr.klein td { font-size: .85em; color: #333; padding-top: 3px; padding-bottom: 3px; }
.blatt__hinweis { margin: 22px 0 0; padding: 8px 10px; font-size: .85rem; color: #333; border: 1px solid #ccc; border-left: 3px solid var(--prim); }

@media print {
  @page { margin: 18mm 15mm; }
  body { background: #fff; }
  .topbar, main, .footer, .druck-leiste, datalist, .admin-only-screen { display: none !important; }
  #druck, #druck[hidden] { display: block !important; position: static; background: none; padding: 0; overflow: visible; }
  .blatt { max-width: none; padding: 0; box-shadow: none; border-radius: 0; font-size: 10.5pt; }
  .blatt table { font-size: 10pt; }
  .blatt__kopf { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Kleine Bildschirme (z. B. iPhone: 393 px) ---------- */
@media (max-width: 640px) {
  input[type=text], input[type=number], input[type=password], input[type=email], select { font-size: 16px; min-height: 44px; } /* kein Auto-Zoom auf iOS */
  .wrap { padding: 0 10px; }
  .topbar { margin-bottom: 14px; }
  .topbar__title { font-size: 17px; }
  .card { padding: 14px; }
  .layout { gap: 14px; padding-bottom: 24px; }
  .zeile__kopf { padding: 8px 12px; }
  .zeile__felder { grid-template-columns: 1fr 1fr; padding: 12px 12px 4px; gap: 10px; }
  .zeile.zusatz { margin-left: 10px; }
  .zeile.zusatz::before { display: none; }
  .zeile__ergebnis { margin: 10px 12px 0; flex-direction: column; align-items: stretch; }
  .bahnen, .zeile__komm { flex: none; }
  .zeile__preis { flex-direction: row; justify-content: space-between; align-items: center; }
  .fehler { margin: -6px 12px 12px; }
  .totals__end { font-size: 17px; }
  #druck { padding: 10px 8px calc(16px + env(safe-area-inset-bottom)); }
  .druck-leiste .btn { flex: 1; min-height: 46px; }
  .blatt { padding: 18px 12px; }
  .blatt table { font-size: .75rem; }
  .blatt th, .blatt td { padding: 6px 4px; }
  .blatt .betrag { white-space: normal; }
}
