/* Design in Anlehnung an das Shopify-Admin (Polaris): ruhige Flaechen, Karten, Badges. */
:root {
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-subdued: #fafafa;
  --border: #e3e3e3;
  --border-strong: #c9c9c9;
  --text: #303030;
  --text-subdued: #616161;
  --topbar: #1a1a1a;
  --topbar-text: #e3e3e3;
  --primary: #303030;
  --primary-hover: #1a1a1a;
  --primary-text: #ffffff;
  --focus: #005bd3;
  --link: #005bd3;
  --success-bg: #cdfed4; --success-text: #0c5132;
  --warning-bg: #ffeb78; --warning-text: #4f4700;
  --critical-bg: #fed1d7; --critical-text: #8e0b21;
  --info-bg: #a4e8f2;    --info-text: #00494f;
  --neutral-bg: #e3e3e3; --neutral-text: #4a4a4a;
  --attention-bg: #ffd6a4; --attention-text: #5e4200;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(26, 26, 26, .07);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1a; --surface: #303030; --surface-subdued: #2a2a2a; --border: #4a4a4a; --border-strong: #616161;
    --text: #e3e3e3; --text-subdued: #b5b5b5; --topbar: #0f0f0f; --primary: #e3e3e3; --primary-hover: #ffffff;
    --primary-text: #1a1a1a; --link: #91d0ff; --focus: #91d0ff;
    --success-bg: #0c5132; --success-text: #cdfed4; --warning-bg: #4f4700; --warning-text: #ffeb78;
    --critical-bg: #8e0b21; --critical-text: #fed1d7; --info-bg: #00494f; --info-text: #a4e8f2;
    --neutral-bg: #4a4a4a; --neutral-text: #e3e3e3; --attention-bg: #5e4200; --attention-text: #ffd6a4;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1a1a; --surface: #303030; --surface-subdued: #2a2a2a; --border: #4a4a4a; --border-strong: #616161;
  --text: #e3e3e3; --text-subdued: #b5b5b5; --topbar: #0f0f0f; --primary: #e3e3e3; --primary-hover: #ffffff;
  --primary-text: #1a1a1a; --link: #91d0ff; --focus: #91d0ff;
  --success-bg: #0c5132; --success-text: #cdfed4; --warning-bg: #4f4700; --warning-text: #ffeb78;
  --critical-bg: #8e0b21; --critical-text: #fed1d7; --info-bg: #00494f; --info-text: #a4e8f2;
  --neutral-bg: #4a4a4a; --neutral-text: #e3e3e3; --attention-bg: #5e4200; --attention-text: #ffd6a4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 20px; -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 28px; font-weight: 650; margin: 0; }
h2 { font-size: 14px; line-height: 20px; font-weight: 650; margin: 0 0 8px; }
.subdued { color: var(--text-subdued); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Kopfleiste */
.topbar { background: var(--topbar); color: var(--topbar-text); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 16px; height: 48px; display: flex; align-items: center; gap: 20px; }
.brand { font-weight: 650; color: #fff; letter-spacing: .1px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 18px; height: 18px; border-radius: 5px; background: #8fe8a0; display: inline-block; }
.topnav { display: flex; gap: 2px; flex: 1; }
.topnav a { color: var(--topbar-text); padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.topnav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.topnav a.active { background: rgba(255,255,255,.16); color: #fff; }
.usermenu { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.usermenu form { margin: 0; }
.linklike { background: none; border: 0; color: var(--topbar-text); cursor: pointer; font: inherit; padding: 6px 8px; border-radius: 8px; }
.linklike:hover { background: rgba(255,255,255,.1); }

/* Seite */
.page { max-width: 1480px; margin: 0 auto; padding: 20px 16px 48px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-header .actions { display: flex; gap: 8px; align-items: center; }
.back { display: inline-block; margin-bottom: 6px; color: var(--text-subdued); }

/* Karten */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--border) inset; margin-bottom: 16px; overflow: hidden; }
.card-body { padding: 16px; }
.card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--border) inset; padding: 12px 16px; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow), 0 0 0 1px var(--border-strong) inset; }
.kpi-label { color: var(--text-subdued); font-weight: 500; }
.kpi-value { font-size: 26px; line-height: 34px; font-weight: 650; }
.kpi.critical .kpi-value { color: var(--critical-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi.critical .kpi-value { color: #ff9aa8; } }

/* Filterleiste */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 5px 10px; border-radius: 8px; color: var(--text-subdued); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { background: var(--surface-subdued); text-decoration: none; }
.tab.active { background: var(--neutral-bg); color: var(--text); }
.tab .count { font-size: 12px; color: var(--text-subdued); }
.search { position: relative; }
.search input[type=text] { padding-left: 32px; min-width: 280px; }
.search svg { position: absolute; left: 9px; top: 8px; width: 16px; height: 16px; color: var(--text-subdued); }

/* Formulare */
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 6px 10px; min-height: 32px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label { display: block; font-weight: 550; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { color: var(--text-subdued); font-size: 12px; margin-top: 4px; }
.btn {
  font: inherit; font-weight: 550; padding: 6px 12px; border-radius: 8px; cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
}
.btn:hover { background: var(--surface-subdued); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-weight: 550; color: var(--text-subdued); padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-subdued); white-space: nowrap; font-size: 13px; }
table.data th a { color: inherit; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-subdued); }
tr.row-link { cursor: pointer; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-subdued); font-size: 12px; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-subdued); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 8px; font-size: 12px; line-height: 18px; font-weight: 550; white-space: nowrap; }
.badge.success { background: var(--success-bg); color: var(--success-text); }
.badge.warning { background: var(--warning-bg); color: var(--warning-text); }
.badge.critical { background: var(--critical-bg); color: var(--critical-text); }
.badge.info { background: var(--info-bg); color: var(--info-text); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral-text); }
.badge.attention { background: var(--attention-bg); color: var(--attention-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; opacity: .75; }

/* Hinweise */
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.banner.success { background: var(--success-bg); color: var(--success-text); }
.banner.warning { background: var(--warning-bg); color: var(--warning-text); }
.banner.critical { background: var(--critical-bg); color: var(--critical-text); }
.banner.info { background: var(--info-bg); color: var(--info-text); }

/* Detail */
dl.props { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--text-subdued); }
dl.props dd { margin: 0; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); }
.pagination .pages { display: flex; gap: 6px; }

/* Anmeldung */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--text); margin-bottom: 16px; }
.log-ok { color: var(--success-text); }

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 16px; }
  .search input[type=text] { min-width: 100%; }
  dl.props { grid-template-columns: 1fr; }
}

/* Filter-Panel, Spaltenauswahl, dichte Tabelle */
.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.popover { position: relative; }
details.popover > summary { list-style: none; cursor: pointer; }
details.popover > summary::-webkit-details-marker { display: none; }
.popover-panel { position: absolute; right: 0; top: 38px; z-index: 30; background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 0 0 1px var(--border) inset; padding: 12px; width: 300px; max-height: 70vh; overflow: auto; }
.panel-title { font-weight: 650; margin-bottom: 8px; }
.colgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 450; margin: 0; padding: 3px 0; cursor: pointer; }
label.check input { width: auto; min-height: 0; }
.panel-actions { display: flex; gap: 8px; margin-top: 12px; }
.filterpanel { padding: 12px 16px 14px; border-bottom: 1px solid var(--border); background: var(--surface-subdued); }
.filterpanel[hidden] { display: none; }
.filtergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.filtergrid .field { margin-bottom: 8px; }
.range { display: flex; gap: 6px; align-items: center; }
.range span { color: var(--text-subdued); }
input[type=date] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 5px 8px; min-height: 32px; width: 100%; }
table.dense td, table.dense th { padding: 8px 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 320px; }
.filtergrid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.range select { width: 130px; flex: none; }
.range input[type=number] { width: 84px; flex: none; }

/* Breite Seiten (Uebersicht): volle Monitorbreite nutzen */
.page.wide { max-width: none; padding-left: clamp(16px, 1.6vw, 32px); padding-right: clamp(16px, 1.6vw, 32px); }
@media (min-width: 1500px) { .topbar-inner { max-width: none; padding-left: clamp(16px, 1.6vw, 32px); padding-right: clamp(16px, 1.6vw, 32px); } }
.autohint { padding: 8px 16px; background: var(--info-bg); color: var(--info-text); font-size: 12px; }
.autohint[hidden] { display: none; }

/* Kompaktere Tabelle: weniger Rand, Fliesstext darf umbrechen */
table.dense { font-size: 13px; line-height: 18px; }
table.dense td, table.dense th { padding: 6px 8px; }
table.dense th { font-size: 12px; }
table.dense .badge { font-size: 11px; padding: 0 6px; }
table.dense .c-name { min-width: 190px; width: 100%; }
table.dense .c-note .clamp, table.dense .c-reason, table.dense .c-vendor { max-width: 150px; overflow-wrap: anywhere; }
table.dense .c-name .clamp { max-width: none; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 2200px) { body { font-size: 15px; } table.dense { font-size: 14px; } }

/* Herstellerspalte: genug Platz, Umbruch nur bei langen Namen und nur an Leerzeichen */
table.dense .c-vendor { min-width: 150px; max-width: 240px; overflow-wrap: normal; word-break: normal; }
table.dense .c-note .clamp, table.dense .c-reason { max-width: 150px; overflow-wrap: anywhere; }

/* Statistik */
:root { --bar-critical: #d72c0d; --bar-ok: #29845a; --bar-warn: #b98900; --bar-neutral: #8a8a8a; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(120px, 2fr) 90px 90px; gap: 12px; align-items: center; padding: 7px 16px; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: 0; }
.stat-row.head { color: var(--text-subdued); font-size: 12px; font-weight: 550; background: var(--surface-subdued); }
.stat-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--neutral-bg); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .crit { background: var(--bar-critical); } .bar .ok { background: var(--bar-ok); } .bar .warn { background: var(--bar-warn); } .bar .neu { background: var(--bar-neutral); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-subdued); padding: 8px 16px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.vrow { grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 2fr) 70px 70px 70px 70px; }
.insight { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-subdued); }

/* Hilfeseite */
.helpgrid { grid-template-columns: minmax(0, 1fr) 240px; }
@media (max-width: 960px) { .helpgrid { grid-template-columns: 1fr; } .helptoc { order: -1; position: static !important; } }
.helptoc { position: sticky; top: 64px; }
ul.toc { list-style: none; margin: 0; padding: 0; } ul.toc li { padding: 3px 0; }
.helpgrid h3 { font-size: 13px; margin: 12px 0 6px; } .helpgrid h3:first-child { margin-top: 0; }
.vis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } @media (max-width: 760px) { .vis { grid-template-columns: 1fr; } }
.vis ul { margin: 0; padding-left: 18px; }
.statusbox { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.statusbox.current { border-color: var(--border-strong); background: var(--surface-subdued); }
.statusbox dl.props { margin-top: 8px; grid-template-columns: 140px 1fr; }
details.faq { border-bottom: 1px solid var(--border); padding: 8px 0; } details.faq:last-child { border-bottom: 0; }
details.faq summary { cursor: pointer; font-weight: 550; } details.faq p { margin: 8px 0 0; color: var(--text-subdued); }

/* Benutzerverwaltung */
.rowactions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: flex; gap: 6px; align-items: center; margin: 0; }
form.inline input[type=password] { width: 190px; }

/* Tooltips an Spaltenueberschriften */
.tip { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.card-header .btn { min-height: 28px; padding: 3px 10px; }

/* Kopier-Symbol: direkt rechts neben dem Wert, nie hoeher als der Text, Farbe folgt dem Text (Hell/Dunkel) */
.cv { white-space: nowrap; }
button.copy {
  box-sizing: content-box; display: inline-block; width: 1em; height: 1em; padding: 1px; margin: 0 0 0 .3em;
  font-size: inherit; line-height: 1; vertical-align: -0.2em; border: 0; border-radius: 4px; background: none;
  color: var(--text-subdued); opacity: .65; cursor: pointer; position: relative;
}
button.copy::before {
  content: ""; position: absolute; inset: 1px; background-color: currentColor;
  -webkit-mask: url("/static/copy.png") center / contain no-repeat; mask: url("/static/copy.png") center / contain no-repeat;
}
button.copy:hover, button.copy:focus-visible { opacity: 1; color: var(--text); background: var(--neutral-bg); }
button.copy.done { opacity: 1; color: var(--bar-ok); }
button.copy.done::before { display: none; }
button.copy.done::after { content: "✓"; position: absolute; inset: 0; font-size: 1em; line-height: 1; font-weight: 700; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Direktlinks in Shopify (gruen) und Pixi (blau), unter den Hinweisen im Kopf der Detailseite */
.headright { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.linkbtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
a.btn.linkbtn { color: #fff; border-color: transparent; gap: 6px; font-weight: 600; }
a.btn.linkbtn:hover { color: #fff; text-decoration: none; filter: brightness(.92); }
a.btn.linkbtn.shopify { background: #008060; }
a.btn.linkbtn.pixi { background: #1f5fbf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a.btn.linkbtn.shopify { background: #2a9d78; } :root:not([data-theme="light"]) a.btn.linkbtn.pixi { background: #3b7be0; } }
@media (max-width: 720px) { .headright { align-items: flex-start; } .linkbtns { justify-content: flex-start; } }

/* Pixi-Symbol hinter Bestellnummern: oeffnet den Auftrag in Pixi (neuer Tab); gleiche Groesse und Ausrichtung wie das Kopier-Symbol */
a.extlink {
  box-sizing: content-box; display: inline-block; width: 1em; height: 1em; padding: 1px; margin: 0 0 0 .2em;
  vertical-align: -0.2em; line-height: 1; border-radius: 4px; color: var(--text-subdued); opacity: .65; position: relative; text-decoration: none;
}
a.extlink::before {
  content: ""; position: absolute; inset: 1px; background-color: currentColor;
  -webkit-mask: url("/static/external.png") center / contain no-repeat; mask: url("/static/external.png") center / contain no-repeat;
}
a.extlink:hover, a.extlink:focus-visible { opacity: 1; color: #1f5fbf; background: var(--neutral-bg); text-decoration: none; }
