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

:root {
  --bg: #f4f3ff;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c4c0f0;
  --sidebar-active: #7c3aed;
  --surface: #ffffff;
  --surface2: #f8f7ff;
  --border: #e8e6ff;
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --accent2: #f59e0b;
  --accent2-light: #fef3c7;
  --accent3: #10b981;
  --accent3-light: #d1fae5;
  --accent4: #ef4444;
  --accent4-light: #fee2e2;
  --accent5: #3b82f6;
  --accent5-light: #dbeafe;
  --text: #1e1b4b;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(124,58,237,0.06);
  --shadow-lg: 0 4px 24px rgba(124,58,237,0.12);
  --sidebar-w: 240px;
  --topbar-h: 80px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  z-index: 200;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem 2rem;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: white;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-item.active { background: rgba(124,58,237,0.3); color: white; }
.nav-icon { font-size: 1rem; }

.sidebar-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #fbbf24;
  font-weight: 600;
}
.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.page-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

.period-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.period-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s;
}
.period-btn.active { background: var(--accent); color: white; }
.period-btn:hover:not(.active) { color: var(--text); }

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto auto auto;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  align-items: start;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.card-head h2 {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.card-tag {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Form ── */
.form-group { margin-bottom: 1.2rem; }
.form-group.half { flex: 1; margin-bottom: 0; }
.form-row { display: flex; gap: 1rem; margin-bottom: 1.2rem; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.input-prefix, .input-suffix {
  padding: 0 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--border);
  align-self: stretch;
  display: flex; align-items: center;
}

input[type="number"], input[type="text"] {
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text);
  width: 100%;
  outline: none;
  font-weight: 600;
}

.select-wrap {
  position: relative;
}
.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
select {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 500;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
select:focus { border-color: var(--accent); }

.salary-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.salary-presets button {
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s;
}
.salary-presets button:hover { background: var(--accent); color: white; }

/* ── Toggles ── */
.toggles-row { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.5rem; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-switch {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-label input:checked + .toggle-switch { background: var(--accent); }
.toggle-label input:checked + .toggle-switch::after { left: 21px; }

/* ── Calc Button ── */
.calc-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: white;
  border: none;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
}
.calc-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,58,237,0.45); }
.btn-arrow { font-size: 1.1rem; }

/* ── Summary Card ── */
.summary-card { grid-row: span 1; }

.takehome-hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.takehome-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.takehome-amount {
  font-family: 'Sora', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}
.takehome-freq { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

/* ── Donut Chart ── */
.chart-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0 auto 1.5rem;
  width: 200px; height: 200px;
}
.chart-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.chart-pct {
  font-family: 'Sora', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
}
.chart-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

/* ── Legend ── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}
.legend-left { display: flex; align-items: center; gap: 0.6rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-name { font-weight: 500; color: var(--text-muted); }
.legend-val { font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.legend-pct { font-size: 0.75rem; color: var(--text-light); margin-left: 0.3rem; }

/* ── Breakdown ── */
.breakdown-card { grid-column: 1 / -1; }
.breakdown-tabs {
  display: flex;
  gap: 0.3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
  margin-bottom: 1.5rem;
}
.btab {
  background: transparent;
  border: none;
  padding: 0.4rem 1.2rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s;
}
.btab.active { background: var(--accent); color: white; }
.btab:hover:not(.active) { color: var(--text); }

.breakdown-table { display: flex; flex-direction: column; gap: 0.4rem; }
.bt-row {
  display: grid;
  grid-template-columns: 1fr 180px 140px;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.bt-row:hover:not(.header):not(.total) { background: var(--surface2); }
.bt-row.header {
  background: var(--surface2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.bt-row.total {
  background: linear-gradient(135deg, var(--accent-light), #f5f3ff);
  border: 1px solid rgba(124,58,237,0.15);
  font-weight: 700;
  margin-top: 0.4rem;
}
.bt-row.deduction .bt-amount { color: var(--accent4); }
.bt-row .bt-label { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; font-size: 0.9rem; }
.bt-row .bt-dot { width: 8px; height: 8px; border-radius: 50%; }
.bt-row .bt-amount { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.95rem; }
.bt-row .bt-rate { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.bt-row.total .bt-amount { color: var(--accent); font-size: 1.05rem; }

/* ── Bands ── */
.bands-card { grid-column: 1 / -1; }
.bands-container {
  margin-bottom: 1rem;
}
.band-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.band-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); width: 120px; flex-shrink: 0; }
.band-bar-wrap { flex: 1; background: var(--surface2); border-radius: 999px; overflow: hidden; height: 28px; position: relative; }
.band-bar {
  height: 100%;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  transition: width 0.5s ease;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.band-amount { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); width: 90px; text-align: right; }

.bands-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
.bands-legend span { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-muted); }
.bl { width: 12px; height: 12px; border-radius: 3px; }
.bl.personal { background: var(--accent3); }
.bl.basic { background: var(--accent5); }
.bl.higher { background: var(--accent2); }
.bl.additional { background: var(--accent4); }

/* ── Guide ── */
.guide-card { grid-column: 1 / -1; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.guide-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.2rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.guide-item:hover { border-color: rgba(124,58,237,0.3); transform: translateY(-2px); }
.guide-icon { font-size: 1.5rem; flex-shrink: 0; }
.guide-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.2rem; }
.guide-val { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 700; color: var(--accent); margin-bottom: 0.2rem; }
.guide-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

/* ── Animations ── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.card { animation: fadeInUp 0.4s ease both; }

/* ── Mobile Nav ── */
.mobile-nav {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 200;
}
.logo-icon-sm {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.mobile-logo-text {
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
}
.mobile-badge {
  margin-left: auto;
  background: rgba(245,158,11,0.2);
  color: #fbbf24;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245,158,11,0.3);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .breakdown-card, .bands-card, .guide-card { grid-column: 1; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; width: 100%; }
  .mobile-nav { display: flex; }
}

@media (max-width: 768px) {
  body { font-size: 15px; }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    gap: 0.8rem;
  }
  .topbar-right { width: 100%; }
  .period-toggle { width: 100%; justify-content: space-between; }
  .period-btn { flex: 1; text-align: center; padding: 0.4rem 0.5rem; font-size: 0.78rem; }

  .grid {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .card { padding: 1.2rem; }

  .form-row { flex-direction: column; gap: 0.75rem; }
  .form-group.half { width: 100%; }

  .salary-presets { gap: 0.3rem; }
  .salary-presets button { font-size: 0.72rem; padding: 3px 8px; }

  .takehome-amount { font-size: 2.5rem; }

  .chart-wrap { width: 180px; height: 180px; }

  .bt-row {
    grid-template-columns: 1fr 110px;
    gap: 0.3rem;
  }
  .bt-row .bt-rate { display: none; }
  .bt-row.header span:last-child { display: none; }

  .band-row { flex-wrap: wrap; gap: 0.4rem; }
  .band-label { width: 100%; font-size: 0.75rem; }
  .band-amount { width: auto; }

  .bands-legend { gap: 0.6rem; }
  .bands-legend span { font-size: 0.75rem; }

  .guide-grid { grid-template-columns: 1fr; }

  .breakdown-tabs { flex-wrap: wrap; width: 100%; }
  .btab { flex: 1; text-align: center; }

  /* Prevent horizontal scroll */
  .breakdown-card, .bands-card, .guide-card { overflow-x: hidden; }
}

@media (max-width: 420px) {
  .takehome-amount { font-size: 2rem; }
  .page-title { font-size: 1.2rem; }
  .card { padding: 1rem; }
  input[type="number"], input[type="text"] { font-size: 0.9rem; padding: 0.6rem 0.8rem; }
}
