/* Stock Planner. Farben und Schrift nach design/README.md: Marke und Aktionsfarbe von Hielscher,
   Status- und Risikofarben von der Plattform (nie Kundenfarbe). Eine Spalte, Kopfleiste bleibt stehen,
   Tabellen werden auf dem Handy zu Karten. */
:root {
  --brand: #2f73c4; --brand-ink: #ffffff; --accent: #2e7d25; --accent-deep: #256a1e; --accent-ink: #ffffff; --progress: #4aab3d;
  --bg: #eceff2; --surface: #ffffff; --sunk: #f2f4f6; --line: #d3d9e0; --ink: #121a23; --ink-2: #4b5664; --ink-3: #6b7684;
  --crit: #a3231b; --crit-soft: #fbddd9; --warn: #7a4b00; --warn-soft: #fbebc4; --soon: #1f5c9e; --soon-soft: #dfeaf8; --ok: #1d6b33; --ok-soft: #e2f1e5;
  --chart-line: #2f73c4; --chart-fill: rgba(47,115,196,.12); --chart-grid: #e1e6ec;
  --f-display: 'Barlow Semi Condensed', system-ui, sans-serif; --f-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 10px; color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--f-body); padding-bottom: env(safe-area-inset-bottom, 0px); }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: .01em; }
.num, td.n { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Kopfleiste */
.bar { position: sticky; top: 0; z-index: 5; background: var(--brand); color: var(--brand-ink); padding-top: env(safe-area-inset-top, 0px); }
.bar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-block: 10px; }
.bar .logo { height: 38px; width: 38px; border-radius: 8px; background: #fff; flex: none; }
.brand { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; }
.brand h1 { font-size: 20px; font-weight: 600; line-height: 1.1; }
.brand .sub { font-size: 12px; opacity: .88; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bar .btn.ghost { border-color: rgba(255,255,255,.5); color: #fff; }
.bar .btn.ghost:hover { background: rgba(255,255,255,.16); }

.btn { font: 600 15px var(--f-display); letter-spacing: .03em; border: 0; border-radius: var(--r); padding: 12px 16px; min-height: 48px; background: var(--accent); color: var(--accent-ink); }
.btn:hover { background: var(--accent-deep); }
.btn.ghost { background: none; border: 1.5px solid var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--sunk); }
.btn.small { font-size: 14px; padding: 6px 12px; min-height: 36px; }
.btn:disabled { background: var(--sunk); color: var(--ink-3); cursor: not-allowed; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--soon); text-decoration: underline; font-size: 13px; }

/* Datenquellen und Hinweise */
.src { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip.ok .dot { background: var(--ok); } .chip.err { background: var(--crit-soft); color: var(--crit); border-color: transparent; } .chip.err .dot { background: var(--crit); }
.chip.load .dot { background: var(--warn); animation: pulse 1s infinite; }
.chip.demo { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .chip.load .dot { animation: none; } }
.notice { margin-top: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.notice.crit { background: var(--crit-soft); }
.notice p { margin: 0; flex: 1 1 280px; }
.msg { font-size: 14px; padding: 8px 10px; border-radius: var(--r); margin: 0; }
.msg.bad { background: var(--crit-soft); color: var(--crit); }

/* Kennzahlen */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.tile .v { font-family: var(--f-display); font-size: 30px; font-weight: 700; line-height: 1.1; }
.tile .d { font-size: 12px; color: var(--ink-2); }
.tile.crit .v { color: var(--crit); } .tile.warn .v { color: var(--warn); } .tile.soon .v { color: var(--soon); }
.tile:hover { border-color: var(--brand); }
@media (max-width: 720px) { .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Reiter */
.tabs { display: flex; gap: 2px; margin-top: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px 14px; color: var(--ink-2); text-decoration: none; font: 600 15px var(--f-display); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--progress); }
.tabs a:hover { color: var(--brand); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-size: 12px; text-align: center; }
.count.crit { background: var(--crit-soft); color: var(--crit); }
section.view { padding-block: 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.lead-in { color: var(--ink-2); max-width: 72ch; margin: 0; }

/* Blöcke und Tabellen */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.block > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.block > header h3 { font-size: 17px; font-weight: 600; }
.block > header .meta { color: var(--ink-3); font-size: 12px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 8px 12px; background: var(--sunk); white-space: nowrap; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.prod { cursor: pointer; }
tr.prod:hover td { background: var(--sunk); }
tr.prod td:first-child { border-left: 4px solid transparent; }
tr.s-overdue td:first-child { border-left-color: var(--crit); }
tr.s-week td:first-child { border-left-color: var(--warn); }
tr.s-soon td:first-child { border-left-color: var(--soon); }
tr.s-later td:first-child, tr.s-wait td:first-child { border-left-color: var(--line); }
.pname { font-weight: 600; }
.psub { color: var(--ink-3); font-size: 12px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.overdue, .pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.week, .pill.warn, .pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.soon { background: var(--soon-soft); color: var(--soon); }
.pill.later, .pill.mute { background: var(--sunk); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.detail td { background: var(--sunk); padding: 12px 14px 16px; }
.detail .cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.detail h4 { margin: 0 0 6px; font: 600 12px var(--f-body); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.mini { width: 100%; font-size: 13px; }
.mini td { padding: 5px 8px; border-top: 1px solid var(--line); background: transparent; }
.mini tr.short td { color: var(--crit); }
.empty { padding: 18px 14px; color: var(--ink-3); }
details.okgroup summary { cursor: pointer; padding: 14px; font-weight: 600; color: var(--ink-2); }
.rowacts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Handy: Tabellen mit .stack werden zu Karten, die Beschriftung kommt aus data-l */
@media (max-width: 720px) {
  .detail .cols { grid-template-columns: minmax(0, 1fr); }
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 12px; padding: 12px 14px; border-top: 1px solid var(--line); border-left: 4px solid transparent; }
  table.stack tr.s-overdue { border-left-color: var(--crit); } table.stack tr.s-week { border-left-color: var(--warn); } table.stack tr.s-soon { border-left-color: var(--soon); }
  table.stack td { display: block; border: 0 !important; padding: 2px 0; text-align: left !important; white-space: normal; }
  table.stack td:first-child { grid-column: 1 / -1; }
  table.stack td.wide { grid-column: 1 / -1; }
  table.stack td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
  table.stack tr.detail { display: block; padding: 0; }
  table.stack tr.detail td { padding: 12px 14px; }
  table.stack .rowacts { justify-content: flex-start; margin-top: 6px; }
  table.stack .rowacts .btn { flex: 1 1 auto; min-height: 48px; }
}

/* Aiko */
.aiko-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .aiko-grid { grid-template-columns: minmax(0, 1fr); } }
.chart { padding: 12px 8px 4px; }
.chart svg { width: 100%; height: auto; display: block; }
.facts { display: flex; flex-direction: column; }
.fact { padding: 11px 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.fact:first-child { border-top: 0; }
.fact .k { color: var(--ink-2); }
.fact .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.callout { padding: 14px; background: var(--soon-soft); border-top: 1px solid var(--line); }
.callout strong { font: 600 19px var(--f-display); display: block; }

/* Filter, Formulare */
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 13px; font-size: 14px; min-height: 38px; }
.filters button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }
.panel h3 { font-size: 18px; }
.panel.login { max-width: 420px; margin: 40px auto; }
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field input, .field select, select { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); min-width: 0; min-height: 40px; max-width: 100%; }
.rowform { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.rowform .field { flex: 1 1 140px; }
.hint { color: var(--ink-3); font-size: 13px; margin: 0; }
.plain { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.plain li { display: flex; gap: 8px; align-items: center; }
.x { border: 0; background: none; color: var(--ink-3); padding: 4px 8px; min-height: 32px; }
.x:hover { color: var(--crit); }
.foot { color: var(--ink-3); font-size: 12px; padding-block: 0 32px; }

/* Datencheck */
.check { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.check:first-child { border-top: 0; }
.check ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.check .body { flex: 1 1 auto; min-width: 0; }

/* Dialog und Meldung */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 24px)); color: var(--ink); background: var(--surface); box-shadow: 0 20px 50px -20px rgba(18,26,35,.6); }
dialog::backdrop { background: rgba(18,26,35,.45); }
#dlgForm { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
#dlgForm h3 { font-size: 20px; }
#dlgForm .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#dlgForm .buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; max-width: calc(100vw - 24px); }
.toast.bad { background: var(--crit); }

.filebtn { display: inline-flex; align-items: center; cursor: pointer; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
