:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202124;
  background: #f7f8fa;
  font-size: 14px;
  --border: #d9dde3;
  --muted: #667085;
  --brand: #126c57;
  --brand-hover: #0b5745;
  --focus: #2e72d2;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 76px; padding: 14px 24px; color: white; background: #20282f;
}
h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0; }
.topbar p { margin: 5px 0 0; color: #c7ced5; }
.export-actions { display: flex; gap: 8px; }

main { padding: 18px 24px 28px; }
.view-tabs {
  display: flex; gap: 2px; margin: -4px 0 16px; border-bottom: 1px solid var(--border);
}
.view-tabs button {
  min-height: 42px; padding: 8px 14px; color: var(--muted); background: transparent;
  border: 0; border-bottom: 3px solid transparent; font-weight: 650;
}
.view-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.app-view[hidden] { display: none; }
.dashboard {
  margin-bottom: 18px; padding: 0 0 18px; background: white;
  border: 1px solid var(--border); border-radius: 7px;
}
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 58px; padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
#dashboard-content[hidden] { display: none; }
.kpi-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}
.kpi {
  min-width: 0; min-height: 84px; padding: 14px;
  border-right: 1px solid var(--border); background: #f8fafb;
}
.kpi:last-child { border-right: 0; }
.kpi span { display: block; min-height: 30px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.kpi strong { display: block; margin-top: 5px; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi.risk { background: #fef3f2; }
.kpi.risk strong { color: var(--danger); }
.kpi.warning { background: #fffaeb; }
.kpi.warning strong { color: #b54708; }
.analytics-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0; padding: 0 14px;
}
.chart-panel { min-width: 0; padding: 16px 0; border-bottom: 1px solid #e9ecf0; }
.chart-wide { grid-column: 1 / -1; }
.chart-wide + .chart-panel { padding-right: 18px; border-right: 1px solid #e9ecf0; }
.chart-wide + .chart-panel + .chart-panel { padding-left: 18px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chart-head h3 { margin: 0; font-size: 13px; }
.chart-head span { color: var(--muted); font-size: 11px; }
.chart-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 22px; }
.chart-list.compact { grid-template-columns: 1fr; }
.chart-row { min-width: 0; }
.chart-label {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 5px; color: #344054; font-size: 11px;
}
.chart-label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-label strong { flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums; }
.bar-track { position: relative; height: 8px; overflow: hidden; border-radius: 3px; background: #eef1f4; }
.bar-track.thin { height: 4px; }
.bar { display: block; height: 100%; border-radius: inherit; }
.bar.budget { background: #1f8f70; }
.bar.risk { background: #d92d20; }
.risk-line { display: grid; grid-template-columns: minmax(80px, 1fr) auto; align-items: center; gap: 8px; margin-top: 4px; }
.risk-line > span { color: var(--danger); font-size: 10px; font-variant-numeric: tabular-nums; }
.manager-list { display: grid; gap: 8px; }
.manager-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(80px, 1.4fr) 36px; align-items: center; gap: 9px; }
.manager-name { overflow: hidden; color: #344054; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.score-track { height: 7px; overflow: hidden; border-radius: 3px; background: #eef1f4; }
.score-track span { display: block; height: 100%; border-radius: inherit; background: #2e72d2; }
.manager-row strong { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-empty { margin: 20px 0; color: var(--muted); font-size: 12px; }
.filters {
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 150px minmax(220px, 1.5fr);
  gap: 12px; margin-bottom: 16px;
}
label { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; color: #202124; background: white;
  border: 1px solid var(--border); border-radius: 6px; outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 3px #2e72d226; }

.button { min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 6px; font-weight: 650; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-hover); }
.button.secondary { color: #202124; background: white; border-color: var(--border); }
.button:disabled { cursor: not-allowed; opacity: .48; }

.notice { margin-bottom: 12px; padding: 10px 12px; border-left: 3px solid var(--brand); background: #eaf6f1; }
.notice.error { border-color: var(--danger); color: var(--danger); background: #fef3f2; }
.table-region { max-height: min(66vh, 760px); overflow: auto; background: white; border: 1px solid var(--border); border-radius: 7px; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #e9ecf0; vertical-align: middle; overflow-wrap: anywhere; }
th { position: sticky; top: 0; z-index: 2; color: #475467; background: #f2f4f7; font-size: 12px; font-weight: 650; }
th:nth-child(1) { width: 21%; } th:nth-child(2) { width: 15%; } th:nth-child(3) { width: 15%; }
th:nth-child(4) { width: 15%; } th:nth-child(5) { width: 11%; } th:nth-child(6), th:nth-child(7) { width: 9%; }
th:last-child { width: 50px; }
th button { width: 100%; padding: 0; text-align: inherit; color: inherit; background: none; border: 0; font-weight: inherit; }
th button.sorted::after { content: " ↓"; }
th button.sorted.asc::after { content: " ↑"; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8fafb; }
.deal-link {
  display: -webkit-box; overflow: hidden; color: #155eef; font-weight: 600; text-decoration: none;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.deal-link:hover { text-decoration: underline; }
.pipeline-tag, .stage-tag, .age-badge {
  display: inline-block; max-width: 100%; padding: 3px 7px; border-radius: 5px;
  overflow: hidden; font-size: 11px; line-height: 1.35; text-overflow: ellipsis;
}
.pipeline-tag { white-space: nowrap; }
.pipeline-zarya { color: #026aa2; background: #e0f2fe; }
.pipeline-imperator { color: #5b21b6; background: #ede9fe; }
.pipeline-repeat { color: #15803d; background: #dcfce7; }
.pipeline-moscow { color: #a16207; background: #fef3c7; }
.pipeline-project { color: #be185d; background: #ffe4e6; }
.pipeline-other { color: #344054; background: #eef1f4; }
.stage-tag { color: #344054; background: #f2f4f7; white-space: normal; }
.age-badge { min-width: 61px; text-align: center; color: #344054; background: #f2f4f7; font-weight: 650; white-space: nowrap; }
.age-badge.fresh { color: #11734b; background: #dcfae6; }
.age-badge.warning { color: #7a5b00; background: #fef7c3; }
.age-badge.risk { color: #b54708; background: #ffead5; }
.age-badge.critical { color: #b42318; background: #fee4e2; }
.budget-cell {
  background-image: linear-gradient(90deg, #d1fadf var(--budget-fill), transparent var(--budget-fill));
  background-size: 100% 58%; background-position: center; background-repeat: no-repeat;
}
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.row-action, .icon-button { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 6px; color: #344054; background: white; font-size: 20px; line-height: 1; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }

.success-view { display: grid; gap: 16px; }
.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 2px 0 4px;
}
.view-head h2 { margin: 0; font-size: 19px; }
.view-head p { max-width: 760px; margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.scope-badge {
  flex: 0 0 auto; padding: 5px 8px; color: #166534; background: #dcfce7;
  border: 1px solid #86efac; border-radius: 5px; font-size: 11px; font-weight: 750;
}
.success-filters {
  grid-template-columns: 105px 105px repeat(3, minmax(170px, 1fr)); margin: 0;
  padding: 12px; background: white; border: 1px solid var(--border); border-radius: 7px;
}
.success-kpis {
  overflow: hidden; background: white; border: 1px solid var(--border); border-radius: 7px;
}
.kpi.success { background: #f7fcf9; }
.kpi.success strong { color: #166534; }
.success-grid {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 12px;
}
.analysis-panel {
  min-width: 0; padding: 14px; background: white; border: 1px solid var(--border);
  border-radius: 7px;
}
.analysis-panel .chart-head { align-items: flex-start; }
.analysis-panel .chart-head h3 { margin-bottom: 4px; font-size: 14px; }
.analysis-panel .chart-head span { display: block; max-width: 720px; line-height: 1.4; }
/* оговорка про охват: фильтры сверху применяются не ко всем блокам */
.chart-head .scope-note { margin-top: 4px; font-style: italic; opacity: 0.85; }
.factors-panel { grid-row: span 2; }
.factor-list { display: grid; }
.factor-row {
  display: grid; grid-template-columns: minmax(180px, 1fr) 125px 82px; align-items: center;
  gap: 12px; min-height: 58px; padding: 9px 0; border-top: 1px solid #e9ecf0;
}
.factor-row:first-child { border-top: 0; }
.factor-main, .factor-effect { min-width: 0; }
.factor-main strong, .factor-main span, .factor-effect strong, .factor-effect span { display: block; }
.factor-main strong { overflow: hidden; color: #344054; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.factor-main span, .factor-effect span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.factor-effect { text-align: right; font-variant-numeric: tabular-nums; }
.factor-row.positive .factor-effect strong { color: #15803d; }
.factor-row.negative .factor-effect strong { color: #b54708; }
.reliability {
  padding: 4px 6px; text-align: center; border-radius: 4px; font-size: 10px; font-weight: 700;
}
.reliability.high { color: #166534; background: #dcfce7; }
.reliability.medium { color: #92400e; background: #fef3c7; }
.reliability.low { color: #475467; background: #eef1f4; }
.benchmark-list { display: grid; gap: 10px; }
.benchmark-row { padding-top: 10px; border-top: 1px solid #e9ecf0; }
.benchmark-row:first-child { padding-top: 0; border-top: 0; }
.benchmark-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.benchmark-head strong { font-size: 12px; }
.benchmark-head span { color: var(--muted); font-size: 10px; text-align: right; }
.benchmark-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.benchmark-metric { min-width: 0; padding: 7px; background: #f7f9fa; border-left: 2px solid #4ade80; }
.benchmark-metric span, .benchmark-metric strong, .benchmark-metric small { display: block; }
.benchmark-metric span { min-height: 27px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.benchmark-metric strong { margin-top: 2px; color: #166534; font-size: 13px; }
.benchmark-metric small { margin-top: 3px; color: #667085; font-size: 9px; }
.stage-benchmark-list { display: grid; gap: 9px; }
.stage-benchmark .bar-track { height: 7px; }
.stage-benchmark .bar { position: absolute; left: 0; top: 0; }
.stage-benchmark .success-p90 { background: #fed7aa; }
.stage-benchmark .success-median { height: 7px; background: #22c55e; }
.metric-guide {
  background: white; border: 1px solid var(--border); border-left: 3px solid #f59e0b;
  border-radius: 6px;
}
.metric-guide summary { padding: 11px 13px; color: #344054; cursor: pointer; font-weight: 650; }
.guide-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
  border-top: 1px solid var(--border);
}
.guide-grid p { margin: 0; padding: 12px; color: #475467; font-size: 11px; line-height: 1.45; border-right: 1px solid #e9ecf0; border-bottom: 1px solid #e9ecf0; }
.guide-grid p:nth-child(3n) { border-right: 0; }
.guide-grid p:nth-last-child(-n+3) { border-bottom: 0; }
.success-table-region { max-height: min(54vh, 640px); }
.success-table { min-width: 1240px; }
.success-table th:nth-child(1) { width: 19%; }
.success-table th:nth-child(2) { width: 9%; }
.success-table th:nth-child(3) { width: 14%; }
.success-table th:nth-child(4) { width: 13%; }
.success-table th:nth-child(5) { width: 11%; }
.success-table th:nth-child(6), .success-table th:nth-child(7), .success-table th:nth-child(8) { width: 8%; }
.success-table th:nth-child(9) { width: 10%; }
.quality-badge {
  display: inline-block; padding: 3px 6px; border-radius: 4px; font-size: 10px; font-weight: 700;
}
.quality-badge.complete { color: #166534; background: #dcfce7; }
.quality-badge.limited { color: #92400e; background: #fef3c7; }

dialog { width: min(520px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 80px #10182842; }
dialog::backdrop { background: #10182880; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.segments { display: grid; grid-template-columns: repeat(3, 1fr); padding: 12px 20px 0; }
.segments button { min-height: 36px; color: var(--muted); background: white; border: 0; border-bottom: 2px solid var(--border); }
.segments button.active { color: var(--brand); border-color: var(--brand); font-weight: 650; }
.dialog-panel { display: none; gap: 14px; padding: 20px; }
.dialog-panel.active { display: grid; }
.crm-link { display: block; margin: 0 20px 20px; color: #155eef; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .success-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .success-grid { grid-template-columns: 1fr; }
  .factors-panel { grid-row: auto; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .export-actions { flex-direction: column; }
  main { padding: 14px 12px 22px; }
  .analytics-grid { grid-template-columns: 1fr; }
  .chart-panel, .chart-wide, .chart-wide + .chart-panel, .chart-wide + .chart-panel + .chart-panel {
    grid-column: 1; padding: 14px 0; border-right: 0;
  }
  .chart-list { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-label { grid-column: 1 / -1; }
  .success-filters { grid-template-columns: 1fr 1fr; }
  .benchmark-metrics { grid-template-columns: 1fr 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-grid p, .guide-grid p:nth-child(3n), .guide-grid p:nth-last-child(-n+3) {
    border-right: 0; border-bottom: 1px solid #e9ecf0;
  }
  .guide-grid p:last-child { border-bottom: 0; }
}

@media (max-width: 460px) {
  .topbar { display: grid; }
  .export-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-last-child(-n+2) { border-bottom: 0; }
  .filters { grid-template-columns: 1fr; }
  .search-label { grid-column: auto; }
  .view-tabs button { flex: 1; padding-inline: 8px; }
  .success-filters { grid-template-columns: 1fr; }
  .factor-row { grid-template-columns: minmax(0, 1fr) 105px; }
  .factor-row .reliability { grid-column: 1 / -1; justify-self: start; }
}

/* ROP rescue control workspace. Data rendering and interaction are provided by rop-dashboard.js. */
.rop-view { min-width: 0; font-size: 12px; }
.rop-view-head, .rop-section-heading, .rop-table-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.rop-view-head { margin-bottom: 8px; }
.rop-view-head h2, .rop-section-heading h3, .rop-table-heading h3 { margin: 0; font-size: 14px; }
.rop-view-head p, .rop-section-heading p, .rop-table-heading p {
  margin: 2px 0 0; color: var(--muted); font-size: 10px; line-height: 1.3;
}
.rop-health { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.rop-health i { width: 8px; height: 8px; border-radius: 50%; background: #d0d5dd; }
.rop-health.green i { background: #15945f; }
.rop-health.yellow i { background: #d8a30b; }
.rop-health.red i, .rop-health.error i { background: #d92d20; }
.rop-top-grid {
  display: grid; grid-template-columns: 264px 264px minmax(360px, 1fr); gap: 12px; align-items: stretch;
  margin-bottom: 10px;
}
.rop-summary-band, .rop-period-panel, .rop-leader-card {
  min-width: 0; border: 1px solid var(--border); border-radius: 7px; background: white;
}
.rop-summary-band { min-height: 142px; padding: 10px; }
.rop-risk-band { border-color: #e4bbb6; background: #fff8f7; }
.rop-rescued-band { border-color: #abd7bc; background: #f3fbf6; }
.rop-summary-heading { display: flex; align-items: center; gap: 7px; min-height: 26px; }
.rop-summary-heading h3 { margin: 0; font-size: 12px; line-height: 1.25; }
.rop-risk-band h3 { color: #9d3028; }
.rop-rescued-band h3 { color: #087443; }
.rop-risk-marker, .rop-rescued-mark, .rop-heart-live, .rop-deal-state { position: relative; display: inline-grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; }
.rop-risk-marker { border: 2px solid #a44840; border-radius: 12px 12px 3px 3px; background: #f2dfdc; }
.rop-risk-marker::before, .rop-risk-marker::after { position: absolute; content: ""; background: #a44840; }
.rop-risk-marker::before { width: 10px; height: 2px; top: 7px; }
.rop-risk-marker::after { width: 2px; height: 10px; top: 3px; }
.rop-rescued-mark { border: 2px solid #329a68; border-radius: 50%; background: #dff3e7; }
.rop-rescued-mark::after { width: 11px; height: 6px; border-bottom: 2px solid #087443; border-left: 2px solid #087443; content: ""; transform: translateY(-1px) rotate(-45deg); }
.rop-heart-live { color: #c23855; font-family: Georgia, serif; font-size: 25px; line-height: 1; }
.rop-heart-live::before { content: "\2665"; }
.rop-summary-values { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 7px; margin-top: 9px; }
.rop-rescued-values { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rop-summary-values div { min-width: 0; padding-right: 7px; border-right: 1px solid #e6d0cd; }
.rop-summary-values div:last-child { padding-right: 0; border-right: 0; }
.rop-rescued-values div { border-color: #d0e8d8; }
.rop-summary-values span { display: block; min-height: 23px; color: var(--muted); font-size: 9px; line-height: 1.25; }
.rop-summary-values strong { display: block; margin-top: 3px; color: #9d3028; font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.05; overflow-wrap: anywhere; }
.rop-summary-values div:first-child strong { font-size: 23px; }
.rop-rescued-values strong { color: #087443; font-size: 14px; }
.rop-rescued-values div:first-child strong { font-size: 22px; }
.rop-summary-band > p { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.3; }
.rop-period-panel { display: grid; grid-template-rows: auto 1fr auto; min-height: 142px; padding: 10px; }
.rop-period-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rop-period-heading h3 { margin: 0; font-size: 13px; }
.rop-period-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.3; }
.rop-period-mode { display: inline-flex; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.rop-period-mode button { min-width: 62px; height: 26px; padding: 0 7px; color: #475467; border: 0; border-right: 1px solid var(--border); background: white; font-size: 9px; font-weight: 650; }
.rop-period-mode button:last-child { border-right: 0; }
.rop-period-mode button.active, .rop-period-mode button[aria-pressed="true"] { color: white; background: var(--brand); }
.rop-period-mode button:focus-visible { position: relative; z-index: 1; outline: 3px solid #9ec5fe; outline-offset: -2px; }
.rop-period-figure { margin: 0; }
.rop-period-chart { display: grid; grid-template-columns: repeat(52, minmax(3px, 1fr)); align-items: end; gap: 2px; min-height: 48px; margin-top: 8px; }
.rop-period-chart span { min-height: 8px; border-radius: 2px 2px 0 0; background: #d9dde3; }
.rop-period-chart .period-risk { background: #dc8179; }
.rop-period-chart .period-reviving { background: #72bfa0; }
.rop-period-chart .period-rescued { background: #16815e; }
.rop-period-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 9px; }
.rop-period-legend span { display: inline-flex; align-items: center; gap: 4px; }
.rop-period-legend i { width: 8px; height: 8px; border-radius: 2px; background: #d9dde3; }
.rop-period-legend i.risk { background: #dc8179; }
.rop-period-legend i.reviving { background: #72bfa0; }
.rop-period-legend i.rescued { background: #16815e; }
.rop-leaders-section { margin-bottom: 10px; }
.rop-section-heading { margin-bottom: 5px; }
.rop-leader-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rop-leader-card { min-height: 132px; padding: 10px; }
.rop-leader-card h4 { margin: 0; color: #344054; font-size: 11px; line-height: 1.25; }
.rop-leader-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 0; }
.rop-leader-metrics div { min-width: 0; }
.rop-leader-metrics dt { color: var(--muted); font-size: 9px; line-height: 1.25; overflow-wrap: anywhere; }
.rop-leader-metrics dd { margin: 2px 0 0; color: #087443; font-size: 13px; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.rop-filters { margin-bottom: 8px; }
.rop-filters select, .rop-filters input { min-height: 32px; padding-block: 5px; font-size: 11px; }
.rop-table-region { max-height: none; margin-bottom: 0; overflow: hidden; }
.rop-table-region > .table-wrap {
  max-width: 100%; max-height: min(58vh, 680px); overflow: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.rop-table-heading { position: sticky; left: 0; padding: 8px 10px; border-bottom: 1px solid var(--border); background: white; }
.rop-deals-table { width: 100%; min-width: 1420px; table-layout: fixed; font-size: 11px; }
.rop-deals-table th, .rop-deals-table td { padding: 7px 8px; }
.rop-deals-table th { position: sticky; top: 0; z-index: 2; white-space: normal; }
.rop-deals-table th span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; line-height: 1.25; }
.rop-sort-button { padding: 0; color: inherit; border: 0; background: transparent; font-weight: inherit; text-align: left; }
.rop-sort-button-secondary { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 500; }
.rop-sort-button:focus-visible { outline: 3px solid #9ec5fe; outline-offset: 2px; }
.rop-deals-table th:nth-child(1), .rop-deals-table td:nth-child(1) { width: 29ch; min-width: 29ch; }
.rop-deals-table th:nth-child(2), .rop-deals-table td:nth-child(2) { width: 20ch; min-width: 20ch; }
.rop-deals-table th:nth-child(3), .rop-deals-table td:nth-child(3) { width: 22ch; min-width: 22ch; }
.rop-deals-table th:nth-child(4), .rop-deals-table td:nth-child(4) { width: 16ch; min-width: 16ch; }
.rop-deals-table th:nth-child(5), .rop-deals-table td:nth-child(5) { width: 28ch; min-width: 28ch; }
.rop-deals-table th:nth-child(6), .rop-deals-table td:nth-child(6) { width: 19ch; min-width: 19ch; }
.rop-deals-table th:nth-child(7), .rop-deals-table td:nth-child(7) { width: 16ch; min-width: 16ch; }
.rop-deals-table th:nth-child(8), .rop-deals-table td:nth-child(8) { width: 19ch; min-width: 19ch; }
.rop-deals-table td { line-height: 1.25; overflow-wrap: anywhere; white-space: normal; vertical-align: top; }
.rop-deals-table th:not(:last-child), .rop-deals-table td:not(:last-child) { border-right: 1px solid #e9ecf0; }
.rop-deals-table td > span, .rop-deals-table td > strong { display: block; }
.rop-deals-table td > strong + span, .rop-deals-table td > span + span { margin-top: 2px; }
.rop-deals-table td > .button {
  width: 100%; min-height: 34px; margin-top: 4px; padding: 5px 7px; font-size: 10px; line-height: 1.2; white-space: normal;
}
.rop-placeholder-row td { height: 68px; color: var(--muted); text-align: center; vertical-align: middle; }
.rop-deals-table tr.rescued, .rop-deals-table tr.won { box-shadow: inset 4px 0 #15945f; background: #f0fbf4; }
.rop-deal-state { border: 1px solid #c7ced6; border-radius: 4px; background: #f8fafb; }
.rop-deal-state.risk { border-color: #d99e97; background: #fbeae8; }
.rop-deal-state.risk::before, .rop-deal-state.risk::after { position: absolute; content: ""; background: #a44840; }
.rop-deal-state.risk::before { width: 9px; height: 13px; border-radius: 6px 6px 2px 2px; }
.rop-deal-state.risk::after { width: 7px; height: 2px; top: 7px; box-shadow: 0 4px 0 #a44840; }
.rop-deal-state.reviving { color: #c23855; border-color: #df96a8; background: #fff4f6; font-family: Georgia, serif; font-size: 23px; }
.rop-deal-state.reviving::before { content: "\2665"; }
.rop-deal-state.saved { border-color: #d8ac19; border-radius: 50%; background: #ffdb53; }
.rop-deal-state.saved::before { position: absolute; top: 8px; left: 7px; width: 3px; height: 3px; border-radius: 50%; background: #624400; box-shadow: 10px 0 #624400; content: ""; }
.rop-deal-state.saved::after { position: absolute; bottom: 6px; left: 8px; width: 10px; height: 5px; border-bottom: 2px solid #624400; border-radius: 0 0 10px 10px; content: ""; }
.rop-deals-table .rop-heart-live, .rop-deal-state.reviving { animation: rop-heartbeat 1.25s ease-in-out infinite; }
.rop-counting-value { animation: rop-count-in 0.9s ease-out both; }
@keyframes rop-heartbeat { 0%, 34%, 100% { transform: scale(1); } 12% { transform: scale(1.13); } 23% { transform: scale(.98); } }
@keyframes rop-count-in { from { opacity: .5; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.rop-deal-state.saved { animation: none; }
dialog.rop-history-dialog { width: min(480px, 100vw); height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border-radius: 0; }
.rop-history-dialog .dialog-head > div { display: grid; flex: 1; min-width: 0; gap: 6px; }
.rop-history-dialog .dialog-head h2, .rop-history-dialog .dialog-head p {
  min-width: 0; margin: 0; line-height: 1.35; overflow-wrap: anywhere;
}
.rop-history-body { padding: 16px 20px; }
.rop-history-events { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; line-height: 1.45; }
.rop-history-events li { display: grid; gap: 6px; min-width: 0; padding-bottom: 10px; border-bottom: 1px solid #e9ecf0; }
.rop-history-events strong, .rop-history-events span { display: block; min-width: 0; overflow-wrap: anywhere; }
.rop-history-event-meta { color: #667085; }
.rop-history-events li:last-child { padding-bottom: 0; border-bottom: 0; }

@media (max-width: 1040px) {
  .rop-top-grid { grid-template-columns: 264px 264px minmax(300px, 1fr); overflow-x: auto; padding-bottom: 2px; }
  .rop-period-panel { min-width: 300px; }
}

@media (max-width: 760px) {
  .rop-view-head, .rop-period-heading { display: grid; }
  .rop-top-grid { grid-template-columns: 1fr; overflow: visible; }
  .rop-summary-band, .rop-period-panel { min-width: 0; }
  .rop-period-mode { width: 100%; }
  .rop-period-mode button { flex: 1; min-width: 0; }
  .rop-leader-grid { grid-template-columns: 1fr; }
  .rop-table-region > .table-wrap { max-height: min(62vh, 680px); }
  .rop-deals-table th:first-child, .rop-deals-table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; }
  .rop-deals-table th:first-child { z-index: 3; }
  .rop-deals-table tr.rescued td:first-child, .rop-deals-table tr.won td:first-child { background: #f0fbf4; }
}

@media (prefers-reduced-motion: reduce) {
  .rop-heart-live,
  .rop-deal-state.reviving,
  .rop-counting-value { animation: none; }
}
