:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #222;
  background: #eef2f5;
  font-synthesis: none;
  --stock-blue: #003366;
  --stock-green: #89b935;
  --stock-red: #c40000;
  --stock-orange: #af5700;
  --line: #dddddd;
  --soft-blue: #eef3f7;
  --soft-green: #eaf2e0;
}
* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef2f5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; }

/* Kopfzeile wie in der Android-App: StockBlue + StockGreen Akzent. */
.topbar { position: sticky; top: 0; z-index: 80; background: var(--stock-blue); color: white; box-shadow: 0 2px 9px rgba(0,0,0,.16); }
.topbar-row { min-height: 58px; padding: 0 18px; display: flex; align-items: stretch; gap: 0; }
.menu-toggle { display: none; width: 54px; border: 0; background: transparent; color: white; font-size: 25px; font-weight: 800; border-right: 1px solid #66d494; }
.brand { display: flex; min-width: 265px; align-items: center; gap: 10px; padding: 6px 18px 6px 4px; font-size: 1.25rem; font-weight: 800; letter-spacing: .1px; }
.brand-logo { width: 39px; height: 39px; object-fit: contain; flex: 0 0 auto; }
.brand-copy { min-width: 0; }
.brand-title { white-space: nowrap; }
.brand small { display: block; opacity: .72; font-weight: 500; font-size: .68rem; margin-top: 1px; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.header-action { border: 0; color: white; background: var(--stock-blue); min-width: 142px; padding: 0 18px; border-left: 1px solid #66d494; font-weight: 700; }
.header-action:hover { background: #084675; }
.header-action.capture { min-width: 116px; background: var(--stock-green); font-weight: 800; }
.header-action.capture:hover { background: #78a62b; }
.header-badge { display: inline-grid; place-items: center; min-width: 23px; height: 20px; margin-left: 6px; padding: 0 6px; background: var(--stock-green); color: white; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.header-security { display: flex; align-items: center; padding: 0 15px; border-left: 1px solid #66d494; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.topbar-accent { height: 4px; background: var(--stock-green); }

main { width: 100%; margin: 0; padding: 0; }
.app-frame { min-height: calc(100vh - 62px); display: grid; grid-template-columns: 286px minmax(0, 1fr); max-width: 1580px; margin: 0 auto; background: white; box-shadow: 0 0 30px rgba(17,37,54,.08); }
.app-drawer { position: sticky; top: 62px; align-self: start; height: calc(100vh - 62px); display: flex; flex-direction: column; background: white; border-right: 1px solid #d9e0e5; overflow: hidden; }
.drawer-scroll { overflow-y: auto; min-height: 0; flex: 1; }
.drawer-menu { width: 100%; height: 52px; border: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; text-align: left; font-weight: 800; font-size: .92rem; }
.drawer-menu.warning { background: var(--stock-red); color: white; }
.drawer-menu.warning:hover, .drawer-menu.warning.active { background: #a90000; }
.drawer-menu.articles { background: var(--stock-blue); color: white; margin-top: 7px; }
.drawer-menu.articles:hover, .drawer-menu.articles.active { background: #084675; }
.drawer-menu.statistics { background: #f0f4f7; color: var(--stock-blue); margin-top: 7px; }
.drawer-menu.statistics:hover, .drawer-menu.statistics.active { background: #dfeaf1; }
.drawer-count { font-weight: 800; }
.drawer-section-title { margin: 18px 16px 7px; color: var(--stock-blue); font-weight: 800; font-size: .94rem; }
.drawer-divider { height: 1px; background: var(--line); }
.drawer-category { width: 100%; min-height: 44px; border: 0; background: transparent; display: flex; align-items: center; gap: 8px; padding: 0 16px; color: #333; text-align: left; }
.drawer-category::before { content: "•"; width: 16px; color: var(--stock-green); font-size: 1.1rem; font-weight: 900; }
.drawer-category span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-category:hover, .drawer-category.active { background: var(--soft-green); color: #487000; font-weight: 700; }
.drawer-bottom { border-top: 1px solid var(--line); }
.drawer-info { padding: 12px 16px; font-size: .76rem; color: #66727e; background: #fafbfc; }
.drawer-disconnect { width: 100%; height: 52px; border: 0; background: white; color: var(--stock-red); text-align: left; padding: 0 16px; font-weight: 800; }
.drawer-disconnect:hover { background: #fff0f0; }
.drawer-scrim { display: none; }

.app-content { min-width: 0; padding: 18px 20px 30px; background: white; }
.content-head { display: flex; align-items: end; gap: 16px; margin-bottom: 12px; }
.content-head h1 { margin: 0; color: var(--stock-blue); font-size: 1.45rem; }
.content-head p { margin: 3px 0 0; color: #6b747c; font-size: .82rem; }
.content-head .head-spacer { flex: 1; }
.content-revision { color: #7c8790; font-size: .75rem; white-space: nowrap; }

/* Pairing / allgemeine Karten */
.standalone-main { max-width: 1180px; margin: 0 auto; padding: 28px 18px 50px; }
.card { background: white; border-radius: 14px; padding: 22px; box-shadow: 0 10px 34px rgba(22,32,42,.08); border: 1px solid rgba(0,0,0,.06); }
.pair-grid { display: grid; grid-template-columns: minmax(280px, 430px) minmax(280px, 1fr); gap: 28px; align-items: center; }
.qr-wrap { display: grid; place-items: center; min-height: 320px; }
canvas { max-width: 300px; width: 100%; height: auto; image-rendering: pixelated; }
h1, h2, h3 { color: var(--stock-blue); }
p { line-height: 1.55; }
.muted { color: #66727e; }
.secure { background: #eef8ef; border-left: 5px solid var(--stock-green); padding: 12px 14px; border-radius: 9px; font-size: .92rem; }
.error { background: #fff0f0; border-left: 5px solid var(--stock-red); padding: 12px 14px; border-radius: 9px; color: #8b1a1a; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions.compact { margin: 0; }
.btn { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 750; }
.btn-primary { background: var(--stock-blue); color: white; }
.btn-green { background: var(--stock-green); color: white; }
.btn-light { background: var(--soft-blue); color: var(--stock-blue); border: 1px solid #c8d3dc; }
.btn-danger { background: #fff0f0; color: #a30000; }
.btn-small { padding: 7px 10px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: default; }

.dashboard { display: grid; gap: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { background: #f7f9fb; border-radius: 10px; padding: 11px 13px; border: 1px solid #dce4e9; }
.metric span { color: #6a747d; font-size: .76rem; }
.metric strong { display: block; font-size: 1.35rem; color: var(--stock-blue); }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 10px; }
.toolbar input { flex: 1; min-width: 220px; border: 1px solid #b9c7d2; border-radius: 9px; padding: 10px 12px; background: white; }
.toolbar select { border: 1px solid #b9c7d2; border-radius: 9px; padding: 10px 12px; background: white; min-width: 150px; }
.screen-panel { border: 1px solid var(--line); background: white; }
.inventory-table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--stock-blue); color: white; font-size: .82rem; }
tr[data-edit] { cursor: pointer; }
tr[data-edit]:hover td { background: #f3f7f9; }
.product-cell { display: flex; align-items: center; gap: 8px; min-width: 230px; }
.stock-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; background: #777; }
.stock-dot.ok { background: #006400; }
.stock-dot.warning { background: var(--stock-red); }
.product-meta { margin-top: 2px; color: #7a838a; font-size: .72rem; }
.expiry { text-align: center; }
.expiry.warning { color: var(--stock-red); font-weight: 700; }
.qty { font-weight: 800; color: #222; text-align: center; }
.empty-state { padding: 36px 20px; color: #6d757c; text-align: center; }
.inventory-bottom-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.inventory-bottom-actions .btn { min-height: 46px; font-size: .94rem; }

.table-card { background: white; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.table-card th { background: var(--stock-blue); color: white; }
.shopping { display: grid; gap: 8px; }
.shopping-item { padding: 11px 13px; border-radius: 9px; background: #f6f8fa; }
.list-card { display: grid; gap: 12px; }
.editable-shopping, .category-list, .batch-list { display: grid; gap: 8px; }
.shopping-edit-row, .category-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border: 1px solid #e1e4e6; border-radius: 9px; background: #f8faf7; }
.shopping-edit-row.done span { text-decoration: line-through; opacity: .55; }
.check { display: flex; gap: 9px; align-items: center; }
.check input { width: 18px; height: 18px; }
.footer-note { color: #6f7b86; font-size: .76rem; text-align: center; margin-top: 20px; }
.e2ee-badge { font-size: .78rem; font-weight: 750; }

.modal-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(4,17,28,.58); display: grid; place-items: center; padding: 18px; overflow: auto; }
.dialog-card { width: min(760px, 100%); max-height: calc(100vh - 36px); overflow: auto; background: white; border-radius: 14px; padding: 22px; box-shadow: 0 22px 70px rgba(0,0,0,.28); display: grid; gap: 16px; }
.dialog-small { width: min(500px, 100%); }
.dialog-head, .section-title { display: flex; align-items: center; gap: 12px; }
.dialog-head h2, .section-title h3 { flex: 1; margin: 0; }
.icon-btn { border: 0; background: var(--soft-blue); color: #334; width: 36px; height: 36px; border-radius: 50%; font-size: 1.45rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, .dialog-card > label { display: grid; gap: 6px; font-size: .87rem; font-weight: 700; color: #44515d; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea, .dialog-card > label input, .dialog-card > label select { width: 100%; border: 1px solid #b9c7d2; border-radius: 9px; padding: 10px 11px; background: white; color: #16202a; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; padding-top: 4px; }
.spacer { flex: 1; }
.batch-row { width: 100%; display: flex; justify-content: space-between; align-items: center; border: 1px solid #e1e7eb; background: #fafbfc; padding: 10px 12px; border-radius: 9px; color: #263746; }
.batch-row:hover { background: #eef4f7; }
.pill { font-size: .78rem; background: #e7f3e8; color: #2e7131; padding: 4px 8px; border-radius: 999px; vertical-align: middle; }
.toast { position: fixed; z-index: 2000; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); background: #183a52; color: white; padding: 12px 16px; border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.25); font-weight: 650; }
.toast.error-toast { background: #9e2424; }
body.busy::after { content: ""; position: fixed; z-index: 3000; inset: 0; cursor: wait; }
hr { border: 0; border-top: 1px solid #e5eaee; width: 100%; }

@media (max-width: 960px) {
  .menu-toggle { display: block; }
  .brand { min-width: 0; padding-left: 12px; }
  .brand small { display: none; }
  .header-security { display: none; }
  .header-action { min-width: 118px; padding-inline: 12px; }
  .app-frame { display: block; }
  .app-drawer { position: fixed; z-index: 120; top: 62px; bottom: 0; left: 0; width: 286px; height: auto; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.22); }
  body.drawer-open .app-drawer { transform: translateX(0); }
  .drawer-scrim { display: block; position: fixed; z-index: 110; inset: 62px 0 0; border: 0; background: rgba(4,17,28,.48); opacity: 0; visibility: hidden; transition: opacity .2s; }
  body.drawer-open .drawer-scrim { opacity: 1; visibility: visible; }
}
@media (max-width: 720px) {
  .topbar-row { padding: 0; }
  .brand-logo { width: 34px; height: 34px; }
  .brand { font-size: 1.05rem; gap: 7px; }
  .header-action { min-width: 0; padding: 0 11px; font-size: .76rem; }
  .header-action.shopping span.label { display: none; }
  .header-action.capture { font-size: 0; width: 56px; }
  .header-action.capture::after { content: "+"; font-size: 25px; }
  .app-content { padding: 14px 10px 24px; }
  .content-revision { display: none; }
  .pair-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .shopping-edit-row, .category-row { align-items: flex-start; flex-direction: column; }
  .row-actions { text-align: left; }
}
@media (max-width: 480px) {
  .brand-title { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}

/* 1.6.5.16 – Filterparität zur Android-App + feste untere Aktionsleiste. */
.app-frame { height: calc(100dvh - 62px); min-height: 0; }
.app-content { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 11px; }
.content-head { flex: 0 0 auto; }
#tab-content { flex: 1 1 auto; min-height: 0; overflow: auto; }
#tab-content.inventory-tab-content { overflow: hidden; }
.app-content > .footer-note { display: none; }

.inventory-screen { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.inventory-search-row { flex: 0 0 auto; display: flex; gap: 9px; align-items: center; margin-bottom: 9px; }
.inventory-search-row input { flex: 1; min-width: 0; border: 1px solid #b9c7d2; border-radius: 9px; padding: 10px 12px; background: white; }
.inventory-list-shell { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.inventory-scroll { height: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.inventory-scroll table { min-width: 570px; }
.inventory-scroll thead th { position: sticky; top: 0; z-index: 3; }
.inventory-bottom-actions { flex: 0 0 auto; margin-top: 8px; padding: 0; background: white; }
.inventory-bottom-actions .btn { height: 48px; }
.btn-filter-active { background: var(--stock-red); color: white; }
.btn-filter-active:hover { background: #a90000; }

.filter-dialog { height: min(820px, calc(100dvh - 36px)); max-height: calc(100dvh - 36px); overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; gap: 0; }
.filter-dialog .dialog-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.filter-dialog .dialog-head h2 { margin: 0; }
.filter-dialog .dialog-head p { margin: 4px 0 0; color: #666; font-size: .8rem; }
.filter-dialog-scroll { min-height: 0; overflow-y: auto; padding: 8px 20px 18px; }
.filter-section { display: grid; gap: 7px; padding-top: 10px; }
.filter-section h3 { margin: 7px 0 1px; font-size: 1rem; }
.filter-section select { width: 100%; border: 1px solid #b9c7d2; border-radius: 9px; padding: 10px 12px; background: white; color: #222; }
.filter-choice { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid #d2d2d2; border-radius: 9px; background: #f7f7f7; color: #333; cursor: pointer; }
.filter-choice input { position: absolute; opacity: 0; pointer-events: none; }
.filter-choice span { flex: 1; }
.filter-choice b { width: 20px; text-align: center; color: var(--stock-green); font-size: 1.05rem; }
.filter-choice.selected { background: #eaf3db; border-color: var(--stock-green); font-weight: 750; }
.filter-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 11px 20px; border-top: 1px solid var(--line); background: white; box-shadow: 0 -5px 16px rgba(0,0,0,.05); }
.filter-dialog-actions .btn { min-height: 46px; }

@media (max-width: 720px) {
  .app-frame { height: calc(100dvh - 62px); }
  .app-content { padding-bottom: 8px; }
  .inventory-search-row { gap: 6px; }
  .inventory-search-row .btn { padding-inline: 10px; }
  .filter-dialog { height: calc(100dvh - 20px); max-height: calc(100dvh - 20px); }
  .filter-dialog .dialog-head, .filter-dialog-scroll, .filter-dialog-actions { padding-left: 12px; padding-right: 12px; }
}

/* 1.6.5.16 – UI-Fix: Header-Ausrichtung, vertikale Button-Zentrierung und Artikeldetailseite. */
.topbar-row {
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
  padding-left: 0;
  padding-right: 0;
}
.brand {
  width: 286px;
  min-width: 286px;
  padding-left: 16px;
  padding-right: 16px;
}
.header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.1;
  text-align: center;
}
.header-action .label { display: inline-flex; align-items: center; justify-content: center; }
.dialog-subtitle { margin: 3px 0 0; color: #6b747c; font-size: .8rem; font-weight: 500; }

#tab-content.product-detail-tab-content { overflow: hidden; }
.product-detail-screen { height: 100%; min-height: 0; overflow: hidden; }
.product-detail-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 18px; }
.product-hero { text-align: center; padding: 8px 12px 12px; }
.product-hero h2 { margin: 4px 0 7px; color: #222; font-size: 1.7rem; font-weight: 500; }
.product-ean { display: flex; align-items: center; justify-content: center; gap: 9px; color: #666; font-size: .9rem; }
.product-ean code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.link-button { border: 0; background: transparent; color: var(--stock-blue); font-weight: 800; padding: 3px 5px; }
.detail-muted { margin-top: 4px; color: #777; font-size: .84rem; }
.detail-category { margin-top: 6px; color: var(--stock-blue); font-size: .84rem; font-weight: 800; }
.expiry-badge { display: inline-block; margin: 14px 0 8px; border: 2px solid #777; border-radius: 999px; padding: 8px 16px; color: white; font-size: 1.05rem; font-weight: 800; }
.expiry-badge.ok { background: #006400; }
.expiry-badge.danger { background: var(--stock-red); }
.expiry-badge.neutral { background: #666; }
.total-stock { font-size: 1.05rem; }
.total-stock strong { color: var(--stock-blue); font-size: 1.6rem; }
.detail-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; }
.detail-stat { border: 1px solid #d9e0e5; background: #f7f9fb; border-radius: 10px; padding: 11px 13px; }
.detail-stat span { display: block; color: #66727e; font-size: .76rem; }
.detail-stat strong { display: block; margin-top: 3px; color: var(--stock-blue); font-size: 1.05rem; }
.detail-stat.danger strong { color: var(--stock-red); }
.detail-card { border: 1px solid #d9e0e5; background: #f7f9fb; border-radius: 12px; padding: 12px; margin-top: 9px; }
.detail-card h3 { margin: 0 0 9px; color: var(--stock-blue); font-size: .96rem; }
.consumption-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.consumption-stat-grid > div { background: white; border: 1px solid #dde3e7; border-radius: 9px; padding: 9px 10px; }
.consumption-stat-grid span { display: block; color: #6f7880; font-size: .73rem; }
.consumption-stat-grid strong { color: var(--stock-blue); font-size: 1.05rem; }
.detail-line { margin: 5px 0; font-size: .84rem; }
.detail-subtitle { margin-top: 9px; color: #666; font-size: .76rem; font-weight: 800; }
.recent-consumption { margin-top: 4px; display: grid; gap: 4px; }
.recent-consumption > div { display: flex; justify-content: space-between; gap: 12px; font-size: .78rem; }
.recent-consumption span { color: #666; }
.detail-help { color: #666; font-size: .78rem; margin: 8px 2px; }
.product-detail-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.product-detail-actions .btn { min-height: 46px; }
.detail-delete, .detail-back { width: 100%; border: 0; background: transparent; font-weight: 800; padding: 11px; }
.detail-delete { color: var(--stock-red); margin-top: 4px; }
.detail-back { color: var(--stock-blue); }

@media (max-width: 960px) {
  .topbar-row { max-width: none; }
  .brand { width: auto; min-width: 0; padding-left: 12px; }
}
@media (max-width: 720px) {
  .detail-stat-grid, .product-detail-actions { grid-template-columns: 1fr; }
  .consumption-stat-grid { grid-template-columns: repeat(3, 1fr); }
  .product-hero h2 { font-size: 1.4rem; }
}

/* 1.6.5.16 – Header-Fix 2: Brand exakt am Drawer ausrichten, Header-Aktionen identisch zentrieren. */
.topbar-row {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  height: 58px;
  min-height: 58px;
  align-items: stretch;
}
.brand {
  width: 286px;
  min-width: 286px;
  margin-left: max(0px, calc((100vw - 1580px) / 2));
  padding: 6px 16px;
}
.header-action {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  align-self: stretch;
  height: 58px;
  min-height: 58px;
  padding: 0;
  line-height: 1;
}
.header-action-inner {
  width: 100%;
  height: 100%;
  min-height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  text-align: center;
}
.header-action .label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  line-height: 1;
}
.header-badge {
  margin-left: 0;
  align-self: center;
}

@media (max-width: 960px) {
  .brand {
    width: auto;
    min-width: 0;
    margin-left: 0;
    padding-left: 12px;
  }
}
@media (max-width: 720px) {
  .topbar-row { height: 58px; min-height: 58px; }
  .header-action-inner { min-height: 58px; padding: 0 11px; }
  .header-action.shopping .label { display: none; }
}

/* 1.6.5.16 – Header-Fix 3: rechte Aktionsgruppe gespiegelt zum Brand am App-Rahmen ausrichten. */
.header-actions-cluster {
  height: 58px;
  min-height: 58px;
  display: flex;
  align-items: stretch;
  align-self: stretch;
  margin-right: max(0px, calc((100vw - 1580px) / 2));
}
.header-actions-cluster .header-action { flex: 0 0 auto; }

@media (max-width: 960px) {
  .header-actions-cluster { margin-right: 0; }
}
