/* ==========================================================================
   Судебный товаровед П.П. — стили интерфейса
   Тёмно-синяя палитра, адаптив от 360 px, отдельные стили печати отчёта.
   ========================================================================== */

:root {
  --bg:            #08101f;
  --bg-grad:       #0d1830;
  --panel:         #111d36;
  --panel-2:       #16243f;
  --panel-3:       #1b2c4b;
  --line:          #25385f;
  --line-soft:     #1c2b4a;
  --text:          #e9effc;
  --text-dim:      #b9c8e4;
  --muted:         #8698ba;
  --accent:        #4a8cff;
  --accent-dark:   #2f6ad6;
  --accent-soft:   rgba(74, 140, 255, .14);
  --teal:          #2fd0c8;
  --ok:            #35b98a;
  --warn:          #f0a53a;
  --bad:           #ef5b5b;

  --sev-insignificant: #7d95bd;
  --sev-minor:         #35b98a;
  --sev-significant:   #f0a53a;
  --sev-critical:      #ef5b5b;

  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 10px 30px rgba(0, 0, 0, .35);
  --maxw:          1180px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые авторские display.
   Иначе, например, .cv-badge { display:inline-flex } включает спрятанный бейдж. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 500px at 12% -8%, #16294c 0%, rgba(22, 41, 76, 0) 60%),
    linear-gradient(180deg, var(--bg-grad) 0%, var(--bg) 340px);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; }
p { margin: 0 0 .6em; }
ul, ol { margin: 0; padding-left: 1.15em; }

a { color: var(--accent); }

.cv-app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 12px 40px;
}

.cv-muted   { color: var(--muted); }
.cv-hint    { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.cv-hint-sm { font-size: 12.5px; }
.cv-req     { color: var(--bad); }

/* ============================== ШАПКА ============================== */

.cv-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #14254a 0%, #0e1a33 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.cv-head-main { display: flex; gap: 12px; align-items: center; min-width: 0; }

.cv-logo {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-dark) 100%);
  font-weight: 800; font-size: 17px; letter-spacing: .5px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(47, 106, 214, .45);
}

.cv-head-text { min-width: 0; }
.cv-title  { font-size: 19px; letter-spacing: .2px; }
.cv-subtitle { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.cv-head-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.cv-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.cv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.cv-dot.is-ok   { background: var(--ok);   box-shadow: 0 0 8px rgba(53, 185, 138, .8); }
.cv-dot.is-bad  { background: var(--bad);  box-shadow: 0 0 8px rgba(239, 91, 91, .7); }
.cv-dot.is-warn { background: var(--warn); box-shadow: 0 0 8px rgba(240, 165, 58, .7); }

.cv-badge-mode {
  background: rgba(240, 165, 58, .14);
  border-color: rgba(240, 165, 58, .5);
  color: #ffce8a;
  font-weight: 700; letter-spacing: .8px;
}

/* ============================ ОШИБКА ============================ */

.cv-error {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 10px; padding: 10px 12px;
  background: rgba(239, 91, 91, .12);
  border: 1px solid rgba(239, 91, 91, .45);
  border-radius: var(--radius-sm);
  color: #ffd7d7;
  font-size: 13.5px;
}
.cv-error[hidden] { display: none; }
.cv-error-icon {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bad); color: #2a0808; font-weight: 800; font-size: 13px;
}
.cv-error-text { flex: 1 1 auto; }
.cv-error-close {
  flex: 0 0 auto; background: none; border: 0; color: #ffd7d7;
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px;
}

/* ============================ АУДИО ============================ */

.cv-audio {
  margin-top: 10px; padding: 10px 14px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 76px;
}
.cv-audio-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.cv-audio-ico  { color: var(--teal); font-size: 15px; }
.cv-audio-title{ font-weight: 600; }
.cv-audio-dur  { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.cv-audio-row  { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cv-audio-btn {
  display: inline-flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
  padding: 6px 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(74, 140, 255, .45);
  color: #cfe0ff;
  border-radius: 999px;
  font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.cv-audio-btn:hover { background: rgba(74, 140, 255, .24); }
.cv-audio-seek {
  flex: 1 1 auto; min-width: 40px; height: 4px;
  -webkit-appearance: none; appearance: none;
  background: var(--line); border-radius: 4px; outline: none; cursor: pointer;
}
.cv-audio-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 0; cursor: pointer;
}
.cv-audio-seek::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 0; cursor: pointer;
}
.cv-audio-time { flex: 0 0 auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.cv-audio-missing { margin: 8px 0 0; font-size: 13px; color: #ffce8a; }
.cv-audio-missing[hidden] { display: none; }

/* ============================ ВКЛАДКИ ============================ */

.cv-tabs {
  position: relative;
  display: flex; gap: 4px;
  margin: 14px 0 12px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cv-tabs::-webkit-scrollbar { display: none; }

.cv-tab {
  flex: 1 1 auto;
  position: relative; z-index: 1;
  padding: 9px 14px;
  background: none; border: 0;
  color: var(--text-dim);
  font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}
.cv-tab:hover { color: var(--text); }
.cv-tab.is-active { color: #fff; }
.cv-tab-glider {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 999px;
  transition: transform .22s ease, width .22s ease;
  pointer-events: none;
}
.cv-tab-glider[hidden] { display: none; }

/* ============================ ПАНЕЛИ ============================ */

.cv-panel[hidden] { display: none; }
.cv-panel { outline: none; }
.cv-panel-head { margin-bottom: 12px; }
.cv-h2 { font-size: 20px; }
.cv-h3 { font-size: 16px; }
.cv-h4 { font-size: 14px; }

.cv-card {
  margin-bottom: 14px; padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cv-card[hidden] { display: none; }

.cv-card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.cv-step {
  flex: 0 0 auto;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid rgba(74, 140, 255, .4);
  color: #bcd6ff; font-size: 12.5px; font-weight: 700;
}
.cv-card-note { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ============================ КНОПКИ ============================ */

.cv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  font: inherit; font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.cv-btn:hover { background: var(--panel-3); }
.cv-btn:disabled { opacity: .5; cursor: not-allowed; }
.cv-btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent-dark); color: #fff;
}
.cv-btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); }
.cv-btn-ghost { background: transparent; color: var(--text-dim); }
.cv-btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ============================ ФОРМА ============================ */

.cv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}
.cv-span2 { grid-column: span 2; }

.cv-field { display: block; min-width: 0; }
.cv-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.cv-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 14px;
  min-height: 38px;
}
.cv-input:focus { outline: 2px solid rgba(74, 140, 255, .55); outline-offset: 0; border-color: var(--accent); }
.cv-textarea { min-height: 62px; resize: vertical; }
select.cv-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.cv-input::-webkit-calendar-picker-indicator { filter: invert(.7); }

.cv-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.cv-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
.cv-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.cv-field-inline { flex: 1 1 200px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: var(--line); border-radius: 4px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent); border: 0; cursor: pointer;
}
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 0; cursor: pointer; }

/* ============================ ЗАГРУЗКА ============================ */

.cv-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 24px 14px;
  text-align: center;
  background: var(--bg);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cv-drop:hover, .cv-drop:focus { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.cv-drop.is-over { border-color: var(--teal); background: rgba(47, 208, 200, .1); }
.cv-drop-ico { font-size: 26px; color: var(--accent); line-height: 1; }
.cv-drop-title { margin: 0; font-weight: 600; }
.cv-drop-sub { margin: 0 0 4px; font-size: 12.5px; color: var(--muted); max-width: 52ch; }
.cv-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.cv-upload-error { margin: 10px 0 0; color: #ffc9c9; font-size: 13.5px; }
.cv-upload-error[hidden] { display: none; }

.cv-filelist { list-style: none; padding: 0; margin: 10px 0 0; }
.cv-filelist:empty { margin: 0; }
.cv-fileitem {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); font-size: 13px;
}
.cv-fileitem-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-fileitem-kind { color: var(--muted); font-size: 12px; }
.cv-fileitem-ok  { color: var(--ok); }
.cv-fileitem-bad { color: var(--bad); }
.cv-filelist .cv-btn-sm { padding: 3px 8px; font-size: 12px; }

.cv-frames { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.cv-frames[hidden] { display: none; }
.cv-frames-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cv-frames-tools { margin-left: auto; display: flex; gap: 6px; }

.cv-filmstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.cv-frame {
  position: relative; flex: 0 0 auto; width: 132px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
}
.cv-frame.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cv-frame.is-checked { border-color: rgba(53, 185, 138, .7); }
.cv-frame img { display: block; width: 100%; height: 84px; object-fit: cover; background: #000; }
.cv-frame-cap {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 7px; font-size: 11.5px; color: var(--text-dim);
}
.cv-frame-cap input { width: 14px; height: 14px; accent-color: var(--ok); cursor: pointer; margin: 0; }
.cv-frame-cap b { font-weight: 600; }
.cv-frame-num {
  position: absolute; top: 4px; left: 4px;
  padding: 1px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, .68); color: #fff; font-size: 10.5px;
}
.cv-frame-bad { position: absolute; top: 4px; right: 4px; padding: 1px 5px; border-radius: 4px; background: rgba(239, 91, 91, .9); color: #2a0808; font-size: 10.5px; font-weight: 700; }

/* ============================ ХОД АНАЛИЗА ============================ */

.cv-runbar { display: flex; align-items: center; gap: 10px; }
.cv-progress { flex: 1 1 auto; height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.cv-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent) 0%, var(--teal) 100%); transition: width .2s linear; }
.cv-progress-num { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.cv-run-status { margin: 8px 0 0; font-size: 13.5px; color: var(--text-dim); }
.cv-run-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.cv-runlog { list-style: none; padding: 0; margin: 12px 0 0; max-height: 230px; overflow-y: auto; }
.cv-runlog:empty { margin: 0; }
.cv-runlog li {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 6px 2px; font-size: 13px;
  border-top: 1px solid var(--line-soft);
}
.cv-runlog li:first-child { border-top: 0; }
.cv-runlog-ico { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.cv-runlog-ico.is-ok   { background: rgba(53, 185, 138, .18); color: var(--ok); }
.cv-runlog-ico.is-bad  { background: rgba(239, 91, 91, .18);  color: var(--bad); }
.cv-runlog-ico.is-info { background: var(--accent-soft);       color: #9dc0ff; }
.cv-runlog-txt { min-width: 0; }
.cv-runlog-time { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ============================ ПРОСМОТР И РАЗМЕТКА ============================ */

.cv-viewer-wrap { position: relative; text-align: center; }
.cv-viewer {
  position: relative;
  display: none;
  width: auto;                 /* контейжёр подстраивается ровно под картинку,
                                 чтобы координаты оверлея совпадали с пикселями */
  max-width: 100%;
  line-height: 0;
  background: #050a14;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cv-viewer.is-on { display: inline-block; }
.cv-viewer-img { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; }

.cv-viewer-svg {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;   /* оверлей не перехватывает клики по интерфейсу */
  overflow: visible;
}
.cv-viewer-svg .cv-rect {
  pointer-events: all;   /* сами прямоугольники дефектов — кликабельны */
  cursor: pointer;
}
.cv-viewer-empty { margin: 16px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.cv-viewer-empty[hidden] { display: none; }
.cv-viewer.is-on + .cv-viewer-empty { display: none; }

.cv-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); justify-content: center; }
.cv-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cv-legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 2px solid rgba(255, 255, 255, .25); }

.cv-desc {
  margin: 0 0 12px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text-dim);
}

/* ============================ ДЕФЕКТЫ ============================ */

.cv-defects { list-style: none; padding: 0; }
.cv-defect {
  margin-bottom: 10px; padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sev-insignificant);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cv-defect.is-sel { background: var(--panel-3); box-shadow: 0 0 0 1px var(--accent); }
.cv-defect.sev-insignificant { border-left-color: var(--sev-insignificant); }
.cv-defect.sev-minor         { border-left-color: var(--sev-minor); }
.cv-defect.sev-significant   { border-left-color: var(--sev-significant); }
.cv-defect.sev-critical      { border-left-color: var(--sev-critical); }

.cv-defect-head { display: flex; align-items: flex-start; gap: 9px; flex-wrap: wrap; }
.cv-defect-num {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #08101f;
}
.cv-defect-name { font-weight: 650; font-size: 14.5px; min-width: 0; }
.cv-defect-el   { color: var(--muted); font-size: 12.5px; }
.cv-defect-tags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.cv-tag {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line); color: var(--text-dim); background: var(--bg);
  white-space: nowrap;
}
.cv-tag-origin-prod { color: #ffce8a; border-color: rgba(240, 165, 58, .5); background: rgba(240, 165, 58, .12); }
.cv-tag-origin-oper { color: #9dc0ff; border-color: rgba(74, 140, 255, .5); background: rgba(74, 140, 255, .12); }
.cv-tag-origin-mix  { color: #b8e6e2; border-color: rgba(47, 208, 200, .5); background: rgba(47, 208, 200, .12); }
.cv-tag-frames      { color: var(--muted); }
.cv-tag-demo        { color: #ffce8a; border-color: rgba(240, 165, 58, .5); background: rgba(240, 165, 58, .12); font-weight: 700; letter-spacing: .5px; }

.cv-defect-comment { margin: 9px 0 0; font-size: 13.5px; color: var(--text-dim); }

.cv-prob { margin-top: 11px; display: grid; gap: 7px; }
.cv-prob-row { display: grid; grid-template-columns: 152px 1fr 62px; align-items: center; gap: 9px; }
.cv-prob-label { font-size: 12.5px; color: var(--text-dim); }
.cv-prob-track { display: block; height: 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.cv-prob-fill  { display: block; height: 100%; width: 0%; border-radius: 999px; transition: width .3s ease; }
.cv-prob-fill.is-prod { background: linear-gradient(90deg, #f0a53a 0%, #f7c46f 100%); }
.cv-prob-fill.is-oper { background: linear-gradient(90deg, #4a8cff 0%, #7fb0ff 100%); }
.cv-prob-val { font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; color: var(--text); }

.cv-why { margin-top: 10px; }
.cv-why-btn {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.cv-why-btn::before { content: "▸ "; }
.cv-why-btn.is-open::before { content: "▾ "; }
.cv-why-body {
  display: none; margin-top: 7px; padding: 9px 11px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dim);
}
.cv-why-body.is-open { display: block; }

.cv-empty {
  margin: 10px 0; padding: 16px;
  text-align: center; color: var(--muted);
  background: var(--panel-2); border: 1px dashed var(--line); border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.cv-empty[hidden] { display: none; }

/* ============================ СТОИМОСТЬ ============================ */

.cv-cost-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; }

.cv-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 420px; }
.cv-table th, .cv-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.cv-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: lowercase; }
.cv-table td.num, .cv-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-table tbody tr:hover { background: var(--panel-2); }
.cv-table .cv-td-sub { color: var(--muted); font-size: 12px; }

.cv-total { margin-top: 12px; padding: 12px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.cv-total-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13.5px; color: var(--text-dim); }
.cv-total-row b { font-variant-numeric: tabular-nums; }
.cv-total-row-main { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 16px; color: var(--text); font-weight: 650; }
.cv-total-row-main b { color: var(--teal); font-size: 20px; }
.cv-total p { margin: 6px 0 0; font-size: 12px; }

.cv-warn { margin: 10px 0 0; color: #ffc9c9; font-size: 13.5px; }
.cv-warn[hidden] { display: none; }

/* ============================ ТЕОРИЯ ============================ */

.cv-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cv-search { position: relative; flex: 1 1 240px; display: block; }
.cv-search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.cv-search-input {
  width: 100%; padding: 9px 10px 9px 30px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 14px; min-height: 38px;
}
.cv-search-input:focus { outline: 2px solid rgba(74, 140, 255, .55); border-color: var(--accent); }
.cv-toolbar-info { font-size: 12.5px; color: var(--muted); }

.cv-intro {
  margin-bottom: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13.5px; color: var(--text-dim);
}
.cv-intro:empty { display: none; }

.cv-acc { display: flex; flex-direction: column; gap: 8px; }
.cv-acc-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cv-acc-item[hidden] { display: none; }
.cv-acc-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px;
  background: none; border: 0; color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
}
.cv-acc-head:hover { background: var(--panel-2); }
.cv-acc-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: var(--accent-soft); color: #bcd6ff; border: 1px solid rgba(74, 140, 255, .35);
}
.cv-acc-min { margin-left: auto; flex: 0 0 auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.cv-acc-caret { flex: 0 0 auto; color: var(--muted); font-size: 12px; transition: transform .18s; }
.cv-acc-item.is-open .cv-acc-caret { transform: rotate(90deg); }
.cv-acc-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--line-soft); padding-top: 12px; font-size: 14px; color: var(--text-dim); }
.cv-acc-item.is-open .cv-acc-body { display: block; }

.cv-block { margin: 0 0 10px; }
.cv-block-text { margin: 0 0 10px; text-align: justify; }
.cv-block-list { margin: 0 0 10px; }
.cv-block-list li { margin-bottom: 4px; }
.cv-block-note {
  margin: 0 0 10px; padding: 9px 12px;
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13.5px;
}
.cv-block-formula {
  margin: 0 0 10px; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; color: #cfe0ff;
  overflow-x: auto; white-space: pre-wrap;
}
.cv-block-table { overflow-x: auto; margin: 0 0 10px; }
.cv-block-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cv-block-table th, .cv-block-table td { padding: 6px 8px; border: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.cv-block-table th { background: var(--panel-2); color: var(--text-dim); font-weight: 600; }

.cv-quiz { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.cv-quiz-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .6px; }
.cv-quiz-item { margin-bottom: 10px; }
.cv-quiz-q { font-size: 13.5px; margin-bottom: 5px; }
.cv-quiz-opts { display: flex; flex-direction: column; gap: 4px; }
.cv-quiz-opt {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 5px 8px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); cursor: pointer;
}
.cv-quiz-opt input { margin: 2px 0 0; accent-color: var(--accent); }
.cv-quiz-opt.is-ok { border-color: rgba(53, 185, 138, .65); background: rgba(53, 185, 138, .1); }
.cv-quiz-opt.is-bad { border-color: rgba(239, 91, 91, .6); background: rgba(239, 91, 91, .1); }
.cv-quiz-res { font-size: 12.5px; color: var(--ok); margin-top: 4px; }
.cv-quiz-res.is-bad { color: var(--bad); }

/* ============================ ДЕМО ============================ */

.cv-demo-banner {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 14px;
  background: rgba(240, 165, 58, .1);
  border: 1px solid rgba(240, 165, 58, .45);
  border-radius: var(--radius);
}
.cv-demo-banner-text { margin: 0; font-size: 13.5px; color: #ffce8a; }
.cv-demo-tag {
  display: inline-block; padding: 3px 9px; border-radius: 5px;
  background: rgba(240, 165, 58, .18); border: 1px solid rgba(240, 165, 58, .6);
  color: #ffce8a; font-size: 11.5px; font-weight: 700; letter-spacing: 1px;
}
.cv-demo-tag-lg { font-size: 13px; padding: 5px 12px; }

.cv-demo-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px; }
.cv-demo-canvas-box, .cv-demo-flow {
  padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.cv-demo-canvas {
  display: block; width: 100%; height: auto; margin-top: 10px;
  background: #050a14; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}

.cv-steps { list-style: none; padding: 0; margin: 10px 0 0; counter-reset: dst; }
.cv-steps li {
  position: relative;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0 7px 4px; font-size: 13.5px; color: var(--muted);
  border-left: 2px solid var(--line); margin-left: 10px;
}
.cv-steps li.is-done { color: var(--ok); border-left-color: var(--ok); }
.cv-steps li.is-active { color: var(--text); border-left-color: var(--accent); font-weight: 600; }
.cv-steps li:first-child { padding-top: 0; }
.cv-steps li:last-child { border-left-color: transparent; }
.cv-steps-ico {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; margin-left: -13px; margin-top: 2px;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.cv-steps li.is-done .cv-steps-ico { background: rgba(53, 185, 138, .2); border-color: var(--ok); color: var(--ok); }
.cv-steps li.is-active .cv-steps-ico { background: var(--accent-soft); border-color: var(--accent); color: #bcd6ff; }
.cv-steps-note { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

.cv-demo-log {
  margin: 12px 0 0; padding: 9px 11px; min-height: 40px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-dim); font-family: "SFMono-Regular", Consolas, monospace;
}

.cv-demo-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 9px 12px;
  background: rgba(240, 165, 58, .1);
  border: 1px solid rgba(240, 165, 58, .45);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.cv-demo-strip[hidden] { display: none; }
.cv-demo-strip-step { font-weight: 700; color: #ffce8a; }
.cv-demo-strip-log  { color: var(--text-dim); min-width: 0; flex: 1 1 auto; }
.cv-demo-strip .cv-btn { margin-left: auto; }

/* ============================ ИНСТРУКЦИЯ ============================ */

.cv-instr-sec { margin-bottom: 14px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.cv-instr-list { list-style: none; padding: 0; counter-reset: st; }
.cv-instr-list li {
  position: relative; counter-increment: st;
  padding: 8px 0 8px 34px; font-size: 14px; color: var(--text-dim);
  border-bottom: 1px solid var(--line-soft);
}
.cv-instr-list li:last-child { border-bottom: 0; }
.cv-instr-list li::before {
  content: counter(st); position: absolute; left: 0; top: 9px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); border: 1px solid rgba(74, 140, 255, .35); color: #bcd6ff;
}
.cv-instr-list b { color: var(--text); }

.cv-hotkeys { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.cv-hotkey { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-dim); }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 2px 6px; border-radius: 5px;
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px;
  font-family: inherit; font-size: 12px; color: var(--text);
}

.cv-faq-item { margin-bottom: 8px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.cv-faq-q {
  display: block; width: 100%; padding: 10px 12px;
  background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  text-align: left; cursor: pointer;
}
.cv-faq-a { display: none; padding: 0 12px 11px; font-size: 13.5px; color: var(--text-dim); }
.cv-faq-item.is-open .cv-faq-a { display: block; }
.cv-faq-item.is-open .cv-faq-q { color: var(--accent); }

.cv-checks { margin: 0; padding: 0; list-style: none; }
.cv-checks li { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 13.5px; color: var(--text-dim); border-bottom: 1px solid var(--line-soft); }
.cv-checks li:last-child { border-bottom: 0; }
.cv-checks li::before { content: "☐"; color: var(--muted); line-height: 1.3; }

.cv-glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.cv-gloss { padding: 9px 11px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.cv-gloss-term { font-weight: 650; font-size: 13.5px; }
.cv-gloss-def  { font-size: 12.5px; color: var(--muted); }

/* ============================ ОТЧЁТ ============================ */

.cv-report { margin: 4px 0 18px; overflow-x: auto; }
.cv-report[hidden] { display: none; }
.cv-report-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.cv-report-bar-title { font-weight: 600; font-size: 14px; }
.cv-report-bar-spacer { flex: 1 1 auto; }

.cv-report-sheet {
  padding: 26px 28px;
  background: #fff; color: #111;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px; line-height: 1.6;
}
.cv-report-sheet h1 { font-size: 20px; margin: 0 0 4px; }
.cv-report-sheet h2 { font-size: 16px; margin: 18px 0 6px; }
.cv-report-sheet h3 { font-size: 14.5px; margin: 14px 0 5px; }
.cv-report-sheet p  { margin: 0 0 8px; }
.cv-report-sheet table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; }
.cv-report-sheet th, .cv-report-sheet td { border: 1px solid #999; padding: 5px 7px; text-align: left; vertical-align: top; }
.cv-report-sheet th { background: #ececec; }
.cv-report-sheet ul, .cv-report-sheet ol { margin: 0 0 10px; padding-left: 1.3em; }
.cv-report-sheet .cv-sign { margin-top: 26px; display: flex; gap: 40px; flex-wrap: wrap; font-size: 13px; }
.cv-report-sheet .cv-sign div { min-width: 200px; }
.cv-report-sheet .cv-sign-line { border-bottom: 1px solid #333; height: 26px; margin-bottom: 3px; }
.cv-report-sheet .cv-stamp {
  display: inline-block; margin: 6px 0; padding: 3px 9px;
  border: 1px solid #b06a00; color: #8a5200; border-radius: 4px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
}

/* ============================ ПОДВАЛ ============================ */

.cv-foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); }
.cv-foot p { margin: 0 0 3px; }

/* ============================ АДАПТИВ ============================ */

@media (max-width: 900px) {
  .cv-demo-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .cv-app { padding: 10px 9px 30px; }
  .cv-grid { grid-template-columns: minmax(0, 1fr); }
  .cv-span2 { grid-column: span 1; }
  .cv-head { padding: 12px; }
  .cv-title { font-size: 17px; }
  .cv-subtitle { font-size: 11.5px; }
  .cv-head-side { width: 100%; }
  .cv-tabs { border-radius: var(--radius); }
  .cv-tab { padding: 9px 11px; font-size: 13px; }
  .cv-card { padding: 11px; }
  .cv-card-note { margin-left: 0; width: 100%; }
  .cv-prob-row { grid-template-columns: 110px 1fr 52px; }
  .cv-report-sheet { padding: 16px 14px; }
  .cv-cost-controls { gap: 10px; }
  .cv-field-inline { flex: 1 1 100%; }
}

@media (max-width: 420px) {
  body { font-size: 14.5px; }
  .cv-app { padding: 8px 7px 24px; }
  .cv-logo { width: 38px; height: 38px; font-size: 14px; border-radius: 9px; }
  .cv-title { font-size: 15.5px; }
  .cv-subtitle { display: none; }
  .cv-tab { padding: 8px 9px; font-size: 12.5px; }
  .cv-h2 { font-size: 18px; }
  .cv-btn { padding: 8px 13px; font-size: 13.5px; }
  .cv-run-actions .cv-btn { flex: 1 1 100%; }
  .cv-prob-row { grid-template-columns: 92px 1fr 46px; gap: 6px; }
  .cv-frame { width: 108px; }
  .cv-frame img { height: 68px; }
  .cv-audio-title { font-size: 12.5px; }
  .cv-demo-tag { font-size: 10.5px; }
  .cv-report-bar .cv-btn { flex: 1 1 100%; }
}

/* ============================ ПЕЧАТЬ: ТОЛЬКО ОТЧЁТ ============================ */

@media print {
  @page { size: A4; margin: 16mm 14mm; }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.45;
  }

  /* печатается ТОЛЬКО заключение */
  body * { visibility: hidden !important; }
  #report-panel, #report-panel * { visibility: visible !important; }

  #report-panel {
    display: block !important;
    position: absolute !important;
    left: 0; top: 0; right: 0;
    width: 100%;
    margin: 0; padding: 0;
    overflow: visible !important;
  }

  .no-print, .cv-report-bar { display: none !important; }

  .cv-report-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .cv-report-sheet h1 { font-size: 15pt; }
  .cv-report-sheet h2 { font-size: 13pt; page-break-after: avoid; }
  .cv-report-sheet h3 { font-size: 12pt; page-break-after: avoid; }
  .cv-report-sheet table { page-break-inside: avoid; }
  .cv-report-sheet tr, .cv-report-sheet .cv-sign { page-break-inside: avoid; }
  .cv-report-sheet a { color: #000 !important; text-decoration: none; }
}
