:root {
  --bg: #f5f0e8;
  --paper: #fffdf7;
  --ink: #2c2c2c;
  --muted: #888;
  --accent: #1a5c3a;
  --border: #d4cfc4;
  --highlight: #e8f5e9;
}

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

body {
  font-family: 'Courier New', Courier, monospace;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 520px;
}

h1 {
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.subtitle {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Receipt paper effect */
.receipt {
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 2rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: relative;
}

.receipt::before, .receipt::after {
  content: '';
  display: block;
  height: 8px;
  background: linear-gradient(135deg, var(--bg) 33.33%, transparent 33.33%) 0 0,
              linear-gradient(225deg, var(--bg) 33.33%, transparent 33.33%) 0 0;
  background-size: 12px 8px;
  position: absolute;
  left: 0; right: 0;
}
.receipt::before { top: -8px; }
.receipt::after { bottom: -8px; transform: rotate(180deg); }

.receipt-header {
  text-align: center;
  border-bottom: 2px dashed var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.receipt-header h2 {
  font-size: 1.3rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.receipt-header .tagline {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

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

.salary-input-wrap span {
  font-size: 1.4rem;
  font-weight: bold;
}

.salary-input-wrap input {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.4rem;
  font-weight: bold;
  border: none;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  width: 100%;
  padding: 0.25rem 0;
  outline: none;
}

.salary-input-wrap input:focus {
  border-bottom-color: var(--accent);
}

.tax-year-select {
  margin-top: 0.75rem;
}

.tax-year-select label {
  font-size: 0.7rem;
  color: var(--muted);
}

.tax-year-select select {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

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

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.summary-row.total {
  font-weight: bold;
  font-size: 0.95rem;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  padding: 0.4rem 0;
  margin: 0.5rem 0;
}

.breakdown-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin: 1.25rem 0 0.75rem;
  text-align: center;
}

.breakdown-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  font-size: 0.8rem;
  padding: 0.35rem 0;
  border-bottom: 1px dotted var(--border);
  align-items: center;
}

.breakdown-wrapper:last-child .breakdown-item {
  border-bottom: none;
}

.breakdown-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-item .pct {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
  min-width: 40px;
}

.breakdown-item .amount {
  font-weight: bold;
  text-align: right;
  min-width: 70px;
}

.bar-container {
  grid-column: 1 / -1;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.daily-note {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--border);
}

.daily-note .big {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--ink);
  display: block;
  margin: 0.25rem 0;
}

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

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.hidden { display: none; }

/* Effective rate badge */
.effective-rate {
  display: inline-block;
  background: var(--highlight);
  border: 1px solid var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 400px) {
  .receipt { padding: 1.5rem 1rem; }
  .salary-input-wrap input { font-size: 1.2rem; }
  .breakdown-item { font-size: 0.75rem; }
}

/* ============================
   Wizard Steps
   ============================ */
.wizard-step {
  animation: fadeIn 0.3s ease;
}

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

.step-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-align: center;
}

.step-desc {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1rem;
}

/* Input mode toggle (salary / tax paid) */
.input-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  padding: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-btn.active {
  background: var(--accent);
  color: var(--paper);
}

.input-hint {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Wizard buttons */
.wizard-btn {
  display: block;
  width: 100%;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem;
  margin-top: 1.25rem;
  background: var(--accent);
  color: var(--paper);
  border: 2px solid var(--accent);
  cursor: pointer;
}

.wizard-btn:hover {
  background: #14482e;
  border-color: #14482e;
}

.wizard-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wizard-btn-back {
  display: block;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-top: 0.75rem;
}

.wizard-btn-back:hover {
  color: var(--ink);
}

/* View toggle (Category / Line Item) */
.view-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.view-btn {
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  padding: 0.4rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.view-btn.active {
  background: var(--accent);
  color: var(--paper);
}

/* Line item view */
.line-item {
  padding: 0.5rem 0;
  border-bottom: 1px dotted var(--border);
}

.line-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.line-item-name {
  font-size: 0.8rem;
  font-weight: bold;
}

.line-item-amount {
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
}

.line-item-desc {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.line-item-parent {
  font-size: 0.6rem;
  color: var(--accent);
  margin-top: 0.1rem;
}

.line-item:last-child {
  border-bottom: none;
}

.line-item .bar-container {
  margin-top: 4px;
}

/* Expandable sub-categories */
.breakdown-item {
  cursor: pointer;
}

.breakdown-item .chevron {
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  display: inline-block;
}

.breakdown-item.expanded .chevron {
  transform: rotate(180deg);
}

.sub-categories {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, overflow 0s 0.3s;
}

.sub-categories.open {
  max-height: 500px;
  overflow: visible;
  transition: max-height 0.3s ease, overflow 0s 0s;
}

.sub-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  padding: 0.2rem 0 0.2rem 1.5rem;
  color: var(--muted);
}

.sub-item .sub-amount {
  font-size: 0.7rem;
  min-width: 60px;
  text-align: right;
}

/* Sub-item info tooltips */
.sub-name {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 0.5rem;
  font-style: italic;
  font-weight: bold;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.info-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.info-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.6rem;
  font-style: normal;
  font-weight: normal;
  line-height: 1.4;
  padding: 0.4rem 0.6rem;
  border-radius: 3px;
  width: max-content;
  max-width: 220px;
  white-space: normal;
  z-index: 10;
  pointer-events: none;
}

.info-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}

/* Salary presets */
.salary-presets {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.preset-btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.6rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Surprise stat carousel */
.surprise-stat {
  background: var(--highlight);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.75rem;
  margin: 1rem 0;
  color: var(--ink);
  user-select: none;
}

.surprise-stat:empty {
  display: none;
}

.stat-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-arrow {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.2rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.2rem;
  flex-shrink: 0;
}

.stat-arrow:hover {
  color: var(--accent);
}

.stat-text {
  font-size: 0.7rem;
  line-height: 1.5;
  flex: 1;
  text-align: center;
}

.stat-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
}

.stat-dot.active {
  background: var(--accent);
}

/* Share section */
.share-section {
  text-align: center;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.copy-link-btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-confirm {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: bold;
}

/* Income percentile badge */
.percentile-badge {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
