﻿/* KalkRaskroy App Shell — ported from Antigravity workshop UI */
/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #090c10;
  --surface: #111720;
  --surface2: #161e29;
  --surface3: #1a2333;
  --border: #1e2d3d;
  --border2: #243444;
  --text: #e4eaf4;
  --muted: #7a8a9e;
  --muted2: #4a5a6e;
  --accent: #c9a227;
  --accent-dim: rgba(201,162,39,0.12);
  --accent-hover: #d4b045;
  --success: #2dd4a3;
  --success-dim: rgba(45,212,163,0.12);
  --danger: #e05555;
  --danger-dim: rgba(224,85,85,0.12);
  --warning: #f59e0b;

  --radius-card: 14px;
  --radius-ctrl: 9px;
  --radius-sm: 6px;

  --sidebar-w: 232px;
  --header-h: 52px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  --font: 'Manrope', system-ui, sans-serif;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  --shadow-card: 0 2px 16px rgba(0,0,0,0.4);
  --shadow-float: 0 8px 32px rgba(0,0,0,0.6);
  --transition: 0.18s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  font-weight: var(--fw-normal);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }
a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }
ul { list-style: none; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}

.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.app-header .logo-mark { display: flex; align-items: center; gap: var(--sp-3); width: auto; height: auto; }
.logo-grid { display: grid; grid-template-columns: repeat(3, 7px); grid-template-rows: repeat(3, 7px); gap: 2px; }
.logo-grid span { background: var(--muted2); border-radius: 1.5px; }
.logo-grid span:nth-child(5) { background: var(--accent); }
.app-header .logo-text,
.sidebar .logo-text { font-size: 15px; font-weight: var(--fw-bold); color: var(--text); letter-spacing: -0.3px; }
.app-header .logo-text em,
.sidebar .logo-text em { color: var(--accent); font-style: normal; }

.header-right { display: flex; align-items: center; gap: var(--sp-4); }
.header-link {
  font-size: 12px; font-weight: var(--fw-medium); color: var(--muted);
  padding: 5px var(--sp-3); border-radius: var(--radius-sm); transition: var(--transition);
}
.header-link:hover { color: var(--text); background: var(--surface2); }

/* SIDEBAR */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; z-index: 5;
}
.sidebar-user {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.user-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1e3a5f, #0f2137);
  border: 1px solid var(--border2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: var(--fw-bold); color: var(--accent); flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: var(--fw-semibold); line-height: 1.6; white-space: nowrap;
}
.badge-free { background: var(--surface3); color: var(--muted); border: 1px solid var(--border2); }
.badge-standard { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(201,162,39,0.3); }
.badge-pro { background: var(--success-dim); color: var(--success); border: 1px solid rgba(45,212,163,0.3); }

/* SIDEBAR NAV */
.sidebar-nav {
  flex: 1; padding: var(--sp-2) var(--sp-2); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-section-label {
  font-size: 10px; font-weight: var(--fw-semibold); color: var(--muted2);
  letter-spacing: 0.8px; text-transform: uppercase; padding: var(--sp-3) var(--sp-2) var(--sp-1);
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3); border-radius: var(--radius-ctrl);
  font-size: 13px; font-weight: var(--fw-medium); color: var(--muted);
  transition: var(--transition); cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .nav-icon { color: var(--muted2); transition: var(--transition); }
.nav-item:hover .nav-icon { color: var(--muted); }
.nav-item .nav-badge { margin-left: auto; }

.sidebar-bottom {
  padding: var(--sp-2) var(--sp-2) var(--sp-3); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item-danger { color: var(--danger); }
.nav-item-danger:hover { background: var(--danger-dim); color: var(--danger); }

/* MAIN CONTENT */
.main-content { overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.screen { display: none; flex: 1; overflow: hidden; flex-direction: column; height: 100%; }
.screen.active { display: flex; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 7px var(--sp-4); border-radius: var(--radius-ctrl);
  font-family: var(--font); font-size: 13px; font-weight: var(--fw-semibold);
  transition: var(--transition); cursor: pointer; border: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #0a0800; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(201,162,39,0.3); }
.btn-primary:active { transform: none; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-success { background: var(--success); color: #001a13; }
.btn-success:hover { background: #38e6b5; }
.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(224,85,85,0.2); }
.btn-danger:hover { background: rgba(224,85,85,0.2); }
.btn-sm { padding: 5px var(--sp-3); font-size: 12px; }
.btn-xs { padding: 3px var(--sp-2); font-size: 11px; border-radius: var(--radius-sm); }
.btn-icon { padding: 7px; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-ctrl); }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-dropdown {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px var(--sp-3); background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius-ctrl);
  font-family: var(--font); font-size: 13px; font-weight: var(--fw-medium); cursor: pointer;
}
.btn-dropdown:hover { background: var(--surface3); color: var(--text); }

/* ============================================================
   CALC TOOLBAR
   ============================================================ */
.calc-toolbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
  position: sticky; top: 0; z-index: 8;
}
.project-selector {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-3); background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-ctrl); cursor: pointer; transition: var(--transition); min-width: 180px;
}
.project-selector:hover { border-color: var(--border2); }
.project-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.project-name { font-size: 13px; font-weight: var(--fw-semibold); color: var(--text); flex: 1; }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.toolbar-spacer { flex: 1; }

/* ============================================================
   CALC BODY
   ============================================================ */
.calc-body { display: grid; grid-template-columns: 40% 60%; flex: 1; overflow: hidden; min-height: 0; }

/* LEFT */
.calc-left { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.calc-left-inner { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; }

/* Segmented */
.seg-control {
  display: flex; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-ctrl); padding: 3px; gap: 2px;
}
.preset-row { flex-wrap: wrap; }
.preset-row .seg-btn { flex: 1 1 calc(33.33% - 4px); min-width: 52px; padding: 6px 2px; font-size: 11px; }
.seg-control--full { width: 100%; }
.seg-btn {
  flex: 1; padding: 6px 4px; border-radius: 7px; font-size: 12px; font-weight: var(--fw-semibold);
  color: var(--muted); background: none; transition: var(--transition); text-align: center;
  cursor: pointer; border: none; font-family: var(--font);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }

/* Fields */
.field-label {
  font-size: 11px; font-weight: var(--fw-semibold); color: var(--muted);
  letter-spacing: 0.4px; margin-bottom: var(--sp-1); text-transform: uppercase;
}
.field-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-ctrl); padding: 9px var(--sp-3); color: var(--text);
  font-size: 13px; font-family: var(--font); outline: none; transition: var(--transition);
}
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.field-input::placeholder { color: var(--muted2); }
.combobox-wrap { position: relative; }
.combobox-wrap::after {
  content: ''; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--muted2); pointer-events: none;
}

/* Inset Group */
.inset-group { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.inset-group-header { display: flex; align-items: center; justify-content: space-between; padding: 8px var(--sp-3); border-bottom: 1px solid var(--border); }
.inset-group-title { font-size: 12px; font-weight: var(--fw-semibold); color: var(--text); letter-spacing: 0.2px; }
.inset-row { display: flex; align-items: center; padding: 7px var(--sp-3); border-bottom: 1px solid var(--border); gap: var(--sp-2); }
.inset-row:last-child { border-bottom: none; }
.inset-row-label { font-size: 13px; color: var(--text); flex: 1; min-width: 0; }
.inset-row--stack { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
.inset-row--stack .inset-row-label { flex: none; }

/* Num Input */
.num-input { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.num-input--wide { flex: 0 0 58%; max-width: 220px; min-width: 156px; margin-left: auto; }
.num-input input {
  flex: 1; min-width: 0; width: auto; background: none; border: none; color: var(--text);
  font-size: 13px; font-family: var(--font); font-weight: var(--fw-semibold); text-align: center;
  padding: 5px 4px; outline: none;
}
.num-input input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.num-input input[type=number]::-webkit-outer-spin-button,
.num-input input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: none;
}
.num-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface2); cursor: pointer; font-size: 15px; font-weight: var(--fw-semibold); line-height: 1; transition: var(--transition); border: none; font-family: var(--font); flex-shrink: 0; }
.num-btn:hover { background: var(--border); color: var(--text); }
.num-unit { font-size: 11px; color: var(--muted); padding: 0 10px 0 4px; background: var(--surface); flex-shrink: 0; }
.layout-settings-inline .stock-pick-list { width: 100%; }
.warehouse-panel {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.warehouse-callout {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface);
}
.warehouse-callout-title {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin: 0 0 6px;
}
.warehouse-callout-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.warehouse-callout-text strong { color: var(--accent); font-weight: var(--fw-semibold); }
.warehouse-callout--empty { border-style: dashed; background: transparent; }
.warehouse-panel .stock-pick-list { margin: 0; max-height: none; }
.warehouse-list-hint {
  margin: 0 0 var(--sp-1);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.inset-row--stack .seg-control--full .seg-btn { padding: 8px 6px; }

/* Switch */
.switch { position: relative; width: 36px; height: 21px; cursor: pointer; flex-shrink: 0; }
.switch input { display: none; }
.switch-track { position: absolute; inset: 0; background: var(--surface3); border: 1px solid var(--border2); border-radius: 999px; transition: var(--transition); }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; background: var(--muted); border-radius: 50%; transition: 0.2s cubic-bezier(0.34,1.56,0.64,1); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }

/* Details Table */
.details-section { display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; min-height: 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0; }
.section-title { font-size: 12px; font-weight: var(--fw-semibold); color: var(--text); letter-spacing: 0.2px; }
.details-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.details-table th { font-size: 10px; font-weight: var(--fw-semibold); color: var(--muted2); text-transform: uppercase; letter-spacing: 0.6px; padding: 4px var(--sp-2); text-align: left; border-bottom: 1px solid var(--border); }
.details-table th.th-num { text-align: center; }
.details-table td { padding: 2px var(--sp-1); border-bottom: 1px solid rgba(30,45,61,0.6); vertical-align: middle; }
.details-table tr:last-child td { border-bottom: none; }
.details-table tbody tr:hover td { background: rgba(22,30,41,0.6); }
/* скрыть нативные спиннеры у number-инпутов во всех браузерах */
.details-table input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.details-table input[type=number]::-webkit-outer-spin-button,
.details-table input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: none;
}
.td-input { width: 100%; background: none; border: none; color: var(--text); font-size: 13px; font-family: var(--font); padding: 4px 6px; border-radius: 5px; outline: none; transition: var(--transition); }
.td-input:focus { background: var(--surface2); box-shadow: 0 0 0 2px var(--accent-dim); }
.td-input-num { text-align: center; font-weight: var(--fw-semibold); }
.td-name { width: auto; }
.td-num { width: 72px; text-align: center; }
.td-qty { width: 52px; text-align: center; }
.td-edge { width: 56px; }
.td-del { width: 32px; text-align: center; }
.del-btn { width: 22px; height: 22px; border-radius: 5px; color: var(--muted2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); background: none; border: none; }
.del-btn:hover { background: var(--danger-dim); color: var(--danger); }
.badge-locked { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: var(--fw-semibold); padding: 1px 5px; border-radius: 4px; background: var(--accent-dim); color: var(--accent); opacity: 0.8; }
.add-row-btn { display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: 8px var(--sp-3); background: transparent; border: 1px dashed var(--border2); border-radius: var(--radius-ctrl); color: var(--muted); font-size: 12px; font-weight: var(--fw-medium); cursor: pointer; transition: var(--transition); font-family: var(--font); }
.add-row-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.calc-sticky { padding: var(--sp-3) var(--sp-5); background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }

/* RIGHT */
.calc-right { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4); padding: var(--sp-8); text-align: center; }
.empty-icon { width: 80px; height: 80px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.empty-title { font-size: 16px; font-weight: var(--fw-semibold); color: var(--text); }
.empty-desc { font-size: 13px; color: var(--muted); max-width: 280px; line-height: 1.5; margin-top: 6px; }

.calc-result { display: none; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.calc-result.visible { display: flex; }
.calc-result.result-panel {
  margin-top: 0;
  padding-bottom: 0;
  scroll-margin-top: 0;
}
.calc-workshop .stats-row {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.calc-workshop .layout-canvas {
  max-width: none;
  height: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
}

.stats-row { display: flex; gap: var(--sp-2); padding: 8px var(--sp-4); border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-ctrl); padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 72px; flex: 1; }
.stat-label { font-size: 10px; font-weight: var(--fw-semibold); color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 16px; font-weight: var(--fw-bold); color: var(--text); line-height: 1; }
.stat-val.accent { color: var(--accent); }
.stat-val.success { color: var(--success); }
.stat-val.danger { color: var(--danger); }
.stat-unit { font-size: 11px; font-weight: var(--fw-normal); color: var(--muted); }

.canvas-area { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 8px var(--sp-4); gap: var(--sp-2); min-height: 0; }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.sheet-nav { display: flex; align-items: center; gap: var(--sp-2); }
.sheet-nav-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); font-size: 13px; }
.sheet-nav-btn:hover { background: var(--surface2); color: var(--text); }
.sheet-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.sheet-counter { font-size: 12px; font-weight: var(--fw-semibold); color: var(--text); min-width: 40px; text-align: center; }
.label-chips { display: flex; gap: var(--sp-1); }
.chip { padding: 4px var(--sp-2); border-radius: 6px; font-size: 11px; font-weight: var(--fw-medium); color: var(--muted); background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: var(--transition); }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(201,162,39,0.3); }
.cutting-canvas { flex: 1; position: relative; overflow: hidden; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--border); min-height: 0; }
.cutting-canvas svg { width: 100%; height: 100%; }

/* ============================================================
   SCREEN HEADERS & BODIES
   ============================================================ */
.screen-header { padding: var(--sp-6) var(--sp-8) var(--sp-5); border-bottom: 1px solid var(--border); flex-shrink: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); }
.screen-title { font-size: 22px; font-weight: var(--fw-bold); color: var(--text); letter-spacing: -0.3px; }
.screen-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.screen-body { flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-8); }

/* Data Table */
.data-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: var(--sp-3) var(--sp-4); font-size: 11px; font-weight: var(--fw-semibold); color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; text-align: left; background: var(--surface2); border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px var(--sp-4); font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover td { background: rgba(22,30,41,0.5); }
.td-muted { color: var(--muted); }
.td-mono { font-size: 12px; font-weight: 600; color: var(--text); }
.qr-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--border); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); }
.qr-btn:hover { color: var(--text); border-color: var(--border2); }

/* Projects */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; transition: var(--transition); cursor: pointer; }
.project-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.project-card-preview { height: 120px; background: var(--surface2); border-bottom: 1px solid var(--border); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.project-card-body { padding: var(--sp-4); }
.project-card-title { font-size: 14px; font-weight: var(--fw-semibold); color: var(--text); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: var(--sp-3); }
.project-card-footer { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* Orders */
.orders-grid { display: grid; grid-template-columns: 380px 1fr; gap: var(--sp-5); }
.profile-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.form-row { display: flex; flex-direction: column; gap: var(--sp-1); }
.form-row-half { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.orders-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.order-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-4); display: flex; gap: var(--sp-4); align-items: flex-start; transition: var(--transition); }
.order-card:hover { border-color: var(--border2); }
.order-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #1a3050, #0e1f33); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: var(--fw-bold); color: var(--accent); flex-shrink: 0; }
.order-body { flex: 1; }
.order-name { font-size: 14px; font-weight: var(--fw-semibold); color: var(--text); }
.order-phone { font-size: 12px; color: var(--muted); margin-top: 2px; }
.order-desc { font-size: 12px; color: var(--muted); margin-top: var(--sp-2); }
.order-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
.order-status { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: var(--fw-semibold); }
.status-new { background: var(--accent-dim); color: var(--accent); }
.status-read { background: var(--surface2); color: var(--muted); }
.status-closed { background: var(--success-dim); color: var(--success); }

/* Account */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.account-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-5); }
.account-card-title { font-size: 14px; font-weight: var(--fw-semibold); color: var(--text); margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.tariff-card { grid-column: 1 / -1; background: linear-gradient(135deg, #111720 0%, #141d2b 100%); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-5); position: relative; overflow: hidden; }
.tariff-card::before { content: ''; position: absolute; top: -40px; right: -40px; width: 160px; height: 160px; background: radial-gradient(circle, rgba(201,162,39,0.06) 0%, transparent 70%); border-radius: 50%; }
.tariff-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--sp-4); }
.tariff-name { font-size: 20px; font-weight: var(--fw-extrabold); color: var(--text); }
.tariff-period { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tariff-features { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.tariff-feature { display: flex; align-items: center; gap: var(--sp-2); font-size: 13px; color: var(--muted); }
.tariff-feature.enabled { color: var(--text); }
.tariff-feature .check { color: var(--success); }

/* ============================================================
   DRAWER
   ============================================================ */
.drawer-overlay { position: fixed; inset: 0; background: rgba(9,12,16,0.7); z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer { position: fixed; top: 0; right: 0; width: 360px; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); z-index: 101; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); box-shadow: var(--shadow-float); }
.drawer.open { transform: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-title { font-size: 15px; font-weight: var(--fw-semibold); color: var(--text); }
.drawer-close { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--border); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); font-size: 16px; }
.drawer-close:hover { color: var(--text); background: var(--surface3); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-5); }
.drawer-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.drawer-section-title { font-size: 11px; font-weight: var(--fw-semibold); color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }

/* ============================================================
   TOAST & MODAL
   ============================================================ */
.toast-container { position: fixed; bottom: var(--sp-6); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; }
.toast { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-card); box-shadow: var(--shadow-float); font-size: 13px; font-weight: var(--fw-medium); color: var(--text); white-space: nowrap; animation: toastIn 0.3s ease forwards; }
.toast.success { border-color: rgba(45,212,163,0.3); }
.toast.error { border-color: rgba(224,85,85,0.3); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-overlay { position: fixed; inset: 0; background: rgba(9,12,16,0.8); z-index: 150; display: flex; align-items: center; justify-content: center; padding: var(--sp-6); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); width: 100%; max-width: 480px; box-shadow: var(--shadow-float); transform: scale(0.96); transition: transform 0.2s; }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: var(--sp-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: var(--fw-bold); color: var(--text); }
.modal-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* Utilities */
.divider { height: 1px; background: var(--border); margin: var(--sp-1) 0; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.process-hint {
  margin: 0 12px 10px;
  line-height: 1.45;
}
.font-semibold { font-weight: var(--fw-semibold); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.mt-2 { margin-top: var(--sp-2); }
.w-full { width: 100%; }
.locked-field { opacity: 0.45; pointer-events: none; }

/* ============================================================
   MOBILE BOTTOM TABBAR
   ============================================================ */
.mobile-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; height: 58px;
  background: var(--surface); border-top: 1px solid var(--border);
  z-index: 50; flex-shrink: 0;
}
.mobile-tabbar-inner {
  display: flex; height: 100%; align-items: stretch;
}
.mobile-tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; background: none; border: none;
  color: var(--muted); font-family: var(--font); font-size: 10px;
  font-weight: var(--fw-semibold); cursor: pointer; transition: var(--transition);
  padding: 0; position: relative;
}
.mobile-tab-btn.active { color: var(--accent); }
.mobile-tab-btn .mtb-badge {
  position: absolute; top: 6px; right: calc(50% - 14px);
  width: 14px; height: 14px; background: var(--accent);
  border-radius: 50%; font-size: 8px; font-weight: 700; color: #000;
  display: flex; align-items: center; justify-content: center;
}
.mobile-calc-tabs {
  display: none; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mobile-calc-tab {
  flex: 1; padding: 11px; text-align: center; font-size: 13px;
  font-weight: var(--fw-semibold); color: var(--muted);
  border-bottom: 2px solid transparent; transition: var(--transition);
  background: none; border-left: none; border-right: none; border-top: none;
  font-family: var(--font); cursor: pointer;
}
.mobile-calc-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================================================
   EDGE PICKER (кромкование)
   ============================================================ */
.edge-cell-btn {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 3px; padding: 4px 2px; background: none; border: none;
  color: var(--muted2); font-size: 11px; font-family: var(--font);
  cursor: pointer; border-radius: 5px; transition: var(--transition);
  font-weight: var(--fw-medium);
}
.edge-cell-btn:hover { background: var(--surface3); color: var(--text); }
.edge-cell-btn.has-edge { color: var(--accent); }
.edge-cell-preview {
  display: inline-grid; grid-template-columns: 6px 6px 6px;
  grid-template-rows: 6px 6px 6px; gap: 0; flex-shrink: 0;
}
.edge-cell-preview span {
  background: var(--border2); border-radius: 0;
}
.edge-cell-preview .ep-top    { grid-column: 1/4; grid-row: 1; height: 2px; background: var(--border2); border-radius: 1px; }
.edge-cell-preview .ep-bot    { grid-column: 1/4; grid-row: 3; height: 2px; background: var(--border2); border-radius: 1px; }
.edge-cell-preview .ep-left   { grid-column: 1;   grid-row: 2; width: 2px; background: var(--border2); border-radius: 1px; }
.edge-cell-preview .ep-right  { grid-column: 3;   grid-row: 2; width: 2px; background: var(--border2); border-radius: 1px; }
.edge-cell-preview .ep-center { grid-column: 2;   grid-row: 2; }

.ep-active { background: var(--accent) !important; }

.edge-popup {
  position: fixed; z-index: 300;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-card); padding: 12px; width: 200px;
  box-shadow: var(--shadow-float); display: none;
}
.edge-popup.open { display: block; }
.edge-popup-title {
  font-size: 11px; font-weight: var(--fw-bold); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.edge-popup-layout {
  display: grid; grid-template-columns: 1fr 80px 1fr;
  grid-template-rows: auto auto auto; gap: 4px; align-items: center;
}
.edge-side-btn {
  padding: 5px 6px; border-radius: 6px; font-size: 11px; font-weight: var(--fw-semibold);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; text-align: center;
  transition: var(--transition); font-family: var(--font);
}
.edge-side-btn:hover { border-color: var(--accent); color: var(--accent); }
.edge-side-btn.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(201,162,39,0.4); }
.edge-popup-center {
  grid-column: 2; grid-row: 2; height: 44px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted); font-weight: 600;
}
.edge-options { display: flex; gap: 4px; margin-top: 10px; }
.edge-opt-btn {
  flex: 1; padding: 5px 4px; border-radius: 6px; font-size: 11px;
  font-weight: var(--fw-semibold); background: var(--surface2);
  border: 1px solid var(--border); color: var(--muted); cursor: pointer;
  transition: var(--transition); text-align: center; font-family: var(--font);
}
.edge-opt-btn:hover { color: var(--text); }
.edge-opt-btn.selected { background: var(--accent-dim); color: var(--accent); border-color: rgba(201,162,39,0.4); }
.edge-popup-close {
  width: 100%; margin-top: 8px; padding: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted); font-size: 12px;
  font-family: var(--font); cursor: pointer; transition: var(--transition);
}
.edge-popup-close:hover { color: var(--text); }

/* ============================================================
   EXPORT DROPDOWN MENU
   ============================================================ */
.export-menu-wrap { position: relative; }
.export-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 100;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-card); overflow: hidden; min-width: 180px;
  box-shadow: var(--shadow-float); display: none;
}
.export-menu.open { display: block; }
.export-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  font-size: 13px; font-weight: var(--fw-medium); color: var(--text);
  cursor: pointer; transition: var(--transition); border: none;
  background: none; width: 100%; font-family: var(--font); text-align: left;
}
.export-menu-item:hover { background: var(--surface2); }
.export-menu-item .em-icon { color: var(--muted); flex-shrink: 0; }
.export-menu-item .em-badge { margin-left: auto; }
.export-menu-sep { height: 1px; background: var(--border); margin: 2px 0; }

/* ============================================================
   PRINT / PDF STYLESHEET
   ============================================================ */
@media print {
  @page { margin: 12mm; size: A4 landscape; }
  body { background: #fff !important; color: #111 !important; overflow: visible !important; font-family: 'Manrope', sans-serif; }

  .app-shell { display: block !important; height: auto !important; }
  .app-header, .sidebar, .calc-toolbar, .calc-sticky,
  .mobile-tabbar, .mobile-calc-tabs, .drawer-overlay,
  .drawer, .modal-overlay, .toast-container, .screen:not(.active),
  .empty-state, .add-row-btn, .del-btn, .edge-cell-btn,
  .export-menu-wrap, .btn-icon, button.btn-ghost { display: none !important; }

  .main-content { overflow: visible !important; }
  .screen.active { display: block !important; height: auto !important; }
  #screen-calc { display: block !important; }

  .calc-body { display: block !important; }
  .calc-left, .calc-right { display: block !important; border: none !important; }
  .calc-result { display: block !important; }

  /* Print header */
  .print-header {
    display: flex !important; align-items: center; justify-content: space-between;
    padding-bottom: 8px; border-bottom: 1px solid #ddd; margin-bottom: 12px;
  }
  .print-logo { font-size: 14px; font-weight: 800; color: #111; letter-spacing: -0.3px; }
  .print-meta { font-size: 11px; color: #666; }

  .stats-row {
    display: flex !important; gap: 8px !important; padding: 0 0 12px !important;
    border-bottom: 1px solid #eee !important; margin-bottom: 12px;
  }
  .stat-card {
    background: #f8f8f8 !important; border: 1px solid #ddd !important;
    color: #111 !important; border-radius: 6px !important;
  }
  .stat-label { color: #666 !important; }
  .stat-val { color: #111 !important; }
  .stat-val.accent { color: #8a6a00 !important; }
  .stat-val.success { color: #0a6b47 !important; }
  .stat-val.danger { color: #9a2020 !important; }

  .cutting-canvas {
    border: 1px solid #ddd !important; background: #f5f8ff !important;
    border-radius: 6px !important; height: 380px !important;
    page-break-inside: avoid;
  }
  .cutting-canvas svg rect[fill="#090c10"], .cutting-canvas svg rect[fill="#0d1620"] {
    fill: #f5f8ff !important;
  }

  .details-table { margin-top: 12px; page-break-inside: avoid; }
  .details-table th { background: #f0f0f0 !important; color: #444 !important; border-bottom: 1px solid #ccc !important; }
  .details-table td { color: #111 !important; border-bottom-color: #eee !important; }
  .td-input { color: #111 !important; }
  .badge-locked, .locked-field { display: none !important; }
}
/* print-header hidden on screen */
.print-header { display: none; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (max-width: 768px) {
  body.cabinet-app,
  body.app-tool,
  body.app-embed { overflow: hidden; }
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto auto 1fr;
  }
  .sidebar { display: none !important; }
  .main-content { grid-column: 1; grid-row: 2 / -1; padding-bottom: 58px; }
  .mobile-tabbar { display: flex; }
  .mobile-calc-tabs { display: flex; }

  .calc-body { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .calc-left { display: none; }
  .calc-right { display: none; }
  .calc-left.mob-active { display: flex; }
  .calc-right.mob-active { display: flex; }

  .calc-toolbar {
    padding: 6px var(--sp-3);
    gap: var(--sp-2);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .calc-toolbar::-webkit-scrollbar { display: none; }
  .toolbar-primary,
  .toolbar-result-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .toolbar-spacer { display: none; }
  .project-selector { min-width: 130px; }

  .stats-row { gap: var(--sp-2); padding: 6px var(--sp-3); }
  .stat-card { min-width: 70px; padding: var(--sp-2) var(--sp-3); }
  .stat-val { font-size: 16px; }
  .canvas-area { padding: var(--sp-3) var(--sp-4); }
  .cutting-canvas { min-height: 180px; }
  .calc-left-inner { padding: var(--sp-3) var(--sp-4); }
  .calc-sticky { padding: var(--sp-2) var(--sp-4); }
  .details-table-wrap { max-height: none; }
  .workshop-left-fold-body { max-height: none; }

  /* toast above tabbar */
  .toast-container { bottom: 70px; }
}

/* ============================================================
   WORKSHOP BRIDGE — prod app.js + legacy forms
   ============================================================ */
body.cabinet-app, body.app-tool { overflow: hidden; height: 100dvh; }
body.cabinet-app .cabinet-root, body.cabinet-app .app-shell { height: 100dvh; }
body.app-embed { overflow: hidden; height: 100dvh; }
body.app-embed .app-tool-header { display: none; }
body.app-embed .kr-workshop-main { height: 100dvh; }
body.app-embed .calc-workshop { height: 100%; }
.app-header.app-tool-header {
  height: var(--header-h);
  min-height: var(--header-h);
  flex-shrink: 0;
  padding: 0 var(--sp-4);
}

.kr-workshop-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.calc-workshop { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.btn-calc-toolbar { display: inline-flex; }
@media (max-width: 768px) { .btn-calc-toolbar { display: none; } }
@media (min-width: 769px) { .calc-sticky { display: none; } }

/* PWA install prompt — discreet bottom banner */
.pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 180;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: min(560px, calc(100vw - 24px));
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-float);
  color: var(--text);
}
.pwa-install-banner[hidden] { display: none !important; }
.pwa-install-text {
  margin: 0;
  flex: 1 1 220px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .pwa-install-banner { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}
@media print {
  .pwa-install-banner { display: none !important; }
}

.drawer-open-btn { justify-content: flex-start; gap: var(--sp-3); }
.drawer-open-hint { margin-left: auto; font-size: 11px; color: var(--muted2); }

.seg-btn-radio { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.seg-btn-radio input { display: none; }

.details-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  overflow: auto;
  background: var(--surface2);
  max-height: min(420px, 48vh);
  flex: 1 1 auto;
  min-height: 148px;
}

/* Cutting regime: guillotine vs CNC / laser */
.cut-type-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 8px;
}
.cut-type-label {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--muted2);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.cut-type-seg .seg-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  font-size: 12px;
  text-align: center;
}

/* Compact always-visible sheet + kerf strip */
.sheet-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 3;
}
.sheet-strip-field {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.sheet-strip-field--kerf { margin-left: auto; }
.sheet-strip-label {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.sheet-strip-input {
  width: 64px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  font-family: var(--font);
  text-align: center;
  padding: 6px 4px;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.sheet-strip-input--kerf { width: 48px; }
.sheet-strip-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.sheet-strip-input[type=number]::-webkit-outer-spin-button,
.sheet-strip-input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: none;
}
.sheet-strip-sep {
  color: var(--muted2);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
}
.sheet-strip-unit {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.sheet-strip-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

.workshop-left-fold {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  background: var(--surface2);
  overflow: hidden;
  flex-shrink: 0;
}
.workshop-left-fold-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.workshop-left-fold-summary::-webkit-details-marker { display: none; }
.workshop-left-fold-summary::before {
  content: '▸';
  color: var(--muted);
  transition: transform 0.15s ease;
}
.workshop-left-fold[open] > .workshop-left-fold-summary::before { transform: rotate(90deg); }
.workshop-left-fold-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: 0 var(--sp-2) var(--sp-2);
  max-height: min(220px, 28vh);
  overflow-y: auto;
}
.workshop-left-fold-body .inset-group { border-radius: var(--radius-sm); }
.workshop-left-fold .process-hint { margin: 6px 10px 8px; }

.parts-section-header {
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}
.parts-section-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.parts-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
}
.parts-chip {
  padding: 5px 8px;
  min-height: 28px;
  font-size: 11px;
  line-height: 1.2;
}
.parts-chip.active {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(45, 212, 163, 0.35);
}
.parts-quick-add {
  display: flex;
  gap: 6px;
  align-items: stretch;
  flex-shrink: 0;
}
.parts-quick-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 12px;
}
.parts-quick-btn {
  flex: 0 0 36px;
  min-width: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: var(--fw-semibold);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  background: var(--surface2);
  color: var(--text);
}
.parts-quick-btn:hover { background: var(--surface3); color: var(--accent); }
.parts-paste-hint {
  margin: 0;
  line-height: 1.4;
}
.details-section.fast-entry .th-label,
.details-section.fast-entry .part-label,
.details-section.fast-entry td:first-child {
  display: none;
}
.details-section.fast-entry .details-table {
  table-layout: fixed;
}
.details-section.fast-entry .th-num,
.details-section.fast-entry td:nth-child(2),
.details-section.fast-entry td:nth-child(3) {
  width: 28%;
}
.details-section.fast-entry .col-qty { width: 30%; }

.parts-table .form-input, .parts-table .part-label, .parts-table .part-dim, .parts-table .part-qty {
  width: 100%; background: none; border: none; color: var(--text); font-size: 13px;
  padding: 6px 6px; border-radius: 5px; outline: none; min-height: 32px;
}
.parts-table .form-input:focus { background: var(--surface2); box-shadow: 0 0 0 2px var(--accent-dim); }
.parts-table .part-dim, .parts-table .part-qty { text-align: center; font-weight: var(--fw-semibold); }
.parts-table .qty-stepper { display: flex; align-items: center; justify-content: center; gap: 2px; }
.parts-table .qty-btn {
  width: 28px; height: 28px; border-radius: 5px;
  background: var(--surface3); border: 1px solid var(--border); color: var(--muted); font-size: 15px;
}
.parts-table .row-actions { display: flex; gap: 2px; justify-content: center; }
.parts-table .btn-add-row, .parts-table .remove-row {
  width: 28px; height: 28px; border-radius: 5px; color: var(--muted2);
}
.parts-table .remove-row:hover { background: var(--danger-dim); color: var(--danger); }
.details-table th.th-label { width: 34%; }
.details-table th.th-num { width: 16%; }
.details-table th.col-qty { width: 22%; }
.details-table th.col-actions { width: 12%; }
.details-table td { padding: 3px 2px; }

.layout-canvas { width: 100%; height: 100%; display: block; }
.cutting-canvas { position: relative; min-height: 0; }
.cutting-canvas .layout-canvas { position: absolute; inset: 0; }

.workshop-error { margin-top: var(--sp-2); }
.workshop-error.is-info { color: var(--muted, #6b7c90); font-weight: 500; }
.workshop-fold { margin: 0 var(--sp-4); flex-shrink: 0; }
.workshop-fold summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--text);
  padding: 6px 0;
  user-select: none;
}
.workshop-fold summary::-webkit-details-marker { display: none; }
.workshop-fold summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.workshop-fold[open] summary::before { transform: rotate(90deg); }
.workshop-offcuts, .workshop-cuts {
  padding: 4px var(--sp-4) 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.workshop-offcuts[open] .offcuts,
.workshop-cuts[open] .cuts-list {
  max-height: min(220px, 28vh);
  overflow-y: auto;
}
.workshop-offcuts .offcuts, .workshop-cuts .cuts-list { margin-top: var(--sp-1); }
.cuts-list-hint {
  margin: 4px 0 0;
  padding: 0 var(--sp-4);
}
.cuts-list {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  list-style: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  max-height: 220px;
  overflow-y: auto;
}
.cuts-list li {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 2px;
  word-break: break-word;
}
.cuts-list li.muted { color: var(--muted2); }
.cuts-step-head {
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted2);
}
.cuts-step-head:first-child { margin-top: 0; }
.cuts-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}
.cuts-item:hover,
.cuts-item:focus-visible,
.cuts-item.is-cut-active {
  background: rgba(250, 204, 21, 0.12);
  color: var(--text);
}
.cuts-num {
  flex: 0 0 auto;
  min-width: 1.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-bold);
  color: #f87171;
}
.cuts-item.is-cut-active .cuts-num { color: #facc15; }
.cuts-body { flex: 1; min-width: 0; }

.shop-flow-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: rgba(45, 212, 163, 0.08);
}
.shop-flow-banner[hidden] { display: none !important; }
.shop-flow-banner-text {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 160px;
}
.shop-flow-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.toolbar-menu-hint {
  margin: 0;
  padding: 6px 12px 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.toolbar-menu-sep {
  height: 1px;
  margin: 4px 8px;
  background: var(--border);
  border: 0;
}
.offcuts { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.offcuts .chip {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--success-dim);
  border: 1px solid rgba(45,212,163,0.25);
  color: var(--success);
}
.stats-row .stat-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-ctrl);
  padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 72px; flex: 1;
}
.stats-row .stat-item .stat-label { font-size: 10px; font-weight: var(--fw-semibold); color: var(--muted); text-transform: uppercase; }
.stats-row .stat-item strong { font-size: 15px; font-weight: var(--fw-bold); color: var(--text); }
.sheet-toolbar { flex-wrap: wrap; gap: 6px var(--sp-2); }
.sheet-fill { white-space: nowrap; }

.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 400;
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-ctrl);
  max-height: 220px; overflow-y: auto; box-shadow: var(--shadow-float); list-style: none;
  margin: 0; padding: 0.35rem;
}
.combo-list[hidden] { display: none !important; }
.combo-wrap.is-open { z-index: 50; position: relative; }
.combo-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.combo-item:hover, .combo-item.is-active, .combo-item.active { background: var(--accent-dim); color: var(--accent); }

.switch input:checked + .switch-track { background: var(--success); border-color: var(--success); }
.switch input:checked + .switch-track + .switch-thumb,
.switch input:checked ~ .switch-thumb { transform: translateX(15px); background: #fff; }

#leadModal[hidden] { display: none !important; }
#leadModal:not([hidden]) {
  position: fixed; inset: 0; z-index: 150; display: flex !important;
  align-items: center; justify-content: center; padding: var(--sp-6);
  background: rgba(9,12,16,0.8);
}
#leadModal .modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: var(--sp-5); width: 100%; max-width: 480px; box-shadow: var(--shadow-float);
}

body.cabinet-app .cabinet-page--app { padding: 0; }
body.cabinet-app .wrap--dash { max-width: none; padding: 0; }
body.cabinet-app .cabinet-root { height: 100%; }
body.cabinet-app .kp-app-header { display: none; }

#screen-calc.active { display: flex; flex-direction: column; min-height: 0; }
#calcMount { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#calcMount .calc-workshop { height: 100%; }

.warehouse-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-3); align-items: end; }
.warehouse-table { width: 100%; border-collapse: collapse; }
.warehouse-table th, .warehouse-table td { padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
.warehouse-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.project-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.project-item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.lead-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.lead-item { padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.lead-item.is-new { border-color: rgba(201,162,39,0.25); }
.lead-status { font-size: 11px; font-weight: var(--fw-semibold); padding: 2px 8px; border-radius: 20px; background: var(--accent-dim); color: var(--accent); }
.manufacturer-profile-form { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 520px; }
.orders-grid { display: grid; grid-template-columns: 360px 1fr; gap: var(--sp-5); }
@media (max-width: 900px) { .orders-grid { grid-template-columns: 1fr; } }

.badge-material { background: var(--surface3); color: var(--muted); border: 1px solid var(--border2); }
.nav-lock-tag { font-size: 9px; padding: 1px 5px; margin-left: auto; }

/* Landing: embedded workshop */
.page-landing {
  --max: 1200px;
}
.calc-section--landing {
  padding: 1.5rem 0 2.5rem;
}
.calc-landing-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.calc-landing-head-text {
  flex: 1 1 16rem;
  min-width: 0;
}
.calc-landing-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.calc-demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a1400;
  background: var(--accent);
  border: 1px solid rgba(201, 162, 39, 0.45);
  line-height: 1.2;
}
.calc-landing-title {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.calc-landing-demo-note {
  margin: 0;
  max-width: 36rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}
.calc-landing-app-cta {
  flex: 0 0 auto;
  white-space: nowrap;
}
.page-landing .wrap--calc-landing {
  max-width: var(--max);
  padding-inline: 1.5rem;
}
.calc-landing-mount {
  height: min(720px, 78dvh);
  min-height: 520px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
}
.calc-landing-mount--demo {
  position: relative;
  border-style: dashed;
  border-color: rgba(201, 162, 39, 0.35);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.08);
}
.calc-landing-mount--demo::before {
  content: "Демо-режим";
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(9, 12, 16, 0.82);
  border: 1px solid rgba(201, 162, 39, 0.35);
  pointer-events: none;
}
.calc-workshop--landing {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.calc-workshop--landing.calc-workshop {
  flex: none;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.calc-workshop--landing .calc-body {
  grid-template-columns: minmax(280px, 34%) 1fr;
  min-height: 0;
  overflow: hidden;
}
.calc-workshop--landing .calc-left {
  overflow: hidden;
}
.calc-workshop--landing .calc-left-inner {
  padding: var(--sp-3) var(--sp-4);
  gap: var(--sp-3);
  overflow-y: auto;
  max-height: none;
}
.calc-workshop--landing .details-table th {
  font-size: 10px;
  padding: 4px 8px;
  letter-spacing: 0.4px;
}
.calc-workshop--landing .details-table td {
  padding: 2px 6px;
}
.calc-workshop--landing .td-input {
  padding: 4px 6px;
}
.calc-workshop--landing .parts-table .qty-btn,
.calc-workshop--landing .parts-table .btn-add-row,
.calc-workshop--landing .parts-table .remove-row {
  width: 24px;
  height: 24px;
}
.calc-workshop--landing .calc-toolbar {
  padding: 6px var(--sp-3);
  flex-wrap: wrap;
  row-gap: var(--sp-1);
}
.calc-workshop--landing .stats-row {
  padding: 6px var(--sp-3);
  gap: var(--sp-2);
}
.calc-workshop--landing .stat-card,
.calc-workshop--landing .stats-row .stat-item {
  min-width: 68px;
  padding: 5px 8px;
}
.calc-workshop--landing .stat-val,
.calc-workshop--landing .stats-row .stat-item strong {
  font-size: 15px;
}
.calc-workshop--landing .calc-right {
  min-width: 0;
  overflow: hidden;
}
.calc-workshop--landing .calc-result,
.calc-workshop--landing .calc-result.visible {
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.calc-workshop--landing .canvas-area {
  flex: 1;
  min-height: 0;
  padding: 6px var(--sp-3);
  overflow: hidden;
}
.calc-workshop--landing .cutting-canvas {
  min-height: 0;
  height: auto;
  flex: 1;
}
.calc-workshop--landing .sheet-toolbar {
  gap: 6px var(--sp-2);
}
.calc-workshop--landing .view-chips {
  flex-wrap: wrap;
}
.calc-workshop--landing .workshop-fold {
  margin: 0 var(--sp-3);
}
.calc-workshop--landing .workshop-offcuts,
.calc-workshop--landing .workshop-cuts {
  padding: 4px var(--sp-3) 6px;
}
.calc-workshop--landing .cuts-list {
  max-height: 120px;
  overflow-y: auto;
}
body:not(.app-tool):not(.app-embed):not(.cabinet-app) .calc-workshop--landing .drawer-body {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
  touch-action: pan-y;
}
.calc-landing-loading {
  padding: 2rem;
  text-align: center;
}
@media (max-width: 768px) {
  .calc-landing-head {
    align-items: stretch;
  }
  .calc-landing-app-cta {
    width: 100%;
  }
  .calc-landing-mount,
  .calc-workshop--landing {
    height: min(78dvh, 640px);
    min-height: 480px;
  }
  .calc-workshop--landing .calc-body {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .calc-workshop--landing .canvas-area {
    min-height: 0;
  }
  .calc-workshop--landing .cutting-canvas {
    height: auto;
    min-height: 200px;
  }
  .calc-workshop--landing .details-table-wrap {
    max-height: min(220px, 28vh);
  }
  .page-landing .wrap--calc-landing { padding-inline: 1.5rem; }
}

@media (min-width: 769px) and (max-height: 820px) {
  .calc-toolbar { padding: 4px var(--sp-3); }
  .stats-row { padding: 4px var(--sp-3); }
  .canvas-area { padding: 4px var(--sp-3); gap: 4px; }
  .calc-left-inner { padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
  .details-table-wrap { max-height: min(320px, 42vh); min-height: 120px; }
  .workshop-left-fold-body { max-height: min(160px, 22vh); }
  .sheet-strip { padding: 4px 6px; }
  .stat-val,
  .stats-row .stat-item strong { font-size: 14px; }
  .cutting-canvas { min-height: 140px; }
}

/* ============================================================
   Wave A0 — parts-first hybrid shell
   ============================================================ */
.toolbar-primary { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.toolbar-result-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.btn-icon-text {
  min-width: 32px;
  padding-inline: 8px;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.toolbar-menu { position: relative; display: inline-flex; }
.toolbar-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 200px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-ctrl);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toolbar-menu-panel--right { left: auto; right: 0; }
.toolbar-menu-panel[hidden] { display: none !important; }
.toolbar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.toolbar-menu-item:hover,
.toolbar-menu-item:focus-visible {
  background: var(--accent-dim);
  color: var(--accent);
  outline: none;
}
.toolbar-menu-item.is-locked { color: var(--muted); }
.toolbar-menu-item[hidden] { display: none !important; }

.material-simple {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.material-simple-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.material-default-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-ctrl);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.material-simple-hint { margin-left: auto; }

.stats-row--kpi3 { gap: var(--sp-2); }
.stats-row--kpi3 .stat-item { min-width: 88px; flex: 1 1 0; }
.stats-row--kpi3 .stat-item--accent strong { color: var(--accent); }
.stats-more {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 4px 2px 8px;
  font-size: 12px;
  color: var(--muted);
}
.stats-more span strong { color: var(--text); font-weight: var(--fw-semibold); }

.post-calc-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.post-calc-bar[hidden] { display: none !important; }
.post-calc-soon {
  margin-left: 6px;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.85;
}
#compareLayoutsBtn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.tier-tag, .pack-mode-pro-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  vertical-align: middle;
}
.pack-mode-pro-tag[hidden] { display: none !important; }
.seg-btn-radio.pack-mode-tight.is-locked {
  opacity: 0.72;
}
.seg-btn-radio.pack-mode-tight.is-locked .seg-btn-radio > span,
.pack-mode-tight.is-locked {
  cursor: pointer;
}

.modal--wide { max-width: 720px; }
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.compare-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface2);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.compare-card.is-winner {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.compare-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.compare-card-title {
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.compare-badge {
  font-size: 10px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.compare-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 0;
}
.compare-metrics div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.compare-metrics dt {
  font-size: 11px;
  color: var(--muted);
}
.compare-metrics dd {
  margin: 0;
  font-size: 15px;
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.compare-card .btn { width: 100%; margin-top: auto; }
.compare-card .btn.is-locked { opacity: 0.85; }

@media (max-width: 640px) {
  .compare-grid { grid-template-columns: 1fr; }
}

.badge-locked { display: none !important; }

#shopMenu[hidden],
.workshop-result-action[hidden] { display: none !important; }

@media (max-width: 768px) {
  .calc-toolbar .toolbar-result-actions {
    order: 0;
    width: auto;
    margin-left: auto;
  }
  .post-calc-bar {
    padding: 4px var(--sp-3);
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .post-calc-bar::-webkit-scrollbar { display: none; }
  .post-calc-bar .btn {
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .material-simple-hint { display: none; }
  .toolbar-menu-panel--right { right: 0; left: auto; }

  /* Nested scroll trap: keep parts form in the page scroll, not a tiny clip box */
  .details-table-wrap,
  .details-table-wrap.table-wrap {
    max-height: none;
    min-height: 0;
    overflow: visible;
    flex: 0 0 auto;
    height: auto;
  }

  .details-section {
    flex: 0 0 auto;
    min-height: 0;
  }

  .mobile-calc-tab {
    min-height: 44px;
    padding: 12px 8px;
  }

  .calc-toolbar .btn,
  .calc-toolbar .btn-sm,
  .toolbar-menu > .btn {
    min-height: 44px;
    min-width: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box;
  }

  /* Mobile card layout: restore field chrome (desktop table is borderless) */
  .parts-table,
  .details-table.parts-table {
    table-layout: auto;
    min-width: 0;
  }

  .parts-table td,
  .parts-table td.col-qty,
  .parts-table td.row-actions,
  .parts-table td.pro-col,
  .details-table.parts-table td {
    width: 100%;
    max-width: none;
    padding: 0.45rem 0;
    border-bottom: none;
  }

  .parts-table tbody tr:hover td,
  .details-table.parts-table tbody tr:hover td {
    background: transparent;
  }

  .parts-table .form-input,
  .parts-table .part-label,
  .parts-table .part-dim,
  .parts-table .part-edge {
    width: 100%;
    box-sizing: border-box;
    background: rgba(9, 12, 16, 0.85);
    border: 1px solid var(--border2);
    border-radius: var(--radius-ctrl, 6px);
    color: var(--text);
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
  }

  .parts-table .form-input:focus,
  .parts-table .part-label:focus,
  .parts-table .part-dim:focus,
  .parts-table .part-edge:focus {
    background: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
  }

  .parts-table .qty-stepper {
    width: 100%;
    max-width: none;
    min-height: 44px;
    box-sizing: border-box;
    border: 1px solid var(--border2);
    background: rgba(9, 12, 16, 0.85);
  }

  .parts-table .qty-btn {
    width: 44px;
    min-width: 44px;
    height: auto;
    min-height: 44px;
    flex-shrink: 0;
  }

  .parts-table .part-qty,
  .parts-table .qty-stepper .part-qty {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    min-height: 44px;
    min-width: 2.5rem;
    width: auto;
    flex: 1 1 auto;
    font-size: 16px;
  }

  .parts-table .btn-add-row,
  .parts-table .remove-row {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }

  .sheet-strip {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .sheet-strip-field--kerf {
    margin-left: 0;
  }

  .sheet-strip-input {
    min-height: 40px;
    width: 72px;
    font-size: 16px;
  }

  .seg-btn,
  .seg-btn-radio {
    min-height: 40px;
  }

  .calc-sticky {
    padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom, 0px));
  }

  .calc-sticky .btn,
  .btn-calc-sticky {
    min-height: 48px;
  }

  /* Compact KPI + schema chrome — free vertical space for nest canvas */
  .calc-workshop .stats-row,
  .calc-workshop .stats-row--kpi3 {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    padding: 4px var(--sp-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
  }
  .calc-workshop .stats-row::-webkit-scrollbar { display: none; }
  .calc-workshop .stats-row .stat-item,
  .calc-workshop .stats-row--kpi3 .stat-item {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 8px;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
  }
  .calc-workshop .stats-row .stat-item .stat-label {
    font-size: 9px;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .calc-workshop .stats-row .stat-item strong {
    font-size: 13px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .calc-right.mob-active .canvas-area {
    padding: 4px var(--sp-3) 6px;
    gap: 4px;
    flex: 1 1 auto;
    min-height: 0;
  }

  .calc-right.mob-active .sheet-toolbar,
  .calc-right.mob-active .canvas-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0;
    padding: 4px 6px;
  }
  .calc-right.mob-active .sheet-toolbar::-webkit-scrollbar,
  .calc-right.mob-active .canvas-toolbar::-webkit-scrollbar { display: none; }

  .calc-right.mob-active .label-chips,
  .calc-right.mob-active .view-chips {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 4px;
  }
  .calc-right.mob-active .view-chip,
  .calc-right.mob-active .label-chips .chip {
    flex-shrink: 0;
    min-height: 32px;
    padding: 4px 8px;
    white-space: nowrap;
  }
  .calc-right.mob-active .sheet-nav,
  .calc-right.mob-active .sheet-fill,
  .calc-right.mob-active .check-inline,
  .calc-right.mob-active .field-label--inline {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .calc-right.mob-active .cutting-canvas {
    flex: 1 1 auto;
    min-height: max(260px, 48vh);
  }

  .calc-right.mob-active .result-panel,
  .calc-right.mob-active .calc-result.visible {
    min-height: 0;
  }
}

@media (max-width: 430px) {
  .calc-right.mob-active .sheet-fill,
  .calc-right.mob-active .field-label--inline {
    display: none;
  }
}