/* ============ Дизайн-система ============ */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e6eaf2;
  --border-strong: #d8dfeb;
  --text: #1a2233;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --navy: #101632;
  --navy-2: #1e1b4b;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 64, .05), 0 1px 3px rgba(16, 24, 64, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 64, .08), 0 2px 4px rgba(16, 24, 64, .04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 64, .16);
}

* { box-sizing: border-box; }

::selection { background: rgba(79, 70, 229, .18); }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 400px at 80% -200px, rgba(124, 58, 237, .07), transparent 60%),
    radial-gradient(900px 380px at 10% -180px, rgba(79, 70, 229, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1280px; margin: 0 auto; padding: 26px 28px 70px; }

h1 { font-size: 25px; font-weight: 800; letter-spacing: -.015em; margin: 6px 0 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 { margin: 6px 0 12px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Навигация ============ */
.topnav {
  display: flex; align-items: center; gap: 2px;
  background: linear-gradient(100deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #dfe4f3;
  padding: 0 22px; height: 58px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 16px rgba(16, 22, 50, .25);
}
.topnav a { color: #b9c2dd; text-decoration: none; padding: 7px 13px; border-radius: 10px; transition: background .15s, color .15s; white-space: nowrap; }
.topnav a:hover { color: #fff; background: rgba(255, 255, 255, .09); text-decoration: none; }
.topnav a.active { color: #fff; background: rgba(124, 133, 255, .22); box-shadow: inset 0 0 0 1px rgba(148, 155, 255, .25); }
.topnav .brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: #fff; margin-right: 16px; letter-spacing: -.01em; }
.topnav .brand:hover { background: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .45);
  font-size: 16px;
}
.topnav .spacer { flex: 1; }
.profile-chip { display: flex; align-items: center; gap: 9px; }
.profile-chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.profile-chip .who b { font-size: 13.5px; color: #f1f3fb; font-weight: 600; }
.profile-chip .who small { font-size: 11px; color: #9aa5c9; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .4);
  flex-shrink: 0;
}
.nav-bell { position: relative; font-size: 17px; }
.bell {
  position: absolute; top: -2px; right: -4px;
  background: #ef4444; color: #fff; border-radius: 999px;
  padding: 0 5.5px; font-size: 10.5px; font-weight: 800; line-height: 16px;
  box-shadow: 0 2px 6px rgba(239, 68, 68, .5);
}
.inline-form { display: inline; }
.linklike { background: none; border: none; color: #b9c2dd; cursor: pointer; font-size: 14px; padding: 7px 13px; border-radius: 10px; font-family: inherit; transition: background .15s, color .15s; }
.linklike:hover { color: #fff; background: rgba(255, 255, 255, .09); }

/* ============ Карточки ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.table-card { padding: 6px 0 2px; overflow-x: auto; }
.empty { text-align: center; color: var(--muted); padding: 52px 20px; font-size: 15.5px; }
.empty::before { content: "🗂"; display: block; font-size: 42px; margin-bottom: 12px; filter: grayscale(.3); opacity: .8; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none; border-radius: 11px;
  padding: 10px 18px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
  box-shadow: 0 3px 10px rgba(79, 70, 229, .28);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79, 70, 229, .36); text-decoration: none; filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: #f8faff; box-shadow: var(--shadow-md); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--accent-soft); border-color: #c7cdf9; box-shadow: none; }
.btn.success { background: linear-gradient(135deg, #16a34a, #059669); box-shadow: 0 3px 10px rgba(22, 163, 74, .28); }
.btn.success:hover { box-shadow: 0 6px 16px rgba(22, 163, 74, .38); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 9px; }
.btn.big { padding: 13px 24px; font-size: 16px; border-radius: 12px; min-height: 48px; }
.btn.wide { width: 100%; }
.btn.disabled { background: #e8ecf3; color: #9aa3b5; cursor: not-allowed; box-shadow: none; }
.btn.disabled:hover { transform: none; box-shadow: none; }

/* ============ Формы ============ */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); font-weight: 400;
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 12px; background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(79, 70, 229, .14);
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.grid2 .span2, .form .span2 { grid-column: span 2; }
.form .actions { display: flex; gap: 10px; margin-top: 18px; }

/* ============ Таблицы ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px; white-space: nowrap; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f7f9ff; }
tr.danger td { background: var(--danger-soft); }
tr.danger:hover td { background: #fde8e8; }
tr.warn td { background: var(--warn-soft); }
tr.warn:hover td { background: #fdf3d7; }
tr.inactive td { opacity: .5; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.clamp { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger { color: var(--danger); }
tr[data-href] { cursor: pointer; }

/* ============ Бейджи ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3.5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.st-draft { background: #f1f4f9; color: #64748b; }
.st-signed { background: #dbeafe; color: #1d4ed8; }
.st-production { background: #ede9fe; color: #6d28d9; }
.st-ready { background: #d1fae5; color: #047857; }
.st-shipped { background: #cffafe; color: #0e7490; }
.st-closed { background: #f1f4f9; color: #9aa3b5; }
.state-ok { background: var(--ok-soft); color: #15803d; }
.state-warn { background: var(--warn-soft); color: #b45309; }
.state-danger { background: var(--danger-soft); color: #b91c1c; }
.state-done { background: #f1f4f9; color: #64748b; }
.tg-mark { background: #dbeafe; color: #1d4ed8; border-radius: 5px; padding: 0 5px; font-size: 10.5px; font-weight: 800; }

/* ============ KPI ============ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px;
}
.kpi-ico {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 21px; background: var(--accent-soft);
}
.kpi.danger .kpi-ico { background: var(--danger-soft); }
.kpi.warn .kpi-ico { background: var(--warn-soft); }
.kpi-num { display: block; font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi.danger .kpi-num { color: var(--danger); }

/* ============ Фильтры ============ */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 15px 20px; }
.filters input[name=q] { flex: 1; min-width: 180px; }
.filters select, .filters input { padding: 8px 11px; }

/* ============ Страница заказа ============ */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.props { display: grid; grid-template-columns: 175px 1fr; gap: 8px 14px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
table.compact th, table.compact td { padding: 7px 9px; font-size: 13.5px; }

/* ============ Панель «Сегодня» ============ */
.today-panel { display: flex; gap: 14px; flex-wrap: wrap; padding: 14px 16px; }
.tp-sec { flex: 1; min-width: 220px; background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; }
.tp-sec.ok { background: var(--ok-soft); }
.tp-sec.danger { background: var(--danger-soft); }
.tp-sec.warn { background: var(--warn-soft); }
.tp-title { font-weight: 700; font-size: 13.5px; margin-bottom: 5px; }
.tp-sec a { text-decoration: none; font-size: 14px; line-height: 1.6; display: inline-block; }
.tp-sec a:hover { text-decoration: underline; }
.tp-sec.danger .tp-title { color: var(--danger); }

/* ============ Спецификация ============ */
.items { margin-bottom: 10px; }
.items input { width: 100%; min-width: 90px; }
.items .qty { width: 84px; }
.items .unit { width: 72px; }
.items-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.total { font-size: 17.5px; }
.static-items input { border: none; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 12.5px; margin: 8px 0 0; }

/* ============ Блок нового клиента ============ */
details.new-client {
  border: 1.5px dashed #c9d2f2; border-radius: 12px;
  padding: 12px 16px; margin: 4px 0 16px; background: #f8faff;
}
details.new-client summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
details.new-client summary:hover { text-decoration: underline; }
details.new-client p { margin: 4px 0 0; font-size: 13px; }

/* ============ Прочее ============ */
.flash {
  background: linear-gradient(90deg, var(--accent-soft), #f5f3ff);
  color: #3730a3;
  border: 1px solid #dfe3fd; border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px;
  white-space: pre-line;
  box-shadow: var(--shadow-sm);
}
.flash.error { background: linear-gradient(90deg, var(--danger-soft), #fff1f1); border-color: #fecaca; border-left-color: var(--danger); color: #991b1b; }

/* Относительные даты и долги */
.rel { font-size: 11.5px; margin-left: 3px; white-space: nowrap; }
.rel-danger { color: var(--danger); font-weight: 700; }
.rel-warn { color: var(--warn); font-weight: 600; }
.rel-ok { color: var(--muted); }
.debt { color: var(--danger); font-size: 11.5px; white-space: nowrap; font-weight: 600; }

/* Крупные кнопки в очереди цеха */
.btn.big { min-height: 48px; }

/* ============ Вход ============ */
body.login-body { background: none; }
body.login-body main { max-width: none; padding: 0; }
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(99, 102, 241, .35), transparent 55%),
    radial-gradient(900px 600px at 85% 100%, rgba(168, 85, 247, .28), transparent 55%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
}
.login-card {
  width: 400px; max-width: calc(100vw - 32px);
  padding: 36px 34px 30px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, .6) inset;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.login-brand .brand-mark { width: 54px; height: 54px; border-radius: 16px; font-size: 28px; box-shadow: 0 8px 22px rgba(99, 102, 241, .45); }
.login-brand h1 { justify-content: center; font-size: 23px; margin: 0; }
.login-brand small { color: var(--muted); font-size: 13.5px; }
.login-card label { margin-bottom: 15px; }
.login-card .btn { margin-top: 6px; padding: 12px; font-size: 15.5px; }

.error-card { max-width: 500px; margin: 70px auto; text-align: center; }
.error-card::before { content: "😕"; display: block; font-size: 44px; margin-bottom: 10px; }
.error-card .btn { margin-top: 12px; }

/* ============ Мобильная раскладка ============ */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 .span2 { grid-column: span 1; }
  main { padding: 16px 14px 50px; }
}

@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive tr {
    display: block; border: 1px solid var(--border); border-radius: 12px;
    margin: 0 10px 12px; padding: 8px 12px; background: #fff;
    box-shadow: var(--shadow-sm);
  }
  table.responsive tbody tr:hover { background: #fff; }
  table.responsive td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    border-bottom: none; padding: 6px 4px;
  }
  table.responsive td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex-shrink: 0;
  }
  table.responsive td.num { justify-content: flex-end; }
  .btn { min-height: 42px; }
  .topnav { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 4px; }
  .profile-chip .who { display: none; }
  .clamp { max-width: 60vw; }
}

/* ============ Печать ============ */
@media print {
  body { background: #fff; }
  .topnav, .filters, .btn, .head-actions, .kpi-row, .no-print, form.inline-form, .flash { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  tr.danger td, tr.warn td { background: #fff !important; }
}

/* ============ Печатная карточка заказа ============ */
.print-body { background: #fff; }
.print-page { max-width: 760px; margin: 0 auto; padding: 30px 20px; }
.print-toolbar { display: flex; gap: 10px; margin-bottom: 18px; }
.print-sub { font-size: 14px; color: var(--muted); font-weight: 400; }
.print-props { width: 100%; border-collapse: collapse; margin: 14px 0 22px; }
.print-props td { padding: 4px 8px 4px 0; border: none; vertical-align: top; }
.print-props td:first-child { color: var(--muted); width: 200px; }
.print-items { margin: 10px 0 30px; }
.print-signs { display: flex; gap: 40px; flex-wrap: wrap; margin-top: 46px; }
.print-date { color: var(--muted); font-size: 12.5px; margin-top: 20px; }

/* ============ Календарь производства ============ */
.cal-nav { align-items: center; }
.cal-nav .btn.ghost { padding: 10px 14px; font-size: 16px; }
.cal-legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 13px 20px; font-size: 13.5px; }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--muted); }
.cal-legend .dot { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }
.cal-legend .dot.production { background: #8b5cf6; }
.cal-legend .dot.ready { background: #10b981; }
.cal-legend .dot.ship { background: #06b6d4; }
.cal-legend .dot.overdue { background: #ef4444; }
.cal-wrap { padding: 14px; overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; min-width: 960px; }
.cal-grid > * { min-width: 0; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 2px 0 4px; }
.cal-day {
  background: #f8fafd; border: 1px solid var(--border); border-radius: 11px;
  min-height: 108px; padding: 7px 8px;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, background .12s;
}
.cal-day:hover { border-color: #c7cdf9; }
.cal-day.weekend { background: #f3f5fb; }
.cal-day.out { opacity: .42; }
.cal-day.today {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3.5px rgba(79, 70, 229, .12);
}
.cal-date { font-weight: 800; font-size: 13px; color: var(--muted); }
.cal-day.today .cal-date { color: var(--accent); }
.cal-today-mark { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); background: #fff; border-radius: 999px; padding: 1px 6px; vertical-align: middle; box-shadow: var(--shadow-sm); }
.cal-chip {
  display: block; font-size: 11.5px; line-height: 1.3;
  padding: 3px 8px; border-radius: 7px;
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid transparent;
  min-width: 0; max-width: 100%;
  transition: filter .1s, transform .1s;
}
.cal-chip:hover { filter: brightness(.95); transform: translateY(-1px); text-decoration: none; }
.cal-chip b { font-weight: 800; margin-right: 3px; }
.cal-chip.production { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.cal-chip.ready { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.cal-chip.ship { background: #cffafe; color: #0e7490; border-color: #a5f3fc; }
.cal-chip.overdue { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* Внесение оплаты в карточке заказа */
.pay-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.pay-form label { margin-bottom: 0; flex: 1; min-width: 140px; }
.pay-form label[for] , .pay-form input[name=note] { min-width: 200px; }

/* ============ Канбан ============ */
.small-note { font-size: 13px; }
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.kcol {
  flex: 0 0 284px; min-width: 0;
  background: #edf0f8; border-radius: 14px; padding: 10px;
  max-height: calc(100vh - 230px);
  display: flex; flex-direction: column;
}
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 2px 6px 4px; }
.kdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.st-dot-draft { background: #94a3b8; }
.st-dot-signed { background: #3b82f6; }
.st-dot-production { background: #8b5cf6; }
.st-dot-ready { background: #10b981; }
.st-dot-shipped { background: #06b6d4; }
.st-dot-closed { background: #94a3b8; }
.ktitle { font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.kcnt { background: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 800; color: var(--muted); }
.kcol-sum { font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 6px 8px; font-variant-numeric: tabular-nums; }
.kcol-body {
  overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  min-height: 130px; padding: 4px; border-radius: 10px;
  border: 2px dashed transparent; transition: border-color .12s, background .12s;
}
.kcol-body.over { border-color: var(--accent); background: #e4eaff; }
.kcard {
  background: #fff; border-radius: 11px; padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid #cbd5e1;
  cursor: grab;
  flex-shrink: 0;
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard.state-danger { border-left-color: var(--danger); }
.kcard.state-warn { border-left-color: var(--warn); }
.kcard.state-ok { border-left-color: #60a5fa; }
.kcard.state-done { opacity: .6; }
.kcard:hover { box-shadow: var(--shadow-md); }
.kcard-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.knum { font-weight: 800; }
.knum:hover { text-decoration: none; color: var(--accent-dark); }
.kamount { font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kclient { font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.kdesc { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kmeta { margin-top: 6px; font-size: 11.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kempty {
  border: 2px dashed var(--border-strong); border-radius: 10px;
  padding: 20px 10px; text-align: center; color: var(--muted); font-size: 12.5px;
}
.kcol-closed .kcard { background: #f6f7fb; }

/* ============ Этапы производства ============ */
.prod-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.prod-progress { display: flex; align-items: center; gap: 10px; }
.pbar { width: 160px; height: 8px; background: #e8ecf5; border-radius: 999px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
.plabel { font-weight: 800; font-size: 13px; color: var(--muted); }
table.stages td { vertical-align: middle; }
.stage-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: #fff;
  color: transparent; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
}
button.stage-check:hover { border-color: var(--ok); color: #d1fae5; }
.stage-check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
span.stage-check.on { cursor: default; }
tr.stage-done td { background: #f6fdf8; }
tr.stage-done td b { color: var(--muted); text-decoration: line-through; }
tr.stage-late td:nth-child(3), tr.stage-late td:nth-child(2) b { }
.scrap-form { display: inline-flex; gap: 4px; align-items: center; }
.scrap-qty { width: 86px; padding: 3px 7px; font-size: 12.5px; }
.stage-qty { display: flex; gap: 6px; align-items: center; }
.stage-qty .qty-input { width: 74px; padding: 4px 8px; font-weight: 700; }
.stage-qty .qty-total { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pbar-mini { width: 120px; height: 5px; margin-top: 5px; margin-bottom: 0; }

/* Калькулятор фасада */
.calc-box { background: #f6f5ff; }
.calc-grid { margin-bottom: 10px; }
.calc-out { font-size: 14px; font-weight: 600; color: var(--accent-dark); background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }

/* Прогресс на канбан-карточке */
.kprogress { height: 5px; background: #e8ecf5; border-radius: 999px; overflow: hidden; margin-top: 7px; }
.kprogress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.kprogress.pp-done i { background: var(--ok); }

/* ============ Цех: план на день ============ */
.kpi.ok .kpi-ico { background: var(--ok-soft); }
.cap-form { display: flex; gap: 6px; align-items: center; }
.cap-input { width: 78px; padding: 6px 8px; font-weight: 700; font-size: 16px; }
.fact-form { display: inline-flex; gap: 6px; align-items: center; }
.fact-input { width: 74px; padding: 5px 8px; font-weight: 700; }
.prod-qty { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--text); background: #f8faff; border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; margin-bottom: 10px; }
.prod-qty b { font-variant-numeric: tabular-nums; }
.forecast { color: var(--accent-dark); }
.pbar-wide { width: 100%; height: 10px; margin-bottom: 12px; }

.stock-move { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stock-note { width: 150px; padding: 4px 8px; font-size: 12.5px; }
.text-ok { color: var(--ok); }

/* ============ Аналитика ============ */
.chart-card { min-width: 0; }
.chart-box { position: relative; height: 280px; }
.chart-box.wide { height: 300px; }
.chart-box canvas { max-height: 100%; }

.batches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.batch-chip { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }

.price-input { width: 110px; padding: 6px 9px; font-weight: 600; }

.kmove { display: none; gap: 6px; margin-top: 6px; }
@media (max-width: 720px) { .kmove { display: flex; } .kmove .btn { flex: 1; min-height: 40px; font-size: 18px; } }

/* ============ Доска: компактная таблица заказов ============ */
.board-table th { text-align: center; }
.board-table td { padding: 9px 12px; }
.ord-cell { max-width: 300px; }
.ord-num { margin-right: 6px; }
.ord-client { font-weight: 600; }
.ord-desc { display: block; font-size: 12px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-main { font-weight: 600; }
.prod-qty { display: block; font-size: 12px; }
.due-cell { font-size: 13.5px; }
td.board-sum { text-align: center; }
td.board-sum .sum-main { white-space: nowrap; }
td.board-sum .debt { display: block; margin-top: 2px; }

/* Готовность заказа: проценты воронки */
.pp-wrap { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.pp-bar { width: 90px; }
.pp-bar.pp-mid i { background: linear-gradient(90deg, #f59e0b, #f97316); }
.pp-bar.pp-high i { background: linear-gradient(90deg, #06b6d4, #3b82f6); }
.pp-bar.pp-done i { background: var(--ok); }
.pp-label { font-size: 13px; font-variant-numeric: tabular-nums; }
.pp-panels { display: block; font-size: 11.5px; }
.what-items { font-size: 13px; }

/* ============ Цех: быстрые тапы, пульт, плитки ============ */
.fact-input { width: 84px; padding: 9px 10px; font-weight: 800; font-size: 16px; }
.fact-ok { min-width: 46px; min-height: 42px; font-size: 16px; }
.fact-plus { min-height: 42px; font-weight: 700; }
.stage-inline { display: flex; flex-direction: column; gap: 6px; }
.tile-stage-name { font-weight: 700; font-size: 13.5px; }
.qty-total { color: var(--muted); font-size: 13px; }
.scrap-inline .scrap-inp { width: 74px; font-size: 13px; padding: 5px 7px; font-weight: 600; }

/* Пульт этапов */
.stageboard { padding: 12px 18px; }
.sb-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sb-chip { background: #f8fafd; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-width: 110px; }
.sb-qty { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sb-name { font-size: 11.5px; color: var(--muted); }

/* Цвет: чипы и фильтры */
.colorbar { padding: 10px 18px; gap: 8px; }
.color-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 12px 4px 6px; font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; }
.color-chip i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.color-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.color-chip:hover { text-decoration: none; }

/* Плитки цеха */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tile-color { color: #fff; border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.tile-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.tile-client { font-weight: 700; font-size: 15px; }
.tile-items { font-size: 13px; }
.tile-stage { display: flex; flex-direction: column; gap: 6px; background: #f6f8ff; border: 1px solid #e3e8fa; border-radius: 10px; padding: 8px 10px; }
.tile-stage-qty { display: flex; align-items: center; gap: 8px; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }

/* Скроллбары */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd4e6; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #aeb9d4; }

/* Daily workflow */
[data-order-panel] { scroll-margin-top: 130px; }
.topnav { height:auto; min-height:58px; flex-wrap:wrap; }
.topnav .nav-more a { color:#26324a; }
.topnav .nav-more summary { white-space:nowrap; }
.work-row > div, .grid2 > *, .detail-grid > * { min-width:0; overflow-wrap:anywhere; }
.order-overview .btn { white-space:normal; text-align:left; }
@media(max-width:1000px) { .topnav { padding:8px; position:relative; } .topnav .who { display:none; } .topnav .brand { margin-right:0; } }
@media(max-width:720px) { .static-items, .stages { display:block; overflow-x:auto; } #items { display:block; overflow-x:auto; } }
[hidden] { display: none !important; }
.nav-more { position: relative; padding: 10px; cursor: pointer; }
.nav-more > div { position:absolute; z-index:30; min-width:180px; padding:10px; background:white; border:1px solid #dce2eb; border-radius:12px; box-shadow:0 8px 32px #172b4d22; }
.nav-more a { display:block; color:#26324a; padding:10px; }
.view-switch,.order-tabs { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0 18px; }
.order-tabs { position:sticky; top:0; z-index:10; background:#f5f7fb; padding:10px 0; }
.order-tabs .active,.view-switch .active { background:#e2eafe; color:#234b9b; }
.work-row { display:flex; justify-content:space-between; align-items:start; gap:24px; padding:18px 0; border-bottom:1px solid #e5e9f0; }
.work-row:last-child { border-bottom:0; }
.work-row p { margin:6px 0; }
.order-overview { border-left:4px solid #456bcb; }
.fact-form { flex-wrap:wrap; min-width:230px; }
.fact-form label { font-size:12px; max-width:180px; }
.fact-form button { min-height:42px; }
.card textarea { width:100%; min-height:72px; border:1px solid #cbd5e1; border-radius:8px; padding:10px; font:inherit; }
@media(max-width:720px) { .work-row { flex-direction:column; gap:10px; } .order-tabs { position:static; } .topnav { flex-wrap:wrap; } .topnav .who { display:none; } .fact-form { min-width:0; } .btn { min-height:42px; } }
@media print { .order-tabs,.nav-more { display:none; } [data-order-panel][hidden] { display:block !important; } }

/* Client creation within an order */
.client-picker-row { display:flex; gap:8px; align-items:center; }
.client-picker-row select { flex:1; min-width:0; }
.client-picker-row .btn { flex:none; font-size:24px; width:46px; height:44px; padding:0; }
.client-dialog { width:min(760px, calc(100vw - 24px)); max-height:90vh; border:1px solid var(--border); border-radius:18px; padding:24px; box-shadow:var(--shadow-lg); color:var(--text); }
.client-dialog::backdrop { background:#10163288; }
[data-client-form] fieldset { min-width:0; margin:16px 0; border:1px solid var(--border); border-radius:12px; padding:16px; }
[data-client-form] legend { font-weight:700; padding:0 8px; }
@media(max-width:720px) { .client-dialog { padding:16px; } }

/* Catalog import: refresh cached application assets. */

/* Dealer price and contract fields. */
.version-note { padding: 12px 24px 24px; text-align: center; font-size: 12px; color: #64748b; }
