/* =========================================================================
   Panel produkcji — hala na żywo · GroDev
   System wizualny: premium / techniczny / ciemny. Bez zależności zewnętrznych.
   ========================================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ol, ul { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* ---------- Tokeny ---------- */
:root {
  --bg:        #050505;
  --bg-1:      #0b0b0c;
  --panel:     #0e0e10;
  --panel-2:   #131316;
  --panel-3:   #1a1a1e;
  --line:      rgba(232,228,218,.10);
  --line-2:    rgba(232,228,218,.16);
  --text:      #E8E4DA;
  --muted:     #9c988f;
  --muted-2:   #8b887f;
  --accent:    #B73D2C;
  --accent-text:#e08a7d;
  --accent-ink:#f0d9d3;
  --accent-dim:rgba(183,61,44,.14);
  --ok:        #7d9b6f;
  --ok-dim:    rgba(125,155,111,.14);
  --warn:      #c99a3c;
  --warn-dim:  rgba(201,154,60,.14);
  --info:      #7188a6;
  --info-dim:  rgba(113,136,166,.14);
  --focus:     #d8b7ac;

  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --radius: 8px;
  --radius-sm: 5px;
  --gap: 16px;
  --header-h: 104px;
  --dur: 170ms;
  --ease: cubic-bezier(.22,.61,.36,1);
  --shadow: 0 1px 0 rgba(232,228,218,.03), 0 8px 24px rgba(0,0,0,.5);
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--header-h);
}

/* Subtelna siatka techniczna w tle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(232,228,218,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,228,218,.022) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 78%);
}

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 6px;
  transform: translateY(-160%); transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- Typografia pomocnicza ---------- */
.eyebrow, .onboard__eyebrow {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* =========================================================================
   NAGŁÓWEK
   ========================================================================= */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  background: rgba(5,5,5,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; text-decoration: none; color: inherit; transition: opacity var(--dur) var(--ease); }
a.brand:hover { opacity: .82; }
.brand__mark {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  color: var(--accent); background: var(--panel);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__text b { font-size: 15px; letter-spacing: -.01em; }
.brand__text small { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.brand__sep { color: var(--muted-2); }

.header-tools { display: flex; align-items: center; gap: 8px; }
.sim-state {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
}
.sim-clock { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.sim-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok-dim); animation: pulse 2.4s var(--ease) infinite; }
.sim-dot[data-state="paused"] { background: var(--muted-2); animation: none; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(125,155,111,.45);} 70%{box-shadow:0 0 0 7px rgba(125,155,111,0);} 100%{box-shadow:0 0 0 0 rgba(125,155,111,0);} }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #cb4634; border-color: #cb4634; }
.btn--danger-ghost { border-color: rgba(183,61,44,.4); color: var(--accent-ink); }
.btn--danger-ghost:hover { background: var(--accent-dim); }
.btn--lg { padding: 13px 22px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 12px; }

.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }

/* ---------- Przełącznik ról ---------- */
.role-switch {
  display: flex; gap: 4px; padding: 0 clamp(14px, 3vw, 28px) 10px;
  overflow-x: auto; scrollbar-width: none;
}
.role-switch::-webkit-scrollbar { display: none; }
.role-btn {
  position: relative; display: inline-flex; flex-direction: column; gap: 1px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--muted); text-align: left; white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.role-btn small { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--muted-2); }
.role-btn b { font-size: 13.5px; font-weight: 600; }
.role-btn:hover { color: var(--text); background: var(--panel); }
.role-btn[aria-selected="true"] {
  color: var(--text); background: var(--panel-2); border-color: var(--line-2);
}
.role-btn[aria-selected="true"] small { color: var(--accent-text); }
.role-btn[aria-selected="true"]::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.role-btn__badge {
  position: absolute; top: 5px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 999px; background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}
.role-btn__badge[hidden] { display: none; }

/* =========================================================================
   UKŁAD WIDOKU
   ========================================================================= */
.view { position: relative; z-index: 1; padding: clamp(18px, 2.6vw, 32px); max-width: 1680px; margin: 0 auto; min-height: calc(100vh - var(--header-h) - 72px); }
.view.view-enter { animation: viewEnter .34s var(--ease); }
@keyframes viewEnter { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.view-head__titles .section-label { margin-bottom: 10px; display: inline-flex; }
.view-head__titles h1 { font-size: clamp(22px, 2.8vw, 30px); letter-spacing: -.03em; line-height: 1.08; font-weight: 700; }
.view-head__titles p { color: var(--muted); font-size: 14px; margin-top: 7px; max-width: 64ch; line-height: 1.6; }
.view-head__aside { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); display: inline-flex; align-items: center; gap: 7px;
}
.section-label .idx { color: var(--accent-text); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel__body { padding: 16px; }

/* =========================================================================
   PASEK KPI
   ========================================================================= */
.kpi-bar {
  display: grid; gap: 10px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi {
  position: relative; padding: 13px 14px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: linear-gradient(180deg, var(--panel-2), var(--panel));
  overflow: hidden;
}
.kpi__label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-weight: 500; }
.kpi__value { font-family: var(--mono); font-size: clamp(22px, 2.6vw, 28px); font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 6px; line-height: 1; }
.kpi__unit { font-size: 13px; color: var(--muted); margin-left: 3px; }
.kpi__sub { font-size: 11px; color: var(--muted-2); margin-top: 5px; font-family: var(--mono); }
.kpi[data-tone="danger"] { border-color: rgba(183,61,44,.34); }
.kpi[data-tone="danger"] .kpi__value { color: var(--accent-ink); }
.kpi[data-tone="warn"] .kpi__value { color: var(--warn); }
.kpi[data-tone="ok"] .kpi__value { color: var(--ok); }
.kpi__flag { position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: transparent; }
.kpi[data-tone="danger"] .kpi__flag { background: var(--accent); }
.kpi[data-tone="warn"] .kpi__flag { background: var(--warn); }
.kpi.is-updated { animation: kpiFlash 900ms var(--ease); }
@keyframes kpiFlash { 0%{ background: var(--accent-dim);} 100%{ background: linear-gradient(180deg, var(--panel-2), var(--panel)); } }

/* =========================================================================
   KANBAN
   ========================================================================= */
.board-wrap { position: relative; }
/* Kanban zawsze mieści się w swoim obszarze: gdy 6 kolumn nie wchodzi,
   przewija się w poziomie zamiast nachodzić na sąsiednie elementy. */
.board-scroll { overflow-x: auto; overflow-y: visible; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.board-scroll-hint {
  display: none; font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin-bottom: 8px; align-items: center; gap: 6px;
}
.board-scroll-hint.is-visible { display: flex; }
.kanban {
  display: grid; gap: 10px; align-items: start;
  grid-template-columns: repeat(6, minmax(184px, 1fr));
}
.column {
  display: flex; flex-direction: column; min-height: 140px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.column__head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: var(--radius) var(--radius) 0 0;
}
.column__title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; }
.column__idx { font-family: var(--mono); font-size: 10px; color: var(--muted-2); }
.column__count { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; }
.column__body { display: flex; flex-direction: column; gap: 9px; padding: 10px; flex: 1; min-height: 60px; }
.column.is-bottleneck { border-color: rgba(183,61,44,.45); box-shadow: 0 0 0 1px rgba(183,61,44,.18), var(--shadow); }
.column.is-bottleneck .column__head { background: linear-gradient(180deg, rgba(183,61,44,.14), var(--panel)); }
.column.is-drop-target .column__body { outline: 1px dashed var(--accent); outline-offset: -4px; border-radius: var(--radius-sm); background: var(--accent-dim); }
.column__bottleneck {
  display: none; align-items: center; gap: 6px; padding: 7px 12px;
  font-family: var(--mono); font-size: 10.5px; color: var(--accent-ink);
  border-top: 1px solid rgba(183,61,44,.28); background: rgba(183,61,44,.08);
}
.column.is-bottleneck .column__bottleneck { display: flex; }
.column__empty { margin: 6px 2px; padding: 20px 8px; text-align: center; font-size: 10.5px; color: var(--muted-2); font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; border: 1px dashed var(--line); border-radius: var(--radius-sm); }

/* ---------- Karta zlecenia ---------- */
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 11px 11px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  cursor: grab;
}
.card:hover { border-color: var(--line-2); background: var(--panel-3); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,.42); }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.card.is-dragging { opacity: .5; cursor: grabbing; }
.card.is-moved { animation: cardMoved 900ms var(--ease); }
@keyframes cardMoved { 0%{ box-shadow: 0 0 0 2px var(--ok);} 100%{ box-shadow: none; } }
.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card__chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; min-width: 0; }
.card__id { flex: 0 0 auto; }
.card__id {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em; color: var(--text);
  background: none; border: none; padding: 2px 0; text-align: left; cursor: pointer;
}
.card__id:hover { color: var(--accent-text); }
.card__id:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.card__client { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.card__product { font-size: 12px; color: var(--muted); }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.card__meta b { color: var(--text); font-weight: 600; }
.card__progress { height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.card__progress i { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width 400ms var(--ease); }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__pct { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.card__station { font-family: var(--mono); font-size: 10.5px; color: var(--info); }

/* Priorytety & statusy — kolor + tekst/kropka (nie tylko kolor) */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid var(--line-2); color: var(--muted); text-transform: uppercase;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip--standard { color: var(--muted); }
.chip--pilne    { color: var(--warn); border-color: rgba(201,154,60,.4); background: var(--warn-dim); }
.chip--krytyczne{ color: var(--accent-ink); border-color: rgba(183,61,44,.45); background: var(--accent-dim); }
.chip--risk     { color: var(--accent-ink); border-color: rgba(183,61,44,.45); background: var(--accent-dim); }
.chip--block    { color: var(--warn); border-color: rgba(201,154,60,.4); background: var(--warn-dim); }
.chip--ok       { color: var(--ok); border-color: rgba(125,155,111,.4); background: var(--ok-dim); }

.card.is-risk { border-color: rgba(183,61,44,.4); }
.card.is-blocked { border-color: rgba(201,154,60,.4); }

/* Mobile: przyciski zmiany etapu na karcie */
.card__stage-nav { display: none; gap: 6px; }
.card__stage-nav .btn { flex: 1; }

/* =========================================================================
   PANEL BOCZNY (drawer)
   ========================================================================= */
.drawer { position: fixed; inset: 0; z-index: 120; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade var(--dur) var(--ease); }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 92vw);
  background: var(--bg-1); border-left: 1px solid var(--line-2); box-shadow: -20px 0 60px rgba(0,0,0,.5);
  display: flex; flex-direction: column; animation: slideIn var(--dur) var(--ease);
}
.drawer__head, .modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; border-bottom: 1px solid var(--line);
}
.drawer__title, .modal__title { font-size: 16px; letter-spacing: -.01em; }
.drawer__body { padding: 16px; overflow-y: auto; flex: 1; }
@keyframes slideIn { from{ transform: translateX(16px); opacity: .4; } to{ transform: none; opacity: 1; } }
@keyframes fade { from{opacity:0;} to{opacity:1;} }

.detail-row { display: grid; grid-template-columns: 116px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.detail-row dt { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.detail-row dd { font-size: 13px; }
.detail-block { margin-top: 18px; }
.detail-block h3 { font-size: 12px; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.stage-flow { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-flow span {
  font-family: var(--mono); font-size: 10.5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted-2);
}
.stage-flow span.done { color: var(--ok); border-color: rgba(125,155,111,.35); }
.stage-flow span.current { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

.mat-need { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.mat-need small { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.drawer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }

/* =========================================================================
   MODAL
   ========================================================================= */
.modal { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 16px; }
.modal__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: fade var(--dur) var(--ease); }
.modal__panel {
  position: relative; width: min(460px, 100%); max-height: 90vh; overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; animation: popIn var(--dur) var(--ease);
}
.modal__body { padding: 16px; overflow-y: auto; }
@keyframes popIn { from{ transform: scale(.97); opacity: .5; } to{ transform: none; opacity: 1; } }

.field { margin-bottom: 14px; }
.field label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 14px;
  transition: border-color var(--dur) var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field__error { display: none; color: var(--accent-ink); font-size: 12px; margin-top: 6px; font-family: var(--mono); }
.field.is-invalid input, .field.is-invalid select { border-color: var(--accent); }
.field.is-invalid .field__error { display: block; }

.radio-grid { display: grid; gap: 8px; }
.radio-card {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--panel-2); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.radio-card:hover { border-color: var(--line-2); background: var(--panel-3); }
.radio-card input { accent-color: var(--accent); width: 18px; height: 18px; }
.radio-card span { font-size: 13.5px; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* =========================================================================
   WIDOK OPERATORA
   ========================================================================= */
.op-shell { display: grid; gap: 16px; grid-template-columns: minmax(0,1fr); max-width: 640px; margin: 0 auto; }
.op-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.op-picker label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.op-picker select { flex: 1; min-width: 180px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 15px; }

.op-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 16px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.op-id { display: flex; flex-direction: column; gap: 2px; }
.op-id b { font-size: 19px; letter-spacing: -.01em; }
.op-id small { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.op-station { text-align: right; }
.op-station .st { font-family: var(--mono); font-size: 13px; color: var(--info); }
.op-clock {
  font-family: var(--mono); font-size: clamp(40px, 12vw, 60px); font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; line-height: 1; text-align: center; padding: 8px 0 2px;
}
.op-clock small { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.op-clock[data-running="true"] { color: var(--ok); }
.op-clock[data-running="downtime"] { color: var(--accent-ink); }

.op-status-band {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px; border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line-2); text-transform: uppercase; letter-spacing: .08em;
}
.op-status-band[data-status="praca"] { color: var(--ok); border-color: rgba(125,155,111,.4); background: var(--ok-dim); }
.op-status-band[data-status="dostepny"] { color: var(--info); border-color: rgba(113,136,166,.4); background: var(--info-dim); }
.op-status-band[data-status="przerwa"] { color: var(--warn); border-color: rgba(201,154,60,.4); background: var(--warn-dim); }
.op-status-band[data-status="przestoj"] { color: var(--accent-ink); border-color: rgba(183,61,44,.45); background: var(--accent-dim); }
.op-status-band[data-status="nieobecny"] { color: var(--muted-2); }

.op-task { padding: 16px; }
.op-task__id { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.op-task__title { font-size: 18px; letter-spacing: -.01em; margin: 4px 0 2px; }
.op-task__desc { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.op-task__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; margin-bottom: 8px; }
.op-stat { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.op-stat small { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.op-stat b { font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; }
.op-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.op-actions .btn { min-height: 52px; font-size: 15px; }
.op-actions .btn--wide { grid-column: 1 / -1; }
.btn--start { background: var(--ok); border-color: var(--ok); color: #06120a; }
.btn--start:hover { background: #8dab7d; }
.btn--downtime { border-color: rgba(183,61,44,.45); color: var(--accent-ink); }
.btn--downtime:hover { background: var(--accent-dim); }
.op-task__empty { text-align: center; padding: 30px 16px; color: var(--muted); }

.op-queue { }
.op-queue__item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.op-queue__item:last-child { border-bottom: none; }
.op-queue__item small { font-family: var(--mono); color: var(--muted); font-size: 11px; }

/* =========================================================================
   MAGAZYN
   ========================================================================= */
.wh-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab-btn {
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 600;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab-btn[aria-selected="true"] { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.tab-btn .c { font-family: var(--mono); font-size: 11px; color: var(--muted-2); margin-left: 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data thead th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data tr.is-low td { background: rgba(183,61,44,.06); }
.mat-name { display: flex; flex-direction: column; }
.mat-name b { font-weight: 600; }
.mat-name small { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Karty magazynowe (mobile) */
.wh-cards { display: none; gap: 10px; }
.wh-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 13px; }
.wh-card.is-low { border-color: rgba(183,61,44,.4); }
.wh-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wh-card__name b { font-size: 14px; }
.wh-card__name small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.wh-card__grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 11px 0; }
.wh-card__grid div { text-align: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.wh-card__grid small { display: block; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; color: var(--muted); }
.wh-card__grid b { font-family: var(--mono); font-size: 16px; }
.wh-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 10px; margin-bottom: 16px; }

/* Historia ruchów */
.moves { max-height: 340px; overflow-y: auto; }
.move-row { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; align-items: center; }
.move-row time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.move-row .m-type { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.move-row .m-type.in { color: var(--ok); }
.move-row .m-type.out { color: var(--warn); }
.move-row .m-type.res { color: var(--info); }
.move-row .m-qty { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* =========================================================================
   WŁAŚCICIEL — dashboard + wykresy
   ========================================================================= */
.owner-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-12 { grid-column: span 12; }

.big-metric { display: flex; flex-direction: column; gap: 4px; }
.big-metric .v { font-family: var(--mono); font-size: clamp(28px, 4vw, 40px); font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.big-metric .l { font-size: 12px; color: var(--muted); }
.big-metric.danger .v { color: var(--accent-ink); }

.chart { width: 100%; height: auto; }
.chart text { font-family: var(--mono); fill: var(--muted); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--info); }
.chart .bar--today { fill: var(--accent); }
.chart .bar--plan { fill: rgba(232,228,218,.18); }
.chart .bar--done { fill: var(--ok); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-caption { font-size: 12px; color: var(--muted); margin-top: 10px; }

.gauge { display: flex; align-items: center; gap: 14px; }
.gauge__ring { flex: none; }
.gauge__meta b { font-family: var(--mono); font-size: 22px; }
.gauge__meta small { display: block; color: var(--muted); font-size: 12px; }

.cost-callout {
  border: 1px solid rgba(183,61,44,.35); background: linear-gradient(180deg, var(--accent-dim), var(--panel));
  border-radius: var(--radius); padding: 16px;
}
.cost-callout .v { font-family: var(--mono); font-size: clamp(30px, 5vw, 46px); color: var(--accent-ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.cost-callout p { font-size: 12px; color: var(--muted); margin-top: 8px; max-width: 44ch; }

/* =========================================================================
   HARMONOGRAM / ZMIANY
   ========================================================================= */
.shift-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.station-load { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.station-load__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.station-load__top b { font-family: var(--mono); font-size: 13px; }
.load-bar { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.load-bar i { display: block; height: 100%; background: var(--ok); transition: width 500ms var(--ease); }
.load-bar i[data-load="warn"] { background: var(--warn); }
.load-bar i[data-load="over"] { background: var(--accent); }
.station-load__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }

.roster { display: flex; flex-direction: column; }
.roster__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.roster__who { display: flex; flex-direction: column; }
.roster__who b { font-size: 13.5px; }
.roster__who small { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.roster__right { display: flex; align-items: center; gap: 12px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill[data-s="dostepny"] { color: var(--info); }
.status-pill[data-s="praca"] { color: var(--ok); }
.status-pill[data-s="przerwa"] { color: var(--warn); }
.status-pill[data-s="nieobecny"] { color: var(--muted-2); }
.roster__eff { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 46px; text-align: right; }

/* =========================================================================
   DZIENNIK ZDARZEŃ
   ========================================================================= */
.event-log { max-height: 360px; overflow-y: auto; }
.event-item { display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.event-item:first-child { animation: evIn 500ms var(--ease); }
@keyframes evIn { from{ background: var(--accent-dim); } to{ background: transparent; } }
.event-item time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.event-item .ev-txt { color: var(--text); }
.event-item .ev-txt b { font-family: var(--mono); }
.event-item[data-kind="downtime"] .ev-dot,
.event-item .ev-txt::before { }
.event-item .tag { font-family: var(--mono); font-size: 9.5px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted-2); margin-right: 6px; }
.event-item[data-kind="downtime"] .tag { color: var(--accent-ink); border-color: rgba(183,61,44,.4); }
.event-item[data-kind="qc"] .tag { color: var(--ok); border-color: rgba(125,155,111,.4); }
.event-item[data-kind="stock"] .tag { color: var(--warn); border-color: rgba(201,154,60,.4); }

/* Layout kierownika: board + boczna kolumna */
/* Domyślnie: tablica pełnej szerokości, panel boczny (dziennik + obłożenie) pod nią.
   Panel obok tablicy dopiero na szerokich ekranach, gdzie 6 kolumn realnie się mieści. */
.mgr-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.mgr-side { display: flex; flex-direction: row; flex-wrap: wrap; gap: 16px; }
.mgr-side > * { flex: 1 1 320px; }
@media (min-width: 1600px) {
  .mgr-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .mgr-side { flex-direction: column; flex-wrap: nowrap; position: sticky; top: calc(var(--header-h) + 16px); }
  .mgr-side > * { flex: 1 1 auto; }
}
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; }

/* =========================================================================
   TOASTY
   ========================================================================= */
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 150; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; border-radius: var(--radius-sm);
  background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: toastIn var(--dur) var(--ease); border-left: 3px solid var(--info);
}
.toast[data-kind="ok"] { border-left-color: var(--ok); }
.toast[data-kind="warn"] { border-left-color: var(--warn); }
.toast[data-kind="danger"] { border-left-color: var(--accent); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-size: 13px; font-weight: 600; }
.toast__msg { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toast__close { color: var(--muted); flex: none; }
.toast.is-out { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastIn { from{ transform: translateX(16px); opacity: 0; } to{ transform: none; opacity: 1; } }
@keyframes toastOut { to{ transform: translateX(16px); opacity: 0; } }

/* =========================================================================
   ONBOARDING
   ========================================================================= */
.onboard { position: fixed; inset: 0; z-index: 160; display: grid; place-items: center; padding: 16px; }
.onboard__scrim { position: absolute; inset: 0; background: rgba(5,5,5,.72); backdrop-filter: blur(4px); }
.onboard__panel {
  position: relative; width: min(520px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: clamp(20px, 4vw, 30px); box-shadow: var(--shadow); animation: popIn 220ms var(--ease);
}
.onboard__title { font-size: clamp(22px, 4vw, 28px); letter-spacing: -.02em; margin: 8px 0 8px; }
.onboard__lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.onboard__list { display: flex; flex-direction: column; gap: 11px; margin-bottom: 22px; counter-reset: ob; }
.onboard__list li { position: relative; padding-left: 34px; font-size: 14px; color: var(--text); }
.onboard__list li::before {
  counter-increment: ob; content: counter(ob); position: absolute; left: 0; top: -1px;
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid rgba(183,61,44,.4); color: var(--accent-ink);
  font-family: var(--mono); font-size: 12px;
}
.onboard__actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.onboard__remember { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.onboard__remember input { accent-color: var(--accent); width: 16px; height: 16px; }

/* =========================================================================
   STOPKA
   ========================================================================= */
.app-footer {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 18px clamp(14px,3vw,28px); margin-top: 20px;
  border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--muted-2);
}
.app-footer__note { color: var(--muted); }

/* Utility */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack-16 > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* =========================================================================
   RESPONSYWNOŚĆ
   ========================================================================= */

/* Tablet */
@media (max-width: 1099px) {
  :root { --header-h: 112px; }
  .owner-grid { grid-template-columns: repeat(6, 1fr); }
  .col-8 { grid-column: span 6; }
  .col-4 { grid-column: span 3; }
}

/* Filtr etapu (Kanban na telefonie) — bazowo ukryty, włączany w media query poniżej */
.stage-filter { display: none; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.stage-filter::-webkit-scrollbar { display: none; }
.stage-filter button {
  white-space: nowrap; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-family: var(--mono); font-size: 12px;
}
.stage-filter button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

/* Telefon */
@media (max-width: 767px) {
  :root { --header-h: 150px; --gap: 12px; }
  .app-header__bar { flex-wrap: wrap; row-gap: 10px; }
  .header-tools { width: 100%; justify-content: space-between; }
  .header-tools .btn { flex: 1; }
  .sim-state { order: -1; }
  .role-btn small { display: none; }
  .role-btn { padding: 9px 13px; }
  .owner-grid { grid-template-columns: 1fr; }
  .col-8, .col-6, .col-4, .col-12 { grid-column: 1 / -1; }
  .kanban { grid-template-columns: 1fr; width: 100% !important; }
  .board-scroll { overflow: visible; }
  .board-scroll .kanban { width: 100%; min-width: 0; }
  .board-scroll .column { width: auto; }
  .board-scroll-hint { display: none; }
  .card { cursor: default; }
  .card__stage-nav { display: flex; }
  .drawer__panel { width: 100%; }
  .wh-view.is-mobile .table-wrap { display: none; }
  .wh-view.is-mobile .wh-cards { display: grid; }
  .op-actions .btn { min-height: 56px; }
  .mgr-side { flex-direction: column; }
  .mgr-side > * { flex: 1 1 auto; }
  .kpi__value { font-size: 22px; }
  /* Kolapsowanie Kanbanu do jednego etapu na telefonie */
  .stage-filter { display: flex; }
  .kanban[data-mobile-filter] .column { display: none; }
  .kanban[data-mobile-filter] .column.is-active-mobile { display: flex; }
}

/* Bardzo wąsko */
@media (max-width: 400px) {
  .view { padding: 12px; }
  .op-actions { grid-template-columns: 1fr; }
}

/* =========================================================================
   REDUKCJA RUCHU
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .sim-dot { animation: none; }
}
