/* Teutonica Werkstatt · Designsprache v0.1
   Ruhige Flächen, hoher Kontrast, Farbe nur für Zustände.
   Keine Pillen-Etiketten: Zustände als Punkt mit Wort, Auswahl als Segment, Liste oder Menü.
   Vom Allgemeinen ins Detail. Nebenhinweise als Tooltip. */

:root {
  --ink: #1B1D20;
  --muted: #4F535A;
  --faint: #6B6F76;
  --ground: #F4F3EF;
  --ground-2: #FAF9F6;
  --surface: #FFFFFF;
  --line: #D9D6CE;
  --line-soft: #ECEAE4;
  --field: #9C988E;
  --accent: #B53A0B;
  --accent-hover: #8F2D08;
  --accent-soft: #FDF1EA;
  --steel: #2E5A78;
  --steel-soft: #EEF3F7;
  --ok: #1F6B3F;
  --warn: #8A5300;
  --crit: #A3201A;
  --radius: 10px;
  --radius-sm: 8px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 15px/1.5 var(--font); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }

/* ---------- Grundaufbau ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.topbar .search { flex: 1 1 280px; display: flex; }
.topbar .search input { flex-grow: 1; }
.shell { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 69px); }
.sidenav { flex: 1 1 200px; max-width: 100%; padding: 16px 12px; background: var(--ground-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sidenav a { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border-left: 3px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink); text-decoration: none; font-weight: 500; }
.sidenav a:hover { background: var(--line-soft); }
.sidenav a[aria-current="page"] { background: var(--surface); border-left-color: var(--accent); font-weight: 600; }
.sidenav .later { min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: var(--faint); }
.sidenav hr { border: 0; height: 1px; background: var(--line); margin: 12px 8px; width: auto; }
.content { flex: 999 1 560px; min-width: 0; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.assistant { flex: 1 1 320px; max-width: 100%; padding: 20px; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.assistant[hidden] { display: none; }
@media (max-width: 720px) {
  .content { padding: 16px; }
  .sidenav { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav a { border-left: 0; border-bottom: 3px solid transparent; border-radius: 0; white-space: nowrap; }
  .sidenav a[aria-current="page"] { border-bottom-color: var(--accent); }
  .sidenav hr, .sidenav .later { display: none; }
}

/* ---------- Pfad ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--steel); text-decoration: none; font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--field); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- Schaltflächen und Felder ---------- */
.btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; border-radius: var(--radius-sm); border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--ground-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-steel { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn-steel:hover { background: #24475f; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--steel); }
.btn-ghost:hover { background: var(--steel-soft); color: var(--steel); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea { min-height: 48px; padding: 0 14px; border: 1.5px solid var(--field); border-radius: var(--radius-sm); background: var(--surface); width: 100%; }
.textarea { padding: 10px 14px; min-height: 96px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(46,90,120,.25); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 20px; }
.form-error { color: var(--crit); font-weight: 600; }

/* Segment-Auswahl (statt Pillen) */
.segmented { display: inline-flex; border: 1.5px solid var(--field); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented a, .segmented button { min-height: 40px; display: inline-flex; align-items: center; padding: 0 16px; border: 0; background: transparent; color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.segmented a + a, .segmented button + button { border-left: 1px solid var(--line); }
.segmented [aria-checked="true"], .segmented [aria-current="true"] { background: var(--ink); color: #fff; }

/* ---------- Karten, Listen, Tabellen ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-pad { padding: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--ink); color: var(--ink); }
.card .card-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 600; }
.card .big { font-family: var(--mono); font-size: 36px; font-weight: 600; line-height: 1; }
.chev { color: var(--field); font-size: 20px; }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.rows-inner { min-width: 560px; }
.row-head, .row { display: grid; grid-template-columns: var(--cols, minmax(0,2fr) minmax(0,1.3fr) minmax(0,1fr) 20px); gap: 16px; align-items: center; padding: 14px 18px; }
.row-head { border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 12px; padding-bottom: 12px; }
.row { border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; }
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--ground-2); color: var(--ink); }
.row .title { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.empty { padding: 20px 18px; color: var(--muted); margin: 0; }

/* Zustand: Punkt und Wort */
.state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.state-ok { color: var(--ok); } .state-warn { color: var(--warn); } .state-crit { color: var(--crit); }
.state-info { color: var(--steel); } .state-neutral { color: var(--muted); }

/* Detail */
.keyfact { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; justify-content: space-between; }
.keyfact .value { font-family: var(--mono); font-size: 40px; font-weight: 600; line-height: 1; }
.facts { margin: 0; padding: 4px 24px; }
.facts > div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
@media (max-width: 560px) { .facts > div { grid-template-columns: 1fr; gap: 2px; } }
.log { padding: 4px 24px; }
.log > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.log > div:last-child { border-bottom: 0; }

/* Meldung nach Aktion */
.toast { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-weight: 500; }
.toast-error { background: var(--crit); }

/* Tooltip über Info-Symbol */
.tip { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.tip-btn { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #B9B5AB; background: var(--surface); color: var(--muted); font: 600 12px/1 var(--font); cursor: help; padding: 0; }
.tip-box { display: none; position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); width: 260px; padding: 10px 12px; background: var(--ink); color: #fff; font: 400 13px/1.45 var(--font); border-radius: var(--radius-sm); z-index: 30; text-align: left; }
.tip:hover .tip-box, .tip:focus-within .tip-box { display: block; }

/* Dialog für Aktionen */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 24px; max-width: 480px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(27,29,32,.4); }

/* ---------- Seiten ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.page-head h1 { display: inline-flex; align-items: center; gap: 10px; }
.section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section-head { display: flex; align-items: baseline; gap: 10px; }
.card-states { display: flex; flex-direction: column; gap: 4px; }
.count { margin: 0; font-size: 13px; }
.num { text-align: right; }
.unit { color: var(--muted); font-size: 13px; font-family: var(--font); }
.nowrap { white-space: nowrap; }
.h1-number { font-size: 16px; font-weight: 500; }

/* Werkzeugleiste über Listen */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.toolbar .segmented a { min-height: 44px; }
.toolbar-search { flex: 1 1 220px; width: auto; min-height: 44px; }
.toolbar-select { flex: 0 1 200px; width: auto; min-height: 44px; }
.toolbar .btn-sm { min-height: 44px; }

/* Detail */
.detail-head { display: flex; flex-direction: column; gap: 6px; }
.detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.keyfact-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.keyfact-main .label { display: inline-flex; align-items: center; gap: 8px; }
.keyfact .value-unit { font-family: var(--font); font-size: 18px; font-weight: 500; color: var(--muted); }
.keyfact .value-text { font-family: var(--font); font-size: 32px; font-weight: 700; }
.actions-secondary { gap: 4px; margin-top: -8px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.detail-grid .facts > div { grid-template-columns: 140px minmax(0, 1fr); }
.facts .pre { white-space: pre-line; }
.log-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-kind { font-weight: 600; }
.log-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex-shrink: 0; }
.log-delta { font-weight: 600; }
.log .empty, .log > p { padding: 12px 0; }
.sub { font-size: 13px; color: var(--muted); }
.row-link { color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--accent); text-decoration: underline; }

/* Dialoge */
.dialog-form { display: flex; flex-direction: column; gap: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.dialog-text { margin: 0; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; font-size: 22px; line-height: 1; }
.hint { font-size: 13px; }
.opt { font-weight: 400; color: var(--faint); }
.radios { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.radios legend { margin-bottom: 4px; padding: 0; }
.radio { min-height: 44px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }

/* Formulare */
.form-stack { display: flex; flex-direction: column; gap: 20px; }
.field-wide { grid-column: 1 / -1; }
.field label { display: inline-flex; align-items: center; gap: 6px; }
.field-error { color: var(--crit); font-size: 13px; font-weight: 600; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--crit); }
.form-actions { padding-top: 4px; }

/* Lagerorte */
.tree { list-style: none; margin: 0; padding: 0; }
.tree-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-height: 44px; padding: 10px 18px 10px calc(18px + var(--depth, 0) * 24px); border-bottom: 1px solid var(--line-soft); }
.tree-row:last-child { border-bottom: 0; }
.tree-row[style*="--depth: 0"] { background: var(--ground-2); }
.tree-name { font-weight: 500; }
.tree-count { margin-left: auto; }

.notfound { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.notfound p { margin: 0; }
@media (max-width: 560px) { .detail-grid .facts > div { grid-template-columns: 1fr; gap: 2px; } .keyfact .actions, .keyfact .actions .btn { width: 100%; } }

/* Angemeldeter Benutzer in der Kopfzeile */
.topbar-user { display: flex; align-items: center; gap: 4px; margin: 0; }
.topbar-name { font-size: 14px; color: var(--muted); padding-left: 8px; white-space: nowrap; }
@media (max-width: 720px) { .topbar-name { display: none; } }

/* Vorschläge: Anzahl in der Navigation, Hinweis auf der Übersicht, Seite /vorschlaege */
.sidenav .nav-count { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--steel); }
.hint-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-left: 3px solid var(--steel); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; }
.hint-line:hover { border-color: var(--steel); color: var(--ink); }
.hint-line .chev { margin-left: auto; }
.prop-rows { min-width: 720px; }
.prop-source { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.prop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.prop-actions form { margin: 0; }
@media (max-width: 760px) {
  .prop-rows { min-width: 0; }
  .prop-rows .row-head { display: none; }
  .prop-rows .row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .prop-actions { justify-content: flex-start; }
}
