/* Panel produkcji Surf.inc — arkusz stylów.
   Narzędzie operacyjne: skanowane, nie czytane. Priorytet ma gęstość informacji
   i to, żeby stan (termin, bramka) czytał się z rzutu oka, bez czytania liczby. */

:root {
  --bg: #f5f6f5;
  --surface: #ffffff;
  --surface-2: #eceeed;
  --ink: #16191a;
  --ink-2: #4d5457;
  --ink-3: #7b8286;
  --rule: #dcdfdd;
  --rule-2: #c2c7c4;
  --accent: #27456e;
  --accent-soft: #e5eaf2;

  --red: #a93429;      --red-bg: #f8e7e4;
  --amber: #8a6008;    --amber-bg: #f9efdb;
  --green: #37633e;    --green-bg: #e4efe5;
  --grey: #6e767b;     --grey-bg: #e9ecea;

  --radius: 4px;
  --shadow: 0 1px 2px rgba(22,25,26,.06), 0 6px 18px -10px rgba(22,25,26,.16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1211; --surface: #171b1a; --surface-2: #1f2422;
    --ink: #e8ebe8; --ink-2: #aeb6b3; --ink-3: #838b88;
    --rule: #2b312f; --rule-2: #3d4542;
    --accent: #8fb0dc; --accent-soft: #1b2739;
    --red: #e8867a;   --red-bg: #331e1b;
    --amber: #d9ae55; --amber-bg: #2e2716;
    --green: #82be8b; --green-bg: #1a2a1d;
    --grey: #98a19d;  --grey-bg: #242927;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px -10px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1211; --surface: #171b1a; --surface-2: #1f2422;
  --ink: #e8ebe8; --ink-2: #aeb6b3; --ink-3: #838b88;
  --rule: #2b312f; --rule-2: #3d4542;
  --accent: #8fb0dc; --accent-soft: #1b2739;
  --red: #e8867a;   --red-bg: #331e1b;
  --amber: #d9ae55; --amber-bg: #2e2716;
  --green: #82be8b; --green-bg: #1a2a1d;
  --grey: #98a19d;  --grey-bg: #242927;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px -10px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ── ramka strony ─────────────────────────────────────────── */
.top {
  background: var(--surface); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 30;
}
.top-in {
  max-width: 1680px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: -.01em; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--ink-3); font-weight: 500; }
.badge-env {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  background: var(--amber-bg); color: var(--amber); padding: 2px 7px; border-radius: 10px;
}
.nav { display: flex; gap: 4px; margin-left: 4px; }
.nav a {
  padding: 5px 11px; border-radius: var(--radius); text-decoration: none;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-3); }

.wrap { max-width: 1680px; margin: 0 auto; padding: 18px 20px 64px; }

/* ── pasek liczb ──────────────────────────────────────────── */
.kpis { display: flex; gap: 1px; background: var(--rule); border: 1px solid var(--rule);
        border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; flex-wrap: wrap; }
.kpi {
  background: var(--surface); padding: 10px 16px; min-width: 118px; flex: 1 1 auto;
  text-decoration: none; color: inherit; display: block;
}
.kpi:hover { background: var(--surface-2); }
.kpi.on { background: var(--accent-soft); }
.kpi .k { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi.warn .v { color: var(--amber); }
.kpi.bad  .v { color: var(--red); }
.kpi.unk  .v { color: var(--grey); }

/* ── filtry ───────────────────────────────────────────────── */
.filters {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px;
}
.frow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.frow + .frow { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.flabel { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.cbx {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--rule-2); border-radius: 14px; padding: 3px 10px 3px 8px;
  font-size: 12.5px; background: var(--surface); user-select: none;
}
.cbx:hover { border-color: var(--accent); }
.cbx input { margin: 0; }
.cbx.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cbx .c { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cbx.on .c { color: var(--accent); }
input[type=search], input[type=text], select {
  font: inherit; padding: 5px 9px; border: 1px solid var(--rule-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); min-width: 0;
}
input[type=search] { min-width: 240px; }
.btn {
  font: inherit; font-weight: 600; padding: 5px 13px; border-radius: var(--radius);
  border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink); cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #0f1211; }
.btn.sm { padding: 3px 9px; font-size: 12.5px; font-weight: 500; }

/* ── tabela ───────────────────────────────────────────────── */
/* 🚨 `overflow-x: auto` tworzy SCROLLPORT także dla pionu, więc przyklejony nagłówek
   tabeli przykleja się do TEGO pudełka, a nie do strony. Przy `top: 49px` dawało to
   49-pikselowy pas pustki nad nagłówkiem i nagłówek nachodzący na pierwszy wiersz
   (zmierzone: thead.top 418 przy table.top 369). Skoro pudełko i tak jest scrollportem,
   robimy z niego scrollport UCZCIWIE: własna wysokość, przewijanie w obu osiach,
   nagłówek przyklejony do jego górnej krawędzi. Filtry i liczniki zostają nad tabelą.
   Pułapka opisana w pamięci projektu jako „sticky thead wymaga scrollportu". */
.scroll { overflow: auto; max-height: calc(100vh - 300px); min-height: 260px;
          background: var(--surface); border: 1px solid var(--rule);
          border-radius: var(--radius); box-shadow: var(--shadow);
          overscroll-behavior: contain; }
.scroll.short { max-height: none; min-height: 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface-2); text-align: left; font-weight: 600; font-size: 11.5px;
  letter-spacing: .03em; color: var(--ink-2); padding: 9px 12px; white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--rule-2);
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.held td { opacity: .62; }
td.prod { max-width: 300px; }
td.prod a { font-weight: 600; text-decoration: none; }
td.prod a:hover { text-decoration: underline; }
td.prod .sub { color: var(--ink-3); font-size: 11.5px; }

/* ── plakietki stanu ──────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}
.chip.red   { background: var(--red-bg);   color: var(--red); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.grey  { background: var(--grey-bg);  color: var(--grey); }
.chip.accent{ background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ── mini tor etapów w wierszu ────────────────────────────── */
.track-mini { display: flex; gap: 2px; align-items: center; }
.tm {
  width: 13px; height: 7px; border-radius: 2px; background: var(--rule-2); flex: none;
}
.tm.done { background: var(--green); opacity: .55; }
.tm.current { background: var(--accent); height: 11px; }
.tm.na { background: transparent; box-shadow: inset 0 0 0 1px var(--rule-2); }
.track-label { font-size: 11.5px; color: var(--ink-2); margin-left: 6px; white-space: nowrap; }

/* ── ilości zamówione/skrojone ────────────────────────────── */
.qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty .cut { color: var(--ink-3); }
.qty .cut.missing { color: var(--red); font-weight: 600; }

/* ── karta zlecenia ───────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
        padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: -.01em; }
.card h2 .hint { font-weight: 400; font-size: 12px; color: var(--ink-3); margin-left: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1080px) { .grid2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.hero { display: flex; gap: 16px; align-items: flex-start; }
.hero img { width: 108px; height: 144px; object-fit: cover; border-radius: var(--radius);
            border: 1px solid var(--rule); background: var(--surface-2); flex: none; }
.hero h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.hero .meta { color: var(--ink-3); font-size: 12.5px; }

/* pełny tor etapów */
.track { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; }
.st {
  flex: none; min-width: 96px; border: 1px solid var(--rule-2); border-radius: var(--radius);
  padding: 7px 10px; background: var(--surface); font-size: 12px;
}
.st .n { font-weight: 600; white-space: nowrap; }
.st .t { color: var(--ink-3); font-size: 11px; margin-top: 2px; white-space: nowrap; }
.st.done { background: var(--green-bg); border-color: transparent; }
.st.done .n { color: var(--green); }
.st.current { background: var(--accent-soft); border-color: var(--accent); }
.st.current .n { color: var(--accent); }
.st.na { opacity: .45; }

/* tabelki wewnątrz karty */
.mini { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.mini th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: 11px;
           text-transform: uppercase; letter-spacing: .04em; padding: 5px 8px;
           border-bottom: 1px solid var(--rule); }
.mini td { padding: 5px 8px; border-bottom: 1px solid var(--rule); }
.mini tr:last-child td { border-bottom: none; }

.note { background: var(--surface-2); border-left: 3px solid var(--rule-2);
        padding: 10px 13px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; }
.note.warn { background: var(--amber-bg); border-left-color: var(--amber); }
.note.bad { background: var(--red-bg); border-left-color: var(--red); }
.note p { margin: 0 0 6px; } .note p:last-child { margin: 0; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--rule);
        font-size: 12px; color: var(--ink-3); }

/* ── logowanie ────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 32px 30px; width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.login p { color: var(--ink-2); margin: 0 0 20px; font-size: 13px; }
.login .err { background: var(--red-bg); color: var(--red); padding: 9px 12px;
              border-radius: var(--radius); font-size: 12.5px; margin-bottom: 14px; }
.login form { display: grid; gap: 9px; }
.login .btn { text-align: center; padding: 9px 14px; }

/* ── widok BAZA ───────────────────────────────────────────── */
.baza table { font-size: 12px; }
.baza td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.colpick { display: flex; flex-wrap: wrap; gap: 5px; }
.colpick .cbx { font-size: 11.5px; padding: 2px 8px; }
