/* Calculator view — namespaced from calculator-new/styles.css */
.calc-view {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}
/* scale override added below in second #app rule */

.calc-view {
  --bg: #FFFFFF;
  --bg2: #F5F2EC;
  --text: #003824;
  --muted: #5C6B65;
  --soft: #EDE9E0;
  --border: #D4CFC6;
  --shadow: 0 10px 40px rgba(0,56,36,.08);
  --radius: 16px;

  /* Category colors — SEB palette */
  --must: #003824;
  --must-light: rgba(0,56,36,.08);
  --need: #027839;
  --need-light: rgba(2,120,57,.10);
  --want: #A0A6A4;
  --want-light: rgba(160,166,164,.12);
  --savings: #60B870;
  --savings-light: rgba(96,184,112,.10);

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  --transition-speed: 0.5s;
}

.calc-view *, .calc-view *::before, .calc-view *::after { box-sizing: border-box; }

.calc-view {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}

.calc-view #app {
  position: relative;
  width: 106.4%;
  height: 106.4%;
  margin-left: -3.2%;
  transform: scale(0.94);
  transform-origin: top center;
  overflow: hidden;
}

/* ── Settings ── */
.calc-view .settings-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 100;
  transition: opacity var(--transition-speed) ease;
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.calc-view .settings-toggle:hover { background: var(--border); }

.calc-view.panel-open .settings-toggle,
.calc-view.panel-open .reset-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

.calc-view .reset-btn {
  position: absolute;
  top: 16px;
  right: 140px;
  z-index: 100;
  transition: opacity var(--transition-speed) ease;
  background: rgba(214,69,69,.06);
  border: 1px solid rgba(214,69,69,.20);
  color: #c53030;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.calc-view .reset-btn:hover { background: rgba(214,69,69,.12); }

.calc-view .settings-panel {
  position: absolute;
  top: 0; right: 0;
  width: 380px;
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 200;
  padding: 24px;
  overflow-y: auto;
  transition: transform var(--transition-speed) ease;
}
.calc-view .settings-panel.hidden {
  transform: translateX(100%);
}
.calc-view .settings-panel h3 {
  margin: 0 0 18px;
  font-size: 18px;
}
.calc-view .settings-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.calc-view .btn-close {
  margin-top: 20px;
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

/* ── Fields ── */
.calc-view .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.calc-view .field span {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}
.calc-view .field input, .calc-view .field select {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.calc-view .field input:focus, .calc-view .field select:focus {
  border-color: var(--need);
  box-shadow: 0 0 0 3px rgba(2,120,57,.15);
}
.calc-view .field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--need);
}

/* ── Donut Container ── */
.calc-view #donut-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  width: 620px;
  z-index: 30;
  transition: left var(--transition-speed) cubic-bezier(.4,0,.2,1),
              transform var(--transition-speed) cubic-bezier(.4,0,.2,1);
}

/* When panel open: center donut in left half */
.calc-view.panel-open #donut-container {
  left: 25%;
  transform: translate(-50%, -52%);
}

/* ── Panel Backdrop ── */
.calc-view #panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,56,36,0);
  z-index: 19;
  pointer-events: none;
  transition: background var(--transition-speed) ease;
}
.calc-view #panel-backdrop.active {
  background: rgba(0,56,36,.12);
  /* No pointer-events — donut stays clickable */
}

.calc-view #donutSvg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0,56,36,.12));
}

/* SVG segment styles */
.calc-view .donut-segment {
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
  stroke: var(--bg);
  stroke-width: 1px;
}
.calc-view .donut-segment:hover {
  opacity: 0.85;
  filter: brightness(1.15);
}
.calc-view .donut-label {
  font-family: var(--sans);
  font-weight: 800;
  fill: var(--text);
  pointer-events: none;
  text-anchor: middle;
}
.calc-view .donut-label-pct {
  font-size: 14px;
}
.calc-view .donut-label-amt {
  font-size: 11px;
  fill: var(--muted);
}

/* Center foreignObject inputs */
.calc-view .center-input-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
  overflow: hidden;
}
.calc-view .center-input-wrap label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.calc-view .salary-input {
  width: 110px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  outline: none;
  -webkit-text-fill-color: var(--text);
  opacity: 1;
}
.calc-view .salary-input:disabled {
  -webkit-text-fill-color: var(--muted);
  color: var(--muted);
  opacity: 1;
}
.calc-view .salary-input:focus {
  border-color: var(--need);
  box-shadow: 0 0 0 3px rgba(2,120,57,.15);
}
.calc-view .household-toggle {
  display: flex;
  gap: 4px;
}
.calc-view .household-toggle button {
  background: rgba(0,56,36,.03);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 700;
}
.calc-view .household-toggle button.active {
  background: var(--need-light);
  color: var(--need);
  border-color: var(--need);
}

/* ── Budget Inputs Row ── */
.calc-view .budget-inputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
  padding: 0 24px;
}
.calc-view .budget-input-pair {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: center;
}
.calc-view .budget-input-pair .cat-label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.calc-view .budget-input-pair .cat-label.must-color { color: var(--must); }
.calc-view .budget-input-pair .cat-label.need-color { color: var(--need); }
.calc-view .budget-input-pair .cat-label.want-color { color: var(--want); }
.calc-view .budget-input-pair .cat-label.savings-color { color: var(--savings); }

.calc-view .input-with-suffix {
  position: relative;
}
.calc-view .input-with-suffix .input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}
.calc-view .budget-input-pair input {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 24px 8px 24px;
  color: var(--text);
  font-size: 15px;
  text-align: center;
  outline: none;
  width: 100%;
  font-weight: 700;
  /* Remove spin buttons so text stays truly centered */
  -moz-appearance: textfield;
  appearance: textfield;
}
.calc-view .budget-input-pair input::-webkit-inner-spin-button,
.calc-view .budget-input-pair input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.calc-view .budget-input-pair input:focus {
  border-color: var(--need);
}
.calc-view .budget-input-pair input.pct-input {
  font-size: 12px;
}

/* ── Calc Panels — right-side drawer, vertically centered ── */
.calc-view .calc-panel {
  position: absolute;
  top: 50%;
  right: 0;
  width: 50vw;
  max-width: 720px;
  height: auto;
  max-height: 92vh;
  z-index: 20;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: -8px 0 40px rgba(0,56,36,.10);
  padding: 32px;
  overflow-y: auto;
  transition: transform var(--transition-speed) cubic-bezier(.4,0,.2,1),
              opacity var(--transition-speed) ease;
  transform: translate(100%, -50%);
  opacity: 0;
  pointer-events: none;
}
.calc-view .calc-panel.hidden {
  transform: translate(100%, -50%);
  opacity: 0;
  pointer-events: none;
}
.calc-view .calc-panel:not(.hidden) {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}

.calc-view .panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}
.calc-view .panel-close:hover { background: var(--soft); color: var(--text); }

.calc-view .panel-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 900;
}
.calc-view .must-color { color: var(--must); }
.calc-view .need-color { color: var(--need); }
.calc-view .want-color { color: var(--want); }
.calc-view .savings-color { color: var(--savings); }

.calc-view .panel-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Panel Cards ── */
.calc-view .calc-card {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.calc-view .calc-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 800;
}

.calc-view .calc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.calc-view .calc-row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.calc-view .calc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-view .calc-field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.calc-view .calc-field input, .calc-view .calc-field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 100%;
}
.calc-view .calc-field input:focus {
  border-color: var(--need);
  box-shadow: 0 0 0 3px rgba(2,120,57,.15);
}

.calc-view .result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 10px;
}
.calc-view .result-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  gap: 8px;
}
.calc-view .result-line .r-label {
  font-size: 13px;
  color: var(--muted);
}
.calc-view .result-line .r-value {
  font-weight: 900;
  font-size: 14px;
  font-family: var(--mono);
}

.calc-view .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Info Icon Tooltip ── */
.calc-view .info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  font-style: italic;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
}
.calc-view .info-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.4;
  white-space: normal;
  width: 260px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,56,36,.15);
}
.calc-view .info-icon:hover .info-tooltip {
  display: block;
}

/* ── SEB product link ── */
.calc-view .seb-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--need);
  text-decoration: none;
  background: rgba(2,120,57,.06);
  border: 1px solid rgba(2,120,57,.2);
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  transition: background 0.15s, border-color 0.15s;
}
.calc-view .seb-link:hover {
  background: rgba(2,120,57,.12);
  border-color: var(--need);
}

/* ── Buy vs Rent comparison ── */
.calc-view .compare-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.calc-view .compare-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-view .compare-heading {
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}
.calc-view .compare-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  gap: 8px;
}
.calc-view .compare-line .r-label {
  font-size: 12px;
  color: var(--muted);
}
.calc-view .compare-line .r-value {
  font-weight: 800;
  font-size: 13px;
  font-family: var(--mono);
}
.calc-view .compare-line.compare-total {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}
.calc-view .compare-line.compare-total .r-label {
  font-weight: 800;
  color: var(--text);
}
.calc-view .compare-col-spend .r-value {
  color: #c53030;
  background: rgba(197,48,48,.06);
  padding: 2px 8px;
  border-radius: 6px;
}
.calc-view .compare-col-invest .r-value {
  color: var(--need);
  background: rgba(2,120,57,.06);
  padding: 2px 8px;
  border-radius: 6px;
}
.calc-view .compare-diff {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 10px;
  background: var(--soft);
  color: var(--muted);
}
.calc-view .compare-diff.diff-negative {
  background: rgba(197,48,48,.06);
  color: #c53030;
}
.calc-view .compare-diff.diff-positive {
  background: rgba(2,120,57,.08);
  color: var(--need);
}

/* ── Latte chart ── */
.calc-view .latte-chart {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.calc-view .latte-chart svg {
  display: block;
}

/* ── Savings waterfall boxes ── */
.calc-view .waterfall {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calc-view .waterfall-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.calc-view .waterfall-box .wf-name {
  font-weight: 800;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.calc-view .waterfall-box .wf-amount {
  font-weight: 900;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--savings);
  text-align: right;
  white-space: nowrap;
}
.calc-view .waterfall-box input {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 90px;
  text-align: right;
}

/* Goal savings mode toggle */
.calc-view .mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.calc-view .mode-toggle button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.calc-view .mode-toggle button.active {
  background: var(--savings-light);
  color: var(--savings);
  border-color: var(--savings);
}

/* ── Donut 4-state positioning ── */
.calc-view.tx-open #donut-container {
  left: 75%;
  transform: translate(-50%, -52%);
}
.calc-view.panel-open.tx-open #donut-container {
  left: 50%;
  transform: translate(-50%, -52%) scale(0.82);
}

/* Two-panel state: shrink panels just enough to clear the donut */
.calc-view.panel-open.tx-open .tx-panel {
  width: 33vw;
  max-width: 480px;
}
.calc-view.panel-open.tx-open .calc-panel {
  width: 37vw;
  max-width: 520px;
}

/* ── Mode Switch Button ── */
.calc-view .mode-switch-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.calc-view .mode-switch-btn:hover { background: var(--border); }
.calc-view .mode-switch-btn.client-active {
  background: var(--need-light);
  border-color: var(--need);
  color: var(--need);
}
.calc-view .mode-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--need);
  color: var(--bg);
  font-size: 10px;
  font-weight: 900;
}

/* ── Transactions Panel ── */
.calc-view .tx-panel {
  position: absolute;
  top: 50%;
  left: 0;
  width: 50vw;
  max-width: 680px;
  height: 90vh;
  z-index: 20;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 16px 16px 0;
  box-shadow: 8px 0 40px rgba(0,56,36,.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-speed) cubic-bezier(.4,0,.2,1),
              opacity var(--transition-speed) ease;
  transform: translate(-100%, -50%);
  opacity: 0;
  pointer-events: none;
}
.calc-view .tx-panel.hidden {
  transform: translate(-100%, -50%);
  opacity: 0;
  pointer-events: none;
}
.calc-view .tx-panel:not(.hidden) {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}

/* ── TX Panel Header ── */
.calc-view .tx-header {
  position: relative;
  flex-shrink: 0;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.calc-view .tx-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  z-index: 1;
}
.calc-view .tx-close-btn:hover { background: var(--soft); color: var(--text); }
.calc-view .tx-header-month {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  padding-right: 40px;
}
.calc-view .tx-header-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  padding-right: 40px;
}

/* ── Category Summary Bars ── */
.calc-view .tx-cat-summary {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.calc-view .tx-cat-row { display: flex; flex-direction: column; gap: 4px; }
.calc-view .tx-cat-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.calc-view .tx-cat-name {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.calc-view .tx-cat-amounts { font-size: 12px; color: var(--muted); font-family: var(--mono); display: flex; align-items: center; gap: 6px; }
.calc-view .tx-cat-over   { color: #c53030; font-size: 11px; font-weight: 700; }
.calc-view .tx-cat-under  { color: var(--savings); font-size: 11px; font-weight: 700; }
.calc-view .tx-cat-bar-bg {
  position: relative;
  height: 6px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}
.calc-view .tx-cat-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.calc-view .tx-cat-bar-fill.over-budget { background: #c53030 !important; }
.calc-view .tx-cat-bar-overflow {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: #c53030;
  border-radius: 999px;
  opacity: 0.6;
}

/* ── Remaining / Transfer ── */
.calc-view .tx-remaining-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 0;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}
.calc-view .tx-remaining-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.calc-view .tx-remaining-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.calc-view .tx-remaining-amount {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 900;
  color: var(--need);
}
.calc-view .tx-transfer-btn {
  background: rgba(2,120,57,.08);
  border: 1px solid rgba(2,120,57,.25);
  border-radius: 8px;
  color: var(--need);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.calc-view .tx-transfer-btn:hover {
  background: rgba(2,120,57,.15);
  border-color: var(--need);
}

/* ── Filter Tabs ── */
.calc-view .tx-filter-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.calc-view .tx-filter-tab {
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.calc-view .tx-filter-tab:hover { background: var(--border); }
.calc-view .tx-filter-tab.active {
  background: var(--need-light);
  color: var(--need);
  border-color: var(--need);
}

/* ── Transaction List ── */
.calc-view .tx-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 24px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.calc-view .tx-list::-webkit-scrollbar { width: 4px; }
.calc-view .tx-list::-webkit-scrollbar-track { background: transparent; }
.calc-view .tx-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.calc-view .tx-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px 9px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s;
  overflow: hidden;
  min-height: 54px;
  flex-shrink: 0;
}
.calc-view .tx-row:hover { transform: translateX(2px); background: var(--border); }
.calc-view .tx-row-border {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.calc-view .tx-row-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; }
.calc-view .tx-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.calc-view .tx-row-merchant {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-view .tx-row-date {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.calc-view .tx-row-amount {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
}
.calc-view .tx-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: middle;
}
.calc-view .tx-pill-must    { background: var(--must-light);    color: var(--must); }
.calc-view .tx-pill-need    { background: var(--need-light);    color: var(--need); }
.calc-view .tx-pill-want    { background: var(--want-light);    color: var(--want); }
.calc-view .tx-pill-savings { background: var(--savings-light); color: var(--savings); }

/* ── Donut Legend ── */
.calc-view .donut-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
.calc-view .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.calc-view .legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,56,36,.10);
}
.calc-view .legend-swatch-outer {
  opacity: 0.75;
}

/* ── Donut Tooltip ── */
.calc-view .donut-tooltip {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}
.calc-view .donut-tooltip.visible {
  opacity: 1;
}

/* ── Budget Warning ── */
.calc-view .budget-warning {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #c53030;
  background: rgba(197,48,48,.06);
  border: 1px solid rgba(197,48,48,.20);
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 8px;
}

/* ── Apply to Budget Button ── */
.calc-view .apply-budget-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px 16px;
  background: rgba(2,120,57,.08);
  border: 1px solid rgba(2,120,57,.25);
  border-radius: 12px;
  color: var(--need);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.calc-view .apply-budget-btn:hover {
  background: rgba(2,120,57,.15);
  border-color: var(--need);
}

/* ── Segment Pulse Animation ── */
@keyframes segmentPulse {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(1.6); }
  70%  { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}
.calc-view .segment-pulse {
  animation: segmentPulse 0.7s ease forwards;
}

/* ── Budget Toast ── */
.calc-view .budget-toast {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,56,36,.10);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 9999;
  white-space: nowrap;
}
.calc-view .budget-toast.toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Client mode: hide settings/reset ── */
.calc-view.client-mode .settings-toggle,
.calc-view.client-mode .reset-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

/* ── Insight Cards ── */
.calc-view .insight-card {
  background: var(--soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calc-view .insight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.calc-view .insight-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.calc-view .insight-badge {
  background: var(--savings-light);
  color: var(--savings);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.calc-view .insight-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.calc-view .insight-pill {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.calc-view .insight-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.calc-view .insight-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}
.calc-view .insight-bar-current {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  opacity: 0.3;
}
.calc-view .insight-bar-target {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: 4px;
}
.calc-view .insight-bar-label {
  min-width: 32px;
  font-family: var(--mono);
  font-size: 0.75rem;
}
.calc-view .insight-tip {
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 3px solid var(--savings);
  padding-left: 10px;
  line-height: 1.4;
}
.calc-view .insight-annual {
  font-size: 0.78rem;
  color: var(--savings);
  font-weight: 600;
  text-align: right;
}
.calc-view .insight-summary {
  border: 1px solid var(--savings);
  border-radius: 12px;
  padding: 16px;
  margin-top: 6px;
  background: var(--savings-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-view .insight-summary-title {
  font-weight: 700;
  font-size: 1rem;
}
.calc-view .insight-summary-line {
  font-size: 0.88rem;
  color: var(--text);
}
.calc-view .insight-summary-extra {
  font-size: 0.82rem;
  color: var(--savings);
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .calc-view #donut-container {
    width: 340px;
  }

  .calc-view.panel-open #donut-container {
    top: 20%;
    left: 50%;
    transform: translate(-50%, 0) scale(0.6);
  }

  .calc-view .calc-panel {
    width: 100vw;
    max-width: 100%;
    top: auto;
    bottom: 0;
    max-height: 70vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border: none;
    border-top: 1px solid var(--border);
    transform: translate(0, 100%);
  }
  .calc-view .calc-panel.hidden { transform: translate(0, 100%); }
  .calc-view .calc-panel:not(.hidden) { transform: translate(0, 0); }


  .calc-view .calc-row, .calc-view .calc-row3 {
    grid-template-columns: 1fr;
  }

  .calc-view .settings-panel {
    width: 100%;
  }

  .calc-view .tx-panel {
    width: 100vw;
    max-width: 100%;
    top: auto;
    bottom: 0;
    left: 0;
    height: 72vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border: none;
    border-top: 1px solid var(--border);
    transform: translate(0, 100%);
  }
  .calc-view .tx-panel.hidden { transform: translate(0, 100%); }
  .calc-view .tx-panel:not(.hidden) { transform: translate(0, 0); }

  .calc-view.tx-open #donut-container {
    top: 20%;
    left: 50%;
    transform: translate(-50%, 0) scale(0.6);
  }
}

/* ── Rebalance Suggestions ── */
.calc-view .rebalance-suggestions {
  position: relative;
  background: rgba(251,191,36,.06);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 8px;
  animation: rebalanceFadeIn 0.25s ease;
}
.calc-view .rebalance-dismiss {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}
.calc-view .rebalance-dismiss:hover { color: var(--text); background: rgba(0,56,36,.05); }
.calc-view .rebalance-header {
  font-weight: 800;
  font-size: 12px;
  color: #92600a;
  margin-bottom: 8px;
  padding-right: 24px;
}
.calc-view .rebalance-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.calc-view .rebalance-cat {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 60px;
}
.calc-view .rebalance-delta {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: #92600a;
}
.calc-view .rebalance-apply-btn {
  background: rgba(2,120,57,.08);
  border: 1px solid rgba(2,120,57,.25);
  border-radius: 8px;
  color: var(--need);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.calc-view .rebalance-apply-btn:hover {
  background: rgba(2,120,57,.15);
  border-color: var(--need);
}
.calc-view .rebalance-apply-all-btn {
  width: 100%;
  margin-top: 8px;
  padding: 7px 14px;
  background: rgba(251,191,36,.06);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 8px;
  color: #92600a;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
}
.calc-view .rebalance-apply-all-btn:hover {
  background: rgba(251,191,36,.12);
  border-color: #92600a;
}
.calc-view .rebalance-note {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-top: 6px;
}
@keyframes rebalanceFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hide mode switch button ── */
.calc-view .mode-switch-btn { display: none !important; }

/* ── Back to ARIA button ── */
.calc-view .calc-back-btn {
  position: absolute;
  top: 8px;
  left: 16px;
  z-index: 200;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border: 1px solid #D4CFC6;
  color: #003824;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}
.calc-view .calc-back-btn:hover {
  background: #003824;
  color: white;
}
