:root {
  --bg: #FAFAFA;
  --surface: #ffffff;
  --border: #CCCBD1;
  --ink: #1A192E;
  --muted: #6D6B7B;
  --violet: #7B1FE4;
  --violet-light: #EDE9FF;
  --green: #1e6e4e;
  --green-light: #d4ede3;
  --orange: #b5670f;
  --orange-light: #faebd4;
  --red: #7B1FE4;
  --red-light: #EDE9FF;
  --blue: #2563a8;
  --blue-light: #d6e4f5;
  --pink: #a3375e;
  --pink-light: #f5dce8;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(124,58,237,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(16,185,129,0.05) 0%, transparent 50%);
}

/* HEADER */
header {
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 12px rgba(124,58,237,0.06);
}

.logo {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.logo span { color: var(--violet); }

.header-badge {
  background: var(--violet-light);
  color: var(--violet);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* HERO */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.hero h1 {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
  margin-bottom: 0.6rem;
  letter-spacing: -1px;
  color: var(--ink);
}

.hero h1 em { font-style: normal; color: var(--violet); }
.hero p { color: var(--muted); font-size: 0.95rem; line-height: 1.6; }

/* SALARY INPUT HERO */
.salary-hero {
  max-width: 480px;
  margin: 1.5rem auto 2rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 4px 24px rgba(124,58,237,0.08);
}

.salary-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 0.5rem;
  display: block;
}

.salary-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.salary-symbol {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 2rem;
  color: var(--violet);
}

#salaryInput {
  flex: 1;
  border: none;
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 2.2rem;
  color: var(--ink);
  background: transparent;
  letter-spacing: -1px;
  width: 100%;
}

#salaryInput:focus { outline: none; }
#salaryInput::placeholder { color: var(--border); }

.salary-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
  text-align: center;
}

/* RULE SELECTOR */
.rule-selector {
  max-width: 480px;
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.rule-btn {
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: 'Open Sans', sans-serif;
}

.rule-btn .rb-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
  display: block;
}

.rule-btn .rb-sub {
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
  margin-top: 0.15rem;
}

.rule-btn.active {
  border-color: var(--violet);
  background: var(--violet-light);
}

.rule-btn.active .rb-title { color: var(--violet); }

/* AD ZONES */
.ad-zone {
  background: #f3f0ff;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  gap: 0.2rem;
}

.ad-zone .ad-size { opacity: 0.45; font-size: 0.72rem; }
.ad-leaderboard { max-width: 960px; margin: 0 auto 2rem; padding: 0 1.5rem; }
.ad-leaderboard .ad-zone { width: 100%; height: 90px; }
.ad-banner { max-width: 960px; margin: 2rem auto 0; padding: 0 1.5rem; }
.ad-banner .ad-zone { width: 100%; height: 90px; }

/* MAIN GRID */
.main-grid {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.4rem;
  align-items: start;
}

@media (max-width: 720px) { .main-grid { grid-template-columns: 1fr; } }

/* CARDS */
.card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 2px 16px rgba(124,58,237,0.04);
}

.card-title {
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* SCORE */
.score-card {
  background: linear-gradient(135deg, var(--violet) 0%, #1b3a5c 100%);
  color: white;
  border: none;
  text-align: center;
  padding: 1.8rem 1.5rem;
}

.score-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.score-number {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 4rem;
  line-height: 1;
  letter-spacing: -2px;
  transition: all 0.5s;
}

.score-max { font-size: 1.5rem; opacity: 0.6; }

.score-emoji {
  font-size: 2rem;
  margin: 0.3rem 0;
  display: block;
}

.score-msg {
  font-size: 0.85rem;
  opacity: 0.9;
  font-weight: 600;
}

/* PROGRESS BARS */
.prog-list { display: flex; flex-direction: column; gap: 0.9rem; }

.prog-item {}

.prog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.prog-name {
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.prog-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.prog-amounts {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
}

.prog-amounts strong {
  font-weight: 800;
  color: var(--ink);
  font-size: 0.9rem;
}

.prog-bar-bg {
  height: 10px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.prog-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
  position: relative;
}

.prog-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 30%;
  background: rgba(255,255,255,0.25);
  border-radius: 0 99px 99px 0;
}

.prog-target {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* PIE CHART */
.pie-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.pie-canvas-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

#pieChart {
  width: 180px;
  height: 180px;
}

.pie-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.pie-center-val {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--ink);
  line-height: 1;
}

.pie-center-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pie-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.pie-legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-legend-text { color: var(--muted); }
.pie-legend-text strong { color: var(--ink); font-weight: 700; display: block; }

/* SUBSCRIPTIONS */
.subs-total {
  background: var(--red-light);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.subs-total-label { font-size: 0.82rem; font-weight: 700; color: var(--red); }
.subs-total-val {
  font-family: 'Open Sans', sans-serif;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--red);
}

.sub-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 320px; overflow-y: auto; padding-right: 0.2rem; }

.sub-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.sub-item:hover { border-color: var(--violet); background: var(--violet-light); }

.sub-item.checked {
  border-color: var(--red);
  background: var(--red-light);
  text-decoration: line-through;
  opacity: 0.7;
}

.sub-checkbox {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  transition: all 0.2s;
}

.sub-item.checked .sub-checkbox {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.sub-icon { font-size: 1.1rem; }
.sub-name { flex: 1; font-weight: 600; font-size: 0.85rem; }
.sub-price {
  font-family: 'Open Sans', sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink);
}

.sub-savings {
  margin-top: 0.8rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--green);
  font-weight: 700;
  padding: 0.5rem;
  background: var(--green-light);
  border-radius: 8px;
  transition: all 0.3s;
}

/* TIPS */
.tips-list { display: flex; flex-direction: column; gap: 0.6rem; }

.tip-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.05rem; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.4s ease forwards; }

@keyframes countUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.count-anim { animation: countUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
