* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.app-container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 16px 40px;
}

h1 {
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: #4b5563;
  margin-bottom: 24px;
}

.card {
  background: #ffffff;
  padding: 20px 24px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

input[type="number"]:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}

.hint {
  font-weight: 400;
  color: #6b7280;
  font-size: 12px;
}

button {
  width: 100%;
  padding: 12px;
  border: none;
  background: #4f46e5;
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}

.error-msg {
  color: #b91c1c;
  margin-top: 8px;
  min-height: 18px;
}

.results h2 {
  margin-top: 0;
}

.result-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

.result-row span:last-child {
  font-weight: 600;
}

.explanation {
  font-size: 13px;
  color: #4b5563;
  margin-top: 8px;
}

.warning {
  background: #fef2f2;
  padding: 10px 12px;
  border: 1px solid #fecaca;
}

.hidden {
  display: none;
}

footer {
  text-align: center;
  margin-top: 12px;
  color: #6b7280;
  font-size: 12px;
}

/* New styles */
.text-green {
  color: #16a34a;
  font-weight: bold;
}

.text-red {
  color: #dc2626;
  font-weight: bold;
}

.highlight-result {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid #e5e7eb;
  text-align: center;
}

.highlight-result .label {
  display: block;
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 4px;
}

.highlight-result .value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #111827;
}

.info-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.info-link:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.info-link svg {
  flex-shrink: 0;
}

.info-link:active {
  transform: translateY(0);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #4b5563;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-link:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  color: #111827;
  transform: translateX(-2px);
}

.back-link svg {
  flex-shrink: 0;
}

.back-link:active {
  transform: translateX(0);
}

.info-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 2px solid #bfdbfe;
  text-decoration: none;
  color: #1e40af;
  transition: all 0.3s ease;
  margin-bottom: 20px;
}

.info-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
  border-color: #93c5fd;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.info-box svg:first-child {
  flex-shrink: 0;
  color: #2563eb;
}

.info-box svg:last-child {
  flex-shrink: 0;
  margin-left: auto;
  color: #60a5fa;
}

.info-box div {
  flex: 1;
}

.info-box strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
  color: #1e40af;
}

.info-box p {
  margin: 0;
  font-size: 13px;
  color: #3b82f6;
}

.demo-params {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px solid #bbf7d0;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.demo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: white;
  border: 1px solid #bbf7d0;
}

.demo-label {
  font-size: 12px;
  color: #16a34a;
  font-weight: 500;
}

.demo-value {
  font-size: 18px;
  font-weight: 700;
  color: #15803d;
}

.formula-box {
  background: #f8fafc;
  border-left: 4px solid #6366f1;
  padding: 20px;
  margin: 16px 0;
  overflow-x: auto;
  text-align: center;
  font-size: 18px;
}

.formula-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  background: #fefce8;
  margin-top: 12px;
  font-size: 14px;
}

.formula-legend div {
  color: #854d0e;
}

.calculation-example {
  background: #f0fdf4;
  border: 1px solid #86efac;
  padding: 16px;
  margin-top: 16px;
}

.calculation-example strong {
  color: #15803d;
  display: block;
  margin-bottom: 8px;
}

.comparison-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.comparison-item {
  padding: 16px;
  text-align: center;
}

.comparison-item.positive {
  background: #f0fdf4;
  border: 2px solid #86efac;
}

.comparison-item.positive strong {
  color: #15803d;
}

.comparison-item.negative {
  background: #fef2f2;
  border: 2px solid #fca5a5;
}

.comparison-item.negative strong {
  color: #b91c1c;
}

.comparison-item p {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: #6b7280;
}

.chart-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  padding: 16px;
  background: #f9fafb;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.summary-item.success {
  border-top: 2px solid #86efac;
  padding-top: 12px;
  margin-top: 4px;
  color: #15803d;
}

.summary-item strong {
  font-size: 16px;
}

/* Collapsible sections */
.collapsible-section {
  margin-bottom: 16px;
}

.collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: #111827;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border:1px solid rgb(205, 204, 204);
  padding-left:10px;
}

.collapsible-toggle.active {
  background: transparent;
  color: #111827;
}

.collapsible-toggle .toggle-icon {
  flex-shrink: 0;
  transition: transform 0.3s ease;
  color: #6b7280;
}

.collapsible-toggle.active .toggle-icon {
  transform: rotate(180deg);
  color: #6b7280;
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.collapsible-content.active {
  max-height: 300px;
  margin-top: 12px;
  opacity: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .app-container {
    margin: 20px auto;
    padding: 0 12px 20px;
  }

  h1 {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .subtitle {
    font-size: 14px;
    margin-bottom: 16px;
  }

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

  .info-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .info-box svg:last-child {
    margin-left: 0;
    align-self: flex-end;
  }

  .info-box strong {
    font-size: 14px;
  }

  .info-box p {
    font-size: 12px;
  }

  .result-row {
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
  }

  .result-row span:last-child {
    font-size: 16px;
  }

  .highlight-result .value {
    font-size: 24px;
  }

  .demo-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  .demo-item {
    padding: 10px;
  }

  .demo-value {
    font-size: 16px;
  }

  .comparison-box {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .formula-box {
    padding: 12px;
    font-size: 16px;
  }

  .formula-legend {
    gap: 12px;
    padding: 10px;
  }

  button {
    padding: 14px;
    font-size: 16px;
  }

  label {
    font-size: 14px;
  }

  input[type="number"] {
    padding: 12px;
    font-size: 16px;
  }

  .collapsible-toggle {
    font-size: 13px;
    padding: 10px;
  }

  footer {
    font-size: 11px;
  }

  .chart-summary {
    padding: 12px;
  }

  .summary-item {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .summary-item strong {
    font-size: 15px;
  }
}

/* Share Section */
.share-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.share-input-group {
  display: flex;
  gap: 0;
}

.share-input-group input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid #d1d5db;
  border-right: none;
  border-radius: 8px 0 0 8px;
  font-size: 13px;
  color: #374151;
  background: #f9fafb;
  min-width: 0;
}

.share-input-group input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: #4f46e5;
  color: white;
  border: 2px solid #4f46e5;
  border-radius: 0 8px 8px 0;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  width: auto;
  margin-top: 0;
}

.share-btn:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.share-btn.copied {
  background: #16a34a;
  border-color: #16a34a;
}

.share-btn svg {
  flex-shrink: 0;
}

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

  .subtitle {
    font-size: 13px;
  }

  .card {
    padding: 12px;
  }

  .info-box {
    padding: 10px 12px;
  }

  .demo-grid {
    grid-template-columns: 1fr;
  }

  .highlight-result .value {
    font-size: 20px;
  }

  input[type="number"] {
    font-size: 16px;
  }

  button {
    font-size: 15px;
  }

  .share-input-group {
    flex-direction: column;
    gap: 8px;
  }

  .share-input-group input {
    border-right: 2px solid #d1d5db;
    border-radius: 8px;
  }

  .share-btn {
    border-radius: 8px;
    width: 100%;
  }
}
