:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #20242c;
  background: #f5f6f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --border: #e2e5e9;
  --muted: #69717d;
  --accent: #5265bc;
}

* { box-sizing: border-box; }

body { min-width: 320px; min-height: 100vh; margin: 0; }

button, input, select { font: inherit; }

.page {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 22px;
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input, select {
  width: 100%;
  min-width: 0;
  height: 37px;
  padding: 0 9px;
  border: 1px solid #d9dde3;
  border-radius: 5px;
  background: #fff;
  color: #20242c;
  font-size: 14px;
}

input:focus, select:focus {
  border-color: var(--accent);
  outline: 2px solid #5265bc22;
}

.section-heading, .results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading { margin: 19px 0 10px; }

h1, h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.data-table, .forecast-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.data-table th, .forecast-table th {
  height: 32px;
  border-bottom: 1px solid var(--border);
}

.data-table td { padding: 6px 5px 6px 0; }
.data-table td:nth-child(1) { width: 47%; }
.data-table td:nth-child(2) { width: 47%; }
.data-table td:last-child { width: 24px; }
.data-table-wrap { max-height: 380px; overflow: auto; }
.data-table thead { position: sticky; top: 0; z-index: 1; background: #fff; }
.data-input.invalid { border-color: #cf5151; }

.upload-controls { display: flex; align-items: center; gap: 10px; margin-top: 13px; }
.upload-button {
  display: inline-flex;
  min-height: 33px;
  align-items: center;
  padding: 0 11px;
  border: 1px solid #d9dde3;
  border-radius: 5px;
  color: #303746;
  font-size: 12px;
  cursor: pointer;
}
.upload-button:hover { border-color: var(--accent); color: var(--accent); }
.upload-formats { color: var(--muted); font-size: 11px; }
.upload-hint { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.upload-hint code { color: #343b47; font-family: Consolas, monospace; }
.upload-status { margin: 7px 0 0; color: #267451; font-size: 12px; }

.remove-row {
  width: 25px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #747b85;
  font-size: 18px;
  cursor: pointer;
}

.format-hint, .equation {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.error-message {
  min-height: 0;
  margin: 0;
  color: #b63838;
  font-size: 12px;
}

.error-message:not(:empty) { margin-top: 9px; }

.results-heading { align-items: flex-start; }
.equation { color: #343b47; font-variant-numeric: tabular-nums; }

.report-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d7dce4;
  border-radius: 5px;
  background: #fff;
  color: #303746;
  font-size: 12px;
  cursor: pointer;
}

.report-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.report-button:disabled { color: #989da5; background: #f6f7f8; cursor: not-allowed; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 15px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.actual-dot { background: #5265bc; }
.forecast-dot { background: #279978; }
.moving-average-dot { background: #d38a30; }
.legend-line { width: 15px; border-top: 2px dashed #949bab; }
.chart-wrap { position: relative; height: 270px; margin-top: 8px; }
.chart-wrap canvas { display: block; width: 100%; height: 100%; }
.errors-section { margin: 0 0 17px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.errors-section h3 { margin: 0 0 11px; font-size: 13px; font-weight: 600; }
.comparison-table { width: 100%; border-collapse: collapse; text-align: left; }
.comparison-table th { height: 30px; padding-right: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.comparison-table td { height: 35px; padding-right: 10px; border-bottom: 1px solid #edf0f2; font-size: 12px; font-variant-numeric: tabular-nums; }
.comparison-table td:not(:first-child), .comparison-table th:not(:first-child) { text-align: right; }
.comparison-table tbody tr:last-child td { border-bottom: 0; }
.comparison-table .best-method td:first-child::after { content: " · lower MAD"; color: #267451; font-size: 10px; }
.metrics-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.table-wrap { max-height: 350px; overflow: auto; }
.forecast-table th { position: sticky; top: 0; background: #fff; }
.forecast-table td { height: 35px; border-bottom: 1px solid #edf0f2; font-size: 13px; }
.forecast-table td:not(:first-child), .forecast-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .page { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .panel { padding: 16px; }
  .chart-wrap { height: 230px; }
  .comparison-table { min-width: 400px; }
  .forecast-table { min-width: 480px; }
}

@media (max-width: 390px) {
  .settings { grid-template-columns: 1fr 1fr; gap: 8px; }
  .section-heading, .results-heading { align-items: flex-start; }
  .report-button { max-width: 145px; white-space: normal; }
}

@media print {
  body { background: #fff; }
  .page { display: block; width: 100%; padding: 0; }
  .inputs-panel, .report-button { display: none; }
  .results-panel { border: 0; padding: 0; }
}
