:root {
  --side: #10302b;
  --side2: #1a443d;
  --paper: #f3f5ef;
  --white: #fff;
  --ink: #142827;
  --muted: #5e736d;
  --line: #dfe5dc;
  --soft: #edf0ea;
  --lime: #d5f06b;
  --green: #2f7d5b;
  --amber: #e0a428;
  --red: #c23a3a;
  --ease: cubic-bezier(.16, .84, .24, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); color: var(--ink); font: 13.5px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.demo-banner { flex: none; margin: 0; padding: 5px 16px; background: var(--lime); font-size: 12px; font-weight: 600; text-align: center; }
svg.i { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 12px; padding: 14px 10px; background: var(--side); color: #dbe7df; }
.identity { display: flex; align-items: center; gap: 9px; padding: 0 6px; text-decoration: none; }
.identity-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--lime); color: var(--ink); font-size: 17px; font-weight: 800; }
.identity strong { display: block; color: #fff; font-size: 13.5px; letter-spacing: .06em; line-height: 1.1; }
.identity small { color: #9db8ad; font-size: 11.5px; }
.views { display: grid; gap: 2px; }
.nav-group { margin: 9px 9px 2px; color: #86a497; font-size: 10px; letter-spacing: .09em; }
.views button, .views a { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 0 9px; border: 0; border-radius: 9px; background: none; color: inherit; font-size: 13px; font-weight: 560; text-align: left; text-decoration: none; cursor: pointer; }
.views button:hover, .views a:hover { background: rgba(255, 255, 255, .06); }
.views button[aria-current=page] { background: var(--side2); color: #fff; }
.views span { flex: 1; white-space: nowrap; }
.views em { padding: 0 7px; border-radius: 9px; background: var(--side2); font-size: 11px; font-style: normal; }
.views em.hot { background: var(--lime); color: var(--ink); font-weight: 700; }
.side-foot { display: grid; gap: 2px; margin-top: auto; }
.link-button { padding: 5px 9px; border: 0; background: none; color: #9db8ad; font-size: 12.5px; text-align: left; text-decoration: none; cursor: pointer; }
.link-button:hover { color: #fff; }
.me { display: flex; gap: 9px; align-items: center; margin-top: 8px; padding: 10px 6px 0; border-top: 1px solid var(--side2); color: #fff; font-weight: 600; }
.me small { display: block; color: #9db8ad; font-size: 11.5px; font-weight: 400; }
.me i, .mobile-bar i { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #f7e4d2; color: #8a4b16; font: 700 10.5px system-ui, sans-serif; }

main { min-width: 0; min-height: 0; overflow: auto; padding: 11px 14px 16px; }
.mobile-bar { display: none; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.topbar h1 { margin-right: auto; font-size: 21px; font-weight: 740; letter-spacing: -.02em; white-space: nowrap; }
.search { display: flex; align-items: center; gap: 7px; width: min(280px, 100%); height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); color: var(--muted); }
.search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
select { appearance: none; -webkit-appearance: none; padding-right: 48px; background-color: var(--white); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235e736d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 6 4.5 4.5L12.5 6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 18px center; background-size: 16px 16px; }
.machine-filter select { height: 38px; padding-left: 12px; border: 1px solid var(--line); border-radius: 11px; }
.primary { min-height: 38px; padding: 0 14px; border: 0; border-radius: 11px; background: var(--ink); color: #fff; font-weight: 640; white-space: nowrap; cursor: pointer; transition: background .2s; }
.primary:hover { background: #2a4a44; }
.ghost { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); font-weight: 620; cursor: pointer; }
.ghost:hover { border-color: #b6c4b3; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 10px; }
.kpi { position: relative; display: grid; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.kpi span { color: var(--muted); font-size: 12px; font-weight: 560; }
.kpi strong { font-size: 22px; font-weight: 760; letter-spacing: -.025em; line-height: 1.2; white-space: nowrap; }
.kpi small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.kpi svg { position: absolute; right: 12px; bottom: 11px; width: 72px; height: 26px; }
.kpi.bad strong, .kpi.bad small { color: var(--red); }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 256px; gap: 9px; align-items: start; }
.board { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 8px; align-items: start; overflow-x: auto; }
.column { padding: 7px; border-radius: 14px; background: #e8ece3; transition: background .2s; }
.column.over { background: #d9e6c6; }
.column-head { display: flex; align-items: center; gap: 7px; padding: 2px 4px 7px; }
.column-head i { width: 8px; height: 8px; border-radius: 50%; }
.column-head h2 { font-size: 12.8px; font-weight: 680; white-space: nowrap; }
.column-head span { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 620; }
.column-list { display: grid; gap: 6px; }
.empty { padding: 14px; color: var(--muted); text-align: center; }
.job { display: grid; width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); text-align: left; cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s; }
.job:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20, 40, 39, .1); }
.job.dragging { opacity: .45; }
.job.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.job-top, .job-foot { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.job-top { margin-bottom: 2px; }
.job-foot { margin-top: 6px; }
.job-id { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.job-title { overflow: hidden; font-size: 13px; font-weight: 680; letter-spacing: -.01em; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.job-sub { overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.job-note { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.due { flex: none; padding: 0 7px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 620; white-space: nowrap; }
.due.warm { background: #fbf0d4; color: #8a6210; }
.due.hot { background: #fbdfd9; color: #a93422; }
.tag { flex: none; padding: 1px 7px; border-radius: 6px; background: #dcefe3; color: #1f5a41; font-size: 11px; font-weight: 680; }
.avatar { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #d9e8d8; color: #1f5a41; font-size: 9.5px; font-weight: 720; }
.avatar.MS { background: #dfe3f6; color: #36428f; }
.avatar.KL { background: #f7e4d2; color: #8a4b16; }
.bar { display: block; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 3px; background: var(--soft); }
.bar i { display: block; height: 100%; background: var(--green); transition: width .6s var(--ease); }
.bar i.set { background: var(--amber); }
.bar i.stop { background: var(--red); }

.rail { display: grid; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 11px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 13px; font-weight: 680; }
.card-head small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.machine-row { display: block; width: 100%; padding: 6px 11px; border: 0; border-top: 1px solid var(--soft); background: none; text-align: left; cursor: pointer; }
.machine-row:first-of-type { border-top: 0; }
.machine-row:hover { background: #f8faf5; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-between b { font-size: 12.5px; font-weight: 680; }
.row-between span.m { color: var(--muted); font-size: 11.5px; }
.status { flex: none; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 640; white-space: nowrap; }
.status.run, .status.ok { background: #dcefe3; color: #1f5a41; }
.status.set, .status.wait { background: #fbf0d4; color: #8a6210; }
.status.stop, .status.bad { background: #fbdfd9; color: #a93422; }
.decision { padding: 7px 11px; border-top: 1px solid var(--soft); }
.decision:first-of-type { border-top: 0; }
.decision b { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; font-weight: 660; }
.decision b::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--red); }
.decision.warn b::before { background: var(--amber); }
.decision p { padding-left: 14px; color: var(--muted); font-size: 11.5px; }
.decision div { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; padding-left: 14px; }
.chip-btn { padding: 2px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); font-size: 11.5px; font-weight: 620; cursor: pointer; }
.chip-btn:hover { border-color: var(--green); color: var(--green); }
.chart-pad { padding: 8px 11px; }
.chart { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 12px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
th, td { padding: 8px 12px; border-top: 1px solid var(--soft); font-size: 13px; text-align: left; white-space: nowrap; }
thead th { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 560; }
th button { padding: 0; border: 0; background: none; font-weight: inherit; cursor: pointer; }
th button:hover { color: var(--ink); }
tbody tr[data-open] { cursor: pointer; }
tbody tr[data-open]:hover { background: #f8faf5; }
td b { font-weight: 680; }
.stage-track { display: inline-flex; gap: 3px; margin-right: 7px; vertical-align: 1px; }
.stage-track i { width: 16px; height: 5px; border-radius: 3px; background: #e3e8df; }
.stage-track i.on { background: var(--side); }
.stage-track i.now { background: var(--green); }

.gantt { padding: 8px 12px 12px; overflow-x: auto; }
.gantt-inner { position: relative; min-width: 720px; }
.gantt-days, .gantt-row { display: grid; grid-template-columns: 126px minmax(0, 1fr); }
.gantt-days div:last-child { display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: 6px; color: var(--muted); font-size: 12px; }
.gantt-row { align-items: center; height: 54px; border-top: 1px solid var(--soft); }
.gantt-row b { font-size: 13px; font-weight: 660; }
.gantt-row small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.track { position: relative; height: 34px; }
.track button { position: absolute; top: 0; height: 34px; padding: 0 8px; overflow: hidden; border: 0; border-radius: 7px; font-size: 12px; font-weight: 640; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.track .slot-a { background: #dceee3; color: #1f6246; }
.track .slot-b { background: #e4e9fb; color: #2f4799; }
.track .slot-hot { background: #fbe3e0; color: #a92f2f; box-shadow: inset 0 0 0 1px #e08b83; }
.track .slot-off { background: var(--soft); color: var(--muted); cursor: default; }
.today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); pointer-events: none; }
.today::before { content: 'teraz'; position: absolute; top: -2px; left: 5px; font-size: 10.5px; font-weight: 700; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.machine-card { display: grid; gap: 7px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.machine-card h2 { font-size: 16px; font-weight: 720; }
.machine-card small { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats div { padding: 6px 8px; border-radius: 8px; background: var(--paper); }
.stats span { display: block; color: var(--muted); font-size: 11px; }
.stats b { font-size: 14.5px; font-weight: 720; }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; min-height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 12px; font-weight: 620; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.queue { display: flex; flex-wrap: wrap; gap: 4px; }
.queue button { padding: 1px 7px; border: 0; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 11.5px; font-weight: 620; cursor: pointer; }
.queue button:hover { color: var(--ink); }

.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 9px; }
.h-bars { display: grid; gap: 8px; padding: 12px; }
.h-bar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 76px; align-items: center; gap: 8px; font-size: 12.5px; }
.h-bar p { height: 9px; overflow: hidden; border-radius: 5px; background: var(--soft); }
.h-bar p i { display: block; height: 100%; background: var(--green); }
.h-bar p i.hot { background: var(--red); }
.h-bar b { font-weight: 660; text-align: right; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; width: min(460px, 100%); overflow-y: auto; padding: 18px 20px 26px; border-left: 1px solid var(--line); background: var(--white); box-shadow: -18px 0 50px rgba(20, 40, 39, .16); animation: drawer .3s var(--ease); }
@keyframes drawer { from { translate: 30px 0; opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; }
.drawer-head small { color: var(--muted); font-weight: 600; }
.drawer-head h2 { font-size: 22px; font-weight: 740; letter-spacing: -.02em; line-height: 1.2; }
.close { width: 36px; height: 36px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 21px; line-height: 1; cursor: pointer; }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 14px 0; }
.step { min-height: 44px; padding: 7px 3px; border: 0; border-top: 3px solid var(--line); background: none; color: var(--muted); font-size: 11.5px; font-weight: 620; line-height: 1.2; cursor: pointer; }
.step.past { border-color: var(--green); }
.step.now { border-color: var(--green); color: var(--ink); font-weight: 760; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.facts div { display: grid; padding: 8px 12px; background: var(--white); }
.facts span { color: var(--muted); font-size: 12px; }
.facts strong { font-size: 14px; font-weight: 640; }
.drawer h3 { margin: 16px 0 7px; font-size: 14px; font-weight: 700; }
.ops { display: grid; gap: 2px; }
.ops label { display: flex; align-items: center; gap: 9px; padding: 5px 0; cursor: pointer; }
.ops input { width: 16px; height: 16px; accent-color: var(--green); }
.drawer select { width: 100%; height: 40px; padding-left: 11px; border: 1px solid var(--line); border-radius: 10px; }
.history { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.history li { padding-left: 11px; border-left: 2px solid var(--line); font-size: 13px; }
.history small { display: block; color: var(--muted); font-size: 11.5px; }
.note-form { display: flex; gap: 6px; margin-top: 10px; }
.note-form input { flex: 1; min-width: 0; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 40; translate: -50% 0; padding: 9px 15px; border-radius: 11px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 14px 34px rgba(20, 40, 39, .3); animation: toast .3s var(--ease); }
@keyframes toast { from { opacity: 0; translate: -50% 10px; } }
dialog { width: min(460px, calc(100vw - 24px)); padding: 22px; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 30px 70px rgba(20, 40, 39, .35); }
dialog::backdrop { background: rgba(16, 48, 43, .45); }
#new-form { display: grid; gap: 10px; }
#new-form h2 { font-size: 20px; font-weight: 740; }
#new-form label { display: grid; gap: 3px; font-size: 13px; font-weight: 600; }
#new-form input, #new-form select { width: 100%; min-height: 42px; padding-block: 8px; padding-left: 11px; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; }
#new-form input { padding-right: 11px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 1100px) {
  .work { grid-template-columns: 1fr; }
  .rail { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { display: block; flex: 1; min-height: 0; overflow: auto; padding-bottom: 66px; }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: block; padding: 7px 6px calc(8px + env(safe-area-inset-bottom)); }
  .identity, .side-foot, .nav-group, .views a { display: none; }
  .views { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .views button { flex: 1 0 68px; flex-direction: column; justify-content: center; gap: 2px; min-height: 44px; padding: 0 4px; color: #9db8ad; font-size: 11.5px; }
  .views button[aria-current=page] { background: none; color: #fff; }
  .views button[aria-current=page] svg { color: var(--lime); }
  .views span { flex: none; }
  .views em { display: none; }
  main { overflow: visible; padding: 0 12px 14px; }
  .mobile-bar { display: flex; align-items: center; gap: 9px; margin: 0 -12px 10px; padding: 9px 12px; background: var(--side); color: #fff; }
  .mobile-bar .identity-mark { width: 28px; height: 28px; font-size: 15px; }
  .mobile-bar strong { letter-spacing: .06em; }
  .mobile-bar small { color: #9db8ad; }
  .mobile-bar i { margin-left: auto; }
  .topbar { flex-wrap: wrap; }
  .topbar h1 { width: 100%; margin: 0; }
  .search { width: 100%; }
  .search, .machine-filter, #new-order { display: none; }
  .view-orders .search, .view-orders .machine-filter, .view-orders #new-order { display: flex; }
  .view-orders .machine-filter { flex: 1; }
  .view-orders .machine-filter select { width: 100%; }
  .kpis, .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .kpi svg { top: 28px; right: 10px; bottom: auto; width: 44px; height: 22px; }
  .work { display: flex; flex-direction: column-reverse; }
  .board { width: calc(100vw - 24px); grid-template-columns: repeat(4, 222px); scroll-snap-type: x mandatory; }
  .column { scroll-snap-align: start; }
  .rail, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .rail { width: 100%; }
  .rail .plan-card { display: none; }
  .h-bar { grid-template-columns: 100px minmax(0, 1fr) 64px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
