/* LYTD Produktionsplanung — Design-Tokens aus der LYTD App (src/index.css): Anthrazit-Stack, weiße Karten,
   Radius 12, Grün nur für Fortschritt/Erledigt, Farbe nur mit Bedeutung. Schriften selbst gehostet. */
@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url('/fonts/poppins-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 500; font-display: swap; src: url('/fonts/poppins-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-display: swap; src: url('/fonts/poppins-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-display: swap; src: url('/fonts/poppins-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-weight: 400; font-display: swap; src: url('/fonts/geist-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-weight: 500; font-display: swap; src: url('/fonts/geist-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  --bg: #f7f7f7;
  --fg: #141414;
  --card: #ffffff;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #e6e6e6;
  --line-soft: #efefef;
  --fill: #f0f0f0;
  --fill-strong: #e8e8e8;
  --accent: #2e2e2e;                    /* Anthrazit als Primär-Akzent */
  --green: #81c833;                     /* LYTD-Grün: nur Erledigt/Fortschritt */
  --green-ink: #4a7a17;
  --green-soft: #f2f9e8;
  --red: #c93a33;                       /* jetzt bestellen / leer */
  --red-soft: #fcefee;
  --amber: #9a5b16;                     /* Überbestand / Entscheidung */
  --amber-soft: #fbf3e6;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .03), 0 4px 16px -6px rgba(20, 20, 20, .07);
  --shadow-hover: 0 2px 4px rgba(20, 20, 20, .05), 0 12px 32px -8px rgba(20, 20, 20, .10);
  --glass: rgba(247, 247, 247, .74);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 14px/1.5 'Poppins', system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.num, .mono { font-family: var(--mono); font-feature-settings: 'tnum'; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand b { font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.brand span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.topbar-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; min-width: 0; }

.seg { display: inline-flex; background: var(--fill-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--muted); cursor: pointer; transition: background .25s var(--ease), color .25s var(--ease);
}
.seg button[aria-selected="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.syncpill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 0; }
.syncpill .txt { overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--green); }
.dot.run { background: var(--fg); animation: pulse 1.2s var(--ease) infinite; }
.dot.err { background: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .25s var(--ease), background .2s; white-space: nowrap;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.primary:hover { box-shadow: var(--shadow-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.icon { width: 36px; padding: 0; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.view { display: none; }
.view.on { display: block; animation: rise .4s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 16px; margin-bottom: 20px; }
.kicker { font-size: 12px; color: var(--muted); letter-spacing: .02em; margin: 0 0 4px; }
h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.02em; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.summary { display: flex; gap: 22px; align-items: baseline; }
.stat { text-align: right; }
.stat .v { font-family: var(--mono); font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); }

/* ---------- Hinweise ---------- */
.alerts { display: grid; gap: 8px; margin-bottom: 18px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); font-size: 13px; background: var(--card); border: 1px solid var(--line); }
.alert .ico { margin-top: 2px; }
.alert.warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.alert.err { background: var(--red-soft); border-color: transparent; color: var(--red); }
.alert.ok { background: var(--green-soft); border-color: transparent; color: var(--green-ink); }
.alert b { font-weight: 600; }

/* ---------- Bestell-Karten (die eine Aktion pro Lieferant) ---------- */
.orders { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--line-soft); }
.oc-head { padding: 18px 20px 14px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.oc-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.oc-total { text-align: right; }
.oc-total .v { font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.oc-total .l { font-size: 12px; color: var(--muted); }
.oc-art { padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.oc-art-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 10px; }
.oc-art-top .name { font-weight: 500; }
.oc-art-top .code { font-family: var(--mono); font-size: 12px; color: var(--faint); margin-left: 6px; }
.oc-art-top .amt { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center;
  padding: 6px 10px 6px 9px; border-radius: 10px; background: var(--fill); font-size: 13px;
}
.chip .sz { font-weight: 600; font-size: 12px; min-width: 22px; }
.chip .q { font-family: var(--mono); font-weight: 500; }
.chip.now { background: var(--red-soft); }
.chip.now .sz { color: var(--red); }
.chip .why { grid-column: 1 / -1; font-size: 11px; color: var(--muted); line-height: 1.3; }
.moqline { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 10px; }
.moqline.warn { color: var(--amber); font-weight: 500; }
.oc-foot { padding: 14px 20px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.oc-foot .note { font-size: 12px; color: var(--muted); }
.done-badge { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--green-ink); background: var(--green-soft); padding: 5px 10px; border-radius: 999px; font-weight: 500; }

.empty { padding: 36px 28px; text-align: left; }
.empty h2 { margin-bottom: 6px; }
.empty p { margin: 0; color: var(--muted); max-width: 60ch; }

/* ---------- Abschnitte ---------- */
.section { margin-top: 34px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.section-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line-soft); }
.row { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 12px; padding: 11px 16px; align-items: center; font-size: 13px; }
.row + .row { border-top: 1px solid var(--line-soft); }
.row .k { font-size: 11px; color: var(--muted); display: block; }

/* ---------- Bestand ---------- */
.art { margin-bottom: 26px; }
.art-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-bottom: 8px; }
.art-head .meta { display: flex; gap: 18px; font-size: 12px; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; }
.art-head .meta b { color: var(--fg); font-weight: 500; font-family: var(--mono); }
.tbl-wrap { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line-soft); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; font-weight: 500; font-size: 11px; color: var(--muted); padding: 10px 12px 8px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { text-align: right; padding: 9px 12px; white-space: nowrap; border-top: 1px solid var(--line-soft); }
tbody tr:first-child td { border-top: 0; }
th:first-child, td:first-child { text-align: left; }
td.l, th.l { text-align: left; }
.sizecell { font-weight: 600; }
tr.is-now td.sizecell { color: var(--red); }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--fill); color: var(--muted); font-family: 'Poppins', sans-serif; font-weight: 500; letter-spacing: 0; }
.tag.now { background: var(--red-soft); color: var(--red); }
.tag.soon { background: var(--fill-strong); color: var(--fg); }
.tag.over { background: var(--amber-soft); color: var(--amber); }
.tag.ok { background: var(--green-soft); color: var(--green-ink); }
.ovmark { color: var(--faint); margin-left: 4px; font-size: 11px; }

/* Bestandsverlauf 16 Wochen (wie im alten Tool): Linie = Bestand ohne neue Bestellung,
   gestrichelt gruen = mit Vorschlag, Strich = offene Bestellung trifft ein, roter Punkt = leer */
.curve { display: block; width: 176px; height: 32px; overflow: visible; }
.curve .base { stroke: var(--line); stroke-width: 1; }
.curve .sq { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.curve .wo { fill: none; stroke: var(--green); stroke-width: 1.6; stroke-dasharray: 3 3; stroke-linejoin: round; }
.curve .po { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 2; }
.curve .po-hit { stroke: transparent; stroke-width: 8; }
.curve .oos { fill: var(--red); }
td.reachnum.now { color: var(--red); font-weight: 600; }
td.reachnum.over { color: var(--amber); font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 6px 0 18px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 18px; height: 6px; border-radius: 3px; display: inline-block; }
.ln { width: 18px; height: 0; border-top: 2px solid var(--accent); display: inline-block; }
.ln.dash { border-top: 2px dashed var(--green); }
.ln.po { width: 0; height: 12px; border-top: 0; border-left: 1px dashed var(--faint); }
.pt { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; }

details.explain { margin-top: 30px; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 0 16px; }
details.explain summary { cursor: pointer; padding: 13px 0; font-weight: 500; list-style: none; display: flex; gap: 8px; align-items: center; }
details.explain summary::-webkit-details-marker { display: none; }
details.explain ul { margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 13px; }
details.explain li { margin: 5px 0; }
details.explain code { font-family: var(--mono); font-size: 12px; color: var(--fg); }

/* ---------- Überbestand ---------- */
.kpis { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: var(--radius-lg); border: 1px solid var(--line-soft); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -.03em; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.spark { width: 100%; height: 46px; margin-top: 10px; display: block; }
.spark path.l { fill: none; stroke: var(--amber); stroke-width: 1.6; }
.spark path.a { fill: var(--amber-soft); }
.spark circle { fill: var(--amber); }

/* ---------- Sheet / Dialog ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 15, 15, .32); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 41; left: 50%; top: 50%; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  background: var(--card); border-radius: 20px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .35);
  transform: translate(-50%, -46%) scale(.98); opacity: 0; pointer-events: none; transition: transform .35s var(--ease), opacity .25s var(--ease);
}
.sheet.on { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.sheet-head { padding: 20px 22px 6px; }
.sheet-body { padding: 8px 22px 6px; }
.sheet-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.poslist { border: 1px solid var(--line-soft); border-radius: var(--radius); margin: 10px 0; }
.poslist div { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 8px 12px; font-size: 13px; }
.poslist div + div { border-top: 1px solid var(--line-soft); }
.poslist .q, .poslist .e { font-family: var(--mono); text-align: right; }
.sheet .fineprint { font-size: 12px; color: var(--muted); }

/* ---------- Laden ---------- */
.sk { border-radius: var(--radius); background: linear-gradient(90deg, var(--fill) 0%, var(--fill-strong) 50%, var(--fill) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 50; background: var(--accent); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; transition: transform .35s var(--ease), opacity .25s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.on { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); padding: 28px 26px 24px; }
.login-card .brand { margin-bottom: 22px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 0 12px; font: inherit; font-size: 15px; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--fill-strong); }
.field .err { font-size: 12px; color: var(--red); min-height: 18px; }
.login-card .btn { width: 100%; height: 42px; }

/* ---------- Mobil ---------- */
@media (max-width: 1080px) {
  .topbar-in { grid-template-columns: minmax(0, 1fr) auto; row-gap: 10px; }
  .topbar .seg { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
}
@media (max-width: 860px) {
  .topbar-in { padding: 10px 16px; }
  .topbar .seg { justify-self: stretch; }
  .topbar .seg button { flex: 1; }
  .brand span { display: none; }
  .syncpill .txt { display: none; }
  main { padding: 20px 16px 64px; }
  .head { grid-template-columns: 1fr; }
  .summary { justify-content: flex-start; }
  .stat { text-align: left; }
  .orders { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr 1fr; }
  .row > :first-child { grid-column: 1 / -1; }
  .art-head { grid-template-columns: 1fr; }
  .art-head .meta { justify-content: flex-start; }
  .curve { width: 140px; }
  .sheet { top: auto; bottom: 0; left: 0; width: 100%; border-radius: 20px 20px 0 0; transform: translateY(24px); max-height: 88dvh; }
  .sheet.on { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* (i)-Erklaerungen */
.tip {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 5px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: 600 9.5px/1 'Poppins', sans-serif; cursor: help; vertical-align: 1px; letter-spacing: 0;
  transition: color .2s, border-color .2s;
}
.tip:hover, .tip:focus-visible { color: var(--fg); border-color: var(--muted); outline: none; }
h1 .tip, h2 .tip { vertical-align: 3px; }
.tipbox {
  position: fixed; z-index: 70; max-width: min(320px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 10px;
  background: #1f1f1f; color: #f4f4f4; font-size: 12px; line-height: 1.5; font-weight: 400; text-align: left; white-space: normal;
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .15s var(--ease);
}
.tipbox.on { opacity: 1; }
.syncpill { cursor: help; }
