/* =============================================================
   STYR — Layout Planner
   Industrial precision · technical CAD aesthetic
   ============================================================= */

:root {
  color-scheme: dark;
  /* ---------- Surfaces ---------- */
  --bg:           #0a0d13;
  --bg-elevated:  #0f131c;
  --surface:      #151a24;
  --surface-2:    #1c2230;
  --surface-3:    #252c3d;
  --border:       #20273436;
  --border-line:  #232a38;
  --border-strong:#2c3446;
  --border-bright:#48526b;

  /* ---------- Text ---------- */
  --text:         #e9edf3;
  --text-bright:  #ffffff;
  --text-muted:   #8c95a8;
  --text-faint:   #5a6272;
  --text-ghost:   #3a4150;

  /* ---------- Accents ---------- */
  --accent:       #4ea1ff;   /* info / selection */
  --accent-2:     #2b6bd1;
  --accent-soft:  rgba(78, 161, 255, 0.16);

  --hit:          #ff8a4c;   /* brand / primary CTA */
  --hit-2:        #e16834;
  --hit-soft:     rgba(255, 138, 76, 0.16);
  --hit-glow:     rgba(255, 138, 76, 0.40);

  --success:      #5fd49a;
  --success-soft: rgba(95, 212, 154, 0.14);

  --warning:      #ffb547;
  --warning-soft: rgba(255, 181, 71, 0.14);

  --danger:       #ff5d6c;
  --danger-soft:  rgba(255, 93, 108, 0.12);

  --cyan:         #54c2ff;

  /* ---------- Effects ---------- */
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md:    0 6px 22px rgba(0, 0, 0, 0.42);
  --shadow-lg:    0 18px 44px rgba(0, 0, 0, 0.58);
  --inset-edge:   inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --ring-accent:  0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft);
  --ring-hit:     0 0 0 1px var(--hit), 0 0 0 4px var(--hit-soft);

  /* ---------- Typography ---------- */
  --font-sans:    'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* ---------- Layout ---------- */
  --toolbar-h:    54px;
  --dock-w:       360px;
  --radius:       6px;
  --radius-sm:    4px;
  --radius-lg:    10px;

  /* ---------- Motion ---------- */
  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:  cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:     120ms;
  --dur-med:      220ms;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}

/* Ambient atmosphere: subtle vignettes radiating from corners */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 800px 600px at 0% 0%, rgba(78, 161, 255, 0.045), transparent 60%),
    radial-gradient(ellipse 800px 600px at 100% 100%, rgba(255, 138, 76, 0.040), transparent 55%),
    radial-gradient(ellipse 600px 400px at 100% 0%, rgba(0, 0, 0, 0.35), transparent 60%);
}

.app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
  z-index: 1;
}

/* ===================================================
   TOOLBAR
   =================================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--toolbar-h);
  padding: 0 12px 0 14px;
  background: linear-gradient(180deg, #131826 0%, #0c1018 100%);
  border-bottom: 1px solid var(--border-line);
  position: relative;
  z-index: 60;
}
.toolbar::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border-strong) 35%, var(--border-strong) 65%, transparent 100%);
  pointer-events: none;
}

/* ---- Brand ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-right: 16px;
  margin-right: 6px;
  height: 36px;
  border-right: 1px solid var(--border-line);
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #1a0a02;
  background: linear-gradient(140deg, #ffaa6b 0%, var(--hit) 45%, var(--hit-2) 100%);
  border-radius: 7px;
  box-shadow:
    0 0 0 1px rgba(255, 200, 150, 0.25) inset,
    0 0 22px var(--hit-soft),
    0 2px 6px rgba(0, 0, 0, 0.45);
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}
.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.22em;
  color: var(--text-bright);
}
.brand-tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---- Tool cluster ---- */
.tool-cluster {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 3px;
  gap: 1px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  box-shadow: var(--inset-edge), var(--shadow-sm);
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 100%;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              transform 80ms var(--ease-out);
}
.tool-btn svg { opacity: 0.86; }
.tool-btn:hover { color: var(--text); background: var(--surface-2); }
.tool-btn:hover svg { opacity: 1; }
.tool-btn:active { transform: translateY(1px); }
.tool-btn:focus-visible { outline: none; box-shadow: var(--ring-accent); }
.tool-btn[aria-pressed="true"],
.tool-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.water-group {
  display: inline-flex;
  align-items: center;
  height: 100%;
  gap: 4px;
}
.water-group .tool-btn[aria-pressed="true"] {
  color: var(--cyan);
  background: rgba(84, 194, 255, 0.16);
}
.water-input-wrap {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 6px 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-line);
  border-radius: 5px;
}
.water-input-wrap input {
  width: 56px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  outline: none;
}
.water-input-wrap input::-webkit-outer-spin-button,
.water-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.water-suffix {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.tool-btn-exit {
  color: #d864ff;
  background: rgba(216, 100, 255, 0.10);
  border-color: rgba(216, 100, 255, 0.32);
}
.tool-btn-exit:hover {
  color: #ee8eff;
  background: rgba(216, 100, 255, 0.16);
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  height: 16px;
  margin-left: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-line);
  border-radius: 3px;
  text-transform: uppercase;
}
.kbd-on-primary {
  color: rgba(26, 10, 2, 0.7);
  background: rgba(26, 10, 2, 0.16);
  border-color: rgba(26, 10, 2, 0.28);
}

.tool-spacer { flex: 1; }

/* ---- Meta strip (status / selection chips) ---- */
.meta-strip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 38vw;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-line);
  border-radius: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.meta-chip-soft {
  color: var(--text-faint);
  border-style: dashed;
  border-color: var(--border-line);
  background: transparent;
}

/* ---- Primary CTA ---- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 1px solid #d56631;
  background:
    linear-gradient(180deg, #ffa066 0%, var(--hit) 38%, var(--hit-2) 100%);
  color: #1a0a02;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 7px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 8px 22px var(--hit-soft),
    0 1px 0 rgba(0, 0, 0, 0.30);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 12px 28px var(--hit-glow),
    0 1px 0 rgba(0, 0, 0, 0.30);
}
.primary-btn:active { transform: translateY(0); }
.primary-glyph {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(26, 10, 2, 0.18);
  color: #1a0a02;
}

/* ===================================================
   WORKSPACE
   =================================================== */

.workspace {
  display: grid;
  grid-template-columns: var(--dock-w) 1fr;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
.workspace.dock-collapsed {
  grid-template-columns: 0 1fr;
}

/* ===================================================
   DOCK (left)
   =================================================== */

.dock {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-line);
  min-width: 0;
  overflow: hidden;
  transition: width var(--dur-med) var(--ease-out);
  position: relative;
  z-index: 10;
}
.workspace.dock-collapsed .dock { width: 0; border-right: 0; }

.dock-tabs {
  display: flex;
  align-items: stretch;
  height: 40px;
  border-bottom: 1px solid var(--border-line);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  position: relative;
}
.dock-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-med) var(--ease-out);
}
.dock-tab:hover { color: var(--text); }
.dock-tab:focus-visible { outline: none; color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.dock-tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--hit);
}
.dock-tab[aria-selected="true"]::before {
  content: '';
  position: absolute;
  inset: auto 25% -2px;
  height: 2px;
  background: var(--hit);
  filter: blur(4px);
  opacity: 0.7;
  pointer-events: none;
}

.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-faint);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.dock-tab[aria-selected="true"] .tab-count {
  color: var(--hit);
  background: var(--hit-soft);
}

.dock-collapse {
  width: 34px;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border-line);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.dock-collapse:hover { color: var(--text); background: var(--surface-2); }
.workspace.dock-collapsed .dock-collapse svg { transform: scaleX(-1); }

/* Edge handle — pull-tab on the left workspace border, only when dock is collapsed */
.dock-expand {
  position: absolute;
  left: 0;
  top: 14px;
  width: 22px;
  height: 64px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-line);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 11;
  box-shadow: var(--shadow-sm);
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}
.workspace.dock-collapsed .dock-expand {
  display: inline-flex;
  animation: dockExpandEnter var(--dur-med) var(--ease-out);
}
.dock-expand:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
}
.dock-expand:focus-visible {
  outline: none;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent-soft);
}
.dock-expand-stripe {
  position: absolute;
  right: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--hit);
  opacity: 0.55;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.dock-expand:hover .dock-expand-stripe { opacity: 1; }

@keyframes dockExpandEnter {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

.dock-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.dock-panel[hidden] { display: none; }

.dock-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-line);
}
.dock-section-head > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.dock-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dock-section-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

/* Section filter — dropdown w nagłówku Aktywne systemy */
.systems-filter {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
  cursor: pointer;
}
.systems-filter-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.systems-filter-input {
  display: inline-flex;
  align-items: center;
  height: 26px;
  background: var(--bg);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.systems-filter-input:hover { border-color: var(--border-bright); }
.systems-filter-input:focus-within {
  border-color: var(--hit);
  box-shadow: 0 0 0 3px var(--hit-soft);
}
.systems-filter-input select {
  appearance: none;
  -webkit-appearance: none;
  width: 140px;
  height: 24px;
  padding: 0 24px 0 8px;
  border: 0;
  background: transparent;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 11px) 11px, calc(100% - 7px) 11px;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  outline: none;
  cursor: pointer;
}
.systems-filter-input select option {
  background: var(--bg-elevated);
  color: var(--text);
}

.dock-hint {
  margin: 12px 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px dashed var(--border-line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.55;
}
.hint-kbd {
  display: inline-block;
  padding: 0 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-line);
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Filter input */
.filter-wrap {
  position: relative;
  margin: 12px 16px 8px;
}
.filter-wrap .filter-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  transition: color var(--dur-fast);
}
.filter-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.filter-wrap input::placeholder { color: var(--text-faint); }
.filter-wrap input:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-wrap input:focus ~ .filter-icon,
.filter-wrap:focus-within .filter-icon { color: var(--accent); }

/* Tree list */
.tree-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.tree-list li {
  padding: 5px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.tree-list li:hover { background: var(--surface); color: var(--text); }
.tree-list li.selected {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Dock footer */
.dock-footer {
  border-top: 1px solid var(--border-line);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
}
.dock-footer-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.dock-footer-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================================================
   SYSTEMS list (inside dock)
   =================================================== */

.systems-host {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.systems-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.dock-totals {
  margin: 6px 16px 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--inset-edge);
}
.dock-totals:empty { display: none; }
.dock-totals .key {
  font-size: 11px;
  color: var(--text-muted);
}
.dock-totals .val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}
.dock-totals .val.accent { color: var(--success); font-size: 13px; }

.hidden { display: none !important; }

/* ===================================================
   DATA TABLE — shared (systems, inventory, iter)
   =================================================== */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.data-table th,
.data-table td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table td { border-bottom: 1px solid var(--border-line); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num,
.data-table th.num { text-align: right; font-family: var(--font-mono); }
.data-table .th-id { width: 30px; color: var(--text-ghost); }
.data-table tbody tr {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.data-table tbody tr:hover { background: var(--surface); }
.data-table tbody tr.active {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
.data-table td.waste {
  color: var(--warning);
  font-family: var(--font-mono);
  font-size: 11px;
}
.data-table tbody tr.best td.waste { color: var(--success); font-weight: 600; }
.data-table td.actions {
  text-align: right;
  white-space: nowrap;
  padding-right: 8px;
}
.data-table button.sys-act {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 2px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-faint);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.data-table button.sys-act:hover {
  color: var(--accent);
  background: var(--surface-2);
  border-color: var(--border-line);
}
.data-table button.sys-act.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* Systems-specific cell */
.systems-table .system-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.systems-table .sys-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04), 0 0 8px currentColor;
}
.systems-table .sys-sec {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--hit);
  background: var(--hit-soft);
  border: 1px solid rgba(255, 138, 76, 0.32);
  border-radius: 3px;
  flex: 0 0 auto;
}

/* ===================================================
   VIEWPORT
   =================================================== */

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}
canvas#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Pick-hint banner */
.pick-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 12px;
  background: rgba(11, 14, 20, 0.86);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--hit);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 138, 76, 0.18);
  font-size: 12px;
  color: var(--text);
  z-index: 35;
  letter-spacing: 0.01em;
  animation: pickHintIn 280ms var(--ease-out) both;
}
@keyframes pickHintIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.pick-hint-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hit);
  box-shadow: 0 0 0 3px var(--hit-soft), 0 0 14px var(--hit);
  animation: pulse 1.5s var(--ease-in-out) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.88); }
}
.pick-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
}
.pick-hint-divider {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
}
.pick-hint-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ===================================================
   CUTS PANEL — faza 'cuts' (wybór elementów tnących)
   =================================================== */

.cuts-panel {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  background: rgba(11, 14, 20, 0.88);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--hit);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 138, 76, 0.18);
  z-index: 34;
  animation: pickHintIn 280ms var(--ease-out) both;
}
.cuts-panel.hidden { display: none; }
.cuts-text {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.3;
}
.cuts-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text);
}
.cuts-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.cuts-meta kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
}
#cuts-count {
  font-family: var(--font-mono);
  color: var(--hit);
  font-weight: 600;
}
.cuts-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 10px;
  background: linear-gradient(180deg, #ffa066 0%, var(--hit) 38%, var(--hit-2) 100%);
  border: 1px solid #d56631;
  color: #1a0a02;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 4px 12px var(--hit-soft);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.cuts-done-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 8px 18px var(--hit-glow);
}
.cuts-done-btn:active { transform: translateY(0); }

/* Odsadzki panel — wariant cuts-panel z dodatkowym inputem */
.odsadzki-panel {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  background: rgba(11, 14, 20, 0.88);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(78, 161, 255, 0.18);
  z-index: 34;
  animation: pickHintIn 280ms var(--ease-out) both;
}
.odsadzki-panel.hidden { display: none; }
.odsadzki-text {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.3;
}
.odsadzki-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text);
}
.odsadzki-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.odsadzki-meta kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
}
#odsadzki-count {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
}
.odsadzki-input {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 6px 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.odsadzki-input:hover { border-color: var(--border-bright); }
.odsadzki-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.odsadzki-input input {
  width: 64px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  outline: none;
}
.odsadzki-input input::-webkit-outer-spin-button,
.odsadzki-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.odsadzki-input span {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
/* Popup edycji wartości offsetu klikniętego segmentu */
.odsadzka-popup {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 8px;
  background: rgba(11, 14, 20, 0.94);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(78, 161, 255, 0.22);
  z-index: 40;
  animation: pickHintIn 200ms var(--ease-out) both;
}
.odsadzka-popup.hidden { display: none; }
.odsadzka-popup-input {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 6px 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
}
.odsadzka-popup-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.odsadzka-popup-input input {
  width: 64px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  outline: none;
}
.odsadzka-popup-input input::-webkit-outer-spin-button,
.odsadzka-popup-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.odsadzka-popup-input span {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.odsadzka-popup button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-line);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.odsadzka-popup button:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--surface-2);
}
.odsadzka-popup button#odsadzka-popup-ok:hover {
  color: var(--success);
  border-color: var(--success);
}
.odsadzka-popup button#odsadzka-popup-clear:hover {
  color: var(--danger);
  border-color: var(--danger);
}
/* ===================================================
   FLOATING PANELS (Stats, Inventory)
   =================================================== */

.float-panel {
  position: absolute;
  z-index: 25;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.float-panel-tr { top: 14px; right: 14px; flex-direction: row-reverse; align-items: flex-start; }
.float-panel-br { bottom: 14px; right: 14px; flex-direction: row-reverse; align-items: flex-end; }
.float-panel-tl { top: 14px; left: 14px; flex-direction: row; align-items: flex-start; }

.float-toggle {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(15, 19, 28, 0.85);
  border: 1px solid var(--border-line);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  box-shadow: var(--shadow-sm), var(--inset-edge);
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.float-toggle:hover {
  color: var(--text-bright);
  border-color: var(--border-bright);
  background: rgba(20, 26, 38, 0.92);
  transform: scale(1.04);
}
.float-toggle:focus-visible { outline: none; box-shadow: var(--ring-accent); }

.float-body {
  pointer-events: auto;
  width: 304px;
  max-height: 64vh;
  overflow-y: auto;
  background: rgba(17, 21, 30, 0.88);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow-lg), var(--inset-edge);
  transform-origin: top right;
  animation: floatIn 200ms var(--ease-out);
}
.float-panel-br .float-body { transform-origin: bottom right; }
.float-panel-tl .float-body { transform-origin: top left; }
@keyframes floatIn {
  from { opacity: 0; transform: scale(0.96) translateY(-6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.float-panel.collapsed .float-body { display: none; }

.float-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--border-line);
}
.float-head h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text);
}
.float-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.float-hint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  line-height: 1.5;
}

/* Stat grid */
.stat-grid {
  margin: 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 14px;
}
.stat-grid dt {
  font-size: 11px;
  color: var(--text-muted);
}
.stat-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.stat-grid dd.accent  { color: var(--accent); font-size: 13px; }
.stat-grid dd.success { color: var(--success); font-size: 13px; }
.stat-grid dd.warning { color: var(--warning); }
.stat-grid dd.muted   { color: var(--text-faint); font-style: italic; font-weight: 400; }

.float-divider {
  height: 1px;
  background: var(--border-line);
  margin: 0 14px;
}

/* Inventory table inside floating panel */
.inventory-table {
  font-size: 11.5px;
}
.inventory-table thead th {
  background: rgba(22, 28, 40, 0.7);
}
.inventory-table td.count {
  text-align: right;
  font-weight: 600;
  color: var(--text-bright);
}
.inventory-table .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 7px;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* ===================================================
   REFINE PANEL  (Pick → Eksport)
   =================================================== */

.refine-panel .float-body {
  width: 296px;
}
.refine-body {
  padding: 12px 14px 14px;
}
.refine-hint {
  margin: 0 0 13px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.refine-cycle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.refine-cats {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.refine-cats li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--border-line);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.refine-cats li.is-empty {
  opacity: 0.45;
}
.refine-cats li:not(.is-empty) {
  border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 35%, var(--border-line));
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 6%, transparent);
}
.refine-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat-color, var(--accent));
  box-shadow: 0 0 6px color-mix(in srgb, var(--cat-color, var(--accent)) 45%, transparent);
}
.refine-cat-label {
  font-size: 11.5px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.refine-cat-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-bright);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.refine-actions {
  display: flex;
  gap: 8px;
}
.refine-actions .btn {
  flex: 1;
  justify-content: center;
  padding: 8px 10px;
  font-size: 11.5px;
}
.refine-btn-export svg {
  margin-right: 2px;
}

/* ===================================================
   MODAL
   =================================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.62);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  display: grid;
  place-items: center;
  z-index: 200;
  animation: modalOverlay 200ms var(--ease-out);
}
.modal.hidden { display: none; }
@keyframes modalOverlay { from { opacity: 0; } to { opacity: 1; } }

.modal-shell {
  width: min(740px, calc(100vw - 40px));
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalShell 260ms var(--ease-out);
}
@keyframes modalShell {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border-line);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  position: relative;
}
.modal-head::after {
  content: '';
  position: absolute;
  inset: auto 24px -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hit) 30%, var(--hit) 70%, transparent);
  opacity: 0.6;
}
.modal-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hit);
}
.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-bright);
}
.modal-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Section selector w header modal — przypisanie systemu do sekcji projektu */
.modal-head-section {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  align-self: center;
  margin-right: 12px;
  margin-left: auto;
}
.modal-head-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal-head-section-input {
  display: inline-flex;
  align-items: center;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.modal-head-section-input:hover { border-color: var(--border-bright); }
.modal-head-section-input:focus-within {
  border-color: var(--hit);
  box-shadow: 0 0 0 3px var(--hit-soft);
}
.modal-head-section-input select {
  appearance: none;
  -webkit-appearance: none;
  width: 170px;
  height: 30px;
  padding: 0 28px 0 10px;
  border: 0;
  background: transparent;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 14px, calc(100% - 9px) 14px;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  outline: none;
  cursor: pointer;
}
.modal-head-section-input select option {
  background: var(--bg-elevated);
  color: var(--text);
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--surface-2);
}

#styro-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px 24px;
  overflow-y: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 660px) {
  .modal-grid { grid-template-columns: 1fr; }
}

.field-group {
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--inset-edge);
}
.field-group legend {
  padding: 0 7px;
  margin-left: -7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-label {
  font-size: 12px;
  color: var(--text-muted);
}
.field-input {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field-input:hover { border-color: var(--border-bright); }
.field-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input input,
.field-input select {
  width: 110px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}
.field-input-select select { width: 188px; text-align: left; }
.field-input input:focus,
.field-input select:focus { outline: none; }
.field-input select option {
  background: var(--surface-2);
  color: var(--text);
}
.field-check .field-input {
  background: transparent;
  border: 0;
  padding: 0 4px;
}
.field-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.field.is-disabled .field-label,
.field.is-disabled .field-suffix {
  opacity: 0.4;
}
.field.is-disabled .field-input {
  opacity: 0.5;
  pointer-events: none;
}
.field.is-disabled .field-input input {
  cursor: not-allowed;
}
.field-input input::-webkit-outer-spin-button,
.field-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-input input[type="number"] { -moz-appearance: textfield; }
.field-suffix {
  padding-right: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* Status line */
.status-line {
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.status-line.has-face {
  border-color: var(--hit);
  background: var(--hit-soft);
  color: var(--hit);
}

/* Buttons */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.actions-spacer { flex: 1; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn svg { opacity: 0.9; }
.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-bright);
}
.btn:focus-visible { outline: none; box-shadow: var(--ring-accent); }
.btn:disabled { opacity: 0.32; cursor: not-allowed; }

.btn-secondary {
  color: var(--text-muted);
}
.btn-secondary:hover:not(:disabled) {
  color: var(--text);
}

.btn-pick {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.btn-pick:hover:not(:disabled) {
  background: rgba(78, 161, 255, 0.24);
  color: var(--text-bright);
}

.btn-primary {
  background: linear-gradient(180deg, #ffa066 0%, var(--hit) 38%, var(--hit-2) 100%);
  border-color: #d56631;
  color: #1a0a02;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 6px 18px var(--hit-soft);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20),
    0 10px 26px var(--hit-glow);
}
.btn-primary:disabled {
  background: var(--surface);
  border-color: var(--border-line);
  color: var(--text-faint);
  box-shadow: none;
}

.btn-danger-ghost {
  background: transparent;
  border-color: var(--border-line);
  color: var(--text-faint);
}
.btn-danger-ghost:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* Iteration results */
.iter-results {
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: iterIn 220ms var(--ease-out);
}
@keyframes iterIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.iter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border-line);
  background: var(--bg-elevated);
}
.iter-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text);
}
.iter-progress {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.iter-table-wrap {
  max-height: 280px;
  overflow-y: auto;
}
.iter-table th, .iter-table td { padding: 6px 12px; font-size: 11.5px; }

/* ===================================================
   SCROLLBARS
   =================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-line);
  border-radius: 5px;
  border: 2px solid var(--bg-elevated);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-color: var(--border-line) transparent; scrollbar-width: thin; }

/* ===================================================
   Misc helpers
   =================================================== */

/* Hide deprecated systems-toggle button (replaced by dock tabs) */
#systems-toggle { display: none !important; }

/* Visually hidden but focusable */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Selection in viewport text */
::selection { background: var(--accent-soft); color: var(--text-bright); }

/* Load progress bar — CSS animation runs independently of main thread */
.load-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--surface);
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
}
.load-progress.hidden { display: none; }
.load-progress::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--hit) 30%,
    #ffd1a8 50%,
    var(--hit) 70%,
    transparent 100%);
  box-shadow: 0 0 12px var(--hit-glow);
  animation: loadSlide 1.3s var(--ease-in-out) infinite;
}
@keyframes loadSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(286%); }
}

/* ---------- Layer visibility toggles (W1/W2/W3) ----------
   Krawędzie warstw mają w app.js zdefiniowane tinty (złoty/niebieski/zielony).
   Te same kolory pokazujemy w toggle-button dot żeby było jasne co odpowiada czemu. */
.layer-toggles {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--border-line);
}
.layer-toggle {
  padding: 6px 9px;
  min-height: 30px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.layer-toggle .layer-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 4px;
  vertical-align: -1px;
  transition: opacity 0.15s var(--ease-out, ease-out);
}
.layer-toggle-1 .layer-dot { background: #c4ad6b; box-shadow: 0 0 6px rgba(196, 173, 107, 0.5); }
.layer-toggle-2 .layer-dot { background: #6f7cb5; box-shadow: 0 0 6px rgba(111, 124, 181, 0.5); }
.layer-toggle-3 .layer-dot { background: #6fb585; box-shadow: 0 0 6px rgba(111, 181, 133, 0.5); }
.layer-toggle-4 .layer-dot { background: #b56f9a; box-shadow: 0 0 6px rgba(181, 111, 154, 0.5); }
.layer-toggle-5 .layer-dot { background: #b58a6f; box-shadow: 0 0 6px rgba(181, 138, 111, 0.5); }
.layer-toggle-6 .layer-dot { background: #6fb5b1; box-shadow: 0 0 6px rgba(111, 181, 177, 0.5); }
.layer-toggle-7 .layer-dot { background: #9ab56f; box-shadow: 0 0 6px rgba(154, 181, 111, 0.5); }
.layer-toggle-8 .layer-dot { background: #8a6fb5; box-shadow: 0 0 6px rgba(138, 111, 181, 0.5); }
.layer-toggle[aria-pressed="false"] {
  opacity: 0.45;
  background: transparent;
}
.layer-toggle[aria-pressed="false"] .layer-dot {
  opacity: 0.3;
  box-shadow: none;
}

/* ===================================================
   RESPONSIVE — Progressive toolbar density
   Industrial CAD-style compaction: shed verbose labels
   first, keep core CTAs accessible to the last pixel.
   =================================================== */

/* Tier 1 — drop technical kbd hints + brand tagline */
@media (max-width: 1620px) {
  .toolbar { gap: 6px; padding: 0 10px 0 12px; }
  .brand { padding-right: 12px; margin-right: 4px; gap: 9px; }
  .brand-tag { display: none; }
  .tool-cluster { padding: 2px; }
  .tool-btn { padding: 0 9px; gap: 6px; }
  .kbd-hint:not(.kbd-on-primary) { display: none; }
}

/* Tier 2 — icon-only cluster buttons */
@media (max-width: 1380px) {
  .toolbar { gap: 4px; padding: 0 8px 0 10px; }
  .brand { padding-right: 10px; margin-right: 2px; }
  .tool-cluster .tool-btn > span:not(.water-suffix) { display: none; }
  .tool-cluster .tool-btn { padding: 0 8px; }
  .water-group .tool-btn > span:not(.water-suffix) { display: none; }
  .water-group .tool-btn { padding: 0 8px; }
}

/* Tier 3 — drop water input + secondary CTA label */
@media (max-width: 1120px) {
  .water-input-wrap { display: none; }
  #styro-import-revit .btn-label { display: none; }
  #styro-import-revit { padding: 0 10px; }
}

/* Tier 4 — last-resort: shrink primary CTA to glyph + label only */
@media (max-width: 920px) {
  .brand { padding-right: 8px; margin-right: 0; border-right: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 12px; letter-spacing: 0.18em; }
  .primary-btn .kbd-hint { display: none; }
  .primary-btn { padding: 0 10px 0 8px; gap: 7px; font-size: 12px; }
}

/* Floating panels: prevent body overflow on narrow viewports */
@media (max-width: 760px) {
  .float-body { width: min(304px, calc(100vw - 32px)); }
}
