/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --primary: #1B3A6B;
  --primary-light: #243E7A;
  --primary-faded: rgba(96, 165, 250, 0.12);
  --text: #1A202C;
  --text-muted: #718096;
  --border: #E8EDF3;

  /* Skattefarver */
  --groen: #059669;
  --roed: #EF4444;
  --moerkeroed: #B91C1C;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --transition: 140ms ease;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, #1B3A6B 0%, #243E7A 100%);
  color: #fff;
  padding: 0.875rem 1.25rem 0.625rem;
  flex-shrink: 0;
}

.header-inner h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.header-inner h1 span {
  color: #90CDF4;
  font-weight: 400;
}

.header-tagline {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.55);
  margin-top: 0.1875rem;
  font-weight: 400;
}

/* ============================================================
   Tab Bar
   ============================================================ */
.tab-bar {
  display: flex;
  overflow-x: auto;
  background: var(--primary);
  padding: 0 0.625rem;
  gap: 0.125rem;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(255, 255, 255, 0.6);
  padding: 0.6875rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  font-family: inherit;
}

.tab-btn:hover {
  color: rgba(255, 255, 255, 0.9);
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: #60A5FA;
}

/* ============================================================
   Main Layout
   ============================================================ */
main {
  flex: 1;
  padding: 1.125rem 1rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
}

.card h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.125rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

/* ============================================================
   Tab Layout — responsive grid
   ============================================================ */
.tab-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.125rem;
}

.tab-layout--total {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .tab-layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .tab-layout--total {
    grid-template-columns: 1fr 1.4fr;
    align-items: start;
  }
}

/* ============================================================
   Input Groups
   ============================================================ */
.input-group {
  margin-bottom: 1rem;
}

.input-group:last-child { margin-bottom: 0; }

.input-group label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
  line-height: 1.4;
}

.input-group--checkbox {
  padding: 0.75rem;
  background: #F8FAFC;
  border-radius: 10px;
  border: 1.5px solid var(--border);
}

.input-group--checkbox label {
  margin-bottom: 0;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.9375rem;
}

.input-group--checkbox input[type="checkbox"] {
  width: 1.0625rem;
  height: 1.0625rem;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.label-note {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8125rem;
}

/* Input with suffix */
.input-suffix {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #D1D9E0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-suffix:focus-within {
  border-color: #60A5FA;
  box-shadow: 0 0 0 3px var(--primary-faded);
}

.input-suffix input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.6875rem 0.875rem;
  font-size: 1rem;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--text);
  min-width: 0;
  font-family: inherit;
}

.input-suffix input::placeholder { color: #BEC3CC; }

.input-suffix .suffix {
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: #F8FAFC;
  border-left: 1.5px solid #D1D9E0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Toggle button */
.toggle-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.1875rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.toggle-btn:hover { background: var(--primary-light); }

/* Tooltip icon */
.tooltip {
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: help;
  user-select: none;
  flex-shrink: 0;
  transition: color var(--transition);
}

.tooltip:hover { color: var(--primary); }

/* Radio group */
.radio-group {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-top: 0.125rem;
}

.radio-group--vertical {
  flex-direction: column;
  gap: 0.625rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  font-size: 0.9375rem;
  cursor: pointer;
  color: var(--text);
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   Results
   ============================================================ */
.results-placeholder {
  color: var(--text-muted);
  font-size: 0.9375rem;
  text-align: center;
  padding: 2.5rem 1rem;
  font-style: italic;
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.875rem;
  border-radius: 7px;
  font-size: 0.9375rem;
  gap: 0.5rem;
  border-bottom: 1px solid transparent;
}

.result-row .label {
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.result-row .value {
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Row variants — standard rows: subtle */
.result-row.neutral    { background: #F8FAFC; }
.result-row.neutral .value { color: #374151; }

/* AM-bidrag, aktieskat, sommerhusskat — blå */
.result-row.tax        { background: #EFF6FF; }
.result-row.tax .value { color: #2563EB; }

/* Bundskat + kommuneskat — indigo */
.result-row.tax-bund   { background: #EEF2FF; }
.result-row.tax-bund .value { color: #4F46E5; }

/* Mellemskat — coral */
.result-row.tax-mid    { background: #FFF1F1; }
.result-row.tax-mid .value { color: #DC2626; }

/* Topskat — rød */
.result-row.tax-high   { background: #FEE2E2; }
.result-row.tax-high .value { color: #EF4444; }

/* Top-topskat — mørkerød */
.result-row.tax-top    { background: #FEE2E2; }
.result-row.tax-top .value { color: #B91C1C; }

/* Nøgle-rækker */
.result-row.total-tax  { background: #FEE2E2; padding: 0.75rem 0.875rem; }
.result-row.total-tax .label { font-weight: 600; }
.result-row.total-tax .value { color: #DC2626; font-size: 1.125rem; }

.result-row.positive   { background: #ECFDF5; padding: 0.75rem 0.875rem; }
.result-row.positive .label { font-weight: 600; }
.result-row.positive .value { color: var(--groen); font-size: 1.125rem; }

.result-row.highlight  { background: #EFF6FF; padding: 0.75rem 0.875rem; }
.result-row.highlight .label { font-weight: 600; }
.result-row.highlight .value { color: var(--primary); font-size: 1.125rem; }

.result-row.fradrag    { background: #F0FDF4; }
.result-row.fradrag .value { color: #15803D; }

.result-divider {
  height: 1px;
  background: var(--border);
  margin: 0.375rem 0;
}

/* Text result below grid */
.result-text {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
  background: #F8FAFC;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  border-left: 4px solid #60A5FA;
}

.result-note {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

/* Info box */
.info-box {
  margin-top: 1rem;
  background: #FFFBEB;
  border: 1px solid #F6E05E;
  border-radius: 8px;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: #744210;
  line-height: 1.6;
}

.info-box-negative {
  background: #F0FDF4;
  border-color: #9AE6B4;
  color: #22543D;
}

/* ============================================================
   Charts
   ============================================================ */
.chart-container {
  margin-bottom: 1.25rem;
  position: relative;
}

.chart-container--bar {
  height: 90px;
}

.chart-container--donut {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-container--donut canvas {
  max-width: 220px;
  max-height: 220px;
}

/* ============================================================
   Total tab
   ============================================================ */
.total-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.total-chart-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.total-chart-card h2 {
  align-self: stretch;
}

/* ============================================================
   Disclaimer footer
   ============================================================ */
.disclaimer {
  background: #2D3748;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  line-height: 1.6;
  flex-shrink: 0;
}

.disclaimer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1.25rem;
}

.disclaimer-section {
  padding: 0.75rem 1rem 0.75rem 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.disclaimer-section:nth-child(2n) {
  border-right: none;
  padding-right: 0;
  padding-left: 1rem;
}

.disclaimer-section:nth-last-child(-n+2) {
  border-bottom: none;
  padding-bottom: 0;
}

.disclaimer-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.4rem;
}

.disclaimer-section p {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.78rem;
  line-height: 1.65;
}

.disclaimer-code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.05em 0.3em;
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.75);
}

.disclaimer-bar {
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.42);
}

/* Footer links */
.disclaimer-link {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.disclaimer-link:hover {
  color: rgba(255, 255, 255, 0.85);
}

/* Udbyder-strip */
.disclaimer-owner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* Legal pages */
.legal-page {
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 0 1.5rem 3rem;
  color: #2D3748;
  font-size: 0.95rem;
  line-height: 1.7;
}
.legal-page h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.legal-page h2 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; color: #4A5568; }
.legal-page p, .legal-page ul { margin-bottom: 0.75rem; }
.legal-page ul { padding-left: 1.25rem; }
.legal-page .back-link { display: inline-block; margin-bottom: 2rem; color: #3182CE; text-decoration: none; font-size: 0.85rem; }
.legal-page .back-link:hover { text-decoration: underline; }
.legal-page .updated { font-size: 0.8rem; color: #718096; margin-bottom: 2rem; }

@media (max-width: 640px) {
  .disclaimer-grid {
    grid-template-columns: 1fr;
    padding: 1.25rem 1rem 1rem;
  }

  .disclaimer-section {
    padding: 0.75rem 0;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .disclaimer-section:nth-child(2n) {
    padding-left: 0;
  }

  .disclaimer-section:nth-last-child(-n+2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding-bottom: 0.75rem;
  }

  .disclaimer-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .disclaimer-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
}

/* ============================================================
   Responsive tweaks
   ============================================================ */
@media (max-width: 400px) {
  main { padding: 0.875rem 0.75rem 1.25rem; }
  .card { padding: 1.125rem 1rem; }
  .result-row { font-size: 0.875rem; }
  .result-row .value { font-size: 0.875rem; }
  .result-row.positive .value,
  .result-row.highlight .value,
  .result-row.total-tax .value { font-size: 1rem; }
}
