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

:root,
[data-theme="light"] {
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --input-bg: #FFFFFF;
  --input-addon-bg: #F9FAFB;
  --text: #374151;
  --text-strong: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --border-input: #D1D5DB;
  --navbar-bg: #1A56DB;
  --navbar-tagline: #93C5FD;
  --panel-header-bg: #1A56DB;
  --accent: #1A56DB;
  --accent-hover: #1E40AF;
  --net-pay: #059669;
  --table-stripe: #F9FAFB;
  --footer-bg: #F3F4F6;
  --error-bg: #FEF2F2;
  --error-border: #FECACA;
  --error-text: #DC2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --toggle-bg: rgba(255, 255, 255, 0.15);
  --toggle-border: rgba(255, 255, 255, 0.3);
  --toggle-text: #FFFFFF;
  --notice-bg: #FFFBEB;
  --notice-border: #D97706;
  --notice-title: #92400E;
  --notice-text: #78350F;
}

[data-theme="dark"] {
  --bg: #111827;
  --surface: #1F2937;
  --input-bg: #111827;
  --input-addon-bg: #374151;
  --text: #D1D5DB;
  --text-strong: #F9FAFB;
  --text-muted: #9CA3AF;
  --border: #374151;
  --border-input: #4B5563;
  --navbar-bg: #1E3A8A;
  --navbar-tagline: #93C5FD;
  --panel-header-bg: #1E40AF;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --net-pay: #34D399;
  --table-stripe: #374151;
  --footer-bg: #0F172A;
  --error-bg: #1F2937;
  --error-border: #374151;
  --error-text: #F87171;
  --shadow: none;
  --toggle-bg: rgba(255, 255, 255, 0.1);
  --toggle-border: rgba(255, 255, 255, 0.2);
  --toggle-text: #E5E7EB;
  --notice-bg: rgba(245, 158, 11, 0.15);
  --notice-border: #F59E0B;
  --notice-title: #FCD34D;
  --notice-text: #D1D5DB;
}

body {
  font-family: 'Lato', 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;
}

.navbar {
  background: var(--navbar-bg);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
}

.navbar-link {
  color: white;
  text-decoration: none;
}
.navbar-link:hover { text-decoration: underline; }

.navbar-tagline {
  color: var(--navbar-tagline);
  font-size: 0.875rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.content-wrapper {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

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

.layout-divider {
  display: none;
}

@media (min-width: 900px) {
  .layout-divider {
    display: block;
    background: var(--border);
    margin: 0 2rem;
    min-height: 100%;
  }
}

.panel-card {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.panel-header {
  background: var(--panel-header-bg);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
}

.panel-body { padding: 1.5rem; }

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

.form-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-field input,
.form-field select {
  width: 100%;
  border: 1px solid var(--border-input);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-strong);
  font-family: inherit;
  background: var(--input-bg);
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--input-addon-bg);
  border: 1px solid var(--border-input);
  border-right: none;
  border-radius: 6px 0 0 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.input-group input {
  border-radius: 0 6px 6px 0;
}

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

.section-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.btn-calculate {
  background: var(--accent);
  color: white;
  width: 100%;
  padding: 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0.5rem;
  transition: background 0.15s ease;
}
.btn-calculate:hover { background: var(--accent-hover); }

.net-pay-amount {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--net-pay);
}

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

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

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

.breakdown-table td {
  padding: 0.6rem 0;
  font-size: 0.875rem;
}

.breakdown-table thead th {
  padding: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.breakdown-table thead th:last-child { text-align: right; }

.breakdown-table tr:nth-child(even) { background: var(--table-stripe); }
.breakdown-table tr:nth-child(odd) { background: transparent; }

.breakdown-table td:first-child {
  color: var(--text-muted);
  text-align: left;
  padding-left: 0.5rem;
}

.breakdown-table td:last-child {
  color: var(--text-strong);
  text-align: right;
  padding-right: 0.5rem;
  font-weight: 500;
}

.breakdown-table tr.bold td {
  font-weight: 700;
  color: var(--text-strong);
}

.breakdown-table tr.net-row td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  color: var(--net-pay);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem !important;
}

.chart-container {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-legend {
  margin-top: 1rem;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.8rem;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label { color: var(--text-muted); }
.legend-value { color: var(--text-strong); font-weight: 600; }

.site-notice {
  background: var(--notice-bg);
  border-top: 3px solid var(--notice-border);
  border-bottom: 3px solid var(--notice-border);
  padding: 1.25rem 2rem;
}

.site-notice-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.site-notice-icon {
  flex-shrink: 0;
  font-size: 1.5rem;
  line-height: 1;
  margin-top: 0.1rem;
}

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

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

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

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

.footer {
  background: var(--footer-bg);
  padding: 1.5rem 2rem;
  margin-top: 3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  transition: background 0.2s ease;
}

.footer-right { white-space: nowrap; }

.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: 1100px;
  margin: 2rem auto;
  padding: 1rem;
  text-align: center;
  color: var(--error-text);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 8px;
}

@media (max-width: 899px) {
  .results-panel { margin-top: 1.5rem; }
  .footer { flex-direction: column; }
  .navbar-tagline { display: none; }
}
