/* ========================================
   Онлайн калькулятор точки безубыточности
   ======================================== */

:root {
  --bg: #f8f6f2;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --accent: #2d5a27;
  --accent-light: #4a8c42;
  --accent-bg: #e8f0e6;
  --border: #e0ddd6;
  --revenue: #2d5a27;
  --variable: #6b4e9e;
  --total: #c44536;
  --profit: #2d5a27;
  --loss: #c44536;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
header {
  margin-bottom: 2.5rem;
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header-site-link {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.header-site-link:hover {
  color: var(--accent-light);
}

.header-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-tag {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.header-tag:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem 0;
}

.subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0;
}

/* Calculator */
.calculator {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 1.25rem 0;
}

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.field .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -0.2rem;
}

.field input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.2s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.field input::placeholder {
  color: #aaa;
}

/* Results */
.results {
  background: var(--accent-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.result-item {
  text-align: center;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.result-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Actions bar (share, export) */
.actions-bar {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
}

.action-group {
  flex: 1;
  min-width: 240px;
}

.action-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.link-copy-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.link-copy-wrap input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9f9f9;
}

.export-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* Scenarios comparison */
.scenarios-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8f9fc 0%, #f0f2f8 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.scenarios-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.scenarios-header h2 {
  margin: 0;
}

.scenarios-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 768px) {
  .scenarios-grid {
    grid-template-columns: 1fr;
  }
  .scenario-diff {
    order: 3;
  }
}

.scenario-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
}

.scenario-col h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.75rem 0;
}

.scenario-col .scenario-name {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.scenario-inputs {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.scenario-inputs .field-compact {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
}

.scenario-inputs .field-compact label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.scenario-inputs .field-compact input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.scenario-result {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.scenario-result .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.scenario-result .row strong {
  color: var(--text);
}

.scenario-result .val {
  color: var(--accent);
  font-weight: 600;
}

.copy-to-scenario {
  width: 100%;
  margin-top: 0.75rem;
}

.scenario-diff {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  min-width: 180px;
}

.scenario-diff h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem 0;
}

.scenario-diff .diff-row {
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.scenario-diff .diff-row strong {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.scenario-diff .diff-positive {
  color: var(--profit);
}

.scenario-diff .diff-negative {
  color: var(--loss);
}

/* Analysis */
.analysis {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.analysis ol {
  margin: 0;
  padding-left: 1.25rem;
}

.analysis li {
  margin-bottom: 0.75rem;
}

.analysis li:last-child {
  margin-bottom: 0;
}

.profit {
  color: var(--profit);
  font-weight: 600;
}

.loss {
  color: var(--loss);
  font-weight: 600;
}

.formula-box {
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-family: 'Manrope', monospace;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 1rem;
}

/* Chart */
.chart-container {
  height: 280px;
  margin: 2rem 0;
  position: relative;
}

/* Sensitivity analysis */
.sensitivity-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f7ef 0%, #e8f0e6 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sensitivity-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem 0;
}

.sensitivity-sliders {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-row label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.slider-row input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.15s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.reset-sliders {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.reset-sliders:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.sensitivity-results {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.sensitivity-output ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.25rem;
}

.sensitivity-output li {
  margin-bottom: 0.35rem;
}

.sensitivity-conclusion {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

/* Info section */
.info-section {
  margin-top: 2.5rem;
}

.info-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.info-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.4rem 0;
  color: var(--accent);
}

.info-section h3:first-of-type {
  margin-top: 1rem;
}

.info-section p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}

.info-section ul {
  margin: 0 0 1rem 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Article section */
.article-section {
  margin-top: 2.5rem;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.article-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1.5rem 0;
}

.article-section h2.article-h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 2rem 0 0.75rem 0;
}

.article-section h2.article-h3:first-of-type {
  margin-top: 1rem;
}

.article-section h3.article-h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.5rem 0;
}

.article-section p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}

.article-section ul {
  margin: 0 0 1rem 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.formula-block {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-family: 'Manrope', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent);
  margin: 1rem 0;
  text-align: center;
}

.formula-quote {
  border-left: 4px solid var(--accent);
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--accent-bg);
  font-style: italic;
  color: var(--text);
}

.article-tips li {
  margin-bottom: 0.75rem;
}

/* Tags section */
.tags-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.tag-tile {
  display: inline-block;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tag-tile:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

/* FAQ accordion */
.faq-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.faq-section .section-title {
  margin-bottom: 1.5rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.faq-item:hover {
  border-color: var(--accent);
}

.faq-item.is-open {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(45, 90, 39, 0.08);
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  gap: 1rem;
}

.faq-question:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.faq-question span:first-child {
  flex: 1;
}

.faq-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
}

.faq-icon::before {
  content: '+';
}

.faq-item.is-open .faq-icon::before {
  content: '−';
}

.faq-item.is-open .faq-icon {
  transform: rotate(180deg);
  background: var(--accent);
  color: white;
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item.is-open .faq-answer {
  max-height: 800px;
}

.faq-answer-inner {
  padding: 0 1.25rem 1.25rem;
  padding-top: 0;
}

.faq-answer-inner p {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.faq-answer-inner p:last-child,
.faq-answer-inner ul:last-child {
  margin-bottom: 0;
}

.faq-answer-inner ul {
  margin: 0 0 0.75rem 0;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.faq-answer-inner li {
  margin-bottom: 0.35rem;
}

.faq-answer-inner strong {
  color: var(--accent);
}

.alert {
  background: #fff8e6;
  border: 1px solid #f0e0a0;
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.9rem;
  color: #7a6100;
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
  .calculator {
    padding: 1.25rem;
  }
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}
