/* Азбука Фасада · CRM — фирменная палитра сайта azbukafasada.ru (красный #b90505, петроль #066678)
   на тёплой «бумаге»; типографика — кириллическая суперсемья Паратайп: PT Sans (интерфейс) + PT Serif
   (заголовки и цифры-акценты). Редакционные приёмы вместо админ-шаблона: волосяные линии, капитель
   в шапках таблиц, табличные цифры, острые акценты цветом бренда. */
@import url('fonts/fonts.css');

:root {
  --sans: 'PT Sans', 'Segoe UI', system-ui, sans-serif;
  --serif: 'PT Serif', Georgia, serif;
  --paper: #f2f0ea;        /* фон-бумага */
  --card: #ffffff;
  --ink: #29261f;          /* тёплый чёрный */
  --ink-soft: #4c463c;
  --muted: #877f71;
  --line: #ddd6c7;
  --line-soft: #eae5d9;
  --red: #b90505;          /* фирменный красный сайта */
  --red-dark: #8f0404;
  --petrol: #066678;       /* фирменный петроль сайта */
  --petrol-dark: #04505e;
  --calc: #f5f2ea;         /* расчётные ячейки сметы */
  --side: #ebe7dc;         /* сайдбар */
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { font: 13.5px/1.45 var(--sans); color: var(--ink); margin: 0; background: var(--paper); }
:focus-visible { outline: 2px solid var(--petrol); outline-offset: 1px; }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* — Кнопки: основная — чернильная, фирменный красный прибережён для акцентов — */
button { font: 13px var(--sans); padding: 6px 13px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 6px; cursor: pointer; transition: border-color .12s, background .12s; }
button:hover { border-color: #b6ad99; }
button.primary { background: var(--ink); border-color: var(--ink); color: #f7f4ed; }
button.primary:hover { background: #000; }
.row-del, .row-order { padding: 3px 9px; font-size: 12px; }
.row-order { border-color: var(--petrol); color: var(--petrol-dark); }
.row-order:hover { background: #eef5f6; }

input, select { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 8px; }
input:focus, select:focus { outline: none; border-color: var(--petrol); box-shadow: 0 0 0 2px rgba(6,102,120,.14); }

/* — Вход — */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--paper); }
.login-card { display: flex; flex-direction: column; gap: 10px; width: 330px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 30px 28px 24px; }
.login-card h1 { font: 700 21px/1.2 var(--serif); }
.login-card h1::after { content: ""; display: block; width: 34px; border-top: 3px solid var(--red); margin-top: 10px; }
.login-card .sub { color: var(--muted); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; margin-top: -8px; }
.login-card input { padding: 8px 10px; }
.login-card button { padding: 9px; margin-top: 4px; }
.login-err { color: var(--red); min-height: 17px; font-size: 12.5px; }

/* — Каркас: сайдбар + страницы — */
#app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; width: 224px; flex: 0 0 224px; background: var(--side);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 0 12px; }
.sidebar .brand { padding: 0 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar .brand h1 { font: 700 17px/1.15 var(--serif); color: var(--ink); }
.sidebar .brand h1 em { font-style: normal; color: var(--red); } /* красная точка-акцент бренда */
.sidebar .sub { display: block; color: var(--muted); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; margin-top: 5px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; padding: 10px 10px; flex: 1; }
.sidebar nav a { color: var(--ink-soft); text-decoration: none; font-size: 13.5px; padding: 7px 12px;
  border-radius: 6px; }
.sidebar nav a:hover { background: rgba(255,255,255,.65); color: var(--ink); }
.sidebar nav a.active { background: var(--card); color: var(--ink); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--red); }
.sidebar .who { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 18px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-soft); }
.sidebar .who button { padding: 3px 10px; font-size: 12px; background: transparent; }

main { flex: 1; padding: 24px 28px 40px; min-width: 0; }
.page h2 { font: 700 21px/1.2 var(--serif); margin: 2px 0 16px; }
.page h2::after { content: ""; display: block; width: 44px; border-top: 3px solid var(--red); margin-top: 7px; }

/* — Дашборд — */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 190px)); gap: 10px; margin-bottom: 14px;
  justify-content: start; max-width: 990px; } /* 5 колонок максимум — блок не растягивается на всю страницу */
.card { display: flex; flex-direction: column; gap: 3px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px 15px; text-decoration: none; color: var(--ink); }
a.card:hover { border-color: var(--petrol); }
.card b { font: 700 23px/1.1 var(--serif); font-feature-settings: 'tnum' 1; }
.card span { color: var(--muted); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.cols h3 { font: 700 11px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 4px; }
.evt { display: block; padding: 6px 2px; border-top: 1px solid var(--line-soft); color: var(--ink);
  text-decoration: none; font-size: 13px; }
.evt:hover { color: var(--petrol-dark); }

/* — Списки (таблицы страниц) — */
table.list { border-collapse: collapse; width: 100%; background: var(--card); }
table.list th { font: 700 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 10px 12px 7px; border-bottom: 2px solid var(--ink); position: sticky; top: 0;
  background: var(--card); }
table.list td { border-bottom: 1px solid var(--line-soft); padding: 9px 12px; vertical-align: middle; }
table.list tr[data-id] { cursor: pointer; }
table.list tr[data-id]:hover td { background: #f8f6ef; }
td.r, th.r { text-align: right; font-feature-settings: 'tnum' 1; }
.title-hint { color: var(--muted); }
.hint { color: var(--muted); font-size: 11px; max-width: 300px; }

.client-form { margin-bottom: 14px; }
.client-form .field { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 8px 0; }
.client-form .lbl { color: var(--muted); font-size: 11px; }
.client-form input, .client-form select { width: 180px; }

/* — Редактор сметы — */
header { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 14px; }
.client { display: flex; gap: 6px; flex-wrap: wrap; }
.client input { width: 150px; }
.toolbar { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#saved { max-width: 260px; }

#grid { border-collapse: collapse; width: 100%; background: var(--card); border-top: 2px solid var(--ink); }
#grid th { font: 700 10px var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  background: #faf8f2; padding: 7px 5px; text-align: center; border: 1px solid var(--line-soft);
  border-top: none; }
#grid td { border: 1px solid var(--line-soft); padding: 3px 5px; text-align: center; }
th.name, th.type, th.io { text-align: left; }
td.name { text-align: left; }
#grid input, #grid select { border-color: transparent; background: transparent; width: 100%; padding: 2px 4px; }
#grid .field input { width: 50px; } /* ⚙-панель: числа доп-параметров не тянутся на всю ширину */
#grid input:hover, #grid select:hover { border-color: var(--line-soft); }
td.calc { background: var(--calc); font-weight: 700; white-space: nowrap; font-feature-settings: 'tnum' 1; }
td.pf, td.pc, td.sum { text-align: right; }
td.sum { font-weight: 700; }
input[type="number"] { text-align: right; width: 68px; }
tr.adv td { background: #faf8f2; text-align: left; padding: 7px 10px; }
tr.adv.adv-hide { display: none; }
tr.adv .lbl { color: var(--muted); font-size: 11px; margin-right: 2px; }
tr.adv span.field { margin-right: 14px; white-space: nowrap; }
tr.adv input[type="number"] { width: 64px; }

#totals { margin-top: 12px; display: flex; gap: 20px; justify-content: flex-end; align-items: baseline;
  font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; font-feature-settings: 'tnum' 1; }
#totals b { font-size: 17px; }
#totals .grand { color: var(--petrol); }
#totals .grand b { font: 700 21px var(--serif); }

/* — Лиды — */
.leads-bar { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; }
.lead-row { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line-soft);
  flex-wrap: wrap; background: var(--card); }
.lead-row:first-child { border-top: none; }
.lead-head { flex: 1 1 auto; }
.lead-row select { width: auto; }
.dup { color: var(--red); font-size: 12px; }
pre.lead-raw { margin: 0 0 10px; padding: 8px 10px; background: var(--card); border: 1px dashed var(--line);
  white-space: pre-wrap; font-size: 12px; }

/* — Заказы: карточка под строкой — */
.order-card { display: flex; flex-direction: column; gap: 10px; background: #faf8f2;
  border: 1px solid var(--line); border-top: none; padding: 12px 14px; margin-bottom: 10px; }
.order-card > div:first-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.order-card select { width: auto; }
.order-card .list th { position: static; }
.pay-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pay-form input, .pay-form select { width: auto; }

/* — Задачи — */
.task-row { display: flex; gap: 9px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line-soft);
  background: var(--card); }
.task-row:first-child { border-top: none; }
.task-title { flex: 1 1 auto; }
.task-row button { padding: 2px 8px; font-size: 12px; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }
.due-over { color: var(--red); font-weight: 700; }
.due-today { color: #8a6410; font-weight: 700; }
.due-far { color: var(--muted); font-size: 12px; }

/* — Справочники — */
.refs-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.refs-row .field { display: flex; align-items: center; gap: 4px; }
.refs-row .lbl { color: var(--muted); font-size: 11px; }
.refs-row input { width: 76px; }
.refs-grid { border-collapse: collapse; margin: 6px 0; }
.refs-grid th, .refs-grid td { border: 1px solid var(--line-soft); padding: 2px 6px; text-align: center; font-size: 12px; }
.refs-grid th { background: #faf8f2; }
.refs-grid input { width: 52px; text-align: right; }

/* — Документы (экран скрывает, печать показывает) — */
.print-head { display: none; }
.akt-sign { display: none; }
.unit { display: none; }
th.remark, td.remark { display: none; }
td.remark { min-width: 140px; }

@media print {
  body { background: #fff; font-size: 12px; }
  .no-print, tr.adv, th.type, td.type, th.blk, td.blk { display: none; }
  main { padding: 0; }
  .print-head { display: block; }
  .print-head h2 { font: 700 15px var(--serif); margin: 0 0 8px; }
  .print-head .t-zavod, .print-head .t-akt { display: none; }
  body.doc-zavod .t-kp { display: none; }
  body.doc-zavod .t-zavod { display: block; }
  body.doc-akt .t-kp { display: none; }
  body.doc-akt .t-akt { display: block; }
  .akt-buyer { font-size: 12px; margin-bottom: 8px; }
  .unit { display: inline; }
  #grid input, #grid select { border: none; padding: 0; background: none; }
  #grid { border-top: 2px solid #000; }
  #grid th { border-color: #bbb; background: #fff; }
  #grid td { border-color: #ccc; }
  td.calc { background: #fff; }
  #totals { background: none; border: none; justify-content: flex-end; }

  /* КП клиенту (лист «Предложение с покр и без»): без вводных размеров, кол-во+марка+цены видны */
  th.io-h, td.io-h, th.io-w, td.io-w, th.io-l, td.io-l,
  th.io-o, td.io-o, th.io-c, td.io-c { display: none; }

  /* Спецификация заводу и акт («КП Детали Стиля», «Акт Приемо-Передачи»): все размеры, БЕЗ цен */
  body.doc-zavod th.io-h, body.doc-zavod td.io-h, body.doc-akt th.io-h, body.doc-akt td.io-h,
  body.doc-zavod th.io-w, body.doc-zavod td.io-w, body.doc-akt th.io-w, body.doc-akt td.io-w,
  body.doc-zavod th.io-l, body.doc-zavod td.io-l, body.doc-akt th.io-l, body.doc-akt td.io-l,
  body.doc-zavod th.io-o, body.doc-zavod td.io-o, body.doc-akt th.io-o, body.doc-akt td.io-o,
  body.doc-zavod th.io-c, body.doc-zavod td.io-c, body.doc-akt th.io-c, body.doc-akt td.io-c { display: table-cell; }
  body.doc-zavod th.pf, body.doc-zavod td.pf, body.doc-akt th.pf, body.doc-akt td.pf,
  body.doc-zavod th.pc, body.doc-zavod td.pc, body.doc-akt th.pc, body.doc-akt td.pc,
  body.doc-zavod th.sum, body.doc-zavod td.sum, body.doc-akt th.sum, body.doc-akt td.sum,
  body.doc-zavod #totals, body.doc-akt #totals { display: none; }

  /* Акт: колонка замечаний + подписи (лист «Акт Приемо-Передачи») */
  body.doc-akt th.remark, body.doc-akt td.remark { display: table-cell; }
  body.doc-akt .akt-sign { display: flex; justify-content: space-between; margin-top: 28px; }
}

/* Этап 1 плана: строка сметы из лида калькулятора — размеры/профиль предположены
   (список — в title строки); правка менеджером снимает пометку. Экранная пометка,
   в печать КП/завода/акта не идёт. */
@media screen {
  tr.unverified td { background: #fbf0cf; }
  tr.unverified td:first-child::after { content: ' ⚠'; color: #b90505; }
}

/* Этап 3 плана: канбан «Воронка» — колонки, карточки, перетаскивание */
.kanban { display: flex; gap: 10px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.kb-col { min-width: 190px; max-width: 230px; flex: 1 0 190px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.kb-col.kb-over { outline: 2px dashed var(--petrol); outline-offset: -4px; }
.kb-title { font-variant: small-caps; letter-spacing: .04em; border-bottom: 1px solid var(--muted);
  padding-bottom: 4px; color: var(--ink); }
.kb-card { border: 1px solid var(--line); border-left: 3px solid var(--petrol); border-radius: 6px;
  background: var(--paper); padding: 6px 8px; font-size: 13px; cursor: grab; display: flex;
  flex-direction: column; gap: 3px; }
.kb-card:active { cursor: grabbing; }
.kb-head { font-weight: 600; }
.kb-sum { font-variant-numeric: tabular-nums; text-align: right; }
.kb-assignee, .lead-assignee { max-width: 150px; font-size: 12px; }
.kb-card button { align-self: flex-end; }

/* журнал действий */
.audit-row { padding: 3px 0; border-bottom: 1px dotted var(--line); font-size: 13px; }

/* слияние клиентов — инлайн-строка в таблице */
tr.merge-row td { background: #fbf0cf; }
tr.merge-row select { max-width: 320px; }

/* Этап 7: отчёты — бары воронки и менеджеров (CSS, без библиотек) */
.bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.bar-lbl { width: 120px; font-size: 13px; color: var(--ink-soft); }
.bar { flex: 1; background: var(--line-soft); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--petrol); height: 100%; }
.bar-val { font-variant-numeric: tabular-nums; width: 40px; text-align: right; font-weight: 600; }

/* Этап 2: панель приёмки — плавающая кнопка + панель заметок по страницам */
#review-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; background: var(--petrol);
  color: #fff; border: none; border-radius: 22px; padding: 10px 16px; font: inherit; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#review-fab:hover { background: var(--petrol-dark); }
#review-panel { position: fixed; right: 18px; bottom: 66px; z-index: 41; width: min(380px, calc(100vw - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
  max-height: min(70vh, 640px); overflow: auto; }
.rv-head { display: flex; align-items: center; gap: 6px; }
.rv-head button { margin-left: auto; }
#review-panel textarea, #review-target { width: 100%; box-sizing: border-box; font: inherit; }
.rv-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-all { font-size: 12px; color: var(--muted); }
.rv-note { border-top: 1px solid var(--line-soft); padding-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.rv-note .rv-meta { font-size: 12px; color: var(--muted); }
.rv-note .rv-text { white-space: pre-wrap; font-size: 13px; }
.rv-note.rv-done .rv-text { color: var(--muted); text-decoration: line-through; }
.rv-chip { color: var(--red); font-weight: 600; }
.rv-done .rv-chip { color: var(--petrol); }
