:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #040b14;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.105);
  --border: rgba(255, 255, 255, 0.14);
  --border-soft: rgba(255, 255, 255, 0.085);
  --text: #f4f8fc;
  --muted: #9eb1c5;
  --blue: #71c9ff;
  --green: #45f1a2;
  --red: #ff747f;
  --amber: #ffc96b;
  --shadow: 0 24px 65px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(
      circle at 88% 4%,
      rgba(33, 111, 172, 0.44),
      transparent 28rem
    ),
    radial-gradient(
      circle at 7% 92%,
      rgba(20, 96, 98, 0.28),
      transparent 34rem
    ),
    linear-gradient(145deg, var(--bg-deep), #0c1c30 52%, #07111f);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.hidden {
  display: none !important;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  place-items: center;
}

.auth-card {
  display: grid;
  width: min(440px, 100%);
  gap: 15px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(155deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(17px);
}

.auth-card h1 {
  font-size: clamp(2rem, 8vw, 2.7rem);
}

.auth-intro {
  margin: 0 0 4px;
  color: var(--muted);
}

.auth-field {
  display: grid;
  gap: 7px;
  color: #c8d7e6;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  min-height: 49px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: rgba(2, 9, 17, 0.42);
  outline: none;
}

.auth-field input:focus-visible {
  border-color: var(--blue);
  outline: 2px solid rgba(113, 201, 255, 0.28);
  outline-offset: 2px;
}

.primary-auth-btn,
.secondary-auth-btn,
.logout-btn {
  min-height: 45px;
  border-radius: 12px;
  cursor: pointer;
}

.primary-auth-btn {
  border: 1px solid rgba(69, 241, 162, 0.6);
  color: #04120d;
  background: var(--green);
}

.secondary-auth-btn {
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.primary-auth-btn:disabled,
.secondary-auth-btn:disabled {
  cursor: wait;
  opacity: 0.55;
}

.auth-message {
  min-height: 24px;
  margin: 0;
  color: var(--green);
  font-size: 0.92rem;
}

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

.dashboard {
  width: min(1480px, 100%);
  margin-inline: auto;
  padding: 38px 28px 54px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.header-controls {
  display: grid;
  min-width: 430px;
  gap: 10px;
}

.period-controls {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr);
  gap: 10px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.account-bar > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-status {
  color: var(--green);
}

.save-status.is-saving {
  color: var(--amber);
}

.save-status.is-error {
  color: var(--red);
}

.logout-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  color: #d4e5f4;
  background: rgba(255, 255, 255, 0.04);
}

.logout-btn:hover {
  border-color: rgba(255, 116, 127, 0.5);
  color: var(--red);
}

.eyebrow,
.card-kicker {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.45rem);
  line-height: 1.1;
}

.month-control,
.reset-day-control {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 600;
}

.month-control input,
.reset-day-control select {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

.reset-day-control select {
  appearance: none;
  color-scheme: dark;
  cursor: pointer;
}

.reset-day-control option {
  color: #edf6ff;
  background: #132235;
}

.reset-day-control option:checked {
  color: #ffffff;
  background: #286db5;
}

.reset-day-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.month-control input:focus-visible,
.reset-day-control select:focus-visible,
.cell-input:focus-visible,
.add-row-btn:focus-visible,
.increment-btn:focus-visible,
.undo-btn:focus-visible,
.delete-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.tracker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr);
  grid-template-areas:
    "fixed income"
    "variable savings"
    "variable summary";
  align-items: stretch;
  gap: 26px;
}

.income-card {
  grid-area: income;
  --accent: var(--green);
}
.fixed-card {
  grid-area: fixed;
  --accent: var(--red);
}
.variable-card {
  grid-area: variable;
  --accent: var(--amber);
}
.savings-card {
  grid-area: savings;
  --accent: #b995ff;
}
.summary-card {
  grid-area: summary;
  --accent: var(--blue);
}

.finance-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(155deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(17px);
}

.finance-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.85;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-heading h2 {
  font-size: 1.65rem;
}

.card-kicker {
  color: var(--muted);
  letter-spacing: 0;
}

.total-badge,
.status-badge {
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.045);
}

.total-badge {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.12rem;
}

.positive {
  color: var(--green);
}
.negative {
  color: var(--red);
}
.neutral {
  color: var(--blue);
}

.table-wrap,
.summary-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: rgba(2, 9, 17, 0.28);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.wide-table table {
  min-width: 560px;
}

.variable-table .amount-column,
.variable-table .budget-column {
  width: 19%;
}

.variable-table .description-column {
  width: 24%;
}

.variable-table .liquidity-column {
  width: 20%;
}

.variable-table .undo-column,
.variable-table .action-column {
  width: 46px;
}

th,
td {
  min-height: 58px;
  padding: 9px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
  vertical-align: middle;
}

thead th {
  padding-block: 13px;
  color: #c8d7e6;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

tbody tr {
  transition: background 160ms ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

tfoot tr:last-child th,
tfoot tr:last-child td,
tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

tfoot th,
tfoot td {
  padding-block: 15px;
  background: rgba(255, 255, 255, 0.035);
}

.cell-input {
  width: 100%;
  min-width: 0;
  height: 39px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  outline: none;
  transition: 160ms ease;
}

.cell-input:hover,
.cell-input:focus {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.055);
}

.amount-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  direction: ltr;
}

.amount-input {
  flex: 0 1 84px;
  width: 84px;
  min-width: 70px;
  padding-left: 2px;
  direction: ltr;
  text-align: left;
  font-weight: 600;
}

.currency-symbol {
  flex: 0 0 auto;
  font-size: 0.92em;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.income-card .amount-currency-symbol {
  color: var(--green);
}

.fixed-card .amount-currency-symbol,
.variable-card .amount-currency-symbol {
  color: var(--red);
}

.variable-card .budget-currency-symbol {
  color: var(--green);
}

.savings-card .amount-currency-symbol {
  color: #b995ff;
}

.income-card .amount-input {
  color: var(--green);
}
.fixed-card .amount-input,
.variable-card .amount-input {
  color: var(--red);
}
.savings-card .amount-input,
.savings-color {
  color: #b995ff;
}
.variable-card .budget-input {
  color: var(--green);
}

.budget-heading,
.budget-cell {
  background: rgba(69, 241, 162, 0.045);
}

.liquidity-heading,
.liquidity-cell {
  background: rgba(113, 201, 255, 0.06);
}

.liquidity-heading {
  color: var(--blue);
}

.increment-btn,
.undo-btn,
.delete-btn {
  display: grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: 160ms ease;
}

.increment-btn {
  color: var(--blue);
  font-size: 1.22rem;
}

.undo-btn {
  color: var(--blue);
  font-size: 1.2rem;
  font-weight: 700;
}

.undo-btn.is-empty {
  color: var(--muted);
  cursor: default;
  opacity: 0.35;
}

.delete-btn {
  color: var(--muted);
  font-size: 1.05rem;
}

.increment-btn:hover {
  border-color: rgba(113, 201, 255, 0.55);
  background: rgba(113, 201, 255, 0.12);
}

.undo-btn:not(.is-empty):hover {
  border-color: rgba(113, 201, 255, 0.55);
  background: rgba(113, 201, 255, 0.12);
}

.delete-btn:hover {
  color: var(--red);
  border-color: rgba(255, 116, 127, 0.5);
  background: rgba(255, 116, 127, 0.1);
}

.undo-heading,
.actions-heading,
.undo-cell,
.action-cell {
  width: 46px;
  text-align: center;
}

.table-total,
.budget-total,
.liquidity-total {
  font-weight: 700;
  white-space: nowrap;
}

.budget-total {
  color: var(--green);
  font-size: 0.95rem;
}

.budget-total.positive {
  color: var(--green);
}

.budget-total.negative {
  color: var(--red);
}

.liquidity-total {
  font-size: 0.95rem;
}

.liquidity-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  direction: ltr;
  font-weight: 700;
  white-space: nowrap;
}

.liquidity-currency-symbol {
  flex: 0 0 auto;
  color: currentColor;
  font-size: 0.92em;
  line-height: 1;
}

.add-row-btn {
  width: 100%;
  margin-top: 14px;
  padding: 11px 15px;
  border: 1px dashed rgba(255, 255, 255, 0.23);
  border-radius: 13px;
  color: #d4e5f4;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: 180ms ease;
}

.add-row-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
}

.summary-card {
  min-height: 350px;
}

.status-badge {
  color: var(--blue);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.status-badge.is-positive {
  color: var(--green);
}

.status-badge.is-negative {
  color: var(--red);
}

.summary-table th,
.summary-table td {
  height: 67px;
}

.summary-table tbody th {
  color: #c9d7e4;
  font-size: 1.08rem;
  font-weight: 600;
}

.summary-number {
  direction: ltr;
  text-align: right;
  font-size: 1.45rem;
  font-weight: 700;
}

.grand-total-row {
  background: rgba(113, 201, 255, 0.055);
}

.grand-total-row th,
.grand-total-row td {
  border-top: 1px solid rgba(113, 201, 255, 0.2);
}

.summary-message {
  margin: 16px 2px 0;
  color: var(--muted);
  line-height: 1.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1000px) {
  .tracker-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "income"
      "fixed"
      "variable"
      "savings"
      "summary";
  }
}

@media (max-width: 640px) {
  .dashboard {
    padding: max(18px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(34px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 18px;
  }

  .page-header h1 {
    font-size: clamp(1.85rem, 8.5vw, 2.35rem);
  }

  .header-controls {
    min-width: 0;
    gap: 12px;
  }

  .period-controls {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .account-bar {
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding-inline: 2px;
  }

  .account-bar > div {
    flex: 1 1 190px;
  }

  .logout-btn {
    min-height: 42px;
    padding-inline: 14px;
  }

  .auth-card {
    grid-template-columns: 1fr;
    padding: 24px 18px;
    border-radius: 20px;
  }

  .month-control {
    min-width: 0;
  }

  .finance-card {
    padding: 16px 13px;
    border-radius: 20px;
  }

  .summary-card {
    min-height: 0;
  }

  .card-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 14px;
  }

  .mobile-accordion-ready .finance-card .card-heading {
    position: relative;
    min-height: 58px;
    padding-inline-end: 42px;
    margin-bottom: 0;
    align-items: center;
    cursor: pointer;
    user-select: none;
  }

  .mobile-accordion-ready .finance-card .card-heading::after {
    position: absolute;
    inset-inline-end: 0;
    display: grid;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    place-items: center;
    color: var(--blue);
    background: rgba(255, 255, 255, 0.045);
    content: "⌄";
    font-size: 1.35rem;
    line-height: 1;
    transition: transform 180ms ease;
  }

  .mobile-accordion-ready .finance-card.is-mobile-open .card-heading {
    margin-bottom: 14px;
  }

  .mobile-accordion-ready
    .finance-card.is-mobile-open:not(.summary-card) {
    display: flex;
    flex-direction: column;
  }

  .mobile-accordion-ready
    .finance-card.is-mobile-open:not(.summary-card)
    .card-heading {
    order: 0;
  }

  .mobile-accordion-ready
    .finance-card.is-mobile-open:not(.summary-card)
    .add-row-btn {
    order: 1;
    margin: 0 0 12px;
  }

  .mobile-accordion-ready
    .finance-card.is-mobile-open:not(.summary-card)
    .table-wrap {
    order: 2;
  }

  .mobile-accordion-ready
    .finance-card.is-mobile-open
    .card-heading::after {
    transform: rotate(180deg);
  }

  .mobile-accordion-ready
    .finance-card:not(.is-mobile-open)
    > :not(.card-heading) {
    display: none;
  }

  .mobile-accordion-ready .card-heading:focus-visible {
    border-radius: 12px;
    outline: 2px solid var(--blue);
    outline-offset: 4px;
  }

  .card-heading h2 {
    font-size: 1.45rem;
  }

  th,
  td {
    padding: 7px 5px;
  }

  .table-wrap,
  .summary-table-wrap {
    overflow: visible;
  }

  .income-card table,
  .fixed-card table,
  .savings-card table,
  .variable-card table {
    min-width: 0;
    table-layout: auto;
  }

  .income-card thead,
  .fixed-card thead,
  .savings-card thead,
  .variable-card thead {
    display: none;
  }

  .income-card tbody,
  .fixed-card tbody,
  .savings-card tbody,
  .variable-card tbody {
    display: grid;
    align-content: start;
    grid-auto-rows: max-content;
    gap: 12px;
    padding: 8px;
  }

  .income-card tbody tr,
  .fixed-card tbody tr,
  .savings-card tbody tr,
  .variable-card tbody tr {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
  }

  .income-card tbody tr,
  .fixed-card tbody tr,
  .savings-card tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "description description"
      "amount amount"
      "undo action";
  }

  .variable-card tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "description description"
      "amount budget"
      "liquidity liquidity"
      "undo action";
  }

  .undo-cell {
    grid-area: undo;
  }
  .description-cell {
    grid-area: description;
  }
  .amount-cell {
    grid-area: amount;
  }
  .budget-cell {
    grid-area: budget;
  }
  .liquidity-cell {
    grid-area: liquidity;
  }
  .action-cell {
    grid-area: action;
  }

  .income-card tbody td,
  .fixed-card tbody td,
  .savings-card tbody td,
  .variable-card tbody td {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .income-card tbody td[data-label],
  .fixed-card tbody td[data-label],
  .savings-card tbody td[data-label],
  .variable-card tbody td[data-label] {
    display: grid;
    gap: 3px;
  }

  .income-card tbody td[data-label]::before,
  .fixed-card tbody td[data-label]::before,
  .savings-card tbody td[data-label]::before,
  .variable-card tbody td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
  }

  .variable-card .liquidity-cell {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(113, 201, 255, 0.06);
  }

  .undo-cell,
  .action-cell {
    display: grid;
    align-items: center;
  }

  .undo-cell {
    justify-items: start;
  }

  .action-cell {
    justify-items: end;
  }

  .undo-btn,
  .delete-btn {
    width: 40px;
    height: 40px;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .delete-btn {
    border-color: rgba(255, 116, 127, 0.62);
    color: #ff8b95;
    background: linear-gradient(
      145deg,
      rgba(255, 116, 127, 0.22),
      rgba(145, 35, 53, 0.14)
    );
    box-shadow:
      inset 0 0 10px rgba(255, 255, 255, 0.035),
      0 0 0 rgba(255, 116, 127, 0);
    animation: mobile-delete-glow 2.6s ease-in-out infinite;
    transition:
      transform 150ms ease,
      color 150ms ease,
      border-color 150ms ease,
      background 150ms ease;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .delete-btn:active {
    transform: scale(0.88);
    border-color: rgba(255, 116, 127, 0.95);
    color: #fff;
    background: rgba(255, 69, 85, 0.32);
  }

  .amount-editor {
    width: 100%;
    gap: 8px;
  }

  .amount-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .cell-input {
    min-height: 48px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.035);
  }

  .increment-btn {
    width: 44px;
    height: 44px;
  }

  .mobile-row-editing-ready .income-card tbody tr,
  .mobile-row-editing-ready .fixed-card tbody tr,
  .mobile-row-editing-ready .savings-card tbody tr,
  .mobile-row-editing-ready .variable-card tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "description amount";
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 9px 12px;
    cursor: pointer;
  }

  .mobile-row-editing-ready
    .income-card
    tbody
    tr:not(.is-mobile-row-open)
    .undo-cell,
  .mobile-row-editing-ready
    .fixed-card
    tbody
    tr:not(.is-mobile-row-open)
    .undo-cell,
  .mobile-row-editing-ready
    .savings-card
    tbody
    tr:not(.is-mobile-row-open)
    .undo-cell,
  .mobile-row-editing-ready
    .variable-card
    tbody
    tr:not(.is-mobile-row-open)
    .undo-cell,
  .mobile-row-editing-ready
    .income-card
    tbody
    tr:not(.is-mobile-row-open)
    .action-cell,
  .mobile-row-editing-ready
    .fixed-card
    tbody
    tr:not(.is-mobile-row-open)
    .action-cell,
  .mobile-row-editing-ready
    .savings-card
    tbody
    tr:not(.is-mobile-row-open)
    .action-cell,
  .mobile-row-editing-ready
    .variable-card
    tbody
    tr:not(.is-mobile-row-open)
    .action-cell,
  .mobile-row-editing-ready
    .variable-card
    tbody
    tr:not(.is-mobile-row-open)
    .budget-cell,
  .mobile-row-editing-ready
    .variable-card
    tbody
    tr:not(.is-mobile-row-open)
    .liquidity-cell {
    display: none;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    td[data-label]::before,
  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .increment-btn {
    display: none;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .cell-input {
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    line-height: 36px;
    pointer-events: none;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .description-cell
    .cell-input {
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .description-cell {
    display: flex;
    align-self: center;
    align-items: center;
    height: 36px;
    justify-self: stretch;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .amount-editor {
    align-items: center;
    width: auto;
    height: 36px;
    gap: 3px;
    justify-content: flex-end;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .amount-cell {
    display: flex;
    align-self: center;
    align-items: center;
    height: 36px;
    justify-self: start;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open)
    .amount-input {
    flex: 0 1 96px;
    width: 96px;
    max-width: 30vw;
    text-align: left;
  }

  .mobile-row-editing-ready
    .finance-card:not(.summary-card)
    tbody
    tr:not(.is-mobile-row-open):focus-visible {
    border-color: var(--blue);
    outline: 2px solid rgba(113, 201, 255, 0.35);
    outline-offset: 2px;
  }

  .mobile-row-editing-ready .income-card tbody tr.is-mobile-row-open,
  .mobile-row-editing-ready .fixed-card tbody tr.is-mobile-row-open,
  .mobile-row-editing-ready .savings-card tbody tr.is-mobile-row-open {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "description description"
      "amount amount";
    gap: 12px;
    padding: 66px 14px 14px;
    cursor: default;
  }

  .mobile-row-editing-ready .variable-card tbody tr.is-mobile-row-open {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "description description"
      "amount budget"
      "liquidity liquidity";
    gap: 12px;
    padding: 66px 14px 14px;
    cursor: default;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .undo-cell,
  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .action-cell {
    position: absolute;
    inset-block-start: 14px;
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .undo-cell {
    inset-inline-start: 14px;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open
    .action-cell {
    inset-inline-end: 14px;
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row {
    grid-template-areas:
      "new-label new-label"
      "description description"
      "amount amount";
  }

  .mobile-row-editing-ready
    .variable-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row {
    grid-template-areas:
      "new-label new-label"
      "description description"
      "amount budget"
      "liquidity liquidity";
  }

  .mobile-row-editing-ready
    .finance-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row::before {
    grid-area: new-label;
    justify-self: start;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.02em;
  }

  .mobile-row-editing-ready
    .income-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row::before {
    color: #55f2ad;
    content: "הכנסה חדשה";
    text-shadow: 0 0 12px rgba(69, 241, 162, 0.46);
  }

  .mobile-row-editing-ready
    .fixed-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row::before {
    color: #ff929c;
    content: "הוצאה קבועה חדשה";
    text-shadow: 0 0 12px rgba(255, 116, 127, 0.46);
  }

  .mobile-row-editing-ready
    .variable-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row::before {
    color: #ff929c;
    content: "הוצאה חדשה";
    text-shadow: 0 0 12px rgba(255, 116, 127, 0.46);
  }

  .mobile-row-editing-ready
    .savings-card
    tbody
    tr.is-mobile-row-open.is-new-mobile-row::before {
    color: #c8a7ff;
    content: "חיסכון חדש";
    text-shadow: 0 0 12px rgba(185, 149, 255, 0.5);
  }

  .income-card tfoot tr,
  .fixed-card tfoot tr,
  .savings-card tfoot tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 9px;
  }

  .income-card tfoot th,
  .income-card tfoot td,
  .fixed-card tfoot th,
  .fixed-card tfoot td,
  .savings-card tfoot th,
  .savings-card tfoot td {
    padding: 10px 4px;
    border: 0;
  }

  .income-card tfoot td:last-child,
  .fixed-card tfoot td:last-child,
  .savings-card tfoot td:last-child {
    display: none;
  }

  .income-card tfoot td:first-child,
  .fixed-card tfoot td:first-child,
  .savings-card tfoot td:first-child {
    display: none;
  }

  .variable-card tfoot tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 8px;
  }

  .variable-card tfoot tr:has(#liquidityFooter.hidden) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .variable-card tfoot th,
  .variable-card tfoot td {
    min-width: 0;
    padding: 9px 3px;
    border: 0;
    text-align: center;
    font-size: 0.82rem;
    white-space: normal;
  }

  .variable-card tfoot th,
  .variable-card tfoot td:first-child,
  .variable-card tfoot td:last-child {
    display: none;
  }

  #variableFooter::before {
    content: "הוצאות: ";
  }

  .add-row-btn {
    min-height: 50px;
    margin-top: 12px;
  }

  .summary-table-wrap {
    overflow: hidden;
  }
}

@media (max-width: 430px) {
  body {
    font-size: 16px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .card-heading {
    gap: 10px;
  }

  .card-heading h2 {
    font-size: 1.4rem;
  }

  .total-badge {
    font-size: 0.95rem;
  }

  .finance-card {
    padding-inline: 10px;
  }

  .income-card tbody,
  .fixed-card tbody,
  .savings-card tbody,
  .variable-card tbody {
    padding-inline: 6px;
  }
}

@media (max-width: 380px) {
  .variable-card tbody tr.is-mobile-row-open {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "description description"
      "amount amount"
      "budget budget"
      "liquidity liquidity";
  }

  .variable-card tbody tr.is-mobile-row-open.is-new-mobile-row {
    grid-template-areas:
      "new-label new-label"
      "description description"
      "amount amount"
      "budget budget"
      "liquidity liquidity";
  }
}

@keyframes mobile-delete-glow {
  0%,
  100% {
    box-shadow:
      inset 0 0 10px rgba(255, 255, 255, 0.035),
      0 0 0 rgba(255, 116, 127, 0);
  }

  50% {
    box-shadow:
      inset 0 0 12px rgba(255, 255, 255, 0.055),
      0 0 14px rgba(255, 116, 127, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .mobile-row-editing-ready .delete-btn {
    animation: none !important;
  }
}

/* Smooth active-table hover effect for desktop pointers */
.finance-card {
  position: relative;
  transform: translateY(0) scale(1);
  transform-origin: center;
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 220ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease;
  will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
  .finance-card:hover {
    z-index: 2;
    transform: translateY(-3px) scale(1.012);
    filter: brightness(1.06);
    border-color: rgba(125, 211, 252, 0.38);
    box-shadow:
      0 18px 40px rgba(0, 0, 0, 0.22),
      0 0 24px rgba(56, 189, 248, 0.07);
  }
}

@media (prefers-reduced-motion: reduce) {
  .finance-card {
    transition:
      filter 120ms ease,
      border-color 120ms ease;
  }

  .finance-card:hover {
    transform: none;
  }
}
