/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f0f2f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #fff;
  text-align: center;
  padding: 2rem 1rem;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  opacity: 0.8;
  font-size: 1rem;
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  background: #16213e;
  padding: 0 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 1rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
  color: #fff;
}

.tab.active {
  color: #fff;
  border-bottom-color: #4fc3f7;
}

/* Main */
main {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
}

.panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.panel > p {
  color: #555;
  margin-bottom: 1.5rem;
}

/* Form */
.calc-form {
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #4fc3f7;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.field-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #777;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s;
}

.form-group select:focus {
  outline: none;
  border-color: #4fc3f7;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.deductions-fieldset {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.deductions-fieldset legend {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0 0.5rem;
  color: #1a1a2e;
}

.btn {
  display: inline-block;
  background: #0f4c75;
  color: #fff;
  border: none;
  padding: 0.7rem 1.8rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.btn:hover {
  background: #1b6ca8;
}

.btn-pdf {
  display: inline-block;
  background: #27ae60;
  margin-top: 1rem;
}

.btn-pdf:hover {
  background: #2ecc71;
}

.btn-pdf.hidden {
  display: none;
}

.btn-share {
  display: inline-block;
  background: #2980b9;
  margin-top: 1rem;
  margin-left: 0.5rem;
}

.btn-share:hover {
  background: #3498db;
}

.btn-share.hidden {
  display: none;
}

/* Results */
.results {
  margin-top: 1.5rem;
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.results.hidden {
  display: none;
}

.results h3 {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.results table {
  width: 100%;
  border-collapse: collapse;
}

.results table tr {
  border-bottom: 1px solid #eee;
}

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

.results table td {
  padding: 0.5rem 0;
}

.results table td:last-child {
  text-align: right;
  font-weight: 600;
}

.highlight {
  color: #0f4c75;
  font-size: 1.3rem;
  font-weight: 700;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: #777;
  font-size: 0.85rem;
}

/* Charts */
.charts-container {
  margin-top: 1.5rem;
}

.charts-container.hidden {
  display: none;
}

.chart-wrapper {
  background: #fff;
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 1rem;
}

.chart-row {
  display: flex;
  gap: 1rem;
}

.chart-half {
  flex: 1;
  min-width: 0;
}

.chart-half canvas {
  min-height: 250px;
}

@media (max-width: 600px) {
  .chart-row {
    flex-direction: column;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .tabs {
    flex-direction: column;
    align-items: stretch;
  }

  .tab {
    text-align: center;
    border-bottom: none;
    border-left: 3px solid transparent;
  }

  .tab.active {
    border-left-color: #4fc3f7;
    border-bottom-color: transparent;
  }

  header h1 {
    font-size: 1.5rem;
  }
}
