/* Airtec Isolierung — clean, modern. Brandsystem Airtec Energie (Skill airtec-design):
   einzige Akzentfarbe Flame Orange #F29100, warmes Stein-Grau, flache weisse Flächen,
   kleine Radien (Stahlrohr-Ästhetik), dünne Rahmen. Schrift: Manrope, falls installiert,
   sonst Systemstack (CSP strikt, keine externen Fonts). Docs: docs/design.md */
:root {
  --orange: #f29100;
  --orange-hover: #d87f00;
  --orange-pressed: #bf6f00;
  --orange-weich: #fff4e5;

  --grund: #f7f5f1;
  --flaeche: #ffffff;
  --flaeche-2: #faf8f5;
  --linie: #e6e1d9;
  --linie-stark: #cfc8bd;
  --text: #1f1d1a;
  --text-2: #5e5850;
  --text-3: #8b847a;

  --ok: #2f7d4a;
  --ok-weich: #e8f3ec;
  --warn: #b7791f;
  --warn-weich: #fdf3e1;
  --rot: #b23a3a;
  --rot-weich: #fbeaea;
  --grau-weich: #eeebe6;

  --radius: 6px;
  --radius-s: 4px;
  --schatten: 0 1px 2px rgba(31, 29, 26, 0.06), 0 1px 1px rgba(31, 29, 26, 0.04);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Manrope, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #161513;
    --flaeche: #1f1d1a;
    --flaeche-2: #262421;
    --linie: #34312c;
    --linie-stark: #4a463f;
    --text: #efece6;
    --text-2: #b8b1a6;
    --text-3: #857e73;
    --orange-weich: #33240f;
    --ok-weich: #16291d;
    --warn-weich: #33270f;
    --rot-weich: #341a1a;
    --grau-weich: #2b2925;
    --schatten: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--grund);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; color: var(--text-2); }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--orange);
}
.leise { color: var(--text-2); }
.leiser { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.versteckt { display: none !important; }

/* ------------------------------------------------------------- Login */
body.loginseite { display: grid; place-items: center; padding: 24px; }
.loginbox {
  width: min(100%, 380px); background: var(--flaeche); border: 1px solid var(--linie); border-radius: 8px;
  padding: 36px 32px 28px;
}
.loginbox .logo { display: block; width: 120px; height: auto; margin: 0 0 20px; }
.loginbox h1 { font-size: 24px; margin: 4px 0 24px; }
.loginbox label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.loginbox input { width: 100%; margin-bottom: 14px; }
.loginbox .fehler { min-height: 20px; color: var(--rot); font-size: 13px; margin-top: 10px; }

/* ------------------------------------------------------------- Formularelemente */
input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--linie-stark); border-radius: var(--radius-s);
  background: var(--flaeche); color: var(--text); outline: none; transition: border-color 120ms, box-shadow 120ms;
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242, 145, 0, 0.18); }
input[type="number"] { font-variant-numeric: tabular-nums; }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
label.feld { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
label.feld input, label.feld select { font-weight: 400; color: var(--text); }

button.primary, button.sekundaer, button.leise, button.gefaehrlich, button.icon {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-s);
  border: 1px solid transparent; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: background-color 120ms, border-color 120ms, box-shadow 120ms, transform 60ms;
}
button.primary { background: var(--orange); color: #fff; box-shadow: var(--schatten); }
button.primary:hover { background: var(--orange-hover); }
button.primary:active { background: var(--orange-pressed); box-shadow: none; transform: translateY(1px); }
button.sekundaer { background: var(--flaeche); border-color: var(--linie-stark); }
button.sekundaer:hover { border-color: var(--text-3); background: var(--flaeche-2); }
button.leise { background: transparent; color: var(--text-2); padding: 6px 8px; }
button.leise:hover { background: var(--grau-weich); color: var(--text); }
button.gefaehrlich { background: transparent; color: var(--rot); border-color: transparent; }
button.gefaehrlich:hover { background: var(--rot-weich); }
button.icon { padding: 6px; background: transparent; color: var(--text-3); }
button.icon:hover { background: var(--grau-weich); color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }
button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- Kopf */
.kopf {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--flaeche) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--linie);
}
.kopf-inhalt { max-width: 1440px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 20px; }
.kopf .logo { height: 34px; width: auto; align-self: flex-start; }
.kopf-titel { display: flex; flex-direction: column; gap: 1px; }
.kopf-titel h1 { font-size: 16px; }
.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.quelle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2);
  padding: 4px 10px; border: 1px solid var(--linie); border-radius: 999px; background: var(--flaeche);
}
.quelle .punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.quelle.ok .punkt { background: var(--ok); }
.quelle.warn .punkt { background: var(--warn); }
.quelle.rot .punkt { background: var(--rot); }

/* ------------------------------------------------------------- Layout */
.seite { max-width: 1440px; margin: 0 auto; padding: 24px 24px 120px; display: grid; gap: 20px; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); }
.karte-kopf { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--linie); flex-wrap: wrap; }
.karte-kopf .rechts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.karte-inhalt { padding: 18px; }

.start { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .start { grid-template-columns: 1fr; } }
.start form { display: grid; gap: 12px; }
.start .zeile { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: end; }
.start .zeile label.feld { min-width: 0; }
.start .hinweis { font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------------------- Berechnung */
.b-kopf { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--linie); flex-wrap: wrap; }
.b-kopf .titel { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.b-kopf .titel h2 { font-size: 18px; }
.b-kopf .titel h2:hover { color: var(--orange-pressed); }
#b-speicher { font-size: 12px; }
.b-kopf .aktionen { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.b-kopf .dicke { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.b-kopf .dicke select { width: 110px; padding: 6px 28px 6px 10px; }

table.positionen { width: 100%; border-collapse: collapse; font-size: 13px; }
table.positionen th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 10px; border-bottom: 1px solid var(--linie); background: var(--flaeche-2); white-space: nowrap;
}
table.positionen th.num { text-align: right; }
table.positionen td { padding: 10px; border-bottom: 1px solid var(--linie); vertical-align: top; }
table.positionen tr.zeile { cursor: pointer; }
table.positionen tr.zeile:hover td { background: var(--flaeche-2); }
table.positionen tr.zeile.offen td { background: var(--orange-weich); border-bottom-color: transparent; }
table.positionen tr.ignoriert td:not(.status-zelle) { color: var(--text-3); }
table.positionen td.pos { color: var(--text-3); font-variant-numeric: tabular-nums; width: 36px; }
table.positionen td.produkt { min-width: 220px; }
table.positionen td.produkt .titel { font-weight: 600; }
table.positionen td.produkt .sku { display: block; margin-top: 2px; }
table.positionen td.menge { width: 96px; }
table.positionen td.menge input { padding: 5px 6px; text-align: right; width: 76px; -moz-appearance: textfield; }
table.positionen td.menge input::-webkit-outer-spin-button, table.positionen td.menge input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
table.positionen td.form { min-width: 160px; }
table.positionen td.form .masse { display: block; color: var(--text-2); font-size: 12px; margin-top: 2px; }
table.positionen td.total { font-weight: 700; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; padding: 1px 6px;
  border-radius: 3px; background: var(--grau-weich); color: var(--text-2); white-space: nowrap;
}
.badge.annahme { background: var(--warn-weich); color: var(--warn); }
.badge.manuell { background: var(--orange-weich); color: var(--orange-pressed); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; white-space: nowrap;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-weich); color: var(--ok); }
.chip.annahme { background: var(--warn-weich); color: var(--warn); }
.chip.pruefen { background: var(--rot-weich); color: var(--rot); }
.chip.nicht_berechenbar { background: var(--rot-weich); color: var(--rot); }
.chip.ignoriert { background: var(--grau-weich); color: var(--text-3); }

tr.details td { padding: 0 10px 16px 46px; background: var(--orange-weich); }
.details-inhalt { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; padding-top: 4px; }
@media (max-width: 900px) { .details-inhalt { grid-template-columns: 1fr; } }
.details-inhalt h3 { margin-bottom: 6px; }
.formel { font-family: var(--mono); font-size: 12px; color: var(--text-2); display: grid; gap: 3px; }
.hinweisliste { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 12.5px; }
.hinweisliste li::before { content: '– '; color: var(--text-3); }
.hinweisliste li.pruefen { color: var(--rot); }
.hinweisliste li.fehlt { color: var(--rot); }
.details-aktionen { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.vergleich { font-size: 12.5px; color: var(--text-2); }

.summen {
  position: sticky; bottom: 0; z-index: 10; margin-top: -1px;
  background: color-mix(in srgb, var(--flaeche) 94%, transparent); backdrop-filter: blur(8px);
  border-top: 2px solid var(--orange); padding: 12px 18px; display: flex; gap: 28px; flex-wrap: wrap; align-items: baseline;
}
.summen .wert { display: flex; flex-direction: column; }
.summen .wert .label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.summen .wert .zahl { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summen .wert.haupt .zahl { color: var(--orange-pressed); font-size: 26px; }
.summen .meta { margin-left: auto; font-size: 12px; color: var(--text-2); text-align: right; }
.summen .meta .warn { color: var(--warn); }

/* ------------------------------------------------------------- Liste */
.liste { display: grid; gap: 0; }
.liste .eintrag { display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--linie); cursor: pointer; }
.liste .eintrag:hover { background: var(--flaeche-2); }
.liste .eintrag:last-child { border-bottom: none; }
.liste .eintrag .t { font-weight: 600; }
.liste .eintrag .m { font-size: 12px; color: var(--text-3); }
.leer { padding: 32px 18px; text-align: center; color: var(--text-3); }

/* ------------------------------------------------------------- Dialoge */
dialog {
  border: 1px solid var(--linie); border-radius: 8px; padding: 0; background: var(--flaeche); color: var(--text);
  width: min(100% - 32px, 720px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
dialog::backdrop { background: rgba(31, 29, 26, 0.35); }
.dialog-kopf { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--linie); }
.dialog-kopf h2 { flex: 1; }
.dialog-inhalt { padding: 20px; display: grid; gap: 16px; }
.dialog-fuss { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--linie); background: var(--flaeche-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--linie); }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px; font-weight: 600; color: var(--text-2); margin-bottom: -1px; }
.tabs button.aktiv { color: var(--text); border-bottom-color: var(--orange); }
.felder { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.suchliste { display: grid; gap: 0; border: 1px solid var(--linie); border-radius: var(--radius-s); max-height: 260px; overflow: auto; }
.suchliste button { text-align: left; background: none; border: none; border-bottom: 1px solid var(--linie); padding: 8px 12px; display: grid; gap: 2px; }
.suchliste button:hover, .suchliste button.aktiv { background: var(--orange-weich); }
.suchliste button:last-child { border-bottom: none; }
.vorschau { border: 1px dashed var(--linie-stark); border-radius: var(--radius-s); padding: 12px 14px; font-size: 13px; display: grid; gap: 6px; }
.vorschau .gross { font-size: 18px; font-weight: 700; }
.optionen { display: flex; gap: 8px; flex-wrap: wrap; }
.optionen label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--linie-stark); border-radius: var(--radius-s); cursor: pointer; font-size: 13px; }
.optionen label:has(input:checked) { border-color: var(--orange); background: var(--orange-weich); }
.optionen input { margin: 0; accent-color: var(--orange); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--grund); padding: 10px 16px; border-radius: var(--radius-s); font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); opacity: 0; pointer-events: none; transition: opacity 160ms;
}
.toast.sichtbar { opacity: 1; }
.toast.fehler { background: var(--rot); color: #fff; }

kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--linie-stark); border-bottom-width: 2px; border-radius: 3px; color: var(--text-2); }

@media (max-width: 760px) {
  .kopf-inhalt, .seite { padding-left: 16px; padding-right: 16px; }
  .kopf-titel .leise { display: none; }
  table.positionen th.opt, table.positionen td.opt { display: none; }
  .summen { gap: 16px; }
}

/* ------------------------------------------------------------- Druck */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .kopf, .start, .no-print, .summen .meta, button, .liste-karte { display: none !important; }
  .seite { padding: 0; max-width: none; }
  .karte { border: none; }
  table.positionen th, table.positionen td { padding: 5px 6px; }
  tr.details { display: none; }
  .summen { position: static; border-top: 2px solid #000; background: none; }
  .chip::before { display: none; }
  .b-kopf .dicke select { border: none; padding: 0; background: none; appearance: none; }
}
