/* ============================================
   COMPOUND INTEREST CALCULATOR — additions
      All classes namespaced .ci-*.
   ============================================ */

.compound-calculator {
  max-width: 1060px;
  margin: 0 auto;
}

/* ===== Top row: mode tabs + currency ===== */
.ci-top-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.ci-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem;
}

.ci-mode-btn {
  padding: 0.7rem 1rem;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.ci-mode-btn:hover { color: var(--text); }

.ci-mode-btn.active {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 3px rgba(var(--primary-rgb), 0.25);
}

.ci-currency-group { margin-bottom: 0; min-width: 220px; }

/* ===== Inputs grid ===== */
.ci-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.ci-inputs .input-group { margin-bottom: 0; }

.ci-input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: var(--transition);
}

.ci-input-prefix:focus-within { border-color: var(--primary); }

.ci-prefix {
  padding: 0 0.875rem;
  display: flex;
  align-items: center;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-right: 1px solid var(--border);
  user-select: none;
}

.ci-input-prefix .input-field {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
}

.ci-input-prefix .input-field:focus { outline: none; }

/* ===== Advanced (inflation + tax) ===== */
.ci-advanced {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.ci-advanced summary {
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.ci-advanced summary::-webkit-details-marker { display: none; }

.ci-advanced summary::after {
  content: '+';
  font-size: 1.4rem;
  color: var(--text-muted);
  font-weight: 300;
  transition: transform 0.2s ease;
}

.ci-advanced[open] summary::after { content: '−'; }

.ci-advanced-grid {
  padding: 0.5rem 1.1rem 1.1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  border-top: 1px solid var(--border);
}

.ci-advanced .input-group { margin-bottom: 0; }

.ci-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ci-tax-timing {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ci-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
  font-size: 0.85rem;
}

.ci-radio:has(input:checked) {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.06);
}

.ci-radio input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ci-radio small {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.3rem;
}

/* ===== Summary cards ===== */
.ci-summary {
  margin-bottom: 1.5rem;
}

.ci-summary-hero {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--on-primary);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.25);
}

.ci-summary-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.8;
  margin-bottom: 0.4rem;
}

.ci-summary-value {
  display: block;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.4rem;
  word-break: break-word;
}

.ci-summary-real {
  display: block;
  font-size: 0.85rem;
  opacity: 0.9;
}

.ci-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.ci-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: left;
  transition: var(--transition);
}

.ci-summary-card-success {
  border-color: var(--success, var(--success));
  background: rgba(var(--success-rgb), 0.06);
}

.ci-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.ci-card-label small {
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  opacity: 0.85;
}

.ci-card-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.ci-card-value small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ===== Goal mode info ===== */
.ci-goal-info {
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.ci-goal-info-error {
  background: rgba(var(--danger-rgb), 0.08);
  border-color: var(--danger);
  color: var(--text);
}

/* ===== Chart ===== */
.ci-chart-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.5rem;
  margin-bottom: 1.25rem;
}

.ci-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ci-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.ci-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.ci-legend-principal { background: rgba(var(--primary-rgb), 0.55); }
.ci-legend-contrib   { background: rgba(var(--primary-dark-rgb), 0.45); }
.ci-legend-interest  { background: rgba(var(--success-rgb), 0.55); }

#ci-chart {
  width: 100%;
  max-width: 100%;
  height: 380px;
  display: block;
}

/* ===== Breakdown ===== */
.ci-breakdown-toggle {
  text-align: center;
  margin-bottom: 1rem;
}

.ci-breakdown-toggle .btn {
  min-height: 44px;
}

.ci-breakdown-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.ci-breakdown-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ci-breakdown-table thead {
  background: var(--surface);
}

.ci-breakdown-table th {
  text-align: right;
  padding: 0.65rem 0.85rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.ci-breakdown-table th:first-child { text-align: left; }

.ci-breakdown-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ci-breakdown-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.ci-breakdown-table tr:hover td { background: var(--surface); }

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

/* ===== Action buttons ===== */
.ci-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.ci-actions .btn {
  min-height: 44px;
  flex: 1 1 auto;
  min-width: 160px;
}

/* ===== Mobile (< 700px) ===== */
@media (max-width: 700px) {
  .ci-top-row {
    grid-template-columns: 1fr;
  }
  .ci-currency-group { min-width: 0; }
  .ci-inputs {
    grid-template-columns: 1fr;
  }
  .ci-advanced-grid {
    grid-template-columns: 1fr;
  }
  .ci-summary-value {
    font-size: 1.9rem;
  }
  .ci-actions .btn {
    flex: 1 1 100%;
  }
  #ci-chart { height: 300px; }
}

