/* main.css — стили проекта v4.0.2 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #ffffff; color: #222; font-family: 'Courier New', monospace; min-height: 100vh; }
header { padding: 12px 16px; background: #f5f5f5; border-bottom: 1px solid #ddd; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
header h1 { font-size: 14px; color: #c00; letter-spacing: 2px; text-transform: uppercase; }
.tab-bar { display: flex; background: #f0f0f0; border-bottom: 2px solid #ddd; }
.tab-btn { padding: 8px 22px; font-size: 14px; font-family: 'Courier New', monospace; letter-spacing: 1px; text-transform: uppercase; border: none; border-bottom: 3px solid transparent; background: transparent; cursor: pointer; color: #000; margin-bottom: -2px; transition: all 0.15s; }
.tab-btn:hover { color: #c00; }
.tab-btn.active { color: #c00; border-bottom-color: #c00; font-weight: bold; background: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.controls { padding: 8px 16px; background: #f5f5f5; border-bottom: 1px solid #ddd; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button { background: #e8e8e8; border: 1px solid #c00; color: #000; padding: 6px 12px; font-size: 14px; font-family: 'Courier New', monospace; cursor: pointer; border-radius: 3px; letter-spacing: 1px; text-transform: uppercase; transition: background 0.2s; }
button:hover, button.active { background: #CCC; color: #fff; }
.zoom-info { font-size: 14px; color: #000; margin-left: auto; }
.canvas-wrap { overflow: auto; width: 100%; height: calc(100vh - 115px); cursor: grab; background: #ffffff; }
.canvas-wrap:active { cursor: grabbing; }
svg { display: block; }
.legend { position: fixed; bottom: 16px; right: 16px; background: #f5f5f5; border: 1px solid #000; border-radius: 6px; padding: 10px 14px; font-size: 14px; line-height: 1.8; z-index: 50; }
.legend-title { color: #c00; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; color: #000; }
.leg-line { width: 24px; height: 3px; }
.leg-rect { width: 14px; height: 14px; border-radius: 2px; border: 2px solid; flex-shrink: 0; }
#tooltip { position: fixed; background: #fff; border: 1px solid #c00; padding: 6px 10px; font-size: 14px; font-family: 'Courier New', monospace; border-radius: 4px; pointer-events: none; display: none; z-index: 100; line-height: 1.6; }
.profile-wrap { padding: 24px; height: calc(100vh - 115px); overflow: hidden; background: #fff; display: flex; flex-direction: column; padding-bottom: 0; }
.profile-scroll { overflow: auto; flex: 1; cursor: grab; }
.profile-scroll:active { cursor: grabbing; }
.profile-wrap h2 { font-size: 16px; color: #c00; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.profile-wrap p { font-size: 14px; color: #000; margin-bottom: 20px; }


/* ─── Редактор опор (sidebar) ───────────────────────────────────────── */
.profile-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.profile-main .profile-scroll {
  flex: 1;
  min-width: 0;
}

.editor-sidebar {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
  background: #fff;
  border-left: 2px solid #000;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.editor-sidebar.open {
  width: 340px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Заголовок панели */
.ed-title {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: #000;
  background: #f0f0f0;
  border-bottom: 2px solid #000;
  position: sticky;
  top: 0;
  z-index: 2;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Глобальный зазор */
.ed-global {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #000;
  background: #fffbe6;
}
.ed-global-label {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  color: #000;
  flex: 1;
}

/* Заголовок таблицы */
.ed-header {
  display: grid;
  grid-template-columns: 32px 60px 1fr 1fr;
  gap: 4px;
  align-items: center;
  padding: 6px 10px;
  background: #000;
  color: #fff;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: sticky;
  top: 47px;
  z-index: 1;
}

/* Строка опоры */
.ed-row {
  display: grid;
  grid-template-columns: 32px 60px 1fr 1fr;
  gap: 4px;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 1px solid #ddd;
  min-height: 34px;
}
.ed-row:hover { background: #fff8e0; }

/* Номер опоры */
.ed-post-num {
  font-size: 15px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: #000;
  text-align: center;
}

/* Якорная метка */
.ed-anchor-tag {
  font-size: 14px;
  color: #c00;
  text-align: center;
}

/* Фиксированное значение якорной опоры */
.ed-fixed {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  color: #000;
  text-align: center;
}

/* Значение (anchor) */
.ed-val {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  color: #000;
  text-align: center;
}

/* Поле ввода числа */
.ed-num {
  width: 100%;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  border: 1px solid #000;
  border-radius: 2px;
  padding: 3px 5px;
  text-align: right;
  background: #fff;
  color: #000;
}
.ed-num:focus {
  outline: 2px solid #c00;
  border-color: #c00;
}
.ed-num:disabled {
  background: #eee;
  color: #888;
  border-color: #ccc;
  cursor: not-allowed;
}

/* Выпадающий список стороны */
.ed-select {
  width: 100%;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  border: 1px solid #000;
  border-radius: 2px;
  padding: 3px 2px;
  background: #fff;
  color: #000;
  cursor: pointer;
  text-align: center;
}
.ed-select:focus { outline: 2px solid #c00; }

/* Единица измерения */
.ed-unit {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  color: #000;
}

/* Кнопка Сохранить в редакторе */
.ed-save-row {
  padding: 12px 10px;
  border-top: 2px solid #000;
}
.ed-save-btn {
  width: 100%;
  background: #000;
  color: #fff;
  border: none;
  padding: 10px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 3px;
  text-transform: uppercase;
}
.ed-save-btn:hover { background: #333; }

/* Ошибки валидации в редакторе */
.ed-row-error { background: #ffe0e0; outline: 1px solid #c00; }
.ed-error-msg {
  margin: 8px 10px;
  padding: 8px 10px;
  background: #fff0f0;
  border-left: 3px solid #c00;
  color: #c00;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
}

/* === Блок выравнивания опор === */
.ed-align-row {
  margin: 10px 0 6px 0;
  padding: 8px 10px;
  background: #f0f4ff;
  border: 1px solid #c0cce8;
  border-radius: 4px;
}
.ed-align-label {
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 6px;
  color: #333;
}
.ed-align-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.ed-align-controls select {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid #aaa;
  border-radius: 3px;
}
.ed-align-btn {
  margin-left: 6px;
  padding: 3px 10px;
  font-size: 12px;
  background: #4a7fd4;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
.ed-align-btn:hover { background: #2f5fa8; }

.ed-delete-btn { background: #c0392b; }
.ed-delete-btn:hover { background: #922b21; }

/* === Панель Сохранить/Загрузить/Сброс === */
.db-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.db-btn {
  padding: 4px 12px;
  font-size: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
}
.db-save  { background: #2a7a2a; color: #fff; }
.db-save:hover  { background: #1e5c1e; }
.db-load  { background: #4a7fd4; color: #fff; }
.db-load:hover  { background: #2f5fa8; }
.db-reset { background: #888; color: #fff; }
.db-reset:hover { background: #555; }
.db-status {
  font-size: 11px;
  font-family: 'Courier New', monospace;
  margin-left: 6px;
}
.db-download { background: #5c3d8f; color: #fff; }
.db-download:hover { background: #3d2760; }
.db-upload { background: #2a6a7a; color: #fff; cursor: pointer; }
.db-upload:hover { background: #1e4f5c; }

/* === Вкладка «Расчёт» === */
.calc-wrap { padding: 24px; height: calc(100vh - 115px); overflow: auto; background: #fff; }
.calc-wrap h2 { font-size: 16px; color: #c00; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.calc-wrap p { font-size: 13px; color: #555; margin-bottom: 16px; max-width: 720px; }

.calc-params {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 10px 14px; margin-bottom: 20px;
  background: #fffbe6; border: 1px solid #e0d090; border-radius: 4px;
}
.calc-params label { font-size: 12px; color: #555; display: flex; align-items: center; gap: 6px; }
.calc-params-group {
  font-size: 12px; color: #555; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e0d090; border-radius: 3px; padding: 4px 8px;
}
.calc-params-group input[type="number"] { width: 48px; }
.calc-params input[type="number"] {
  width: 64px; font-size: 13px; font-family: 'Courier New', monospace;
  border: 1px solid #000; border-radius: 3px; padding: 4px 6px; text-align: right;
}

.calc-columns { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.calc-col { flex: 1; min-width: 300px; }

.calc-block-title {
  font-size: 13px; font-weight: bold; color: #000; letter-spacing: 1px;
  text-transform: uppercase; margin: 18px 0 8px 0; padding-bottom: 4px;
  border-bottom: 2px solid #000;
}
.calc-block-title:first-child { margin-top: 0; }

.calc-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.calc-table th {
  background: #000; color: #fff; text-align: left; padding: 6px 10px;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
}
.calc-table td { padding: 5px 10px; border-bottom: 1px solid #ddd; }
.calc-row-gate td { background: #fff0f0; }

.calc-gate-tag { color: #c00; font-weight: bold; font-size: 12px; }
.calc-ok-tag { color: #2a7a2a; font-size: 12px; }

.calc-summary {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;
}
.calc-summary-item {
  background: #f0f7f0; border: 1px solid #a0d0a0; border-radius: 4px;
  padding: 6px 10px; font-size: 12px; color: #333;
}
.calc-summary-item b { color: #2a7a2a; font-size: 14px; }
.calc-summary-buy { background: #fff0e0; border-color: #e0a060; }
.calc-summary-buy b { color: #b05a00; }
.calc-summary-ok { background: #e6f5e6; border-color: #7ac07a; }
.calc-summary-ok b { color: #1e6b1e; }

.calc-cutlist-title { font-size: 12px; color: #888; margin-bottom: 4px; }
.calc-cutlist { list-style: decimal; padding-left: 22px; font-size: 12px; color: #333; margin-bottom: 4px; }
.calc-cutlist li { padding: 2px 0; border-bottom: 1px dashed #eee; }

.calc-hint { font-size: 12px; color: #888; margin-bottom: 10px; }
.calc-warn {
  font-size: 12px; color: #c00; background: #fff0f0; border-left: 3px solid #c00;
  padding: 6px 10px; margin: 8px 0;
}

.calc-gate-add {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.calc-gate-add select {
  font-size: 12px; font-family: 'Courier New', monospace;
  border: 1px solid #000; border-radius: 3px; padding: 4px 6px;
}

.calc-gate-card {
  border: 1px solid #ccc; border-radius: 4px; padding: 10px 12px; margin-bottom: 14px; background: #fafafa;
}
.calc-gate-card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.calc-gate-label {
  font-size: 13px; font-family: 'Courier New', monospace; font-weight: bold;
  border: 1px solid #999; border-radius: 3px; padding: 3px 6px; flex: 1; min-width: 140px;
}
.calc-gate-span-tag {
  font-size: 12px; color: #7a5c00; background: #fff5d6; border: 1px solid #e0c060;
  border-radius: 3px; padding: 2px 8px;
}
.calc-gate-type {
  font-size: 12px; font-family: 'Courier New', monospace;
  border: 1px solid #999; border-radius: 3px; padding: 3px 6px;
}
.calc-import-badge {
  font-size: 12px; color: #1e4f5c; background: #e6f3f7; border: 1px solid #7ab8cc;
  border-radius: 3px; padding: 6px 10px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.calc-import-btn {
  display: inline-block; font-size: 11px; padding: 4px 10px; text-transform: none; letter-spacing: 0;
  background: #2a6a7a; color: #fff; border-radius: 3px; cursor: pointer;
}
.calc-import-btn:hover { background: #1e4f5c; }
.calc-gate-del, .calc-seg-del {
  background: #c0392b; color: #fff; border: none; border-radius: 3px;
  font-size: 11px; padding: 4px 8px; cursor: pointer; text-transform: none; letter-spacing: 0;
}
.calc-gate-del:hover, .calc-seg-del:hover { background: #922b21; }
.calc-seg-del { padding: 2px 8px; }

.calc-seg-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 6px; }
.calc-seg-table th { text-align: left; color: #888; font-weight: normal; padding: 3px 6px; border-bottom: 1px solid #ccc; }
.calc-seg-table td { padding: 3px 6px; }
.calc-seg-table input[type="number"] {
  width: 72px; font-size: 12px; font-family: 'Courier New', monospace;
  border: 1px solid #999; border-radius: 3px; padding: 3px 5px; text-align: right;
}
.calc-seg-add {
  font-size: 11px; padding: 4px 10px; text-transform: none; letter-spacing: 0;
  background: #4a7fd4; color: #fff; border: none; border-radius: 3px; cursor: pointer;
}
.calc-seg-add:hover { background: #2f5fa8; }
