/* ── NBU pulse ────────────────────────────────────────────────────────────── */
@keyframes nbu-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}
.nbu-pulse {
  animation: nbu-pulse 1.2s ease-in-out infinite;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  background: #f4f6f9;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* ── Editor layout ─────────────────────────────────────────────────────────── */
.editor-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-section {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 8px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

.form-label-sm {
  font-size: 11px;
  color: #6c757d;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  display: block;
  margin-bottom: 3px;
}

/* ── Summary section ──────────────────────────────────────────────────────── */
.summary-section {
  background: linear-gradient(135deg, #e8f4fd 0%, #f0f9ff 100%);
  border-color: #b8d9f0;
}

.summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-card {
  background: #fff;
  border: 1px solid #cce5ff;
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 150px;
  flex: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.summary-label {
  font-size: 10px;
  color: #6c757d;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .4px;
  margin-bottom: 4px;
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
  color: #1a3d5c;
}

.summary-sub {
  font-size: 12px;
  color: #868e96;
  margin-top: 2px;
}

/* Margin color classes: >35% dark-green | 20-35% green | 15-20% orange | <15% red */
.margin-great  { background: #b8dfc4 !important; border-color: #8fcba3 !important; }
.margin-good   { background: #d4edda !important; border-color: #c3e6cb !important; }
.margin-ok     { background: #ffe5cc !important; border-color: #ffd5a8 !important; }
.margin-bad    { background: #f8d7da !important; border-color: #f5c6cb !important; }

.margin-great .summary-value { color: #0a3d1f; }
.margin-good  .summary-value { color: #155724; }
.margin-ok    .summary-value { color: #7d4000; }
.margin-bad   .summary-value { color: #721c24; }

.text-margin-great { color: #0a6b2c !important; }
.text-margin-good  { color: #28a745 !important; }
.text-margin-ok    { color: #fd7e14 !important; }
.text-margin-bad   { color: #dc3545 !important; }

/* ── By-type breakdown ──────────────────────────────────────────────────────── */
.by-type-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.by-type-card {
  flex: 1;
  min-width: 160px;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid #dee2e6;
}

.by-type-label {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.by-type-row {
  display: flex;
  justify-content: space-between;
  color: #495057;
}

.type-ОА  { background: #deeaf1; border-color: #b8d4e8; }
.type-ОП  { background: #e2efda; border-color: #c6e0b4; }
.type-ДО  { background: #e8e0f7; border-color: #c5b3ef; }
.type-ДОП { background: #fde8f4; border-color: #f0b8de; }
.type-ММ  { background: #fff2cc; border-color: #ffe699; }
.type-Р   { background: #fce4d6; border-color: #f4b183; }

/* ── Component table ──────────────────────────────────────────────────────── */
.type-header-ОА  { background: #deeaf1; border-radius: 4px; padding: 6px 10px; border-bottom: none; }
.type-header-ОП  { background: #e2efda; border-radius: 4px; padding: 6px 10px; border-bottom: none; }
.type-header-ДО  { background: #e8e0f7; border-radius: 4px; padding: 6px 10px; border-bottom: none; }
.type-header-ДОП { background: #fde8f4; border-radius: 4px; padding: 6px 10px; border-bottom: none; }
.type-header-ММ  { background: #fff2cc; border-radius: 4px; padding: 6px 10px; border-bottom: none; }
.type-header-Р   { background: #fce4d6; border-radius: 4px; padding: 6px 10px; border-bottom: none; }

.comp-table {
  font-size: 12px;
  border-collapse: collapse;
}

.comp-table thead th {
  background: #f8f9fa;
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: .2px;
  padding: 5px 6px;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

.comp-table tbody td {
  padding: 4px 6px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

.comp-table tfoot td {
  padding: 6px 6px;
  border-top: 2px solid #dee2e6;
}

.comp-table .form-control-sm {
  font-size: 12px;
  padding: 2px 6px;
  height: 26px;
}

.coef-row td {
  background: #fffbf0;
  padding-top: 2px !important;
  border-bottom: 1px solid #ffe5a0 !important;
}

.btn-xs {
  padding: 1px 5px;
  font-size: 12px;
  border: none;
  background: none;
  cursor: pointer;
}

.btn-xs:hover { opacity: 0.7; }

/* ── Drag-and-drop ────────────────────────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: #ccc;
  width: 18px;
  padding: 4px 2px !important;
  user-select: none;
}
.drag-handle:hover { color: #888; }
.drag-handle:active { cursor: grabbing; }

/* Row being dragged — applied via JS classList */
tr.dragging { opacity: 0.35; }

/* Drop target: insert before — top border */
tr.drag-over td {
  border-top: 2px solid #0d6efd !important;
}

/* Drop target: drop INTO subgroup — bottom border + subtle tint */
tr.drag-into td {
  border-bottom: 2px solid #0d6efd !important;
  background: rgba(13, 110, 253, 0.06) !important;
}

/* Subgroup "Додати" button */
.btn-subgroup-add {
  font-size: 11px;
  padding: 1px 8px;
  border: 1px solid #adb5bd;
  border-radius: 4px;
  background: #fff;
  color: #495057;
  cursor: pointer;
  white-space: nowrap;
}
.btn-subgroup-add:hover {
  background: #e9ecef;
  border-color: #6c757d;
}

/* Lift the focused section above its siblings so autocomplete dropdowns render on top */
.editor-section:focus-within {
  position: relative;
  z-index: 10;
}

/* ── Autocomplete dropdown ────────────────────────────────────────────────── */
.ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 320px;
  max-width: 480px;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #0d6efd;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  z-index: 9999;
}

.ac-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: #e8f4fd; }

.ac-name {
  font-size: 12px;
  font-weight: 600;
  color: #1a3d5c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-meta {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #6c757d;
  margin-top: 1px;
}
.ac-article {
  font-family: monospace;
  font-size: 11px;
  color: #495057;
}
.ac-price {
  margin-left: auto;
  font-weight: 700;
  color: #0d6efd;
}

/* ── Financial table ─────────────────────────────────────────────────────── */
.fin-table {
  font-size: 12px;
}

.fin-table td input {
  width: 80px;
}

/* ── Projects list ──────────────────────────────────────────────────────── */
.projects-table {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.projects-table tbody tr:hover {
  background: #e8f4fd;
}

/* ── Editor footer ──────────────────────────────────────────────────────── */
.editor-footer {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  bottom: 12px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.1);
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.badge.bg-info { font-size: 11px; }

/* ── Bundle header row ──────────────────────────────────────────────────────── */
.bundle-header-row td {
  background: #ede9fe !important;
  border-bottom: 1px solid #c4b5fd !important;
}

/* Bundle item sub-rows */
.bundle-item-row td {
  background: #f5f3ff !important;
  border-bottom: 1px dashed #ddd6fe !important;
  padding: 3px 6px !important;
  font-size: 11px;
}

/* ── Stage tabs ──────────────────────────────────────────────────────────── */
.stage-tab {
  min-width: 64px;
  font-weight: 600;
  letter-spacing: .3px;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}

.stage-tab[disabled] {
  opacity: .35;
  pointer-events: none;
}

/* Faded look for disabled fieldset controls */
fieldset[disabled] input,
fieldset[disabled] select,
fieldset[disabled] textarea {
  background: #f0f3f6 !important;
  color: #6c757d !important;
  border-color: #dee2e6 !important;
  cursor: default;
}

@media (max-width: 768px) {
  .editor-container { padding: 8px; }
  .summary-grid { flex-direction: column; }
  .by-type-grid { flex-direction: column; }
}
