/* ============================================================
   Partlyx — Industrial Werkstatt design system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700;800&family=Barlow+Semi+Condensed:wght@600;700;800&family=Spline+Sans+Mono:wght@400;500;600;700&display=swap');

:root {
  --font-sans: 'Barlow', system-ui, -apple-system, sans-serif;
  --font-cond: 'Barlow Semi Condensed', var(--font-sans);
  --font-mono: 'Spline Sans Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* light (default) */
  --paper: #F1EFEB;
  --surface: #FFFFFF;
  --surface-2: #F8F6F2;
  --surface-3: #EFEDE8;
  --ink: #18191B;
  --ink-2: #595D63;
  --ink-3: #8B9096;
  --line: #E1DED7;
  --line-2: #D0CCC3;
  --line-strong: #B7B2A8;

  --accent: #E2560F;
  --accent-hover: #C9490A;
  --accent-ink: #FFFFFF;

  --ok: #2D7D4E;
  --warn: #B7770C;
  --danger: #C23A2D;

  --hazard-a: #1A1A1A;
  --hazard-b: #F2C200;

  --r-xs: 3px;
  --r-sm: 5px;
  --r: 7px;
  --r-lg: 11px;

  --shadow-1: 0 1px 2px rgba(20,18,15,.07), 0 1px 1px rgba(20,18,15,.04);
  --shadow-2: 0 4px 14px rgba(20,18,15,.10), 0 2px 4px rgba(20,18,15,.05);
  --shadow-3: 0 18px 50px rgba(20,18,15,.20), 0 6px 16px rgba(20,18,15,.10);

  --sb-w: 244px;
  --tb-h: 64px;
}

html[data-theme='dark'] {
  --paper: #121315;
  --surface: #1B1D20;
  --surface-2: #212429;
  --surface-3: #282C31;
  --ink: #ECEAE5;
  --ink-2: #9DA2A8;
  --ink-3: #6B7077;
  --line: #2C3035;
  --line-2: #363B41;
  --line-strong: #454B52;

  --accent: #F26A24;
  --accent-hover: #FF7d3a;
  --accent-ink: #15110D;

  --ok: #4DB87A;
  --warn: #E2A33A;
  --danger: #E4665C;

  --shadow-1: 0 1px 2px rgba(0,0,0,.40);
  --shadow-2: 0 6px 18px rgba(0,0,0,.45);
  --shadow-3: 0 22px 60px rgba(0,0,0,.62), 0 8px 20px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.45;
}
#root { min-height: 100vh; }
::selection { background: var(--accent); color: var(--accent-ink); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ---- scrollbars ---- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- typographic helpers ---- */
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3); font-family: var(--font-sans);
}
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }
svg.ico { width: 20px; height: 20px; flex: none; }
/* Icon-Boxen: zentrieren und Glyph proportional zur Box skalieren */
.kpi-ico { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); flex: none; }
.kpi-ico > .ico { width: 54%; height: 54%; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.tnum { font-variant-numeric: tabular-nums; }
.cond { font-family: var(--font-cond); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px; letter-spacing: 0.01em;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  transition: background .14s, border-color .14s, color .14s, transform .04s, box-shadow .14s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 18px; height: 18px; flex: none; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; gap: 6px; }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { opacity: .9; }

.btn-outline { border-color: var(--line-2); background: var(--surface); color: var(--ink); }
.btn-outline:hover { border-color: var(--line-strong); background: var(--surface-2); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); }

.btn:disabled { opacity: .45; pointer-events: none; }
.btn-block { width: 100%; }

/* ============================================================
   SURFACES
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-1);
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

/* ============================================================
   BADGES / CHIPS / TAGS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid transparent; line-height: 1; white-space: nowrap;
}
.badge .ico { width: 13px; height: 13px; }
.badge-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.badge-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.badge-neutral { color: var(--ink-2); background: var(--surface-3); border-color: var(--line); }
.badge-accent { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line-2); background: var(--surface); transition: all .12s; white-space: nowrap;
}
.chip .ico { width: 15px; height: 15px; }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.input, .select, textarea.input {
  height: 42px; width: 100%; padding: 0 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: 14.5px; transition: border-color .14s, box-shadow .14s; outline: none;
}
textarea.input { height: auto; padding: 10px 13px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input-mono { font-family: var(--font-mono); letter-spacing: -0.01em; }
.select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B9096' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .ico { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search-wrap .input { padding-left: 40px; }

/* toggle switch */
.switch { position: relative; width: 44px; height: 26px; border-radius: 20px; background: var(--line-2); border: none; transition: background .16s; flex: none; padding: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .16s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

/* ============================================================
   STEPPER (qty +/-)
   ============================================================ */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); height: 38px; }
.stepper button { width: 38px; border: none; background: var(--surface); color: var(--ink-2); display: flex; align-items: center; justify-content: center; transition: background .12s, color .12s; }
.stepper button:hover { background: var(--surface-3); color: var(--ink); }
.stepper button.minus:hover { color: var(--danger); }
.stepper button.plus:hover { color: var(--ok); }
.stepper button .ico { width: 17px; height: 17px; }
.stepper .val { min-width: 46px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 600; font-size: 15px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.stepper.sm { height: 32px; }
.stepper.sm button { width: 32px; }
.stepper.sm .val { min-width: 38px; font-size: 13.5px; }

/* ============================================================
   STOCK BAR
   ============================================================ */
.stockbar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.stockbar > i { display: block; height: 100%; border-radius: 3px; transition: width .3s; }
.stockbar.ok > i { background: var(--ok); }
.stockbar.warn > i { background: var(--warn); }
.stockbar.danger > i { background: var(--danger); }

/* ============================================================
   TABLE
   ============================================================ */
.tbl-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
table.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr { transition: background .1s; cursor: pointer; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.td-right { text-align: right; }
.td-center { text-align: center; }

/* ============================================================
   HAZARD / STRIPE MOTIF
   ============================================================ */
.hazard-bar { height: 6px; width: 100%; background: repeating-linear-gradient(-45deg, var(--hazard-a) 0 11px, var(--hazard-b) 11px 22px); }
.hazard-edge { border-left: 4px solid; border-image: repeating-linear-gradient(-45deg, var(--hazard-a) 0 6px, var(--hazard-b) 6px 12px) 4; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sb-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px; }
.brand-mark { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: center; flex: none; position: relative; overflow: hidden; }
.brand-mark .ico { width: 22px; height: 22px; position: relative; z-index: 1; color: var(--accent); }
.brand-name { font-family: var(--font-cond); font-weight: 800; font-size: 19px; letter-spacing: 0.02em; line-height: 1; }
.brand-name b { color: var(--accent); }
.brand-sub { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-top: 3px; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; transition: background .12s, color .12s; position: relative;
}
.nav-item .ico { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--paper); }
.nav-item.active .ico { color: var(--accent); }
.nav-item .count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); padding: 1px 7px; border-radius: 10px; }
.nav-item.active .count { background: color-mix(in srgb, var(--accent) 24%, transparent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.avatar { width: 34px; height: 34px; border-radius: var(--r-xs); background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--tb-h); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .crumb { color: var(--ink-3); font-weight: 600; }
.page { padding: 26px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-2); margin-top: 3px; font-size: 14.5px; }

/* ============================================================
   KPI TILE
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi .kpi-ico { width: 34px; height: 34px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--ink-2); }
.kpi .kpi-ico .ico { width: 19px; height: 19px; }
.kpi .kpi-val { font-family: var(--font-cond); font-weight: 800; font-size: 38px; line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi .kpi-val small { font-size: 19px; color: var(--ink-3); font-weight: 700; margin-left: 2px; }
.kpi .kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.kpi.alert { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.kpi.alert .kpi-ico { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

/* ============================================================
   DRAWER / MODAL
   ============================================================ */
.scrim { position: fixed; inset: 0; background: rgba(15,13,10,.42); backdrop-filter: blur(2px); z-index: 100; animation: fade .16s ease; }
html[data-theme='dark'] .scrim { background: rgba(0,0,0,.6); }
@keyframes fade { from { opacity: 0; } }

.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 94vw; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-3); z-index: 101; display: flex; flex-direction: column; animation: slideIn .22s cubic-bezier(.2,.7,.3,1); }
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 560px; max-width: 94vw; max-height: 90vh; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); z-index: 101; display: flex; flex-direction: column; animation: pop .18s cubic-bezier(.2,.7,.3,1); }
@keyframes pop { from { transform: translate(-50%,-46%) scale(.97); opacity: .5; } }
@keyframes tourpop { from { transform: translateY(5px) scale(.98); opacity: 0; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.modal-title { font-size: 18px; font-weight: 700; }

.icon-btn { width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--ink-2); display: flex; align-items: center; justify-content: center; transition: all .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn .ico { width: 19px; height: 19px; }

/* ============================================================
   DETAIL ROWS / META
   ============================================================ */
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.meta-cell { background: var(--surface); padding: 12px 14px; }
.meta-cell .k { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.meta-cell .v { font-size: 15px; font-weight: 600; }

.divider { height: 1px; background: var(--line); margin: 20px 0; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }

/* empty state */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.empty .ico { width: 40px; height: 40px; margin-bottom: 12px; color: var(--ink-3); }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-3); font-weight: 600; font-size: 14px; animation: toastIn .2s ease; }
.toast .ico { width: 18px; height: 18px; }
.toast.ok .ico { color: var(--ok); }
.toast.accent .ico { color: var(--accent); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }

/* utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.full { width: 100%; }
.nowrap { white-space: nowrap; }
.hide-sm { }

.mobile-menu { display: none; }

.dash-cols { }

@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { position: fixed; left: 0; top: 0; width: 100%; box-shadow: none !important; border: none !important; }
  .scrim, .modal-head, .modal-foot { display: none !important; }
}

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .dash-cols { grid-template-columns: 1fr !important; }
  .hero-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
  .auth-grid { grid-template-columns: 1fr !important; }
  .auth-side { display: none !important; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .page { padding: 18px; }
  .hide-sm { display: none !important; }
  .mobile-menu { display: flex; }
}
