/* ── Toast ───────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  font-size: var(--text-sm);
  min-width: 280px;
  animation: slideIn 0.2s ease;
  color: var(--text);
}

.toast.error { border-left-color: var(--red); }
.toast.toast-exit { animation: slideOut 0.3s ease forwards; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOut {
  to { transform: translateX(20px); opacity: 0; }
}

/* ── Loading skeleton ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 2px;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-icon { font-size: 40px; margin-bottom: 16px; }

.empty-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-style: italic;
}

.empty-sub { font-size: var(--text-sm); line-height: 1.6; max-width: 360px; margin: 0 auto; }


/* ── Secondary button (used in mobile settings) ──────────── */
.btn-secondary {
  flex-shrink: 0;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border-radius: 2px;
}
.btn-secondary:hover { border-color: var(--text-dim); color: var(--text); }

/* ── Button press feedback ───────────────────────────────── */
.modal-create:active,
.modal-cancel:active,
.add-account-btn:active,
.sidebar-btn:active,
.setup-cta:active,
.demo-btn:active,
.btn-secondary:active {
  transform: scale(0.97);
  transition: transform 0.05s;
}

/* ── Theme mode 3-state toggle (DARK / AUTO / LIGHT) ────── */
.theme-toggle {
  position: relative;
  width: 135px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s;
  padding: 0;
}
.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 42px;
  height: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  z-index: 1;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
/* thumb positions by data-mode */
.theme-toggle[data-mode="dark"]  .theme-toggle-thumb { transform: translateX(0); }
.theme-toggle[data-mode="auto"]  .theme-toggle-thumb { transform: translateX(45px); background: var(--accent-dim); border-color: var(--accent-border); }
.theme-toggle[data-mode="light"] .theme-toggle-thumb { transform: translateX(90px); background: var(--accent-dim); border-color: var(--accent-border); }

.theme-toggle-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 2;
  transition: color 0.2s;
  pointer-events: none;
  width: 45px;
  text-align: center;
}
.theme-toggle-dark  { left: 0; }
.theme-toggle-auto  { left: 45px; }
.theme-toggle-light { left: 90px; }

/* label colors — active segment gets accent */
.theme-toggle[data-mode="dark"]  .theme-toggle-dark  { color: var(--accent-text); }
.theme-toggle[data-mode="auto"]  .theme-toggle-auto  { color: var(--accent-text); }
.theme-toggle[data-mode="light"] .theme-toggle-light { color: var(--accent-text); }
.theme-toggle[data-mode="dark"]  .theme-toggle-auto,
.theme-toggle[data-mode="dark"]  .theme-toggle-light { color: var(--text-dim); }
.theme-toggle[data-mode="auto"]  .theme-toggle-dark,
.theme-toggle[data-mode="auto"]  .theme-toggle-light { color: var(--text-dim); }
.theme-toggle[data-mode="light"] .theme-toggle-dark,
.theme-toggle[data-mode="light"] .theme-toggle-auto  { color: var(--text-dim); }

/* ── Privacy Mode ────────────────────────────────────────── */
.privacy-btn {
  margin-top: 8px;
  border-color: var(--border);
  color: var(--text-dim);
}
.privacy-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}
.privacy-btn.active {
  border-color: var(--accent);
  color: var(--accent-text);
}

body.privacy-mode .stat-value,
body.privacy-mode .account-balance,
body.privacy-mode .acct-row-balance,
body.privacy-mode .txn-amount,
body.privacy-mode .hd-total-value,
body.privacy-mode #overviewSpendTotal,
body.privacy-mode #spendTotal,
body.privacy-mode #nwDelta,
body.privacy-mode #holdingsDelta,
body.privacy-mode .holding-shares-cell,
body.privacy-mode .holding-value-cell,
body.privacy-mode .holding-gain-cell,
body.privacy-mode .cb-figure,
body.privacy-mode .inv-figure,
body.privacy-mode .inc-yield,
body.privacy-mode .category-total-value,
body.privacy-mode .cat-bar-fill,
body.privacy-mode .budget-bar-fill,
body.privacy-mode .budget-bar-labels,
body.privacy-mode .nw-overlay,
body.privacy-mode .spend-ov-gauge-wrap,
body.privacy-mode .spend-ov-center-val,
body.privacy-mode .spend-ov-vs-last,
body.privacy-mode .spend-ov-amount,
body.privacy-mode canvas {
  filter: blur(6px);
  user-select: none;
  transition: filter 0.2s;
}

/* ── Responsive ──────────────────────────────────────────── */
/* Tablet */
@media (max-width: 900px) {
  #overviewGrid, .widget-grid { grid-template-columns: repeat(2, 1fr); }
  #overviewGrid [data-widget-type="full"],
  .widget-grid [data-widget-type="full"] { grid-column: 1 / -1; }
  #overviewGrid [data-widget-type="half"],
  .widget-grid [data-widget-type="half"] { grid-column: 1 / -1; }
  #overviewGrid [data-widget-type="mini"],
  .widget-grid [data-widget-type="mini"] { grid-column: span 1; }
  .page { padding: 28px 28px; }
}

@media (max-width: 768px) {
  #currentDate { display: none; }
  #overviewGreeting { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat-card { padding: 12px; }
  .stat-label { margin-bottom: 6px; }
  .stat-value { font-size: var(--text-xl); }
  .page { padding: 20px 12px; }
  .page-header { padding-left: 28px; }
  .widget-picker-grid { grid-template-columns: repeat(2, 1fr); }
  .widget-picker-card[style*="span 4"] { grid-column: span 2 !important; }
  .drag-handle { display: none; }
  #widgetEditDoneBtn.visible { display: block !important; }
  /* ── Recent Transactions ────────────────────────────────
     The title and its three filters share one flex row, and .txn-table-controls
     carries flex-shrink: 0 — so at phone widths their intrinsic width (a 140px
     category select plus two more, each with a 20px right margin) is wider than
     the card and they spilled outside it. Stack the controls under the title
     and let the selects share the row instead. */
  [data-widget="txn_table"] .chart-title {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .txn-table-controls { margin-right: 0; gap: 6px; }
  /* The two long filters split the row; the limit picker and + button keep
     their natural width, since their labels are short and fixed-length. */
  .txn-table-controls select { margin-right: 0; flex: 1 1 0; min-width: 0; }
  #ovTxnCategory { min-width: 0; }
  #ovTxnLimit { flex: 0 0 auto; }

  /* Tighter card so the table gets that width back. The negative margin below
     bleeds the table to the card edge, so the two have to stay in sync. */
  [data-widget="txn_table"] { padding: 16px; }
  #ovTxnTableWrap { margin: 0 -16px -16px; }
  #ovTxnTableWrap th, #ovTxnTableWrap td { padding: 8px 0; }
  #ovTxnTableWrap th:first-child, #ovTxnTableWrap td:first-child { padding-left: 12px; }
  #ovTxnTableWrap th:last-child,  #ovTxnTableWrap td:last-child  { padding-right: 12px; }
  #ovHoldingsTableWrap { margin: 0 -24px -24px; }
  #ovHoldingsTableWrap th, #ovHoldingsTableWrap td { padding: 8px 0; }
  #ovHoldingsTableWrap th:first-child, #ovHoldingsTableWrap td:first-child { padding-left: 12px; }
  /* Daily Gain (7th), not :last-child — the last column (% of Portfolio) is
     hidden below, so padding it would leave the visible edge flush. */
  #ovHoldingsTableWrap th:nth-child(7), #ovHoldingsTableWrap td:nth-child(7) { padding-right: 12px; }
  #ovHoldingsTableWrap .holding-name { display: none; }
  #ovHoldingsTableWrap th:nth-child(3), #ovHoldingsTableWrap td:nth-child(3) { display: none; }
  #ovHoldingsTableWrap th:nth-child(4), #ovHoldingsTableWrap td:nth-child(4) { display: none; }
  #ovHoldingsTableWrap th:nth-child(8), #ovHoldingsTableWrap td:nth-child(8) { display: none; }
}

@media (max-width: 520px) {
  .budget-bar-marker-label { display: none; }
}

