:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #141817;
  --muted: #64706b;
  --line: #dce3dc;
  --line-strong: #c7d1c8;
  --green: #245c4a;
  --green-soft: #e6f1eb;
  --rust: #b86b28;
  --rust-soft: #f7eadf;
  --red: #b83642;
  --red-soft: #f8e5e7;
  --violet: #5b4bb7;
  --shadow: 0 18px 45px rgba(20, 24, 23, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 92, 74, 0.14);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  color: #fff;
  background: #151817;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand.compact {
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 2px;
  color: #b9c4be;
  font-size: 12px;
}

.brand.compact small {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-link {
  border-radius: var(--radius);
  padding: 11px 12px;
  color: #cbd5d0;
  font-weight: 750;
}

.nav-link:hover,
.nav-link.active {
  background: #24302c;
  color: #fff;
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #fff;
}

.sidebar-user small {
  color: #b9c4be;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1,
.auth-card h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--rust);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
  touch-action: manipulation;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.ghost-button {
  background: transparent;
  color: #fff;
  border-color: #3a423f;
}

.danger-button {
  background: var(--red);
  color: #fff;
}

.full {
  width: 100%;
}

.is-copied {
  background: var(--violet);
  color: #fff;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 750;
}

.alert-success {
  background: var(--green-soft);
  color: var(--green);
}

.alert-error {
  background: var(--red-soft);
  color: var(--red);
}

.panel,
.metric,
.auth-card,
.market-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head span,
.panel-head a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.narrow {
  max-width: 980px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.metric strong {
  font-size: 26px;
  line-height: 1.1;
}

.dashboard-grid,
.detail-grid,
.scanner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 18px;
  margin-bottom: 18px;
}

.side-stack,
.stack {
  display: grid;
  gap: 14px;
}

.pie-wrap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.pie {
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 10px solid #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 25px rgba(20, 24, 23, 0.08);
}

.pie-legend {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pie-legend li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.pie-legend li span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot);
}

.pie-legend small {
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-field {
  flex: 1 1 280px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  vertical-align: middle;
}

.data-table td strong,
.data-table td span {
  display: block;
}

.data-table td span {
  color: var(--muted);
  font-size: 12px;
}

.sku-link,
.sku-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #edf1ee;
  color: var(--green);
  padding: 5px 10px;
  font-weight: 900;
}

.table-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  font-weight: 850;
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
}

.status-received {
  background: #eceff3;
  color: #3c4654;
}

.status-washed {
  background: #e8f1f8;
  color: #2b637e;
}

.status-photographed {
  background: #efeafa;
  color: #5b4bb7;
}

.status-listed {
  background: var(--green-soft);
  color: var(--green);
}

.status-sold {
  background: var(--rust-soft);
  color: var(--rust);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.span-2 {
  grid-column: span 2;
}

.form-actions,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.sku-banner {
  grid-column: span 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius);
  background: #edf1ee;
  padding: 14px 16px;
}

.sku-banner span {
  color: var(--muted);
  font-weight: 800;
}

.sku-banner strong {
  color: var(--green);
  font-size: 22px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-head h2 {
  margin: 12px 0 4px;
  font-size: 28px;
}

.detail-head p,
.notes {
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.facts div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfb;
}

.facts span,
.facts strong {
  display: block;
}

.facts span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.facts strong {
  margin-top: 3px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.brand-cloud {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-cloud span {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 750;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.user-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.check-row.ok {
  background: var(--green-soft);
  border-color: #bed9ca;
}

.check-row.bad {
  background: var(--red-soft);
  border-color: #efc3c8;
}

.check-row span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--muted);
  background: #fbfcfb;
  text-align: center;
  font-weight: 760;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 460px);
  display: grid;
  gap: 20px;
  padding: 28px;
}

.auth-card.wide {
  width: min(100%, 560px);
}

.scanner-panel {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  padding: 0;
  background: #101312;
}

.scanner-panel video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 22%;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.scanner-controls {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #fff;
}

.scanner-controls span {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
  padding: 9px 12px;
  font-weight: 850;
}

.market-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px;
}

.market-card h2 {
  margin: 14px 0 4px;
  font-size: 34px;
}

.market-card p {
  margin: 0;
  color: var(--muted);
}

.market-price {
  margin: 18px 0;
  border-radius: var(--radius);
  background: #151817;
  color: #fff;
  padding: 16px;
}

.market-price span,
.market-price strong {
  display: block;
}

.market-price span {
  color: #cbd5d0;
  font-size: 13px;
  font-weight: 800;
}

.market-price strong {
  font-size: 34px;
}

.label-workspace {
  display: grid;
  place-items: center;
  gap: 18px;
}

.label-actions {
  display: flex;
  gap: 10px;
}

.print-label {
  width: var(--label-w);
  height: var(--label-h);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 2mm;
  overflow: hidden;
  border: 1px solid #111;
  border-radius: 2px;
  background: #fff;
  color: #111;
  padding: 2.2mm;
  box-shadow: var(--shadow);
}

.label-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15mm;
  gap: 2mm;
  align-items: center;
  min-height: 15mm;
}

.label-code-main {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
}

.label-qr {
  width: 15mm;
  height: 15mm;
}

.print-label header,
.print-label footer {
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  align-items: center;
  min-width: 0;
  font-size: 8pt;
  line-height: 1;
}

.print-label footer span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barcode-svg {
  width: 100%;
  height: 100%;
  min-height: 10mm;
}

.qr-svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    max-width: 100%;
  }

  .sidebar-user {
    margin-left: auto;
    margin-top: 0;
  }

  .metric-grid,
  .dashboard-grid,
  .detail-grid,
  .scanner-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    background: #eef2ef;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .main {
    padding: 14px;
    padding-bottom: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
  }

  .topbar h1,
  .auth-card h1 {
    font-size: 30px;
  }

  .topbar .primary-button {
    display: none;
  }

  .metric-grid,
  .facts,
  .form-grid,
  .pie-wrap {
    grid-template-columns: 1fr;
  }

  .span-2,
  .sku-banner {
    grid-column: span 1;
  }

  .toolbar {
    align-items: stretch;
    gap: 10px;
  }

  .toolbar > * {
    flex: 1 1 100%;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 8px 12px;
    min-height: 54px;
    gap: 8px;
    box-shadow: 0 10px 22px rgba(20, 24, 23, 0.16);
  }

  .brand {
    flex: 1 1 auto;
    min-width: 180px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small,
  .eyebrow {
    display: none;
  }

  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: flex;
    gap: 6px;
    width: auto;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    background: rgba(21, 24, 23, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -14px 32px rgba(20, 24, 23, 0.18);
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex: 1 0 76px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 9px;
    font-size: 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.04);
  }

  .sidebar-user {
    width: auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .sidebar-user span,
  .sidebar-user small {
    display: none;
  }

  .ghost-button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .panel,
  .metric,
  .auth-card,
  .market-card {
    box-shadow: 0 10px 28px rgba(20, 24, 23, 0.07);
  }

  .panel {
    padding: 13px;
  }

  .table-wrap {
    overflow: visible;
  }

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 24px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .pie {
    width: min(220px, 70vw);
    justify-self: center;
  }

  .scanner-panel,
  .scanner-panel video {
    min-height: 62vh;
  }

  .scanner-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .scanner-controls span {
    text-align: center;
  }

  .data-table {
    min-width: 0;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 8px 22px rgba(20, 24, 23, 0.05);
  }

  .data-table td {
    border-bottom: 0;
    padding: 0;
  }

  .data-table td:nth-child(1) {
    order: 1;
    align-self: start;
  }

  .data-table td:nth-child(3) {
    order: 2;
    justify-self: end;
    align-self: start;
  }

  .data-table td:nth-child(2) {
    order: 3;
    grid-column: 1 / -1;
    padding-top: 4px;
  }

  .data-table td:nth-child(4) {
    order: 4;
    min-width: 0;
  }

  .data-table td:nth-child(5) {
    order: 5;
    justify-self: end;
    text-align: right;
    min-width: 0;
  }

  .data-table td:nth-child(6) {
    order: 6;
    grid-column: 1 / -1;
  }

  .data-table td:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(6)) {
    display: grid;
    gap: 2px;
  }

  .data-table td::before {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .data-table td:nth-child(1)::before,
  .data-table td:nth-child(2)::before,
  .data-table td:nth-child(3)::before,
  .data-table td:nth-child(6)::before {
    display: none;
  }

  .data-table td:nth-child(4)::before {
    content: "Preis";
  }

  .data-table td:nth-child(5)::before {
    content: "Lagerort";
  }

  .data-table td:nth-child(2) strong {
    font-size: 17px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .data-table td:nth-child(4),
  .data-table td:nth-child(5),
  .facts strong,
  .market-price strong {
    overflow-wrap: anywhere;
  }

  .table-actions {
    justify-content: stretch;
    gap: 8px;
    padding-top: 8px;
  }

  .table-actions a {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fbfcfb;
  }

  .form-actions,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .form-actions > *,
  .button-row > * {
    width: 100%;
  }

  .detail-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .detail-head h2,
  .market-card h2 {
    font-size: 28px;
    overflow-wrap: anywhere;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-card {
    padding: 16px;
  }

  .market-price strong {
    font-size: 30px;
  }

  .user-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-cloud {
    max-height: 55vh;
    overflow: auto;
  }

  .label-workspace {
    overflow-x: auto;
    justify-items: start;
  }

  .label-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .main {
    padding: 10px;
  }

  .topbar h1,
  .auth-card h1 {
    font-size: 26px;
  }

  .auth-shell {
    padding: 12px;
    align-items: stretch;
  }

  .auth-card {
    padding: 18px;
  }

  .panel {
    padding: 12px;
  }

  .facts div {
    padding: 10px;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }

  .scanner-overlay {
    inset: 18%;
  }

  .market-price {
    padding: 14px;
  }

  .market-price strong {
    font-size: 27px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .alert,
  .label-actions {
    display: none !important;
  }

  .app-shell,
  .main,
  .label-workspace {
    display: block;
    min-height: auto;
    padding: 0;
    margin: 0;
  }

  .print-label {
    box-shadow: none;
    border: none;
    page-break-after: always;
  }
}
