/* База интерфейса демо КП. Тёмная служебная оболочка, светлое КП.
   Печатные страницы и адаптив расширяются в Task 3 и Task 6. */

:root {
  --bg-dark: #14181f;
  --bg-panel: #1d232e;
  --text-main: #e8ecf2;
  --text-muted: #9aa6b5;
  --accent: #3f7fd4;
  --accent-hover: #5a93de;
  --paper: #ffffff;
  --ink: #1c2430;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
}

.service-line {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-panel);
  border-bottom: 1px solid #2a3342;
}
.service-line.storage-warning { background: #4d3a17; color: #ffe2a8; }

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid #2a3342;
}

.header-title { font-size: 17px; font-weight: 600; }
.header-deal { color: var(--text-muted); font-weight: 400; margin-left: 6px; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: #3a4656;
}

.btn-secondary:hover { color: var(--text-main); border-color: var(--text-muted); background: transparent; }

.btn-excursion { font-weight: 600; }

.btn-new-kp {
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
}

.workspace,
#workspace {
  display: flex;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}

.document-pane { flex: 1 1 auto; min-width: 0; }
.document-state { color: var(--text-muted); font-size: 12px; margin: 0 0 8px; }
.document-state-stale { color: #ffe2a8; font-weight: 600; }

.panel-pane {
  flex: 0 0 360px;
  background: #f7f8fa;
  border: 1px solid #d9dfe8;
  border-radius: 8px;
  padding: 14px;
  color: #1c2430;
}

.kp-document {
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
}

/* ---- A4-страницы документа: один набор для предпросмотра, PNG и печати ---- */

.kp-page {
  width: 794px;
  min-height: 1123px;
  padding: 48px 56px;
  background: var(--paper);
  color: var(--ink);
  margin: 0 auto 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.kp-pages { transform-origin: top left; }

.doc-measure {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 682px;
}

.png-export-host {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 794px;
  pointer-events: none;
}

.doc-block { margin-bottom: 18px; }

.doc-head { border-bottom: 2px solid #24384f; padding-bottom: 10px; }
.doc-supplier { font-size: 16px; font-weight: 700; }
.doc-contacts { font-size: 12px; color: #4c5a6a; margin-top: 2px; }
.doc-demo-mark {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: #6b7a8c;
  border: 1px solid #c3ccd6;
  border-radius: 3px;
  padding: 1px 6px;
}
.doc-title { font-size: 19px; font-weight: 700; margin-top: 10px; }
.doc-client { font-size: 13px; margin-top: 6px; }

.doc-intro .doc-paragraph { font-size: 14px; margin: 0 0 8px; }
.doc-total { font-size: 15px; }
.doc-total-label { font-weight: 600; }
.doc-total-sum { font-size: 24px; font-weight: 700; color: #17364f; }
.doc-total-note { font-size: 12px; color: #4c5a6a; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid #c9d2dc; padding: 6px 8px; text-align: left; }
.doc-table th { background: #eef2f6; font-weight: 600; }
.doc-num { text-align: right; white-space: nowrap; }
.doc-total-cell { font-weight: 700; }
.doc-included { margin-top: 8px; font-size: 12px; color: #33414f; }

.doc-subtitle { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.doc-list { margin: 4px 0 0 18px; padding: 0; font-size: 13px; }
.doc-list li { margin-bottom: 3px; }
.doc-paragraph { font-size: 13px; margin: 4px 0; }

.doc-card-title { font-size: 14px; font-weight: 700; }
.doc-card-photo {
  display: block;
  max-width: 100%;
  max-height: 230px;
  margin: 8px 0;
  object-fit: contain;
}

.doc-faq-q { font-size: 13px; font-weight: 600; margin-top: 8px; }
.doc-faq-a { font-size: 13px; margin-top: 2px; }

.doc-next { border-top: 2px solid #24384f; padding-top: 10px; }
.doc-footer { font-size: 11px; color: #55636f; margin-bottom: 0; }

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg-panel);
  border: 1px solid #2a3342;
  border-radius: 8px;
}

.export-hint { font-size: 12px; color: var(--text-muted); }
.png-links { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.png-warning { width: 100%; color: #ffb84d; font-size: 13px; }

/* ---- Панели работы с КП ---- */

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-title { font-size: 16px; font-weight: 700; color: #1c2430; }
.panel-subtitle { font-size: 13px; font-weight: 700; color: #5b6675; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.4px; }

.edit-item, .catalog-item { background: #ffffff; border: 1px solid #d9dfe8; border-radius: 8px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.edit-item-title, .catalog-title { font-size: 15px; font-weight: 700; color: #1c2430; margin-bottom: 8px; }
.edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 11px; font-weight: 700; color: #5b6675; text-transform: uppercase; letter-spacing: 0.3px; }
.panel-pane .input-num, .panel-pane .input-wide, .panel-pane select, .panel-pane textarea {
  background: #ffffff; border: 1px solid #c6cfda; color: #1c2430; border-radius: 6px;
}
.panel-pane .input-num:focus, .panel-pane .input-wide:focus, .panel-pane select:focus, .panel-pane textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(63, 127, 212, 0.25);
}
.input-num { width: 110px; padding: 6px 8px; }
.input-wide { width: 100%; padding: 6px 8px; margin-bottom: 8px; }
.panel-pane .btn-secondary { color: #5b6675; border-color: #b9c3d0; }
.panel-pane .btn-secondary:hover { color: #1c2430; border-color: #8b97a6; background: #ffffff; }
.btn-add { width: 100%; margin-bottom: 4px; }
.btn-remove { border: 1px solid #d64541; color: #d64541; background: #ffffff; }
.btn-remove:hover { background: #d64541; color: #ffffff; }
.field-error { color: #c23a2e; font-size: 12px; margin: 4px 0; }

.delivery-box { border: 1px solid #d9dfe8; border-radius: 6px; padding: 10px; margin-top: 8px; background: #fbfcfe; }
.delivery-title { font-size: 12px; font-weight: 700; color: #5b6675; margin-bottom: 6px; text-transform: uppercase; }
.delivery-status { font-size: 12px; flex: 1 1 auto; }
.delivery-status.is-ok { color: #1e7d3e; font-weight: 700; }
.delivery-status.is-warn { color: #a05a00; font-weight: 700; }
.delivery-status.is-miss { color: #c23a2e; font-weight: 700; }

.edit-cond { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.edit-cond label { font-size: 12px; color: #5b6675; }
.toggle-line { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.ai-fab {
  width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, #3f7fd4 0%, #6a5ad4 100%); color: #ffffff;
  font-size: 16px; font-weight: 800; cursor: pointer; letter-spacing: 0.5px;
  box-shadow: 0 0 0 3px rgba(90, 147, 222, 0.35), 0 4px 14px rgba(63, 127, 212, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ai-fab:hover { background: var(--accent-hover); }
.ai-fab:hover { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(90, 147, 222, 0.45), 0 6px 18px rgba(63, 127, 212, 0.6); }
.ai-fab:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .ai-fab { transition: none; } }
.ai-popover {
  position: fixed; z-index: 70; width: 300px; max-width: calc(100vw - 24px);
  background: var(--bg-panel); border: 1px solid var(--accent); border-radius: 12px;
  padding: 14px; color: var(--text-main);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transform-origin: top right; animation: ai-pop-in 0.18s ease;
}
@keyframes ai-pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.ai-pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-pop-title { font-weight: 700; font-size: 15px; }
.ai-pop-badge { font-size: 11px; font-weight: 700; color: var(--accent-hover); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; }
.ai-pop-text { font-size: 13px; line-height: 1.45; color: var(--text-muted); margin: 0 0 10px; }
.ai-pop-microw { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 10px; }
.ai-pop-mic {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, #3f7fd4 0%, #6a5ad4 100%);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(63, 127, 212, 0.5); transition: transform 0.15s ease;
}
.ai-pop-mic svg { width: 22px; height: 22px; fill: #ffffff; }
.ai-pop-mic:hover { transform: scale(1.06); }
.ai-pop-miclabel { font-size: 12px; color: var(--text-muted); }
.ai-pop-note {
  font-size: 12px; color: #ffb86b; background: rgba(255, 184, 107, 0.08);
  border: 1px solid rgba(255, 184, 107, 0.4); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px;
}
@media (prefers-reduced-motion: reduce) { .ai-popover { animation: none; } .ai-pop-mic { transition: none; } }

.catalog-photo { width: 100%; max-height: 150px; object-fit: contain; margin-bottom: 8px; }
.catalog-price { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.catalog-chars { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.check-ok { color: #1e7d3e; font-size: 13px; margin-bottom: 8px; }
.check-note { color: #5b6675; font-size: 12px; margin: 8px 0; }
.problem-list { margin: 4px 0 10px 18px; padding: 0; font-size: 13px; }
.problem-list.warning li { color: #ffb84d; }
.role-line { font-size: 13px; font-weight: 600; margin-bottom: 10px; }

.history-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.history-line span { flex: 1 1 auto; }
.journal-list { margin: 0 0 12px 18px; padding: 0; font-size: 12px; color: #5b6675; }
.history-line { color: #1c2430; }
.journal-list li { margin-bottom: 3px; }

.stale-banner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #4d3a17;
  border: 1px solid #a8842d;
  color: #ffe2a8;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.doc-status { font-size: 12px; color: #6b7a8c; margin-top: 4px; }
.doc-extra { color: #33414f; }

.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.overlay-box {
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  font-size: 15px;
  background: var(--bg-panel);
  border: 1px solid #2a3342;
  border-radius: 10px;
  padding: 16px;
}

.overlay-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.overlay-title { font-size: 18px; font-weight: 700; }
.ai-short { font-size: 14px; }
.ai-more { margin-top: 12px; border-top: 1px solid #2a3342; padding-top: 10px; }
.ai-part-title { font-weight: 700; font-size: 13px; margin-top: 10px; }
.ai-part-text { font-size: 13px; margin-top: 3px; }
.ai-note { font-size: 12px; color: var(--text-muted); margin-top: 12px; }
.about-part { font-size: 15px; font-weight: 700; margin: 14px 0 6px; }
.about-intro, .about-text { font-size: 15px; line-height: 1.5; }
.about-list { margin: 4px 0 0 18px; padding: 0; font-size: 15px; }
.about-list li { margin-bottom: 6px; line-height: 1.45; }
.about-list-small { font-size: 14px; }
.about-list-small li { margin-bottom: 4px; line-height: 1.4; }
.about-more { margin-top: 12px; border-top: 1px solid #2a3342; padding-top: 10px; }

.newkp-text { font-size: 14px; line-height: 1.5; }
.newkp-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.newkp-note { font-size: 12px; color: var(--text-muted); margin-top: 12px; line-height: 1.45; }

@media (max-width: 900px) {
  .panel-pane {
    position: fixed;
    inset: auto 0 0 0;
    top: 56px;
    flex: none;
    width: auto;
    max-height: calc(100vh - 70px);
    overflow: auto;
    z-index: 30;
    border-radius: 10px 10px 0 0;
  }
}

/* ---- Экскурсия ---- */

.tour-invite {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 440px;
  max-width: calc(100vw - 32px);
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px;
  z-index: 40;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.tour-invite-text { font-size: 15px; margin-bottom: 12px; }
.tour-invite-row { display: flex; gap: 8px; }

.tour-box {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 460px;
  max-width: calc(100vw - 32px);
  background: var(--bg-panel);
  border: 1px solid #3a4656;
  border-radius: 10px;
  padding: 16px;
  z-index: 45;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.tour-progress { font-size: 13px; font-weight: 700; color: var(--accent-hover); margin-bottom: 10px; }
.tour-text { font-size: 15px; margin-bottom: 12px; line-height: 1.45; }
.tour-details { font-size: 13px; color: var(--text-muted); margin-top: 10px; line-height: 1.45; }
.tour-nav { display: flex; gap: 10px; margin-top: 14px; }

@media print {
  .tour-invite, .tour-box { display: none !important; }
}

/* ---- Печать: только страницы документа, фиксированные разрывы ---- */

@media print {
  @page { size: A4 portrait; margin: 0; }

  body { background: #fff; }
  .service-line, .app-header, .export-bar, .panel-pane, #document-state, .stale-banner { display: none !important; }
  #workspace { padding: 0; gap: 0; }
  .kp-document { background: #fff; height: auto !important; }
  .kp-pages { transform: none !important; }
  .kp-page {
    box-shadow: none;
    margin: 0;
    page-break-after: always;
    break-after: page;
  }
  .kp-page:last-child { page-break-after: auto; break-after: auto; }
}

/* Подтверждения внутри страницы, без системных блокирующих окон. */
.action-dialog {
  color: var(--text-main);
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 20px;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.action-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.action-dialog h2 { font-size: 18px; margin: 0 0 12px; }
.action-dialog p { line-height: 1.5; }
.action-dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }
@media print { .action-dialog { display: none !important; } }

.png-link { display: inline-block; text-decoration: none; }

.draft-data-warning { font-size: 12px; color: #805600; margin: 6px 0; }

/* Живой блок Битрикс24: статус в служебной строке и секция в карточке «О демо» */
.bx-live { margin-left: 10px; }
.bx-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.bx-dot-ok { background: #34c07c; box-shadow: 0 0 6px rgba(52, 192, 124, 0.7); }
.bx-dot-fail { background: #e0655f; }
.bx-dot-idle { background: #8a93a6; }
.bx-section { margin-top: 14px; padding: 12px; border: 1px solid #2a3342; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.bx-section-text { font-size: 14px; }
.bx-status { font-size: 14px; font-weight: 600; }
.bx-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.bx-form input {
  flex: 1 1 150px;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid #2a3342;
  background: #10151f;
  color: var(--text-main);
  font: inherit;
}
.bx-msg { font-size: 13px; margin-top: 8px; min-height: 14px; }
.bx-msg-ok { color: #5fd39a; }
.bx-msg-err { color: #f09a95; }
.bx-note { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
