/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root,
[data-theme='light'] {
  /* Surfaces */
  --color-bg:             #f5f4f0;
  --color-surface:        #faf9f6;
  --color-surface-2:      #ffffff;
  --color-surface-offset: #ede9e3;
  --color-border:         #d6d2ca;
  --color-divider:        #e0dbd4;

  /* Text */
  --color-text:           #1e1c17;
  --color-text-muted:     #6b6960;
  --color-text-faint:     #b0aca5;

  /* Primary (deep teal) */
  --color-primary:        #016870;
  --color-primary-hover:  #0c4e55;
  --color-primary-light:  #c8dbda;

  /* Accents */
  --accent-amber:         #b85c00;
  --accent-amber-soft:    #fdecd3;
  --accent-teal-soft:     #d0e8e6;
  --accent-purple:        #6b35b8;
  --accent-purple-soft:   #e4d8f5;
  --accent-green:         #3b7a20;
  --accent-green-soft:    #d4e8cc;
  --accent-red:           #b52c2c;
  --accent-red-soft:      #fad8d8;

  /* Chart colors */
  --chart-vst:            #e07b00;
  --chart-ust:            #0070a8;
  --chart-gst:            #8b3b9a;
  --chart-abgabe:         #c03030;
  --chart-rest:           #2e8b57;
  --chart-aufsteller:     #3a6e9e;
  --chart-gastwirt:       #6ba89e;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(30,28,23,0.07);
  --shadow-md: 0 4px 14px rgba(30,28,23,0.09);
  --shadow-lg: 0 12px 36px rgba(30,28,23,0.12);

  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --text-xs:   clamp(0.75rem,  0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.75vw,   1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem + 2.5vw,  3.5rem);

  --content-default: 1100px;
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body:    'Satoshi', 'Inter', sans-serif;
}

[data-theme='dark'],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #171510;
    --color-surface:        #1d1b16;
    --color-surface-2:      #23211c;
    --color-surface-offset: #201e19;
    --color-border:         #3a3830;
    --color-divider:        #2c2a24;
    --color-text:           #cccac5;
    --color-text-muted:     #7a7870;
    --color-text-faint:     #555350;
    --color-primary:        #4fa0ad;
    --color-primary-hover:  #2a818e;
    --color-primary-light:  #2a4045;
    --accent-amber:         #f5a030;
    --accent-amber-soft:    #3d2e15;
    --accent-teal-soft:     #1e3a3a;
    --accent-purple:        #b07ae0;
    --accent-purple-soft:   #2e1f4a;
    --accent-green:         #70b04a;
    --accent-green-soft:    #1e3015;
    --accent-red:           #e06060;
    --accent-red-soft:      #3a1515;
    --chart-vst:            #f59030;
    --chart-ust:            #40a0d0;
    --chart-gst:            #c080e0;
    --chart-abgabe:         #e07070;
    --chart-rest:           #5abd80;
    --chart-aufsteller:     #70a8d8;
    --chart-gastwirt:       #8ecfc9;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 36px rgba(0,0,0,0.45);
  }
}

[data-theme='dark'] {
  --color-bg:             #171510;
  --color-surface:        #1d1b16;
  --color-surface-2:      #23211c;
  --color-surface-offset: #201e19;
  --color-border:         #3a3830;
  --color-divider:        #2c2a24;
  --color-text:           #cccac5;
  --color-text-muted:     #7a7870;
  --color-text-faint:     #555350;
  --color-primary:        #4fa0ad;
  --color-primary-hover:  #2a818e;
  --color-primary-light:  #2a4045;
  --accent-amber:         #f5a030;
  --accent-amber-soft:    #3d2e15;
  --accent-teal-soft:     #1e3a3a;
  --accent-purple:        #b07ae0;
  --accent-purple-soft:   #2e1f4a;
  --accent-green:         #70b04a;
  --accent-green-soft:    #1e3015;
  --accent-red:           #e06060;
  --accent-red-soft:      #3a1515;
  --chart-vst:            #f59030;
  --chart-ust:            #40a0d0;
  --chart-gst:            #c080e0;
  --chart-abgabe:         #e07070;
  --chart-rest:           #5abd80;
  --chart-aufsteller:     #70a8d8;
  --chart-gastwirt:       #8ecfc9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.45);
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100dvh;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p, li { max-width: 72ch; text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.2; font-family: var(--font-display); }
table { border-collapse: collapse; width: 100%; }

/* ============================================================
   LAYOUT PRIMITIVES
   ============================================================ */
.container {
  width: min(var(--content-default), 100%);
  margin-inline: auto;
  padding-inline: clamp(1rem, 5vw, 2.5rem);
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklab, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-block: 0.875rem;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(1rem, 5vw, 2.5rem);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--color-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.logo-text { color: var(--color-text); font-size: 1rem; }

.header-nav {
  display: flex;
  gap: 0.25rem;
  margin-inline-start: auto;
}

.header-nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  transition: background var(--transition), color var(--transition);
}
.header-nav a:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
  text-decoration: none;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding-block: clamp(3rem, 8vw, 6rem);
  background: linear-gradient(160deg,
    color-mix(in oklab, var(--color-primary) 6%, var(--color-bg)) 0%,
    var(--color-bg) 60%
  );
  border-bottom: 1px solid var(--color-border);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 1.25rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 1rem;
  line-height: 1.1;
}

.hero-sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 62ch;
  line-height: 1.7;
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}
.section--alt {
  background: var(--color-surface);
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  margin-top: 2px;
}

.section-title {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 0.2rem;
}

.section-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  max-width: none;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--color-divider);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  .header-nav { display: none; }
}

.controls-card, .results-card { /* grid items */ }

.chart-card {
  margin-top: 0;
}

/* ============================================================
   CONTROLS
   ============================================================ */
.control-group {
  margin-bottom: 1.25rem;
}

.control-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.control-group select {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6960' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  cursor: pointer;
  transition: border-color var(--transition);
}
.control-group select:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; border-color: var(--color-primary); }

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type='range'] {
  flex: 1;
  accent-color: var(--color-primary);
  cursor: pointer;
  height: 4px;
}

.slider-val {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary);
  min-width: 5.5ch;
  text-align: right;
  white-space: nowrap;
}

.hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 0.35rem;
  line-height: 1.5;
  max-width: none;
}

.radio-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--color-text);
}
.radio-label input { accent-color: var(--color-primary); }

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kpi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-divider);
  gap: 0.5rem;
}
.kpi:last-child { border-bottom: none; }

.kpi-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex: 1;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  text-align: right;
  white-space: nowrap;
}

.kpi-tax .kpi-label { padding-left: 0.875rem; color: var(--color-text-faint); font-size: var(--text-xs); }
.kpi-tax .kpi-value { color: var(--accent-red); }

.kpi-divider {
  border-top: 2px solid var(--color-border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}
.kpi-total { font-size: var(--text-base) !important; color: var(--accent-red) !important; }

.kpi-remain { background: var(--accent-green-soft); border-radius: var(--radius-md); padding: 0.6rem 0.75rem; margin-top: 0.5rem; border: none; }
.kpi-green { color: var(--accent-green) !important; font-size: var(--text-base) !important; }
.kpi-red { color: var(--accent-red) !important; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-wrap {
  position: relative;
}
.chart-wrap--wide { height: 260px; }
.chart-wrap--tall { height: 320px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }

.compare-table th,
.compare-table td {
  padding: 0.65rem 0.875rem;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-divider);
  text-align: left;
}

.compare-table th {
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.text-right { text-align: right !important; }

.compare-table .row-tax td { color: var(--color-text-muted); background: color-mix(in oklab, var(--color-bg) 50%, transparent); }
.compare-table .row-total td { font-weight: 700; background: var(--accent-red-soft); color: var(--accent-red); border-top: 2px solid var(--color-border); }
.compare-table .row-remain td { font-weight: 700; background: var(--accent-green-soft); color: var(--accent-green); }

/* ============================================================
   ANALYSIS BOX
   ============================================================ */
.analysis-card { border-left: 4px solid var(--color-primary); }

.analysis-content {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.75;
}
.analysis-content strong { color: var(--color-text); }
.analysis-content p + p { margin-top: 0.875rem; }

/* ============================================================
   INFO GRID
   ============================================================ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.info-card-title {
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  margin-bottom: 0.625rem;
}

.info-grid .card p + p { margin-top: 0.5rem; }
.info-grid .card p { font-size: var(--text-sm); color: var(--color-text-muted); }

.source-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.source-list li::before { content: '→ '; color: var(--color-primary); }
.source-list a { font-size: var(--text-xs); color: var(--color-primary); word-break: break-all; }

/* ============================================================
   INFO BOX (inline note)
   ============================================================ */
.info-box {
  background: var(--accent-teal-soft);
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.6;
}
.info-box strong { font-weight: 700; }

/* ============================================================
   FOOTNOTES
   ============================================================ */
.footnote {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 1rem;
  line-height: 1.5;
  max-width: none;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.footer-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  max-width: 70ch;
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
