.page--calc {
  max-width: 1460px;
  margin: 0 auto;
  padding: 20px 22px 44px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.calc-head__left h1 { margin: 6px 0 4px; font-size: clamp(22px, 2.5vw, 30px); }
.calc-head__sub { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 780px; }
.calc-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.calc-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

.dc-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
.dc-source-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dc-source-card.is-dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dc-source-card.is-loaded { border-color: color-mix(in srgb, var(--src-color, var(--accent)) 45%, var(--border)); }

.dc-src-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dc-src-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.dc-src-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--src-color, var(--accent));
}
.dc-src-name {
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-size: 13.5px; font-weight: 650; padding: 2px 6px; border-radius: 6px; min-width: 0; width: 100%;
}
.dc-src-name:hover, .dc-src-name:focus { border-color: var(--border); background: var(--surface); outline: none; }

.dc-src-meta { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.dc-src-status {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted); background: var(--surface); white-space: nowrap;
}
.dc-src-status.is-ok { color: #10b981; border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.12); }
.dc-src-status.is-err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.dc-src-remove {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  display: inline-grid; place-items: center; font-size: 15px; line-height: 1;
}
.dc-src-remove:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

.dc-url-row { display: flex; gap: 6px; align-items: center; }
.dc-url-row .input { flex: 1 1 auto; min-width: 0; font-size: 12.5px; padding: 6px 9px; }

.dc-drop-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 8px; border: 1px dashed var(--border-strong);
  background: var(--surface); font-size: 12px; color: var(--text-muted);
}
.dc-drop-row__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-file-input { display: none; }

.dc-src-selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dc-src-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dc-src-field label { font-size: 11px; font-weight: 650; color: var(--text-muted); }
.dc-combo { display: flex; flex-direction: column; gap: 4px; }
.dc-combo .input, .dc-combo .select { font-size: 12.5px; padding: 5px 8px; width: 100%; min-width: 0; }
.dc-src-error {
  font-size: 12px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 6px; padding: 6px 8px;
}
.dc-src-error[hidden] { display: none; }

.dc-cond-body { display: flex; flex-direction: column; gap: 10px; }
.dc-presets-row { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr) auto; gap: 12px; align-items: end; }
.dc-custom-labels[hidden] { display: none; }
.dc-custom-labels__pair { display: flex; gap: 6px; }
.dc-custom-labels__pair .input { width: 118px; font-size: 12.5px; padding: 6px 8px; }
.dc-formula-hint {
  font-family: var(--mono, Consolas, monospace);
  font-size: 11.5px; color: var(--text-muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 7px; padding: 6px 10px;
}
.dc-cond-grid { display: grid; grid-template-columns: minmax(240px, 1.3fr) minmax(200px, 1fr) auto auto; gap: 12px; align-items: end; }
.dc-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dc-check-row {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  min-height: 36px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); font-size: 12.5px;
}
.dc-check-row .check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; margin: 0; }
.dc-compare-btn { min-height: 38px; padding: 0 22px; font-weight: 700; font-size: 13.5px; white-space: nowrap; }

.dc-results-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dc-show-cols-wrap { display: inline-flex; align-items: center; gap: 6px; }
.dc-toolbar-label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.dc-show-cols-wrap .ms__control { min-width: 190px; max-width: 260px; }
.dc-search-input { width: 185px; padding: 5px 9px; font-size: 12.5px; }
.dc-filter-select { width: auto; min-width: 145px; padding: 5px 9px; font-size: 12.5px; }

.dc-stats-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dc-stat-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
}
.dc-stat-pill:hover, .dc-stat-pill.is-active { border-color: var(--accent); background: var(--accent-soft); }
.dc-stat-pill__num { font-weight: 750; font-variant-numeric: tabular-nums; }

.dc-empty-state { text-align: center; padding: 36px 16px; border: 1px dashed var(--border); border-radius: 10px; background: var(--bg-soft); }
.dc-empty-state__title { margin: 0 0 6px; font-size: 15px; font-weight: 700; }

.dc-table-wrap { width: 100%; max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.dc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dc-table th {
  position: sticky; top: 0; z-index: 3; background: var(--bg-soft);
  border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; font-weight: 700; white-space: nowrap;
}
.dc-table td {
  padding: 7px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  vertical-align: top; max-width: 280px; overflow-wrap: anywhere;
}
.dc-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.dc-src-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; color: #fff; margin-right: 5px; vertical-align: middle; }
.dc-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.dc-badge--matched { color: #10b981; background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.35); }
.dc-badge--partial { color: #f59e0b; background: rgba(245, 158, 11, 0.14); border: 1px solid rgba(245, 158, 11, 0.35); }
.dc-badge--only { color: #ef4444; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.35); }
.dc-badge--diff { color: #a855f7; background: rgba(168, 85, 247, 0.14); border: 1px solid rgba(168, 85, 247, 0.35); }

.dc-cell-missing { color: var(--text-faint); font-style: italic; }
.dc-cell-diff { background: rgba(245, 158, 11, 0.12) !important; font-weight: 600; }
.dc-cell-num { font-variant-numeric: tabular-nums; }

@media (max-width: 1020px) {
  .dc-presets-row { grid-template-columns: 1fr 1fr; }
  .dc-cond-grid { grid-template-columns: 1fr 1fr; }
  .dc-field--cta { grid-column: 1 / -1; }
  .dc-compare-btn { width: 100%; }
}
@media (max-width: 640px) {
  .page--calc { padding: 14px 12px 32px; }
  .dc-sources-grid, .dc-presets-row, .dc-cond-grid, .dc-src-selectors { grid-template-columns: 1fr; }
  .dc-search-input { width: 100%; }
}
