:root {
  --bg: #120e12;
  --bg-soft: #191217;
  --surface: #211821;
  --surface-2: #2b1d29;
  --surface-3: #342332;
  --field: #151015;
  --line: #4a3544;
  --line-soft: #362734;
  --text: #f6efe6;
  --muted: #c6b5a6;
  --muted-2: #9f8b80;
  --gold: #d7b46a;
  --gold-soft: #f1dba5;
  --rose: #d89aa5;
  --plum: #5a263f;
  --moss: #89a38d;
  --danger: #e78b82;
  --success: #a8c99a;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(215, 180, 106, 0.08) 0%, transparent 32%),
    linear-gradient(180deg, #1b1118 0%, var(--bg) 44%, #0f0d0f 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

h1 {
  margin: 20px;
  font-size: 28px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0;
}

.kpi-bar {
  margin: 0 20px 8px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.kpi {
  background: linear-gradient(180deg, rgba(43, 29, 41, 0.96), rgba(31, 23, 31, 0.98));
  border: 1px solid rgba(215, 180, 106, 0.28);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 220px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--gold-soft);
}

.kpi-delta {
  font-size: 12px;
  margin-top: 2px;
}

.kpi-delta.up {
  color: var(--success);
}

.kpi-delta.down {
  color: var(--danger);
}

.layout {
  display: flex;
  gap: 24px;
  padding: 0 20px 30px;
}

.panel {
  flex: 0 0 360px;
  background: rgba(33, 24, 33, 0.96);
  border: 1px solid rgba(215, 180, 106, 0.22);
  border-radius: 8px;
  padding: 16px;
  position: -webkit-sticky;
  position: sticky;
  top: 120px;
  align-self: flex-start;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.panel h3 {
  margin: 12px 0 6px;
  color: var(--gold-soft);
  font-size: 16px;
  font-weight: 600;
}

.panel .panel-val {
  color: var(--text);
  font-weight: 600;
}

.cell-pct {
  color: var(--muted-2);
  font-weight: normal;
  font-size: 12px;
}

label {
  display: block;
  font-size: 13px;
  margin-top: 10px;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--gold);
}

.full-input {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-sizing: border-box;
}

select {
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="number"],
input[type="text"] {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  outline: 1px solid var(--gold);
  border-color: var(--gold);
}

.season-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.season-row input {
  width: 2.2em;
  padding: 4px 2px;
  font-size: 12px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-sizing: border-box;
}

.money-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 4px;
}

.money-row input {
  width: 100%;
  min-width: 0;
  padding: 5px 4px;
  font-size: 12px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-sizing: border-box;
}

.fact-panel {
  border: 1px solid rgba(215, 180, 106, 0.24);
  border-radius: 8px;
  padding: 8px;
  margin: 8px 0 14px;
  background: rgba(21, 16, 21, 0.72);
}

.fact-panel summary {
  cursor: pointer;
  color: var(--gold-soft);
  font-weight: 600;
  font-size: 13px;
}

.fact-subtitle {
  color: var(--muted-2);
  font-size: 11px;
  margin: 10px 0 4px;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.fact-grid label {
  margin: 0;
  min-width: 0;
  font-size: 11px;
}

.fact-grid input {
  width: 100%;
  min-width: 0;
  padding: 5px 4px;
  margin-top: 3px;
  font-size: 12px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-sizing: border-box;
}

hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 14px 0;
}

.content-wrap {
  flex: 1;
  background: rgba(25, 18, 23, 0.82);
  border: 1px solid rgba(215, 180, 106, 0.18);
  border-radius: 8px;
  padding: 16px;
  min-width: 0; /* важно, чтобы горизонтальный скролл был внутри таблицы, а не у всей страницы */
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

.table-wrap {
  background: transparent;
  border-radius: 12px;
  padding: 0;
  overflow-x: auto;
}

.charts-wrap {
  padding: 0 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.chart-card {
  flex: 0 0 calc(50% - 10px);
  min-width: 320px;
  height: 260px;
  background: linear-gradient(180deg, rgba(43, 29, 41, 0.96), rgba(24, 18, 24, 0.98));
  border: 1px solid rgba(215, 180, 106, 0.2);
  border-radius: 8px;
  padding: 12px;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(246, 239, 230, 0.04);
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 20px 12px;
}

.tab-button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid rgba(215, 180, 106, 0.48);
  background: rgba(33, 24, 33, 0.9);
  color: var(--gold-soft);
  font-size: 14px;
  cursor: pointer;
}

.tab-button.tab-active {
  background: var(--gold);
  color: #1d1411;
  border-color: var(--gold);
}

.tab-content {
  display: none;
}

.tab-content-active {
  display: block;
}

.bottom-wrap {
  padding: 0 20px 16px;
}

.scenario-compare,
.sensitivity-wrap {
  margin-bottom: 12px;
}

.sensitivity-analysis {
  padding: 4px 0 16px;
}

.sensitivity-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.sensitivity-header h3 {
  margin: 0 0 6px;
  color: var(--gold-soft);
  font-size: 18px;
  font-weight: 600;
}

.sensitivity-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 720px;
}

.sensitivity-kpi {
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 180, 106, 0.28);
  border-radius: 8px;
  background: rgba(33, 24, 33, 0.82);
  text-align: right;
}

.sensitivity-kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.sensitivity-kpi strong {
  color: var(--gold-soft);
  font-size: 18px;
}

#sensitivityAnalysisTable th:nth-child(3),
#sensitivityAnalysisTable td:nth-child(3) {
  min-width: 180px;
}

#sensitivityAnalysisTable th:nth-child(6),
#sensitivityAnalysisTable td:nth-child(6),
#sensitivityAnalysisTable th:nth-child(7),
#sensitivityAnalysisTable td:nth-child(7) {
  min-width: 120px;
}

.sensitivity-input {
  width: 150px;
  padding: 6px 8px;
  text-align: right;
  box-sizing: border-box;
}

.sens-positive {
  color: var(--success);
  font-weight: 700;
}

.sens-negative {
  color: var(--danger);
  font-weight: 700;
}

.sens-neutral {
  color: var(--muted);
}

.sens-rank {
  color: var(--gold-soft);
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: rgba(24, 18, 24, 0.7);
}

th, td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
  min-width: 260px;
}

thead th {
  background: #2b1d29;
  font-weight: 600;
  color: var(--gold-soft);
}

.subsection td {
  background: #241a22;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  padding-top: 8px;
}

td.nb-over-limit {
  background: rgba(176, 86, 77, 0.22) !important;
  color: #ffd0c8 !important;
  font-weight: 700;
}

td.cash-negative {
  background: rgba(176, 86, 77, 0.22) !important;
  color: #ffd0c8 !important;
  font-weight: 700;
}

.section td {
  background: #3a2535;
  font-weight: 700;
  color: var(--text);
}

.total td {
  font-weight: 700;
  color: var(--text);
}

.panel p[style],
.table-wrap span[style] {
  color: var(--muted) !important;
}

.chart-card h3,
.scenario-compare h3,
.sensitivity-wrap h3 {
  color: var(--gold-soft) !important;
}

#scenarioTable,
#sensitivityTable {
  background: var(--surface) !important;
  border: 1px solid rgba(215, 180, 106, 0.18);
}

#scenarioTable thead tr,
#sensitivityTable thead tr {
  background: #2b1d29 !important;
}

#scenarioTable th,
#sensitivityTable th {
  color: var(--gold-soft) !important;
}

#scenarioTable td,
#sensitivityTable td {
  border-bottom-color: var(--line-soft) !important;
  color: var(--text);
}

.model-error {
  background: rgba(176, 86, 77, 0.18) !important;
  border-color: rgba(231, 139, 130, 0.55) !important;
  color: #ffd0c8 !important;
}

button[style] {
  background: #3a2535 !important;
  color: var(--gold-soft) !important;
  border: 1px solid rgba(215, 180, 106, 0.35) !important;
  border-radius: 6px !important;
}

input[style] {
  background: var(--field) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #171116;
}

::-webkit-scrollbar-thumb {
  background: #5d403f;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

@media print {
  .panel, .no-print, button { display: none !important; }
  .layout { display: block; }
  .table-wrap { overflow: visible; }
  table { font-size: 11px; }
  body { background: #fff; color: #000; }
  th, td { color: #000 !important; border-color: #333 !important; }
  .section td { background: #eee !important; color: #000 !important; }
  .total td { color: #000 !important; }
  td.nb-over-limit { background: #ffdddd !important; color: #990000 !important; }
  td.cash-negative { background: #ffdddd !important; color: #990000 !important; }
}
