*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root,
[data-theme="light"] {
  --bg: #F8F9FC;
  --surface: #FFFFFF;
  --input-bg: #F3F4F8;
  --text: #1A1D2E;
  --text-muted: #6B7280;
  --border: #E2E4EE;
  --logo-crunch: #1A1D2E;
  --accent: #6C63FF;
  --accent-net: #00D4AA;
  --error: #DC2626;
  --select-chevron: %238B8FA8;
  --slider-track: #E2E4EE;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --toggle-bg: #F3F4F8;
  --toggle-border: #E2E4EE;
  --toggle-hover: #E8EAF0;
  --notice-bg: #FFFBEB;
  --notice-border: #FCD34D;
  --notice-icon-bg: #F59E0B;
  --notice-icon-color: #FFFFFF;
  --notice-title: #92400E;
  --notice-text: #78350F;
}

[data-theme="dark"] {
  --bg: #0D0F1A;
  --surface: #161929;
  --input-bg: #0D0F1A;
  --text: #E8EAF0;
  --text-muted: #8B8FA8;
  --border: #2A2D3E;
  --logo-crunch: #E8EAF0;
  --accent: #6C63FF;
  --accent-net: #00D4AA;
  --error: #FF6B6B;
  --select-chevron: %238B8FA8;
  --slider-track: #2A2D3E;
  --shadow: none;
  --toggle-bg: #161929;
  --toggle-border: #2A2D3E;
  --toggle-hover: #2A2D3E;
  --notice-bg: rgba(245, 158, 11, 0.12);
  --notice-border: #F59E0B;
  --notice-icon-bg: #F59E0B;
  --notice-icon-color: #111827;
  --notice-title: #FCD34D;
  --notice-text: #E8EAF0;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
  position: relative;
}

.page-toolbar {
  position: absolute;
  top: 2rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-switcher {
  display: flex;
  align-items: center;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.lang-btn.active {
  background: var(--toggle-hover);
  color: var(--text);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  background: var(--toggle-hover);
  color: var(--text);
}

.hero { text-align: center; margin-bottom: 2.5rem; padding-top: 0.5rem; }

.logo {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.logo-net { color: #00D4AA; }
.logo-pay { color: #6C63FF; }
.logo-crunch { color: var(--logo-crunch); }

.tagline { color: var(--text-muted); font-size: 1rem; }

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .main-grid {
    grid-template-columns: 55% 45%;
    align-items: start;
  }
}

.card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.results-card {
  position: sticky;
  top: 2rem;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.section-label + .pill-group,
.deduction-field + .section-label { margin-top: 1.5rem; }

.salary-hero { margin-bottom: 1.5rem; }

.salary-input-wrap {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.salary-prefix {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.salary-input {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  transition: transform 0.15s ease;
}
.salary-input.pulse { animation: salaryPulse 0.2s ease; }

@keyframes salaryPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.salary-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--slider-track);
  outline: none;
}

.salary-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6C63FF;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
}

.salary-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6C63FF;
  cursor: pointer;
  border: none;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.pill {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.pill:hover { border-color: var(--accent); color: var(--text); }
.pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.select-wrap { position: relative; }

.select-wrap select,
.suffix-input-wrap input,
.prefix-input-wrap input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  font-family: inherit;
  appearance: none;
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.select-wrap select:focus,
.suffix-input-wrap input:focus,
.prefix-input-wrap input:focus {
  border-color: var(--accent);
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  pointer-events: none;
}

[data-theme="dark"] .select-wrap::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B8FA8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}

.collapsible-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.75rem 0;
  font-family: inherit;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.toggle-icon { color: var(--accent); font-size: 1.25rem; }

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.collapsible-content.open { max-height: 500px; }

.deduction-field { margin-top: 1rem; }

.suffix-input-wrap,
.prefix-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.suffix-input-wrap input { padding-right: 2rem; }
.input-suffix {
  position: absolute;
  right: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.prefix-input-wrap .input-prefix {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.prefix-input-wrap input { padding-left: 1.75rem; font-size: 1rem; }
.suffix-input-wrap input { font-size: 1rem; }

.net-pay-amount {
  font-size: 2.5rem;
  font-weight: 800;
  color: #00D4AA;
}

.pay-period-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.line-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.line-item .label { color: var(--text-muted); }
.line-item .amount { color: var(--text); font-weight: 600; }
.line-item.gross .label,
.line-item.gross .amount { font-weight: 700; }
.net-pay-repeat {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0 1rem;
  font-size: 0.9rem;
}
.net-pay-repeat .label,
.net-pay-repeat .amount {
  color: #00D4AA;
  font-weight: 800;
}

.stacked-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
  margin-top: 0.5rem;
}

.bar-segment {
  height: 12px;
  transition: width 300ms ease;
  min-width: 0;
}
.bar-segment:first-child { border-radius: 6px 0 0 6px; }
.bar-segment:last-child { border-radius: 0 6px 6px 0; }

.site-notice {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--notice-border);
  background: var(--notice-bg);
  box-shadow: var(--shadow);
}

.site-notice-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--notice-icon-bg);
  color: var(--notice-icon-color);
  font-weight: 800;
  font-size: 1.1rem;
}

.site-notice-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--notice-title);
  margin-bottom: 0.35rem;
}

.site-notice-text {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--notice-text);
}

.site-notice-text strong {
  color: var(--notice-title);
  font-weight: 700;
}

.site-notice-privacy {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--notice-border);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--notice-title);
}

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3rem;
  line-height: 1.6;
}

.footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer a:hover { color: var(--text); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript-fallback {
  max-width: 900px;
  margin: 2rem auto;
  padding: 1rem;
  text-align: center;
  color: var(--error);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

@media (max-width: 767px) {
  .page-toolbar { top: 1rem; right: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
}
