:root {
  --bg: #f6f4ef;
  --paper: #ffffff;
  --header: #eef3ef;
  --grid: rgba(31, 29, 26, 0.1);
  --text: #1f1d1a;
  --muted: #7a746c;
  --income: #1d8f61;
  --expense: #c7513a;
  --warn: #d3a444;
  --accent: #0b7a75;
  --shadow: 0 14px 34px rgba(40, 33, 21, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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;
}

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

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

.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;
  border: 1px solid var(--grid);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

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

.budget-table th,
.budget-table td {
  padding: 10px 12px;
  vertical-align: top;
  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: center;
  font-weight: 800;
  font-size: 0.92rem;
  background: var(--header);
  color: var(--muted);
}

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

.budget-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: rgba(255, 255, 255, 0.98);
}

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

.budget-row:hover {
  background: rgba(11, 122, 117, 0.03);
}

.budget-row.drag-target {
  box-shadow: inset 0 0 0 2px rgba(11, 122, 117, 0.28);
  background: rgba(11, 122, 117, 0.05);
}

.budget-row.active {
  box-shadow: inset 0 0 0 2px rgba(11, 122, 117, 0.18);
}

.budget-row.warn {
  background: rgba(255, 250, 239, 0.9);
}

.budget-row.danger {
  background: rgba(255, 245, 243, 0.92);
}

.budget-row.warn td:first-child {
  background: rgba(255, 250, 239, 0.98);
}

.budget-row.danger td:first-child {
  background: rgba(255, 245, 243, 0.98);
}

.budget-row.today td:first-child {
  background: rgba(255, 223, 136, 0.42);
}

.history-divider td {
  padding: 6px 12px;
  background: rgba(247, 244, 238, 0.98);
}

.history-divider__button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(57, 42, 19, 0.08);
}

.cell-date {
  min-width: 112px;
  white-space: nowrap;
  font-weight: 700;
}

.cell-balance,
.cell-total,
.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-text {
  min-width: 320px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.entries-cell {
  display: grid;
  gap: 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entry-chip,
.add-chip,
.hint-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(57, 42, 19, 0.1);
  padding: 7px 12px;
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.entry-chip {
  gap: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  border-color: rgba(57, 42, 19, 0.14);
}

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

.entry-chip.drag-over {
  box-shadow: inset 0 0 0 2px rgba(11, 122, 117, 0.24);
}

.entry-chip.income {
  background: rgba(29, 143, 97, 0.16);
  border-color: rgba(29, 143, 97, 0.28);
}

.entry-chip.expense {
  background: rgba(199, 81, 58, 0.16);
  border-color: rgba(199, 81, 58, 0.26);
}

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

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

.add-chip {
  cursor: pointer;
  background: rgba(11, 122, 117, 0.16);
  border-color: rgba(11, 122, 117, 0.24);
  color: var(--accent);
  font-weight: 700;
}

.hint-chip {
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
}

.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;
}

.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-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;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 0 0 1px rgba(57, 42, 19, 0.08);
}

.workspace-account .status-label {
  font-size: 0.78rem;
}

.workspace-account .status-value {
  font-size: 0.92rem;
}

.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;
}

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

.wallet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 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);
}

.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-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;
}

.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 0 64px;
  }

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

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

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

  .table-shell {
    height: calc(100vh - 160px);
    border-radius: 0;
  }

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

  .workspace-topbar {
    margin: 8px 8px 0;
  }

  .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;
  }

  .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: 8px;
    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: grid;
    grid-template-columns: 1fr 1fr;
  }
}
