/* ========== PERUSTEET ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --accent: #111827;
  --accent-soft: #f3f4f6;
  --positive: #059669;
  --negative: #dc2626;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

/* ========== APP LAYOUT ========== */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========== CARDS ========== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-head h3 {
  font-size: 15px;
  font-weight: 600;
}

/* ========== PRODUCTS ========== */
.products {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.product {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  transition: opacity 0.15s, background 0.15s;
}

.product.disabled {
  opacity: 0.5;
  background: #f9fafb;
}

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.product-label {
  font-weight: 600;
  font-size: 14px;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-total {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ========== SLIDERS ========== */
.sliders {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  gap: 10px;
}

.slider-label {
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.slider-value:hover {
  background: var(--accent-soft);
}

/* Inline edit input inside slider-value */
.inline-edit {
  width: 80px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: right;
  outline: none;
  background: var(--card);
  color: var(--text);
  -moz-appearance: textfield;
}

.inline-edit::-webkit-outer-spin-button,
.inline-edit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.inline-edit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.1);
}

.slider-range-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Range input (slider) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 4px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow);
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== QUANTITY CONTROL ========== */
.qty {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.qty button {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.qty button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.qty button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.qty span {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* ========== TOGGLE SWITCH ========== */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #d1d5db;
  border-radius: 22px;
  transition: 0.2s;
}

.slider-toggle::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .slider-toggle {
  background: var(--accent);
}

input:checked + .slider-toggle::before {
  transform: translateX(18px);
}

.switch.small {
  width: 32px;
  height: 18px;
}

.switch.small .slider-toggle {
  border-radius: 18px;
}

.switch.small .slider-toggle::before {
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
}

.switch.small input:checked + .slider-toggle::before {
  transform: translateX(14px);
}

/* ========== EXPENSE CATEGORY TOGGLE ========== */
.category-toggle {
  display: inline-flex;
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  font-size: 11px;
}

.category-toggle button {
  border: none;
  background: transparent;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.category-toggle button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ========== TOGGLE ROW (starttiraha, projektio) ========== */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toggle-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* ========== GROWTH SECTION ========== */
.growth-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.growth-section.hidden {
  display: none;
}

/* ========== RESULTS ========== */
.result-group {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.result-group:last-child {
  border-bottom: none;
}

.result-group h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}

.result-row span {
  color: var(--text-muted);
}

.result-row.sub {
  padding: 0 0 4px 0;
  font-size: 12px;
}

.result-row.sub span {
  color: var(--text-light);
}

.result-row.sub strong {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.result-row strong {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-row.big {
  padding: 8px 0;
}

.result-row.big span {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.result-row.big strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.result-group.highlight {
  background: var(--accent-soft);
  margin: 4px -20px -20px;
  padding: 14px 20px 18px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.positive {
  color: var(--positive) !important;
}

.negative {
  color: var(--negative) !important;
}

/* ========== PROJECTION TABLE ========== */
.projection-table {
  width: 100%;
  overflow-x: auto;
}

.projection-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.projection-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.03em;
}

.projection-table th:last-child,
.projection-table td:last-child {
  text-align: right;
  padding-right: 0;
}

.projection-table td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--border);
}

.projection-table tr:last-child td {
  border-bottom: none;
}

/* ========== HIDDEN ========== */
.hidden {
  display: none !important;
}

/* ========== FOOTER ========== */
.footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 12px;
}

/* ========== MOBIILI ========== */
@media (max-width: 900px) {
  .app {
    padding: 16px 12px 32px;
  }

  .header h1 {
    font-size: 22px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .results {
    position: static;
    order: 2;
  }

  .inputs {
    order: 1;
  }

  .card {
    padding: 16px;
  }

  .result-group.highlight {
    margin: 4px -16px -16px;
    padding: 14px 16px 18px;
  }

  .product-head {
    flex-wrap: wrap;
  }

  .result-row.big strong {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 20px;
  }

  .product-meta {
    width: 100%;
    justify-content: space-between;
    margin-top: 4px;
  }
}
