:root {
  --bg: #f5f7fa;
  --paper: #ffffff;
  --header: #f8f9fb;
  --grid: #e9ecf0;
  --text: #101828;
  --text-secondary: #475467;
  --muted: #98a1b2;
  --income: #15803d;
  --income-bg: #e8f7ee;
  --income-border: #bbe7cc;
  --expense: #b42318;
  --expense-bg: #fdecec;
  --expense-border: #f7c7c7;
  --neutral-bg: #eef2f6;
  --neutral-text: #475467;
  --warn: #d97706;
  --accent: #0b7a75;
  --accent-blue: #3b82f6;
  --today-bg: #eff6ff;
  --today-border: #3b82f6;
  --selected-bg: #dbeafe;
  --selected-border: #60a5fa;
  --both-bg: #bfdbfe;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --cell-total-offset: 3px;
  --row-height: 52px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.workspace {
  padding: 12px 12px 86px;
  position: relative;
}

.brand-logo {
  display: block;
  width: auto;
  max-width: 100%;
}

.brand-logo--auth-shell {
  height: 120px;
  margin: 0 auto;
}

.workspace-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.workspace-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

/* Mobile strip hidden by default on desktop */
.scenario-strip-wrap {
  display: none;
}

.scenario-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

/* Desktop: bar wraps below logo inside topbar if needed, but stays in flow */
.scenario-bar-wrap {
  flex: 1;
  min-width: 0;
}

.brand-logo--topbar {
  height: 42px;
}

.workspace-topbar__right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.top-help-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 30px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(31, 29, 26, 0.08);
  box-shadow: 0 28px 60px rgba(40, 33, 21, 0.1);
}

.auth-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.auth-text {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 24px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(31, 29, 26, 0.06);
}

.auth-tab {
  border: 0;
  border-radius: 14px;
  min-height: 46px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.auth-tab.is-active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(31, 29, 26, 0.08);
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.auth-form input {
  min-height: 56px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(57, 42, 19, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #fcfbf8 100%);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.auth-form input:focus {
  outline: none;
  border-color: rgba(11, 122, 117, 0.4);
  box-shadow: 0 0 0 4px rgba(11, 122, 117, 0.14);
}

.auth-submit {
  margin-top: 4px;
  min-height: 52px;
  justify-self: start;
  min-width: 180px;
}

.auth-link {
  justify-self: start;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.auth-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.auth-message.is-error {
  color: var(--expense);
}

.auth-message.is-success {
  color: var(--income);
}

.auth-local-actions {
  margin-top: 10px;
}

.auth-local-button {
  min-height: 48px;
  font-weight: 700;
}

.table-shell {
  height: calc(100vh - 144px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.budget-table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
}

.budget-table th,
.budget-table td {
  padding: 12px 16px;
  vertical-align: middle;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
}

.budget-table th:last-child,
.budget-table td:last-child {
  border-right: 0;
}

.budget-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--header);
  color: var(--muted);
  border-bottom: 1.5px solid var(--grid);
}

.budget-table thead th:first-child {
  left: 0;
  z-index: 7;
}

.budget-table thead th:not(:first-child) {
  text-align: left;
}

.budget-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #ffffff;
}

/* Zebra stripes */
.budget-row:nth-child(even) td:first-child {
  background: #fafafa;
}
.budget-row:nth-child(even) {
  background: #fafafa;
}

.budget-row {
  transition: background 80ms ease;
}

.budget-row:hover {
  background: #f5f7fa !important;
}

.budget-row:hover td:first-child {
  background: #f5f7fa !important;
}

.budget-row.drag-target {
  box-shadow: inset 0 0 0 2px var(--accent-blue);
  background: rgba(59, 130, 246, 0.04) !important;
}

/* Warn / danger balance states */
.budget-row.warn {
  background: #fffbeb;
}
.budget-row.warn td:first-child {
  background: #fffbeb;
}
.budget-row.danger {
  background: #fff7f7;
}
.budget-row.danger td:first-child {
  background: #fff7f7;
}

/* Today — full row blue tint + left accent */
.budget-row.today {
  background: var(--today-bg) !important;
}
.budget-row.today td:first-child {
  background: var(--today-bg) !important;
  border-left: 3px solid var(--today-border);
  padding-left: 13px;
}

/* Selected row */
.budget-row.active {
  background: var(--selected-bg) !important;
}
.budget-row.active td:first-child {
  background: var(--selected-bg) !important;
  border-left: 3px solid var(--selected-border);
  padding-left: 13px;
  box-shadow: inset 2px 0 8px rgba(96, 165, 250, 0.12);
}

/* Today + selected */
.budget-row.today.active {
  background: var(--both-bg) !important;
}
.budget-row.today.active td:first-child {
  background: var(--both-bg) !important;
  border-left: 3px solid var(--accent-blue);
}

.history-divider td {
  padding: 6px 16px;
  background: var(--header);
}

.history-divider__button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--grid);
}

.cell-date {
  min-width: 120px;
  position: relative;
  padding: 12px 16px;
  padding-bottom: 28px;
}

.day-diff {
  min-width: 92px;
  text-align: right;
  white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.84);
}

.cell-date-label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.cell-text {
  min-width: 320px;
  position: relative;
  padding: 10px 16px;
  padding-bottom: 28px;
  vertical-align: middle;
}

.entries-cell {
  display: block;
}

.cell-corner-total {
  position: absolute;
  bottom: var(--cell-total-offset);
  right: var(--cell-total-offset);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.73rem;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  background: transparent;
  border: 0;
}

.cell-corner-total.income {
  color: var(--income);
}

.cell-corner-total.expense {
  color: var(--muted);
}

.cell-corner-total.balance {
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 2px 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.add-chip {
  flex-shrink: 0;
}

.entry-chip,
.add-chip,
.hint-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 4px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  transition: filter 100ms ease, transform 100ms ease;
}

.entry-chip {
  gap: 5px;
  cursor: pointer;
  background: var(--neutral-bg);
  color: var(--neutral-text);
  border-color: #d5dce6;
}

.entry-chip:hover {
  filter: brightness(0.97);
}

.entry-chip:active {
  transform: scale(0.97);
}

.entry-chip.dragging {
  opacity: 0.45;
}

.entry-chip.drag-over {
  box-shadow: 0 0 0 2px var(--accent-blue);
}

/* Touch drag ghost — floating clone that follows the finger */
.touch-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  opacity: 0.92;
  transform: scale(1.05);
  box-shadow: 0 14px 32px rgba(20, 14, 5, 0.22);
  transition: transform 80ms ease;
}

body.touch-dragging {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* Income — green */
.entry-chip.income {
  background: var(--income-bg);
  border-color: var(--income-border);
  color: var(--income);
}

/* Expense — red, clear but not aggressive */
.entry-chip.expense {
  background: var(--expense-bg);
  border-color: var(--expense-border);
  color: var(--expense);
}

.entry-chip.recurring {
  border-style: dashed;
}

.entry-chip.wallet-linked {
  box-shadow: inset 0 0 0 1px rgba(11, 122, 117, 0.16);
}

.add-chip {
  cursor: pointer;
  background: rgba(11, 122, 117, 0.07);
  border-color: rgba(11, 122, 117, 0.18);
  color: var(--accent);
  font-weight: 600;
  min-height: 28px;
}

.add-chip:hover {
  background: rgba(11, 122, 117, 0.12);
}

.hint-chip {
  background: var(--neutral-bg);
  color: var(--muted);
  border-color: var(--grid);
}

.negative {
  color: var(--expense);
}

.status-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 35;
  display: grid;
  grid-template-columns: auto auto minmax(0, 2fr) minmax(180px, 0.9fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border-radius: 20px;
  background: rgba(255, 250, 244, 0.98);
  box-shadow: 0 14px 36px rgba(47, 33, 12, 0.1);
  backdrop-filter: blur(12px);
}

.mobile-status-toggle {
  display: none;
}

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 14, 0.46);
  z-index: 120;
}

.tour-tooltip {
  position: fixed;
  z-index: 130;
  width: min(340px, calc(100vw - 20px));
  background: #fff;
  border: 1px solid rgba(57, 42, 19, 0.12);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(25, 18, 10, 0.2);
  padding: 12px;
}

.tour-tooltip h4 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}

.tour-tooltip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.tour-tooltip__footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tour-tooltip__actions {
  display: flex;
  gap: 6px;
}

.tour-step-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.tour-highlight {
  position: relative;
  z-index: 140 !important;
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.4), 0 0 0 8px rgba(11, 122, 117, 0.16) !important;
  border-radius: 10px;
}

.status-bar__actions {
  display: flex;
  gap: 8px;
}

.status-bar__group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  overflow: auto hidden;
  white-space: nowrap;
}

.status-bar__group--compact {
  justify-content: center;
  min-width: 130px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(242, 245, 243, 0.98);
  border: 1px solid rgba(57, 42, 19, 0.08);
  font-size: 0.82rem;
}

.status-chip.is-deficit {
  background: rgba(199, 81, 58, 0.08);
  border-color: rgba(199, 81, 58, 0.18);
}

.status-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.status-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
}

.status-divider {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 2px;
  opacity: 0.7;
}

.status-value--trend.is-up { color: var(--income, #15803d); }
.status-value--trend.is-down { color: var(--expense, #b42318); }

.status-icon-button {
  min-width: 52px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 1.3rem;
  box-shadow: inset 0 0 0 1px rgba(57, 42, 19, 0.08);
  cursor: pointer;
}

.status-icon-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.status-select {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.status-select:focus {
  outline: none;
}

.status-bar__button {
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  background: linear-gradient(135deg, #0b7a75, #135e7c);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.status-link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.workspace-account {
  display: inline-flex;
  align-items: center;
}

.wallet-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, calc(100vw - 24px));
  z-index: 40;
  pointer-events: none;
}

.wallet-panel.open {
  pointer-events: auto;
}

.wallet-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 14, 0.24);
  opacity: 0;
  transition: opacity 180ms ease;
}

.wallet-panel.open::before {
  opacity: 1;
}

.wallet-panel__card {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  padding: 22px;
  background: #fffdf9;
  box-shadow: -24px 0 56px rgba(33, 23, 9, 0.12);
  transform: translateX(102%);
  transition: transform 220ms ease;
  overflow: auto;
}

.wallet-panel.open .wallet-panel__card {
  transform: translateX(0);
}

.wallet-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.wallet-panel__header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.wallet-panel__text {
  margin: 12px 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.wallet-total {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(11, 122, 117, 0.06);
  color: var(--accent);
  font-weight: 800;
}

/* Mobile: wallet panel becomes a full-screen sheet that stops above the
   bottom tabbar so the add-wallet form is always reachable */
@media (max-width: 700px) {
  .wallet-panel {
    inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0;
    width: 100vw;
  }
  .wallet-panel::before {
    inset: 0;
    background: transparent;
  }
  .wallet-panel__card {
    width: 100vw;
    height: 100%;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
    border-radius: 0;
    transform: translateY(102%);
    box-shadow: none;
  }
  .wallet-panel.open .wallet-panel__card {
    transform: translateY(0);
  }
}

.wallet-list {
  display: grid;
  gap: 12px;
}

.wallet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 80px auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(57, 42, 19, 0.1);
}

/* New card-based wallet UI */
.wallet-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(57, 42, 19, 0.1);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 120ms ease, border-color 120ms ease;
}

.wallet-card:focus-within {
  border-color: rgba(11, 122, 117, 0.3);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.08);
}

.wallet-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wallet-card__name-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding: 0;
  outline: none;
  min-width: 0;
}

.wallet-card__name-input::placeholder {
  color: rgba(31, 29, 26, 0.3);
  font-weight: 500;
}

.wallet-card__delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(199, 81, 58, 0.2);
  background: rgba(199, 81, 58, 0.06);
  color: var(--expense);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease;
}

.wallet-card__delete:hover {
  background: rgba(199, 81, 58, 0.14);
  border-color: rgba(199, 81, 58, 0.4);
}

.wallet-card__body {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(31, 29, 26, 0.04);
  border-radius: 12px;
  padding: 4px 4px 4px 12px;
}

.wallet-card__amount-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.wallet-card__sym {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
}

.wallet-card__amount-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding: 6px 0;
  outline: none;
  min-width: 0;
  -moz-appearance: textfield;
}

.wallet-card__amount-input::-webkit-outer-spin-button,
.wallet-card__amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.wallet-card__currency-select {
  flex-shrink: 0;
  border: none;
  background: rgba(11, 122, 117, 0.1);
  color: var(--accent);
  font-family: "Manrope", sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  letter-spacing: 0.04em;
}

.wallet-card__currency-select:focus {
  background: rgba(11, 122, 117, 0.18);
}

.wallet-card__eq {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  padding-left: 2px;
}

.wallet-currency-select {
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid rgba(57, 42, 19, 0.12);
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.wallet-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 22px 0 10px;
}

.wallet-settings-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(57, 42, 19, 0.1);
  border-radius: 18px;
  padding: 4px 0;
  overflow: hidden;
}

.wallet-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.wallet-settings-row--top {
  align-items: flex-start;
}

.wallet-settings-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wallet-settings-label__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.wallet-settings-label__hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.wallet-settings-divider {
  height: 1px;
  background: rgba(57, 42, 19, 0.08);
  margin: 0;
}

.wallet-base-currency-row,
.wallet-rates-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.wallet-base-label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.wallet-base-currency-select {
  border: none;
  background: rgba(11, 122, 117, 0.1);
  color: var(--accent);
  font-family: "Manrope", sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  letter-spacing: 0.03em;
}

.wallet-base-currency-select:focus {
  background: rgba(11, 122, 117, 0.18);
}

.rates-status {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.rates-status--ok {
  color: var(--income);
}

.wallet-rates-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 14px;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.wallet-rate-chip {
  font-size: 0.76rem;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(31, 29, 26, 0.05);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
}

.wallet-row input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(57, 42, 19, 0.12);
}

.wallet-row input:focus {
  outline: 2px solid rgba(11, 122, 117, 0.18);
  border-color: rgba(11, 122, 117, 0.28);
}

.wallet-actions {
  margin-top: 16px;
}

.entry-dialog {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  background: transparent;
}

.entry-dialog::backdrop {
  background: rgba(27, 24, 19, 0.42);
  backdrop-filter: blur(8px);
}

.dialog-card {
  margin: 0;
  padding: 28px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(252, 248, 241, 0.98) 100%);
  border: 1px solid rgba(87, 68, 38, 0.08);
  box-shadow:
    0 28px 90px rgba(37, 24, 8, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.dialog-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.95rem;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.dialog-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dialog-grid input,
.dialog-grid select {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(57, 42, 19, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #fcfbf8 100%);
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 2px rgba(31, 29, 26, 0.03);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    transform 140ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.dialog-grid input:focus,
.dialog-grid select:focus {
  outline: none;
  border-color: rgba(11, 122, 117, 0.4);
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(11, 122, 117, 0.14),
    0 10px 24px rgba(11, 122, 117, 0.08);
  transform: translateY(-1px);
}

.dialog-grid input::placeholder {
  color: #b0a89d;
  font-weight: 600;
}

.dialog-grid select {
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(31, 29, 26, 0.66) 50%),
    linear-gradient(135deg, rgba(31, 29, 26, 0.66) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.dialog-grid input[type="date"] {
  letter-spacing: -0.02em;
}

.dialog-grid input[type="number"] {
  padding-right: 14px;
}

.span-2 {
  grid-column: 1 / -1;
}

.dialog-hint {
  display: block;
  margin-top: 8px;
  color: rgba(57, 42, 19, 0.62);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}


.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(57, 42, 19, 0.08);
}

.dialog-actions-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dialog-rec {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(180, 35, 24, 0.35);
  background: #fff;
  color: var(--expense, #b42318);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  padding: 0;
  font: inherit;
  transition: transform 120ms ease, background 140ms ease, box-shadow 140ms ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.dialog-rec:hover {
  background: rgba(180, 35, 24, 0.08);
}

.dialog-rec__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--expense, #b42318);
  display: inline-block;
}

.dialog-rec__label {
  font-size: 9px;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--expense, #b42318);
}

.dialog-rec.is-recording {
  background: var(--expense, #b42318);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.18);
  animation: dialog-rec-pulse 1.1s ease-in-out infinite;
}

.dialog-rec.is-recording .dialog-rec__dot {
  background: #fff;
  animation: dialog-rec-blink 0.7s linear infinite;
}

.dialog-rec.is-recording .dialog-rec__label {
  color: #fff;
}

.dialog-rec.is-processing {
  background: rgba(180, 35, 24, 0.10);
  cursor: progress;
}

.dialog-rec.is-processing .dialog-rec__dot {
  background: rgba(180, 35, 24, 0.4);
  animation: dialog-rec-blink 0.6s linear infinite;
}

.dialog-rec[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

@keyframes dialog-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.18); }
  50%      { box-shadow: 0 0 0 9px rgba(180, 35, 24, 0.10); }
}

@keyframes dialog-rec-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.dialog-rec-hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #0b7a75, #135e7c);
  color: white;
  font-weight: 700;
  box-shadow: 0 14px 24px rgba(19, 94, 124, 0.22);
}

.ghost-button,
.icon-button {
  background: rgba(57, 42, 19, 0.08);
  color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.danger-text {
  color: var(--expense);
}

@media (max-width: 900px) {
  .workspace {
    padding: 0;
  }

  .auth-shell {
    padding: 14px;
    gap: 10px;
  }

  .auth-card {
    padding: 22px;
    border-radius: 24px;
  }

  .brand-logo--auth-shell {
    height: 94px;
  }

  .table-shell {
    height: calc(100dvh - 158px);
    border-radius: 0;
    box-shadow: none;
  }

  .wallet-row {
    grid-template-columns: 1fr 1fr;
  }

  .wallet-row input:first-child {
    grid-column: 1 / -1;
  }

  .workspace-topbar {
    margin: 8px 8px 0;
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .workspace-topbar__left {
    overflow: hidden;
    flex: 0 0 auto;
  }

  .workspace-topbar__right {
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
    flex-wrap: wrap;
  }

  .workspace-topbar__right .view-toggle { display: none; }

  .workspace-account {
    flex-shrink: 1;
    min-width: 0;
  }

  .workspace-account .status-label,
  .workspace-account .status-value {
    display: none;
  }

  /* Scenario bar (mobile strip) — give it its own full-width row */
  .scenario-strip-wrap {
    width: 100%;
    order: 10;
  }

  /* Hide desktop scenario bar on mobile */
  #scenarioBarContainer {
    display: none;
  }

  /* Mobile scenario strip — horizontal scrollable row */
  .scenario-strip-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 6px 8px 2px;
  }

  .scenario-strip-wrap::-webkit-scrollbar {
    display: none;
  }

  .scenario-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: max-content;
    min-width: 100%;
  }

  .scenario-strip .scenario-tab-wrap {
    flex-shrink: 0;
  }

  .scenario-strip .scenario-tab {
    flex-shrink: 0;
    white-space: nowrap;
    height: 30px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .brand-logo--topbar {
    height: 34px;
  }

  .status-bar {
    left: 8px;
    right: 8px;
    bottom: 60px;
    grid-template-columns: 1fr;
    transform: translateY(calc(100% + 76px));
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
    backdrop-filter: none;
    box-shadow: 0 8px 18px rgba(47, 33, 12, 0.08);
  }

  .status-bar.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .status-bar__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-bar__button {
    min-height: 46px;
    width: 100%;
  }

  .mobile-status-toggle {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 36;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    background: rgba(241, 237, 231, 0.98);
    box-shadow: 0 10px 24px rgba(47, 33, 12, 0.16);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
  }

  .mobile-status-toggle[aria-expanded="true"],
  .mobile-status-toggle[aria-expanded="false"] {
    background: rgba(241, 237, 231, 0.98);
    color: var(--text);
  }

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

  .span-2 {
    grid-column: auto;
  }

  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dialog-actions-right {
    display: flex;
    gap: 10px;
    align-items: center;
  }
  .dialog-actions-right > #cancelDialogButton,
  .dialog-actions-right > #saveDialogButton { flex: 1 1 auto; }
  .dialog-actions-right > .dialog-rec { flex: 0 0 auto; }

  .budget-row,
  .entry-chip,
  .add-chip,
  .ghost-button,
  .primary-button,
  .icon-button {
    transition: none !important;
  }
}

/* ─── Scenario Bar ──────────────────────────────────────────────────────────── */

.scenario-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.scenario-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(57, 42, 19, 0.14);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.scenario-tab:hover {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-color: rgba(57, 42, 19, 0.22);
}

.scenario-tab.is-active.scenario-tab--base {
  background: linear-gradient(135deg, #0b7a75, #135e7c);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(11, 122, 117, 0.28);
}

.scenario-tab.is-active.scenario-tab--hypo {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.4);
  border-style: dashed;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.scenario-tab--hypo {
  border-style: dashed;
}

.scenario-tab--add {
  border-style: dashed;
  background: transparent;
  color: var(--accent);
  border-color: rgba(11, 122, 117, 0.3);
  font-size: 0.8rem;
}

.scenario-tab--add:hover {
  background: rgba(11, 122, 117, 0.06);
  border-color: rgba(11, 122, 117, 0.5);
  color: var(--accent);
}

.scenario-tab__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
  flex-shrink: 0;
  opacity: 0.7;
}

.scenario-tab.is-active .scenario-tab__dot {
  background: #60a5fa;
  opacity: 1;
}

.scenario-manage-btn {
  font-size: 0.82rem;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border: 1px dashed rgba(37, 99, 235, 0.3);
  white-space: nowrap;
}

.scenario-manage-btn:hover {
  background: rgba(37, 99, 235, 0.14);
}

/* ─── Scenario Entry Chip ────────────────────────────────────────────────────── */

.entry-chip.scenario-entry {
  border-color: rgba(37, 99, 235, 0.4) !important;
  border-style: dashed !important;
  background: rgba(37, 99, 235, 0.08) !important;
  color: #1e40af !important;
}

.entry-chip.scenario-entry.income {
  background: rgba(37, 99, 235, 0.1) !important;
  border-color: rgba(37, 99, 235, 0.35) !important;
}

.entry-chip.scenario-entry.expense {
  background: rgba(124, 58, 237, 0.08) !important;
  border-color: rgba(124, 58, 237, 0.3) !important;
  color: #5b21b6 !important;
}

.scenario-entry-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  margin-right: 3px;
  flex-shrink: 0;
  vertical-align: middle;
}

.entry-chip.scenario-entry.expense .scenario-entry-dot {
  background: #7c3aed;
}

/* ─── Scenario Panel (slide-over, mirrors wallet-panel) ─────────────────────── */

.scenario-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, calc(100vw - 24px));
  z-index: 40;
  pointer-events: none;
}

.scenario-panel.open {
  pointer-events: auto;
}

.scenario-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 14, 0.24);
  opacity: 0;
  transition: opacity 180ms ease;
}

.scenario-panel.open::before {
  opacity: 1;
}

.scenario-panel__card {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  padding: 22px;
  background: #f4f8ff;
  box-shadow: -24px 0 56px rgba(33, 23, 9, 0.12);
  transform: translateX(102%);
  transition: transform 220ms ease;
  overflow: auto;
  border-left: 2px solid rgba(37, 99, 235, 0.15);
}

.scenario-panel.open .scenario-panel__card {
  transform: translateX(0);
}

/* ─── Scenario Bar responsive ────────────────────────────────────────────────── */

/* ─── Scenario multiselect in entry dialog ──────────────────────────────────── */

.scenario-multiselect-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.scenario-multiselect {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scenario-checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(57, 42, 19, 0.14);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  user-select: none;
}

.scenario-checkbox-item:hover {
  background: rgba(37, 99, 235, 0.05);
  border-color: rgba(37, 99, 235, 0.25);
}

.scenario-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: unset;
  padding: 0;
  accent-color: #2563eb;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
}

.scenario-checkbox-item:has(input:checked) {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.scenario-checkbox-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.scenario-checkbox-item:has(input:checked) .scenario-checkbox-name {
  color: #1d4ed8;
}

/* ─── Scenario panel entry tags ─────────────────────────────────────────────── */

.scenario-entry-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.scenario-entry-tag--source {
  background: rgba(124, 58, 237, 0.08);
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.2);
}

.scenario-panel-entry--shared {
  border-color: rgba(124, 58, 237, 0.25) !important;
  background: rgba(124, 58, 237, 0.03) !important;
}

/* ─── Date header arrow ─────────────────────────────────────────────────────── */

#dateHeaderCell {
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.date-header-label {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(122, 116, 108, 0.5);
}

#dateHeaderCell:hover .date-header-label {
  text-decoration-color: var(--muted);
}

.date-header-arrow {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.6rem;
  line-height: 1;
  vertical-align: middle;
  color: var(--muted);
  opacity: 0;
  transform: translateY(0px);
  transition: opacity 200ms ease, transform 200ms ease;
  width: 10px;
  text-align: center;
}

.date-header-arrow--down,
.date-header-arrow--up {
  opacity: 1;
}

.date-header-arrow--down {
  color: var(--accent);
  animation: arrowPulse 400ms ease;
}

.date-header-arrow--up {
  color: var(--muted);
  animation: arrowPulse 400ms ease;
}

@keyframes arrowPulse {
  0% { opacity: 0.3; transform: scale(0.7); }
  60% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* ─── Scenario dropdown in entry dialog ─────────────────────────────────────── */

.scenario-dropdown-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.scenario-dropdown {
  position: relative;
}

.scenario-dropdown__trigger {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(57, 42, 19, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #fcfbf8 100%);
  color: var(--text);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease, border-radius 140ms ease;
}

.scenario-dropdown__trigger:hover {
  border-color: rgba(57, 42, 19, 0.22);
}

.scenario-dropdown__trigger.is-open {
  outline: none;
  border-color: rgba(11, 122, 117, 0.4);
  box-shadow: 0 0 0 4px rgba(11, 122, 117, 0.14);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.scenario-dropdown__trigger:focus:not(.is-open) {
  outline: none;
  border-color: rgba(11, 122, 117, 0.4);
  box-shadow: 0 0 0 4px rgba(11, 122, 117, 0.14);
}

.scenario-dropdown__chevron {
  font-size: 0.75rem;
  color: var(--muted);
  transition: transform 180ms ease;
  flex-shrink: 0;
}

.scenario-dropdown__trigger.is-open .scenario-dropdown__chevron {
  transform: rotate(180deg);
}

.scenario-dropdown__menu {
  /* Inline flow — no absolute positioning */
  border: 1px solid rgba(11, 122, 117, 0.4);
  border-top: none;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  box-shadow: 0 0 0 4px rgba(11, 122, 117, 0.14);
  background: #ffffff;
  overflow: hidden;
  margin-top: -2px;
}

.scenario-dropdown__list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scenario-dd-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 100ms ease;
  user-select: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.scenario-dd-item:hover {
  background: rgba(11, 122, 117, 0.06);
}

.scenario-dd-checkbox {
  display: none;
}

.scenario-dd-check {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid rgba(57, 42, 19, 0.22);
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
  position: relative;
}

.scenario-dd-check::after {
  content: "";
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 100ms ease;
}

.scenario-dd-item:has(.scenario-dd-checkbox:checked) .scenario-dd-check {
  background: #0b7a75;
  border-color: #0b7a75;
}

.scenario-dd-item:has(.scenario-dd-checkbox:checked) .scenario-dd-check::after {
  opacity: 1;
}

.scenario-dd-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.scenario-dd-item:has(.scenario-dd-checkbox:checked) .scenario-dd-name {
  color: #0b7a75;
}

.scenario-dropdown__footer {
  padding: 8px 10px;
  border-top: 1px solid rgba(57, 42, 19, 0.08);
  display: flex;
  justify-content: flex-end;
}

.scenario-dropdown__done {
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0b7a75, #135e7c);
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

/* ─── Scenario tab pencil edit button ──────────────────────────────────────── */

.scenario-tab-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.scenario-tab-edit {
  position: absolute;
  right: -6px;
  top: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(37, 99, 235, 0.3);
  background: #fff;
  color: #2563eb;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 2;
  padding: 0;
}

.scenario-tab-wrap:hover .scenario-tab-edit {
  opacity: 1;
  transform: scale(1);
}

.scenario-tab-edit:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* ─── Scenario create dialog options ────────────────────────────────────────── */

.scenario-create-option {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(57, 42, 19, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #fcfbf8 100%);
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  user-select: none;
}

.scenario-create-option:has(input:checked) {
  border-color: rgba(11, 122, 117, 0.4);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.1);
}

.scenario-create-option input[type="radio"] {
  display: none;
}

.scenario-create-option__icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent);
}

.scenario-create-option__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scenario-create-option__text strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.scenario-create-option__text span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Recurrence symbol in chip ─────────────────────────────────────────────── */

.recurrence-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  opacity: 0.7;
  letter-spacing: -0.02em;
  margin-left: 1px;
}

/* ─── View toggle ────────────────────────────────────────────────────────────── */

.view-toggle {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(57, 42, 19, 0.14);
  background: rgba(255, 255, 255, 0.7);
}

.view-toggle__btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-toggle__btn.is-active {
  background: var(--accent);
  color: #fff;
}

.view-toggle__btn:not(.is-active):hover {
  background: rgba(11, 122, 117, 0.08);
  color: var(--accent);
}

/* ─── Calendar shell ─────────────────────────────────────────────────────────── */

.calendar-shell {
  height: calc(100vh - 120px);
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.calendar-nav__btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(57, 42, 19, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-nav__btn:hover {
  background: rgba(11, 122, 117, 0.08);
  border-color: rgba(11, 122, 117, 0.3);
  color: var(--accent);
}

.calendar-nav__title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  text-transform: capitalize;
  letter-spacing: -0.02em;
}

.calendar-grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--grid);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--header);
  border-bottom: 1.5px solid var(--grid);
}

.calendar-weekdays span {
  text-align: center;
  padding: 9px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 1;
}

.cal-cell {
  min-height: 110px;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background 80ms ease;
  position: relative;
  background: #ffffff;
}

.cal-cell:nth-child(even) {
  background: #fafafa;
}

.cal-cell:nth-child(7n) {
  border-right: none;
}

.cal-cell:hover {
  background: #f5f7fa !important;
}

.cal-cell.today {
  background: var(--today-bg) !important;
  border-left: 3px solid var(--today-border);
  padding-left: 5px;
}

.cal-cell.today .cal-cell__day {
  background: var(--accent-blue);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cal-cell.active {
  background: var(--selected-bg) !important;
  border-left: 3px solid var(--selected-border);
  padding-left: 5px;
}

.cal-cell.today.active {
  background: var(--both-bg) !important;
}

.cal-cell.warn {
  background: #fffbeb !important;
}

.cal-cell.danger {
  background: #fff7f7 !important;
}

.cal-cell--empty {
  cursor: default;
  background: var(--header) !important;
}

.cal-cell__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.cal-cell__day {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  flex-shrink: 0;
}

.cal-cell__balance {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
}

.cal-cell__balance.negative {
  color: var(--expense);
  font-weight: 700;
}

.cal-cell__balance.positive {
  color: var(--income);
  font-weight: 600;
}

.cal-cell__balance.zero {
  color: var(--muted);
}

.cal-chip-more {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  padding: 1px 4px;
  flex-shrink: 0;
}

.cal-cell__chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

/* Calendar chips — same color system as table entry-chips */
.cal-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cal-chip.income {
  background: var(--income-bg);
  border-color: var(--income-border);
  color: var(--income);
}

.cal-chip.expense {
  background: var(--expense-bg);
  border-color: var(--expense-border);
  color: var(--expense);
}

.cal-cell__add {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
  margin-top: 2px;
}

.cal-cell:hover .cal-cell__add {
  opacity: 1;
}

.cal-cell__add .add-chip {
  min-height: 20px;
  height: 20px;
  padding: 0 8px;
  font-size: 0.72rem;
}

.cal-add-expense {
  background: var(--expense-bg) !important;
  border-color: var(--expense-border) !important;
  color: var(--expense) !important;
}

/* ─── Calendar mobile ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .calendar-shell {
    height: calc(100dvh - 158px);
    padding: 6px;
    gap: 6px;
  }

  .calendar-nav__title {
    font-size: 0.95rem;
  }

  .calendar-grid-wrap {
    border-radius: 10px;
    overflow: hidden;
  }

  /* Force exactly 7 equal columns — critical for mobile */
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .calendar-weekdays {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .calendar-weekdays span {
    font-size: 0.6rem;
    padding: 6px 1px;
    letter-spacing: 0;
    text-align: center;
  }

  .cal-cell {
    min-height: 72px;
    min-width: 0;
    padding: 4px 3px;
    gap: 2px;
    overflow: hidden;
  }

  .cal-cell.today {
    border-left: 2px solid var(--today-border);
    padding-left: 2px;
  }

  .cal-cell.active {
    border-left: 2px solid var(--selected-border);
    padding-left: 2px;
  }

  .cal-cell__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 2px;
  }

  .cal-cell__day {
    font-size: 0.72rem;
    font-weight: 700;
  }

  .cal-cell.today .cal-cell__day {
    width: 18px;
    height: 18px;
    font-size: 0.68rem;
  }

  .cal-cell__balance {
    font-size: 0.55rem;
    font-weight: 600;
  }

  /* Mobile chips — pill shape, very compact, full width */
  .cal-chip {
    font-size: 0.58rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
  }

  .cal-cell__chips {
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
  }

  .cal-cell__add {
    display: none;
  }
}

@media (max-width: 480px) {
  .cal-cell {
    min-height: 56px;
    padding: 3px 2px;
  }

  .cal-cell__balance {
    display: none;
  }

  /* At very small sizes: colored dots instead of text */
  .cal-chip {
    width: 7px;
    height: 7px;
    min-width: 7px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    flex-shrink: 0;
    border: none;
    display: inline-block;
  }

  .cal-chip.income {
    background: var(--income);
  }

  .cal-chip.expense {
    background: var(--expense);
  }

  .cal-cell__chips {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
    max-height: 24px;
    overflow: hidden;
  }

  .calendar-weekdays span {
    font-size: 0.55rem;
    padding: 5px 1px;
  }

  .cal-cell__day {
    font-size: 0.65rem;
  }

  .cal-cell.today .cal-cell__day {
    width: 16px;
    height: 16px;
    font-size: 0.62rem;
  }
}

/* ─── Balance amount colors ──────────────────────────────────────────────────── */

.balance--positive {
  color: var(--income);
  font-weight: 700;
}

.balance--negative {
  color: var(--expense);
  font-weight: 700;
}

.balance--zero {
  color: var(--muted);
  font-weight: 600;
}

/* ─── Column collapse (Google Sheets style) ─────────────────────────────────── */

.col-header {
  position: relative;
}

.col-header__full {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.col-hide-btn {
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  border: 1px solid var(--grid);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.1em;
  cursor: pointer;
  transition: opacity 120ms ease, background 100ms ease, color 100ms ease;
  flex-shrink: 0;
}

th.col-header:hover .col-hide-btn {
  opacity: 1;
}

.col-hide-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.col-header__stub {
  display: flex;
  align-items: center;
  justify-content: center;
}

.col-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  border: 1px solid var(--grid);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.1em;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}

.col-expand-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Collapsed column — header shrinks to narrow stub */
th.col-header--collapsed {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 8px 4px !important;
  overflow: hidden;
  background: #f8f9fb;
  border-right: 2px solid var(--grid);
}

/* Hide cell content when column collapsed, show only narrow stub */
.budget-table.col-income-hidden tr td:nth-child(2) {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 0 !important;
  overflow: hidden;
  background: #f8f9fb !important;
}

.budget-table.col-expense-hidden tr td:nth-child(3) {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 0 !important;
  overflow: hidden;
  background: #f8f9fb !important;
}

/* Hide actual content inside collapsed cells */
.budget-table.col-income-hidden tr td:nth-child(2) > * {
  display: none;
}

.budget-table.col-expense-hidden tr td:nth-child(3) > * {
  display: none;
}

/* ─── Hide view toggle on mobile (only table view available) ────────────────── */

@media (max-width: 900px) {
  #viewToggle {
    display: none;
  }
}

/* ─── AI Assistant Panel ────────────────────────────────────────────────────── */

.ai-fab {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(11, 122, 117, 0.78);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(11, 122, 117, 0.32), 0 4px 10px rgba(16, 24, 40, 0.18);
  transition: transform 160ms ease, background 140ms ease, box-shadow 140ms ease, opacity 160ms ease;
}

.ai-fab:hover {
  background: rgba(11, 122, 117, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(11, 122, 117, 0.42), 0 6px 14px rgba(16, 24, 40, 0.22);
}

.ai-fab:active {
  transform: translateY(0);
}

.ai-fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}

.ai-fab__label {
  pointer-events: none;
}

@media (max-width: 700px) {
  .ai-fab {
    right: 14px;
    bottom: calc(64px + max(8px, env(safe-area-inset-bottom)));
    width: 54px;
    height: 54px;
  }
}

.ai-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, calc(100vw - 24px));
  z-index: 50;
  pointer-events: none;
}

.ai-panel.open {
  pointer-events: auto;
}

.ai-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.32);
  opacity: 0;
  transition: opacity 180ms ease;
}

.ai-panel.open::before {
  opacity: 1;
}

.ai-panel__card {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  box-shadow: -24px 0 56px rgba(16, 24, 40, 0.18);
  transform: translateX(102%);
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
}

.ai-panel.open .ai-panel__card {
  transform: translateX(0);
}

.ai-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--grid);
}

.ai-panel__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-suggestions {
  padding: 4px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggestions__title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.ai-suggestion {
  background: var(--neutral-bg);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}

.ai-suggestion:hover {
  background: #fff;
  border-color: var(--accent);
}

.ai-suggestion:active {
  transform: scale(0.98);
}

.ai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 0.95rem;
  white-space: normal;
}

.ai-msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg--assistant {
  align-self: flex-start;
  background: var(--neutral-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.ai-msg--loading {
  opacity: 0.55;
  letter-spacing: 0.15em;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--grid);
}

.ai-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  font: inherit;
  outline: none;
  background: #fff;
}

.ai-input:focus {
  border-color: var(--accent);
}

.ai-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 44px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
}

.ai-send:hover {
  filter: brightness(1.08);
}

/* AI chat mic reuses the .dialog-rec REC look (red circle with dot + label).
   Click toggles record (no press-and-hold) so longer chat messages are easy. */
.ai-mic.dialog-rec {
  width: 44px;
  height: 44px;
}

/* Map legacy --active / --processing classes to the unified rec states */
.ai-mic--active {
  background: var(--expense, #b42318) !important;
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.18) !important;
  animation: dialog-rec-pulse 1.1s ease-in-out infinite;
}
.ai-mic--active .dialog-rec__dot {
  background: #fff !important;
  animation: dialog-rec-blink 0.7s linear infinite;
}
.ai-mic--active .dialog-rec__label {
  color: #fff !important;
}

.ai-mic--processing {
  opacity: 0.6;
  cursor: progress;
  pointer-events: none;
}
.ai-mic--processing .dialog-rec__dot {
  background: rgba(180, 35, 24, 0.4) !important;
  animation: dialog-rec-blink 0.6s linear infinite;
}

/* AI chat: mobile layout (placed AFTER base rules so it actually overrides) */
@media (max-width: 700px) {
  .ai-panel {
    width: 100vw;
    inset: 0;
    z-index: 70;
  }
  .ai-panel::before { display: none; }

  .ai-panel__card {
    border-radius: 0;
    box-shadow: none;
    width: 100vw;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .ai-panel__header {
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    background: var(--paper, #fff);
    border-bottom: 1px solid var(--grid);
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .ai-panel__header h2 { font-size: 1.05rem; }
  .ai-panel__header .icon-button { width: 38px; height: 38px; }

  .ai-messages {
    padding: 14px 14px 8px;
    gap: 12px;
    overscroll-behavior: contain;
  }
  .ai-msg {
    max-width: 88%;
    font-size: 1rem;
    padding: 11px 14px;
  }

  .ai-suggestions {
    padding: 6px 14px 10px;
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
  }
  .ai-suggestions::-webkit-scrollbar { display: none; }
  .ai-suggestions__title { display: none; }
  .ai-suggestion {
    flex: 0 0 auto;
    padding: 9px 14px;
    border-radius: 999px;
    white-space: nowrap;
    scroll-snap-align: start;
    background: rgba(11, 122, 117, 0.07);
    border-color: rgba(11, 122, 117, 0.18);
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 600;
  }

  .ai-input-row {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
    align-items: flex-end;
    background: var(--paper, #fff);
  }
  .ai-input {
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 1rem;
  }
  .ai-send {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    flex: 0 0 auto;
  }
  .ai-mic.dialog-rec {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
  }
}

/* Telegram link modal */
.tg-link-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 14, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}

.tg-link-card {
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(28, 22, 14, 0.25);
  width: 100%;
  max-width: 420px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tg-link-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tg-link-card__header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.tg-link-card__close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.tg-link-card__close:hover { color: var(--text); }

.tg-link-card__lead {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.tg-link-card__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 140ms ease;
}

.tg-link-card__cta:hover {
  background: #075c58;
  color: #fff;
}

.tg-link-card__or {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.tg-link-card__code {
  display: block;
  background: var(--bg);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  user-select: all;
}

.tg-link-card__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

/* ════════════════════════════════════════════════════════════════════════════
   ONBOARDING (post-registration)
   ════════════════════════════════════════════════════════════════════════════ */

.onboarding-shell {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FBF7F1 0%, #F4ECDF 100%);
  z-index: 80;
  overflow-y: auto;
  padding: 72px 64px 120px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.onboarding-shell[hidden] { display: none; }

.onb-stage {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.onb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}

.onb-topbar .brand-logo--topbar {
  height: 22px;
}

.onb-progress {
  display: flex;
  gap: 8px;
}

.onb-progress__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.12);
  transition: width 200ms ease, background 200ms ease;
}

.onb-progress__dot.is-current {
  width: 24px;
  background: var(--accent);
}

.onb-progress__dot.is-done {
  background: rgba(11, 122, 117, 0.55);
}

.onb-skip-all {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 0;
}

.onb-skip-all:hover {
  color: var(--text);
}

.onb-screen {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.onb-screen[hidden] { display: none; }

.onb-eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

.onb-title {
  margin: 0;
  font-size: 3rem;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 760px;
}

.onb-text {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 680px;
}

.onb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.onb-tag {
  background: rgba(11, 122, 117, 0.07);
  border: 1px solid rgba(11, 122, 117, 0.18);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, transform 60ms ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.onb-tag:hover {
  background: rgba(11, 122, 117, 0.14);
}

.onb-tag:active {
  transform: translateY(1px);
}

.onb-currency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.onb-currency {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 28px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font: inherit;
  transition: border-color 140ms ease, background 140ms ease;
}

.onb-currency:hover {
  border-color: var(--accent);
}

.onb-currency.is-selected {
  border-color: var(--accent);
  background: rgba(11, 122, 117, 0.08);
}

.onb-currency__symbol {
  font-size: 1.7rem;
  font-weight: 800;
  font-family: "IBM Plex Mono", monospace;
  color: var(--text);
}

.onb-currency__code {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.onb-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.onb-list:empty { display: none; }

.onb-list-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 14px 16px;
}

.onb-list-item__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(11, 122, 117, 0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 0.9rem;
}

.onb-list-item__name {
  font-weight: 600;
}

.onb-list-item__amount {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}

.onb-list-item__currency {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.onb-list-item__remove {
  background: transparent;
  border: 1px solid var(--grid);
  color: var(--text-secondary);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
}

.onb-list-item__remove:hover {
  border-color: var(--expense, #b42318);
  color: var(--expense, #b42318);
}

.onb-form {
  display: grid;
  grid-template-columns: 1.4fr 160px 110px auto;
  gap: 18px;
  align-items: center;
}

.onb-form--columns {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

.onb-form--columns .onb-field--wide {
  grid-column: 1 / -1;
}

.onb-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.onb-field--wide {
  grid-column: 1 / -1;
}

.onb-field__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-secondary);
}

.onb-input {
  height: 56px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--grid);
  background: var(--paper, #fff);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.onb-input.mono {
  font-family: "IBM Plex Mono", monospace;
}

.onb-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
}

.onb-add {
  height: 56px;
  padding: 0 24px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.onb-add:hover {
  background: #075c58;
}

.onb-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.onb-cta {
  min-width: 220px;
  height: 56px;
  padding: 0 32px;
  font-size: 1rem;
}

.onb-back, .onb-skip {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 10px 6px;
}

.onb-back:hover, .onb-skip:hover { color: var(--text); }

.onb-skip { margin-left: auto; }

@media (max-width: 900px) {
  .onboarding-shell { padding: 48px 32px 80px; }
  .onb-stage { gap: 40px; }
  .onb-screen { gap: 28px; }
  .onb-title { font-size: 2.2rem; }
  .onb-form--columns { grid-template-columns: 1fr 1fr; gap: 18px; }
}

@media (max-width: 600px) {
  .onboarding-shell { padding: 32px 20px 64px; }
  .onb-stage { gap: 32px; }
  .onb-screen { gap: 24px; }
  .onb-title { font-size: 1.7rem; }
  .onb-text { font-size: 1rem; }
  .onb-form { grid-template-columns: 1fr; gap: 14px; }
  .onb-form--columns { grid-template-columns: 1fr; gap: 16px; }
  .onb-list-item { grid-template-columns: auto 1fr auto auto; }
  .onb-list-item__icon { display: none; }
  .onb-cta { width: 100%; min-width: 0; }
  .onb-actions { margin-top: 24px; gap: 14px; }
}

.onb-currency-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.onb-currency-row__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.onb-currency-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.onb-currency-chip {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color 120ms ease, background 120ms ease;
}

.onb-currency-chip:hover {
  border-color: var(--accent);
}

.onb-currency-chip.is-selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ════════════════════════════════════════════════════════════════════════════
   GUIDED TOUR (post-onboarding)
   ════════════════════════════════════════════════════════════════════════════ */

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}

.tour-overlay[hidden] { display: none; }

.tour-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 12px;
  box-shadow:
    0 0 0 4px rgba(11, 122, 117, 0.55),
    0 0 0 9999px rgba(20, 14, 5, 0.62);
  transition: top 220ms ease, left 220ms ease, width 220ms ease, height 220ms ease;
  pointer-events: none;
}

.tour-tooltip {
  position: fixed;
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 16px 40px rgba(20, 14, 5, 0.25);
  width: 320px;
  max-width: calc(100vw - 32px);
  pointer-events: auto;
  font-family: "Manrope", sans-serif;
  z-index: 96;
  transition: top 220ms ease, left 220ms ease;
}

.tour-tooltip__progress {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.tour-tooltip__title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.tour-tooltip__body {
  margin: 0 0 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.tour-tooltip__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tour-skip {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 0;
  margin-right: auto;
}

.tour-prev,
.tour-next {
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: 0;
}

.tour-prev {
  background: rgba(34, 26, 15, 0.06);
  color: var(--text);
}

.tour-prev:hover {
  background: rgba(34, 26, 15, 0.12);
}

.tour-next {
  background: var(--accent);
  color: #fff;
}

.tour-next:hover {
  background: #075c58;
}

/* Tour spotlight relies on box-shadow for the dim, so the target element
   doesn't need any positioning override — touching position would break
   fixed elements like the AI FAB and the topbar buttons. */

/* ════════════════════════════════════════════════════════════════════════════
   ACHIEVEMENTS (stars)
   ════════════════════════════════════════════════════════════════════════════ */

.top-achievements-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(168, 116, 26, 0.10);
  color: #8a5d10;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: 0;
  transition: background 120ms ease;
}

.top-achievements-button:hover {
  background: rgba(168, 116, 26, 0.20);
}

.achv-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.achv-count {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
}

.achievements-popover {
  position: fixed;
  top: 64px;
  right: 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 14, 5, 0.18);
  padding: 16px;
  z-index: 70;
  font-family: "Manrope", sans-serif;
}

.achievements-popover[hidden] { display: none; }

.achievements-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.achievements-popover__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.achievements-popover__close {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
}

.achievements-popover__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border-radius: 8px;
}

.achievement-row.is-earned {
  background: rgba(11, 122, 117, 0.06);
}

.achievement-row__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f5f7fa);
  font-size: 0.95rem;
}

.achievement-row.is-earned .achievement-row__icon {
  background: rgba(168, 116, 26, 0.18);
}

.achievement-row__name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.achievement-row.is-earned .achievement-row__name { color: var(--text); }
.achievement-row:not(.is-earned) .achievement-row__name { color: var(--text-secondary); }

.achievement-row__star {
  font-size: 0.95rem;
  opacity: 0.4;
}

.achievement-row.is-earned .achievement-row__star { opacity: 1; }

.achievement-toast-stack {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.achievement-toast {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-left: 4px solid #d97706;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 12px 32px rgba(20, 14, 5, 0.18);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Manrope", sans-serif;
  pointer-events: auto;
  animation: achv-slide-in 240ms ease, achv-fade-out 320ms ease 4s forwards;
  max-width: 320px;
}

.achievement-toast__icon { font-size: 1.4rem; }

.achievement-toast__text { display: flex; flex-direction: column; }

.achievement-toast__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 700;
}

.achievement-toast__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

@keyframes achv-slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes achv-fade-out {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── Tour: visual mocks ────────────────────────────────────────────────────── */

.tour-tooltip__visual {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px;
  margin: 4px 0 12px;
  background: linear-gradient(180deg, #FBF7F1 0%, #F4ECDF 100%);
  border: 1px solid var(--grid);
  border-radius: 12px;
  min-height: 56px;
  justify-content: center;
}

.tour-tooltip__visual[hidden] { display: none; }

.tour-mock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0;
  user-select: none;
  pointer-events: none;
}

.tour-mock--pill {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.tour-mock--accent {
  background: rgba(11, 122, 117, 0.12);
  border-color: rgba(11, 122, 117, 0.30);
  color: var(--accent);
}

.tour-mock--ghost {
  background: rgba(34, 26, 15, 0.06);
  color: var(--text-secondary);
}

.tour-mock--ghost-strong {
  background: var(--paper, #fff);
  border-color: var(--grid);
  color: var(--text);
}

.tour-mock--dashed {
  background: transparent;
  border: 1px dashed var(--grid);
  color: var(--text-secondary);
}

.tour-mock--income {
  background: var(--income-bg, rgba(63, 122, 58, 0.10));
  border-color: var(--income-border, rgba(63, 122, 58, 0.22));
  color: var(--income, #15803d);
}

.tour-mock--expense {
  background: var(--expense-bg, rgba(163, 58, 42, 0.08));
  border-color: var(--expense-border, rgba(163, 58, 42, 0.20));
  color: var(--expense, #b42318);
}

.tour-mock--dark {
  background: #221A0F;
  color: #FAF6EE;
  border: none;
}

.tour-mock--seg {
  display: inline-flex;
  background: var(--bg, #f5f7fa);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  height: 32px;
}

.tour-mock__seg-btn {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.tour-mock__seg-btn.is-active {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  color: var(--text);
}

.tour-mock--icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--grid);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.tour-mock--fab {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.85);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 10px 28px rgba(11, 122, 117, 0.30), 0 4px 10px rgba(34, 26, 15, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.onb-tags--below {
  margin-top: 4px;
}

.onb-tags--below::before {
  content: "Быстрый старт:";
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-secondary);
  align-self: center;
  margin-right: 8px;
}

.onb-tags--above {
  margin-top: 4px;
  margin-bottom: 4px;
}

.onb-tags--under-input {
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.onb-tags--under-input::before {
  content: "Быстрый старт:";
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-secondary);
  align-self: center;
  margin-right: 4px;
}

@media (max-width: 900px) {
  .onb-tags--under-input::before {
    display: none;
  }
}

.tour-tooltip__visual[data-align="left"] { justify-content: flex-start; }
.tour-tooltip__visual[data-align="right"] { justify-content: flex-end; }
.tour-tooltip__visual[data-align="center"] { justify-content: center; }

/* Hide achievements badge once everything is earned */
.top-achievements-button[data-all-earned="true"] { display: none; }

/* Achievements congrats modal */
.achievements-congrats {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 5, 0.55);
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
  animation: ach-congrats-fade 220ms ease;
}

.achievements-congrats[hidden] { display: none; }

.achievements-congrats__card {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(20, 14, 5, 0.30);
}

.achievements-congrats__sparkle {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 14px;
}

.achievements-congrats__title {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.achievements-congrats__body {
  margin: 0 0 22px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.achievements-congrats__close {
  min-width: 140px;
}

@keyframes ach-congrats-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE STRUCTURE — feed cards, top summary, bottom tabbar
   ════════════════════════════════════════════════════════════════════════════ */

.mobile-summary { display: none; }
.mobile-tabbar { display: none; }

@media (max-width: 700px) {
  /* Hide top-bar elements that aren't part of the mobile structure */
  .workspace-topbar .brand-logo--topbar,
  .workspace-topbar .top-help-button,
  .workspace-topbar .top-achievements-button,
  .workspace-topbar .view-toggle,
  .workspace-topbar .workspace-account {
    display: none;
  }

  .workspace-topbar {
    margin: 8px 12px 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    height: auto;
    flex-wrap: wrap;
  }

  .workspace-topbar__left,
  .workspace-topbar__right {
    flex: 1 1 100%;
    overflow: visible;
  }

  /* Top scenarios — always horizontal scrollable strip */
  .scenario-strip-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 0 12px;
    margin-top: 6px;
  }
  .scenario-strip-wrap::-webkit-scrollbar { display: none; }
  #scenarioBarContainer { display: none; }

  /* Mobile summary card (balance + cash-gap) */
  .mobile-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 12px 14px;
    gap: 12px;
  }

  .mobile-summary__balance,
  .mobile-summary__forecast {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .mobile-summary__forecast {
    align-items: flex-start;
    padding-left: 8px;
    border-left: 1px solid var(--grid);
  }

  .mobile-summary__value--forecast {
    font-size: 1.15rem;
    color: var(--text-secondary);
  }
  .mobile-summary__value--forecast.is-up { color: var(--income, #15803d); }
  .mobile-summary__value--forecast.is-down { color: var(--expense, #b42318); }

  .mobile-summary__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-weight: 700;
  }

  .mobile-summary__value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }

  .mobile-summary__gap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    background: var(--expense-bg, rgba(180, 35, 24, 0.08));
    border: 1px solid var(--expense-border, rgba(180, 35, 24, 0.20));
    border-radius: 12px;
    padding: 8px 12px;
    color: var(--expense, #b42318);
    font-family: "Manrope", sans-serif;
  }

  .mobile-summary__gap[hidden] { display: none; }

  .mobile-summary__gap-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
  }

  .mobile-summary__gap-value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.95rem;
    font-weight: 700;
  }

  .mobile-summary__gap--ok {
    background: rgba(63, 122, 58, 0.10);
    border-color: rgba(63, 122, 58, 0.22);
    color: var(--income, #15803d);
  }

  /* Workspace padding for tabbar */
  .workspace {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* Table → stacked cards */
  .table-shell-wrap {
    padding: 0;
    margin: 0;
  }
  .table-shell {
    height: auto !important;
    overflow: visible !important;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .budget-table {
    display: block;
    width: 100%;
    background: transparent;
    border: 0;
    min-width: 0;
  }

  .budget-table > thead { display: none; }
  .budget-table > tbody { display: block; }

  .budget-table > tbody > tr {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    grid-template-columns: none;
    background: var(--paper, #fff);
    border: 1px solid var(--grid);
    border-radius: 14px;
    padding: 12px 14px 14px;
    margin: 8px 12px;
    position: relative;
    min-height: 0;
    border-left-width: 1px;
  }

  .budget-table > tbody > tr.today {
    border-color: var(--accent, #0b7a75);
    box-shadow: 0 0 0 1px var(--accent, #0b7a75);
    background: var(--paper, #fff);
  }

  .budget-table > tbody > tr.danger {
    border-color: var(--expense-border, rgba(180, 35, 24, 0.22));
    background: var(--expense-bg, rgba(180, 35, 24, 0.06));
  }

  .budget-table > tbody > tr > td {
    display: contents;
    padding: 0 !important;
    border: 0;
  }

  /* Date row spans full width */
  .budget-table > tbody > tr > td.cell-date {
    display: flex;
    flex: 1 1 100%;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
    padding: 0;
    position: static;
  }

  .budget-table > tbody > tr > td.cell-date .cell-date-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
  }

  .budget-table > tbody > tr.today .cell-date-label::after {
    content: "СЕГОДНЯ";
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--accent, #0b7a75);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    font-weight: 700;
    vertical-align: middle;
  }

  /* Balance — pinned to top-right of the card */
  .budget-table > tbody > tr > td.cell-date .cell-corner-total.balance {
    position: absolute;
    top: 12px;
    right: 14px;
    margin: 0;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
  }

  .budget-table > tbody > tr.today .cell-date-stack { /* no-op for older markup */ }

  /* Subtotal pills inside cell-text — hidden on mobile */
  .budget-table > tbody > tr > td.cell-text > .cell-corner-total {
    display: none !important;
  }

  /* Mobile cards: chips flow inline together via display: contents on the
     cell-text wrappers, so income + expense + add buttons mix freely */
  .budget-table > tbody > tr > td.cell-text {
    display: contents;
  }

  .budget-table > tbody > tr > td.cell-text > .entries-cell {
    display: contents;
  }

  .budget-table > tbody > tr > td.cell-text > .entries-cell > .chip-list {
    display: contents;
  }

  .budget-table > tbody > tr > td.cell-text .entry-chip,
  .budget-table > tbody > tr > td.cell-text .add-chip {
    flex: 0 0 auto;
  }

  /* Income / expense add chips wear their colours so the eye picks them up
     among the inline-flowing entry chips */
  .budget-table > tbody > tr > td.cell-text .add-chip[data-type="income"] {
    background: var(--income-bg);
    border-color: var(--income-border);
    color: var(--income);
  }
  .budget-table > tbody > tr > td.cell-text .add-chip[data-type="income"]:hover {
    background: #d8efdf;
  }
  .budget-table > tbody > tr > td.cell-text .add-chip[data-type="expense"] {
    background: var(--expense-bg);
    border-color: var(--expense-border);
    color: var(--expense);
  }
  .budget-table > tbody > tr > td.cell-text .add-chip[data-type="expense"]:hover {
    background: #fbdadd;
  }

  /* Push '+ доход' / '+ расход' to the bottom of the day card and force each
     onto its own full-width row so they always sit after entered entries */
  .budget-table > tbody > tr > td.cell-text .add-chip {
    order: 99;
    flex: 1 1 100%;
    min-width: 100%;
    justify-content: center;
  }

  /* Hide day-net (4th col) on mobile — balance already shown */
  .budget-table > tbody > tr > td.cell-net,
  .budget-table > thead > tr > th.col-net {
    display: none;
  }

  /* Bottom tabbar */
  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    background: var(--paper, #fff);
    border-top: 1px solid var(--grid);
    z-index: 60;
    align-items: stretch;
  }

  .mobile-tab {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
  }

  .mobile-tab__icon {
    font-size: 1.25rem;
    line-height: 1;
  }

  .mobile-tab__label {
    font-weight: 600;
    letter-spacing: 0;
  }

  .mobile-tab.is-active {
    color: var(--accent, #0b7a75);
  }

  /* Status bar (desktop footer) hidden on mobile — mobileSummary takes over */
  .status-bar {
    display: none !important;
  }

  /* AI FAB stays bottom-right but lifted above tabbar */
  body.calm .ai-fab,
  .ai-fab {
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
  }
}

/* Mobile profile sheet — full-width, sits above bottom tabbar */
.mobile-profile-overlay {
  position: fixed;
  inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0;
  background: linear-gradient(180deg, #FBF7F1 0%, #F4ECDF 100%);
  z-index: 55;
  overflow-y: auto;
  padding: 28px 20px 32px;
}

.mobile-profile-sheet {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mobile-profile-sheet__header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 8px 24px -16px rgba(20, 14, 5, 0.12);
}

.mobile-profile-sheet__avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.10);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.mobile-profile-sheet__id {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mobile-profile-sheet__email {
  font-weight: 700;
  font-size: 1rem;
  word-break: break-all;
}

.mobile-profile-sheet__meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
}

.mobile-profile-sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-profile-sheet__btn {
  height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mobile-profile-sheet__btn:not(.mobile-profile-sheet__btn--ghost):not(.mobile-profile-sheet__btn--danger) {
  background: var(--accent, #0b7a75);
  color: #fff;
}

.mobile-profile-sheet__btn--ghost {
  background: rgba(34, 26, 15, 0.06);
  color: var(--text);
}

.mobile-profile-sheet__btn--danger {
  background: rgba(180, 35, 24, 0.10);
  color: var(--expense, #b42318);
}

/* ════════════════════════════════════════════════════════════════════════════
   AUTH-SHELL · landing sections under the form
   ════════════════════════════════════════════════════════════════════════════ */

.auth-shell {
  align-items: flex-start;
  padding: 32px 20px 80px;
  overflow-y: auto;
}

.auth-shell .auth-card {
  margin-top: 40px;
}

.landing {
  width: 100%;
  max-width: 960px;
  margin: 56px auto 0;
  display: flex;
  flex-direction: column;
  gap: 48px;
  font-family: "Manrope", sans-serif;
}

.landing__section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing__heading {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--text);
}

.landing__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.landing__card {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(20, 14, 5, 0.06);
}

.landing__icon {
  font-size: 1.6rem;
  line-height: 1;
}

.landing__card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.landing__card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.95rem;
}

.landing__personas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.landing__persona {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.landing__persona h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.landing__persona p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.55;
  font-size: 0.95rem;
}

.landing__cta {
  text-align: center;
  padding: 32px 24px;
  background: rgba(11, 122, 117, 0.06);
  border: 1px solid rgba(11, 122, 117, 0.18);
  border-radius: 18px;
}

.landing__cta-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}

.landing__cta-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

@media (max-width: 700px) {
  .auth-shell {
    padding: 24px 16px 64px;
  }
  .landing {
    margin-top: 36px;
    gap: 36px;
  }
  .landing__heading {
    font-size: 1.4rem;
  }
  .landing__grid {
    grid-template-columns: 1fr;
  }
  .landing__personas {
    grid-template-columns: 1fr;
  }
  .landing__cta {
    padding: 24px 18px;
  }
}

/* ════════════════════════════════════════════════════════════════════════════
   AUTH-SHELL · two-column hero (left: pitch + visual, right: form)
   ════════════════════════════════════════════════════════════════════════════ */

.auth-hero-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  align-items: start;
  padding-top: 24px;
}

.auth-shell .auth-hero-wrap .auth-card {
  margin-top: 0;
  width: 100%;
  max-width: none;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-hero .brand-logo--auth-shell {
  height: 36px;
  width: auto;
  align-self: flex-start;
}

.auth-hero__title {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text);
}

.auth-hero__lead {
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-hero__visual {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 40px -12px rgba(11, 122, 117, 0.18);
  display: flex;
  flex-direction: column;
}

.auth-hero__chrome {
  padding: 14px 18px;
  border-bottom: 1px solid var(--grid);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(248, 252, 252, 0.7);
}

.auth-hero__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.auth-hero__dot--red { background: #FCA5A5; }
.auth-hero__dot--yellow { background: #FCD34D; }
.auth-hero__dot--green { background: #86EFAC; }

.auth-hero__url {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}

.auth-hero__body {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-hero__topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-hero__caps {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-hero__amount {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.auth-hero__trend {
  font-size: 0.85rem;
  color: #15803d;
  margin-left: 4px;
}

.auth-hero__chart {
  width: 100%;
  height: 120px;
  display: block;
}

.auth-hero__chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-hero__chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  background: rgba(11, 122, 117, 0.10);
  color: #064F4B;
}
.auth-hero__chip--income {
  background: rgba(63, 122, 58, 0.10);
  color: #15803d;
}
.auth-hero__chip--expense {
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
}

@media (max-width: 900px) {
  .auth-hero-wrap {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .auth-hero__title { font-size: 2rem; }
}

/* ════════════════════════════════════════════════════════════════════════════
   AUTH-SHELL · v2 redesign (cream gradient, hero left, clean form right)
   ════════════════════════════════════════════════════════════════════════════ */

.auth-shell {
  background: linear-gradient(180deg, #FBF7F1 0%, #F4ECDF 100%);
  padding: 48px 32px;
  align-items: center;
  min-height: 100vh;
  overflow-y: auto;
}

.auth-hero-wrap {
  padding-top: 0;
  gap: 80px;
  align-items: center;
}

.auth-hero {
  gap: 24px;
}

.auth-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent, #0b7a75);
  text-transform: uppercase;
  padding: 6px 12px;
  background: rgba(11, 122, 117, 0.07);
  border-radius: 999px;
  font-weight: 600;
}

.auth-hero__eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent, #0b7a75);
}

.auth-hero__title {
  font-size: 3.2rem;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--text);
}

.auth-hero__accent {
  color: var(--accent, #0b7a75);
}

.auth-hero__lead {
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
  max-width: 520px;
}

.auth-hero__points {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.98rem;
  color: var(--text);
}

.auth-hero__points li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.auth-hero__point-mark {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.12);
  color: var(--accent, #0b7a75);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Form card */
.auth-shell .auth-hero-wrap .auth-card {
  background: #fff;
  border: 1px solid var(--grid);
  border-radius: 22px;
  padding: 40px 40px 36px;
  box-shadow: 0 24px 60px -20px rgba(20, 14, 5, 0.18);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-shell .brand-logo--auth-shell { display: none; }

.brand-logo--auth-hero {
  display: block;
  height: 40px;
  width: auto;
  margin-bottom: 8px;
  align-self: flex-start;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(34, 26, 15, 0.05);
  border-radius: 14px;
  padding: 5px;
  gap: 0;
  margin: 0 0 4px;
}

.auth-tab {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.auth-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(20, 14, 5, 0.06);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 0;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-secondary);
}

.auth-form input {
  height: 56px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--grid);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  text-transform: none;
  letter-spacing: 0;
}

.auth-form input:focus {
  border-color: var(--accent, #0b7a75);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
}

.auth-shell .auth-submit.primary-button {
  height: 58px;
  background: var(--accent, #0b7a75);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 8px 22px -8px rgba(11, 122, 117, 0.55);
  margin-top: 8px;
}

.auth-shell .auth-submit.primary-button:hover {
  background: #075c58;
  filter: none;
}

.auth-message {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  min-height: 1em;
}

.auth-message.is-error { color: #b42318; }
.auth-message.is-success { color: #15803d; }

.auth-local-actions {
  display: flex;
  justify-content: center;
  margin: 0;
}

.auth-shell .ghost-button.auth-local-button {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 0;
}

.auth-shell .ghost-button.auth-local-button:hover {
  color: var(--text);
}

/* Landing cards refresh */
.auth-shell .landing {
  margin-top: 80px;
}

.landing__heading {
  font-size: 2rem;
  letter-spacing: -0.02em;
  position: relative;
  padding-left: 16px;
}

.landing__heading::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--accent, #0b7a75);
  border-radius: 2px;
}

.landing__card {
  background: #fff;
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.landing__card:hover {
  transform: translateY(-2px);
  border-color: rgba(11, 122, 117, 0.22);
  box-shadow: 0 16px 36px -16px rgba(11, 122, 117, 0.18);
}

.landing__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(11, 122, 117, 0.10);
  color: var(--accent, #0b7a75);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.landing__card h3 {
  font-size: 1.1rem;
}

.landing__persona {
  background: #fff;
  border: 1px solid var(--grid);
  border-radius: 18px;
  padding: 26px 24px;
  position: relative;
}

.landing__persona::before {
  content: "";
  position: absolute;
  top: 24px;
  left: -1px;
  width: 4px;
  height: 28px;
  background: var(--accent, #0b7a75);
  border-radius: 2px;
}

.landing__persona h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 8px 12px;
}

.landing__persona p {
  margin: 0 0 0 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.landing__cta {
  background: linear-gradient(135deg, rgba(11, 122, 117, 0.10), rgba(11, 122, 117, 0.04));
  border: 1px solid rgba(11, 122, 117, 0.20);
  border-radius: 22px;
  padding: 40px 32px;
}

.landing__cta-title {
  font-size: 1.6rem;
}

@media (max-width: 1100px) {
  .auth-shell { padding: 48px 24px 80px; }
  .auth-hero-wrap { gap: 48px; }
  .auth-hero__title { font-size: 2.6rem; }
}

@media (max-width: 900px) {
  .auth-shell { padding: 32px 18px 64px; }
  .auth-hero-wrap { gap: 32px; padding-top: 8px; }
  .auth-hero__title { font-size: 2rem; }
  .auth-hero__lead { font-size: 1rem; }
  .auth-shell .auth-hero-wrap .auth-card { padding: 28px 22px 24px; gap: 20px; }
  .auth-shell .landing { margin-top: 56px; }
  .landing__heading { font-size: 1.5rem; }
}

/* ════════════════════════════════════════════════════════════════════════════
   STATS + PROFILE PANEL (opens from account email or mobile Профиль tab)
   ════════════════════════════════════════════════════════════════════════════ */

.stats-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(540px, calc(100vw - 24px));
  z-index: 55;
  pointer-events: none;
}
.stats-panel.open { pointer-events: auto; }

.stats-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 14, 0.32);
  opacity: 0;
  transition: opacity 180ms ease;
}
.stats-panel.open::before { opacity: 1; }

.stats-panel__card {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: #fffdf9;
  box-shadow: -24px 0 56px rgba(33, 23, 9, 0.16);
  transform: translateX(102%);
  transition: transform 220ms ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 24px 32px;
}
.stats-panel.open .stats-panel__card { transform: translateX(0); }

.stats-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.stats-panel__header h2 { margin: 0; font-size: 1.35rem; }

.stats-panel__period {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(34, 26, 15, 0.05);
  border-radius: 12px;
  padding: 4px;
}
.stats-period {
  flex: 1 1 0;
  min-width: 0;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.stats-period.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(20, 14, 5, 0.06);
}

.stats-panel__totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stats-tile {
  background: var(--paper, #fff);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stats-tile__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 700;
}
.stats-tile__value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.stats-tile--income { border-color: var(--income-border); }
.stats-tile--income .stats-tile__value { color: var(--income); }
.stats-tile--expense { border-color: var(--expense-border); }
.stats-tile--expense .stats-tile__value { color: var(--expense); }
.stats-tile--net.is-up .stats-tile__value { color: var(--income); }
.stats-tile--net.is-down .stats-tile__value { color: var(--expense); }

.stats-panel__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-panel__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.stats-panel__section-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.stats-panel__hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stats-panel__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(80px, 1.5fr) auto auto;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
}
.stats-row__title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.stats-row__bar {
  height: 8px;
  background: rgba(34, 26, 15, 0.06);
  border-radius: 999px;
  overflow: hidden;
  min-width: 0;
}
.stats-row__bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.stats-row--expense .stats-row__bar > span { background: var(--expense); }
.stats-row--income .stats-row__bar > span { background: var(--income); }
.stats-row__amount {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  white-space: nowrap;
}
.stats-row__share {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: "IBM Plex Mono", monospace;
  width: 38px;
  text-align: right;
}
.stats-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.stats-panel__divider {
  border: 0;
  height: 1px;
  background: var(--grid);
  margin: 4px 0;
}

.stats-profile__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.stats-profile__avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.10);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stats-profile__email {
  font-weight: 700;
  word-break: break-all;
}
.stats-profile__meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: "IBM Plex Mono", monospace;
}
.stats-profile__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-profile__btn {
  height: 46px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.stats-profile__btn--ghost { background: rgba(34, 26, 15, 0.06); color: var(--text); }
.stats-profile__btn--danger { background: rgba(180, 35, 24, 0.10); color: var(--expense); }

.stats-profile__lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.stats-profile__lang select {
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--grid);
  background: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Auth: telegram entry button + divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 4px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--grid);
}

.auth-tg-widget {
  display: flex;
  justify-content: center;
  align-items: center;
}
.auth-tg-widget:empty {
  display: none;
}
.auth-tg-widget iframe {
  border-radius: 12px;
  overflow: hidden;
}

.auth-tg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 50px;
  padding: 0 18px;
  background: #2aabee;
  color: #fff;
  border-radius: 14px;
  border: 0;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 140ms ease, transform 80ms ease, box-shadow 140ms ease;
  box-shadow: 0 8px 22px -10px rgba(42, 171, 238, 0.55);
}
.auth-tg-button:hover {
  background: #1f99d4;
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -10px rgba(42, 171, 238, 0.65);
}
.auth-tg-button:active { transform: translateY(0); }
.auth-tg-button__icon { display: inline-block; flex: 0 0 auto; }

.top-account-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  background: var(--accent, #0b7a75);
  color: #fff;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 14px -6px rgba(11, 122, 117, 0.55);
  transition: background 140ms ease, transform 80ms ease, box-shadow 140ms ease;
}
.top-account-button:hover {
  background: #075c58;
  box-shadow: 0 10px 20px -6px rgba(11, 122, 117, 0.55);
  transform: translateY(-1px);
}
.top-account-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px -4px rgba(11, 122, 117, 0.55);
}

.top-account-button__avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0;
  color: #fff;
  flex: 0 0 auto;
}

.top-account-button__label {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .top-account-button { padding: 0 12px 0 4px; height: 34px; }
  .top-account-button__avatar { width: 24px; height: 24px; font-size: 0.8rem; }
}

/* Mobile: full-screen stats sheet that stops above the bottom tabbar */
@media (max-width: 700px) {
  .stats-panel {
    width: 100vw;
    inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0;
    z-index: 55;
  }
  .stats-panel::before { background: transparent; }
  .stats-panel__card {
    width: 100vw;
    height: 100%;
    transform: translateY(102%);
    box-shadow: none;
    border-radius: 0;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
    gap: 14px;
  }
  .stats-panel.open .stats-panel__card { transform: translateY(0); }

  .stats-panel__totals { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stats-tile { padding: 10px 12px; }
  .stats-tile__value { font-size: 1rem; }

  .stats-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .stats-row__bar { display: none; }

  .stats-period { font-size: 0.8rem; padding: 0 6px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   PARTICIPANTS MODAL (scenario sharing)
   ════════════════════════════════════════════════════════════════════════════ */

.participants-overlay {
  position: fixed;
  inset: 0;
  z-index: 92;
  background: rgba(28, 22, 14, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.participants-card {
  width: 100%;
  max-width: 460px;
  background: var(--paper, #fff);
  border-radius: 20px;
  border: 1px solid var(--grid);
  padding: 26px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 28px 80px -24px rgba(20, 14, 5, 0.32);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.participants-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.participants-card__head h2 {
  margin: 4px 0 0;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.participants-card__hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Form: stacked vertical layout ─── */
.participants-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.participants-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.participants-field__label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-secondary);
}

.participants-form input[type="email"] {
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--grid);
  font: inherit;
  background: #fff;
  outline: none;
  font-size: 1rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.participants-form input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.14);
}

/* Role — two card-shaped radios */
.participants-role {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.participants-role__opt {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.participants-role__opt input { position: absolute; opacity: 0; pointer-events: none; }
.participants-role__opt:has(input:checked) {
  border-color: var(--accent);
  background: rgba(11, 122, 117, 0.06);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.participants-role__title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.participants-role__hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.participants-form__submit {
  height: 48px;
  border-radius: 12px;
  font-size: 0.95rem;
  margin-top: 2px;
}

.participants-card__msg {
  margin: 0;
  font-size: 0.86rem;
  color: var(--accent);
  padding: 8px 12px;
  background: rgba(11, 122, 117, 0.08);
  border-radius: 10px;
}
.participants-card__msg.is-error {
  color: var(--expense, #b42318);
  background: rgba(180, 35, 24, 0.08);
}

.participants-divider {
  height: 1px;
  background: var(--grid);
  margin: 4px 0;
}

.participants-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.participants-section__head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.participants-section__count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(34, 26, 15, 0.05);
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 700;
}
.participants-section__count:empty { display: none; }

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.participants-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--grid);
  border-radius: 14px;
  background: #fff;
  transition: border-color 140ms ease;
}
.participants-item:hover { border-color: rgba(11, 122, 117, 0.30); }

.participants-item__avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.10);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.02rem;
  flex: 0 0 auto;
}

.participants-item__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.participants-item__email {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participants-item__role {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
}
.participants-item__role--edit {
  color: var(--accent);
  background: rgba(11, 122, 117, 0.10);
}
.participants-item__role--view {
  color: var(--text-secondary);
  background: rgba(34, 26, 15, 0.06);
}

.participants-item__remove {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 0;
  background: rgba(180, 35, 24, 0.08);
  color: var(--expense, #b42318);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  transition: background 120ms ease, transform 80ms ease;
}
.participants-item__remove:hover { background: rgba(180, 35, 24, 0.18); }
.participants-item__remove:active { transform: scale(0.94); }

.participants-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px 0;
  background: rgba(34, 26, 15, 0.03);
  border: 1px dashed var(--grid);
  border-radius: 12px;
}

@media (max-width: 600px) {
  .participants-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .participants-card {
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 24px);
  }
  .participants-card__head h2 { font-size: 1.15rem; }
  .participants-role { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════════════════
   INVITATION MODAL (shown when someone shared a scenario with you)
   ════════════════════════════════════════════════════════════════════════════ */

.invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(20, 14, 5, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.invite-overlay.is-busy { pointer-events: none; opacity: 0.7; }

.invite-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper, #fff);
  border-radius: 22px;
  padding: 28px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
  box-shadow: 0 32px 80px -24px rgba(20, 14, 5, 0.40);
  animation: invite-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@keyframes invite-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.invite-card__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
}

.invite-card__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.invite-card__text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.invite-card__text strong { color: var(--text); font-weight: 700; }

.invite-card__role {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: rgba(34, 26, 15, 0.03);
}
.invite-card__role-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-secondary);
}
.invite-card__role-value {
  font-weight: 800;
  font-size: 0.98rem;
}
.invite-card__role-value--edit { color: var(--accent); }
.invite-card__role-value--view { color: var(--text-secondary); }
.invite-card__role-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.invite-card__actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.invite-card__btn {
  height: 48px;
  border-radius: 12px;
  font-size: 0.95rem;
  padding: 0;
}

@media (max-width: 600px) {
  .invite-overlay { padding: 16px; }
  .invite-card { padding: 24px 20px 22px; max-width: 100%; }
  .invite-card__title { font-size: 1.15rem; }
  .invite-card__text { font-size: 0.92rem; }
}

/* Shared scenario badge */
.scenario-panel__badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.10);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
