*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden { display: none !important; }

:root {
  --bg: #232a2e;
  --surface: #2d353b;
  --surface-2: #343f44;
  --border: #475258;
  --text: #d3c6aa;
  --text-muted: #859289;
  --deposit: #a7c080;
  --deposit-bg: #2d3d30;
  --debit: #e67e80;
  --debit-bg: #3d2b2b;
  --accent: #7fbbb3;
  --accent-bg: #283d3b;
  --radius: 8px;
}

/* ── Oak light theme ── */

[data-theme="oak"] {
  --bg:         #f7f2ea;
  --surface:    #ffffff;
  --surface-2:  #f0e8d8;
  --border:     #d9cbb5;
  --text:       #2a1a0a;
  --text-muted: #8a7055;
  --deposit:    #4a7c3a;
  --deposit-bg: #e8f3e2;
  --debit:      #b83a2a;
  --debit-bg:   #fce8e4;
  --accent:     #b07020;
  --accent-bg:  #fdf0d8;
}

/* Switch native inputs to light mode in oak theme */
[data-theme="oak"] input,
[data-theme="oak"] select {
  color-scheme: light;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Screen visibility ── */

#setup-screen,
#auth-screen,
#app { display: none; }

#setup-screen.screen-visible,
#auth-screen.screen-visible  {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

#app.screen-visible {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

/* ── Auth / Setup card ── */

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
}

.auth-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}

.auth-tab.active {
  background: var(--accent);
  color: white;
}

.auth-form,
#setup-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input,
#setup-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.1s;
}

.auth-form input:focus,
#setup-form input:focus {
  border-color: var(--accent);
}

.auth-form button[type="submit"],
#setup-form button[type="submit"] {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.1s;
}

.auth-form button[type="submit"]:hover,
#setup-form button[type="submit"]:hover {
  opacity: 0.88;
}

.auth-error {
  font-size: 0.8125rem;
  color: var(--debit);
  text-align: center;
}

.verify-msg {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: inherit;
  text-align: center;
  padding: 0;
  transition: color 0.1s;
}

.link-btn:hover {
  color: var(--accent);
}

/* ── Sign out button ── */

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#signout-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: inherit;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.1s, color 0.1s;
}

#signout-btn:hover {
  background: var(--debit-bg);
  color: var(--debit);
  border-color: var(--debit);
}

/* ── App shell ── */

/* ── Header ── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}

nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

nav button {
  width: 32px;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

nav button:hover {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

h1 {
  font-size: 1.125rem;
  font-weight: 600;
  min-width: 190px;
  text-align: center;
}

#summary {
  display: flex;
  gap: 6px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 5px 14px;
  border-radius: var(--radius);
  min-width: 100px;
}

.summary-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

.summary-value {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-top: 1px;
}

.summary-item.credits {
  background: var(--deposit-bg);
  color: var(--deposit);
}

.summary-item.debits,
.summary-item.expenses {
  background: var(--debit-bg);
  color: var(--debit);
}

.summary-item.net {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.summary-item.net.positive {
  background: var(--deposit-bg);
  color: var(--deposit);
  border-color: transparent;
}

.summary-item.net.negative {
  background: var(--debit-bg);
  color: var(--debit);
  border-color: transparent;
}

/* ── Main row (budget pane + calendar) ── */

#main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
}

/* ── Left column (budget + goals) ── */

#left-col {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ── Budget pane ── */

#budget-pane {
  flex: 1;
  min-height: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#budget-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#budget-pane-header span:first-child {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

#budget-collapse-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.1s, transform 0.2s;
}

#budget-collapse-btn:hover {
  background: var(--border);
}

#budget-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.budget-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  gap: 8px;
  cursor: pointer;
}

.budget-item-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.budget-item-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.budget-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.budget-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.budget-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--deposit);
  transition: width 0.3s;
}

.budget-progress-fill.over {
  background: var(--debit);
}

.budget-spend-text {
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.budget-spend-text.over {
  color: var(--debit);
}

.budget-tag {
  font-size: 0.6875rem;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.budget-item:not(.editing):hover {
  background: var(--surface);
}

.budget-item:not(.editing):hover .del-btn {
  opacity: 0.5;
}

.budget-item.editing {
  padding: 6px 10px;
  gap: 6px;
  cursor: default;
  background: var(--surface);
}

.budget-item.editing input {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  color-scheme: dark;
  transition: border-color 0.1s;
}

.budget-item.editing input:focus {
  border-color: var(--accent);
}

.budget-item.editing input[type="text"]   { flex: 1; min-width: 0; }
.budget-item.editing input[type="number"] { width: 68px; flex-shrink: 0; }

.edit-save-btn,
.edit-cancel-btn {
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}

.edit-save-btn   { color: var(--deposit); }
.edit-save-btn:hover   { background: var(--deposit-bg); }
.edit-cancel-btn { color: var(--text-muted); }
.edit-cancel-btn:hover { background: var(--border); }

.budget-item-name {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.budget-item-amount {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--debit);
  flex-shrink: 0;
}

.budget-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding: 20px 14px;
}

#budget-footer {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#budget-add-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}

#budget-add-btn:hover {
  background: var(--accent-bg);
}

#budget-form {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#budget-form.hidden {
  display: none;
}

#budget-form input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.1s;
  color-scheme: dark;
}

#budget-form input:focus {
  border-color: var(--accent);
}

/* ── Calendar ── */

#calendar {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#day-headers span {
  padding: 8px 0;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#days-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
}

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  transition: background 0.1s;
}

/* Remove right border on every 7th cell (last column) */
.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.empty {
  background: var(--surface);
  cursor: default;
}

.day-cell:not(.empty):hover {
  background: var(--accent-bg);
}

.day-cell.selected {
  background: var(--accent-bg);
}

.day-num {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.day-cell.today .day-num {
  background: var(--accent);
  color: white;
}

.indicators {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.indicator.deposit { background: var(--deposit); }
.indicator.debit   { background: var(--debit); }

.day-balance {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--deposit);
  margin-top: auto;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-balance.negative {
  color: var(--debit);
}

/* ── Side panel (permanent) ── */

#side-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sp-back {
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}

#sp-back:hover {
  background: var(--border);
  color: var(--text);
}

#sp-back.hidden {
  display: none;
}

#sp-title {
  font-size: 0.875rem;
  font-weight: 600;
}

#sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* ── Month overview ── */

.day-group {
  margin-bottom: 4px;
}

.day-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  cursor: pointer;
  gap: 8px;
  transition: background 0.1s;
}

.day-group-label:hover {
  background: var(--surface);
}

.day-group-label-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day-group-label-totals {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.day-group-label-totals span {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.day-group-label-totals .dep {
  background: var(--deposit-bg);
  color: var(--deposit);
}

.day-group-label-totals .deb {
  background: var(--debit-bg);
  color: var(--debit);
}

.overview-txn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 16px 5px 24px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.overview-txn:hover {
  background: var(--surface);
}

.overview-txn-name {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.overview-txn-amount {
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.overview-txn.deposit .overview-txn-amount { color: var(--deposit); }
.overview-txn.debit   .overview-txn-amount { color: var(--debit); }

/* ── Day detail ── */

.detail-list {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 24px 0;
}

.txn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
  cursor: pointer;
}

.txn-edit-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}

.txn-edit-form input,
.txn-edit-form select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.1s;
  color-scheme: dark;
}

.txn-edit-form input:focus,
.txn-edit-form select:focus {
  border-color: var(--accent);
}

.edit-date-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.edit-date-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.txn-item.deposit { border-left: 3px solid var(--deposit); }
.txn-item.debit   { border-left: 3px solid var(--debit); }

.txn-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.txn-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-recur {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.txn-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.txn-amount {
  font-size: 0.875rem;
  font-weight: 600;
}

.txn-item.deposit .txn-amount { color: var(--deposit); }
.txn-item.debit   .txn-amount { color: var(--debit); }

.del-btn {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
}

.txn-item:hover .del-btn,
.budget-item:hover .del-btn {
  opacity: 0.5;
}

.del-btn:hover {
  background: var(--debit-bg);
  color: var(--debit);
  opacity: 1 !important;
}

/* ── Side panel footer (add form) ── */

#sp-footer {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#sp-footer.hidden {
  display: none;
}

#add-btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}

#add-btn:hover {
  background: var(--accent-bg);
}

#add-form {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#add-form.hidden {
  display: none;
}

#add-form input,
#add-form select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.1s;
  color-scheme: dark;
}

#add-form input:focus,
#add-form select:focus {
  border-color: var(--accent);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#end-date-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#end-date-row.hidden {
  display: none;
}

#end-date-row label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#end-date-row label span {
  font-style: italic;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.form-actions button {
  padding: 8px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: inherit;
  transition: background 0.1s, opacity 0.1s;
}

.form-actions button[type="submit"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.form-actions button[type="submit"]:hover {
  opacity: 0.88;
}

.form-actions button[type="button"] {
  background: var(--surface);
  color: var(--text-muted);
}

.form-actions button[type="button"]:hover {
  background: var(--border);
}

/* ── Mobile layout ── */

@media (max-width: 700px) {
  #app {
    padding: 10px;
    gap: 8px;
  }

  header {
    flex-wrap: wrap;
    gap: 8px;
  }

  #summary {
    width: 100%;
    justify-content: space-between;
  }

  .summary-item {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
  }

  .summary-label {
    font-size: 0.6rem;
  }

  .summary-value {
    font-size: 0.8rem;
  }

  #main {
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
  }

  #budget-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #left-col {
    width: 100%;
    flex-direction: row;
    gap: 8px;
    flex: none;
  }

  #budget-pane {
    flex: 1;
    min-height: 0;
    max-height: 220px;
    transition: max-height 0.25s ease;
    overflow: hidden;
  }

  #budget-pane.collapsed {
    max-height: 41px;
  }

  #budget-pane.collapsed #budget-collapse-btn {
    transform: rotate(180deg);
  }

  #budget-pane.collapsed #budget-list,
  #budget-pane.collapsed #budget-footer {
    display: none;
  }

  #goals-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #goals-pane {
    flex: 1;
    min-height: 0;
    max-height: 220px;
    transition: max-height 0.25s ease;
    overflow: hidden;
  }

  #goals-pane.collapsed {
    max-height: 41px;
  }

  #goals-pane.collapsed #goals-collapse-btn {
    transform: rotate(180deg);
  }

  #goals-pane.collapsed #goals-body {
    display: none;
  }

  #calendar {
    min-height: 300px;
    flex: none;
    height: 45dvh;
  }

  #side-panel {
    width: 100%;
    flex: none;
    min-height: 200px;
    max-height: 40dvh;
  }

  #side-panel.form-active {
    max-height: 80dvh;
  }

  #side-panel.form-active #sp-body {
    display: none;
  }

  #side-panel.form-active #sp-footer {
    flex: 1;
    overflow-y: auto;
  }

  .day-cell {
    padding: 4px 5px;
  }

  .indicator {
    width: 14px;
    height: 14px;
    font-size: 0.5rem;
  }

  .del-btn {
    opacity: 0.5;
  }

  .txn-item:hover .del-btn,
  .budget-item:hover .del-btn {
    opacity: 0.5;
  }
}

/* ── Admin panel ────────────────────────────────────────────────────────── */

#admin-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#admin-screen.screen-visible {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: var(--bg);
}

#admin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

#admin-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

#admin-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

#admin-back:hover {
  color: var(--text);
  background: var(--surface-2);
}

#admin-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.admin-loading,
.admin-error {
  color: var(--text-muted);
  padding: 16px 0;
}

.admin-error { color: var(--debit); }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.admin-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  position: sticky;
  top: 0;
}

.admin-table tbody tr:hover {
  background: var(--surface-2);
}

.admin-cell-status {
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.banned {
  background: var(--debit-bg);
  color: var(--debit);
}

.badge.admin {
  background: var(--accent-bg);
  color: var(--accent);
}

.admin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-btn {
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  white-space: nowrap;
}

.admin-btn:hover { background: var(--surface); }
.admin-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.admin-btn.danger {
  border-color: var(--debit);
  color: var(--debit);
}

.admin-btn.danger:hover {
  background: var(--debit-bg);
}

#admin-btn {
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}

#admin-btn:hover {
  color: var(--text);
  background: var(--surface);
}

@media (max-width: 700px) {
  .admin-table th:nth-child(2),
  .admin-table td:nth-child(2) {
    display: none;
  }

  .admin-table {
    font-size: 0.8rem;
  }

  .admin-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
}

/* ── Goals panel ──────────────────────────────────────────────────────────── */

#goals-pane {
  flex: 1;
  min-height: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#goals-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#goals-collapse-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.1s, transform 0.2s;
}

#goals-collapse-btn:hover {
  background: var(--border);
}

#goals-pane-header span {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

#goals-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.goals-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goals-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.goals-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}


.goals-add-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}

.goals-add-btn:hover {
  background: var(--accent-bg);
}

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goals-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.goal-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.goal-card:not(.editing) {
  cursor: pointer;
}

.goal-card:not(.editing):hover {
  border-color: var(--accent);
}

.goal-card:not(.editing):hover .del-btn {
  opacity: 0.5;
}

.goal-card.editing {
  gap: 8px;
  cursor: default;
}

.goal-card.editing input {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  color-scheme: dark;
  transition: border-color 0.1s;
  width: 100%;
}

.goal-card.editing input:focus {
  border-color: var(--accent);
}

.goal-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.goal-progress {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.goal-progress.reached {
  color: var(--deposit);
  font-weight: 600;
}

.goal-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.budget-progress-fill.reached {
  background: var(--deposit);
}

.goals-add-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.goals-add-form input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.1s;
  color-scheme: dark;
}

.goals-add-form input:focus {
  border-color: var(--accent);
}

.goals-date-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.goals-date-row span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Tutorial ────────────────────────────────────────────────────────────── */

/* Overlay positioning handled entirely by JS inline styles */
#tutorial-overlay { display: none; }

#tutorial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 1.5rem;
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  z-index: 10001;
}

#tutorial-close {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  background: none; border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2px 6px;
}
#tutorial-close:hover { color: var(--text); }

#tutorial-step-counter {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

#tutorial-content h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }

#tutorial-card input,
#tutorial-card select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.1s;
  color-scheme: dark;
}

#tutorial-card input:focus,
#tutorial-card select:focus { border-color: var(--accent); }

[data-theme="oak"] #tutorial-card input,
[data-theme="oak"] #tutorial-card select { color-scheme: light; }

#tutorial-card label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
#tutorial-card label span { font-size: 0.75rem; }

.tutorial-desc {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

#tutorial-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

#tutorial-nav button {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: inherit;
  transition: background 0.1s, opacity 0.1s;
}

#tutorial-back {
  background: var(--surface);
  color: var(--text-muted);
}
#tutorial-back:hover { background: var(--border); }

#tutorial-next {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
#tutorial-next:hover { opacity: 0.88; }

#tutorial-back.hidden { visibility: hidden; }

.tutorial-summary {
  list-style: none;
  padding: 0; margin: 0.25rem 0 0.5rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.tutorial-summary li strong { color: var(--text); }

.tutorial-completion-actions {
  display: flex;
  gap: 0.75rem;
}
.tutorial-completion-actions button {
  flex: 1;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: inherit;
  transition: background 0.1s, opacity 0.1s;
}
.tutorial-completion-actions button:first-child {
  background: var(--surface);
  color: var(--text-muted);
}
.tutorial-completion-actions button:first-child:hover { background: var(--border); }
.tutorial-completion-actions button:last-child {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.tutorial-completion-actions button:last-child:hover { opacity: 0.88; }

/* Spotlight: inset shadow so it's never clipped by parent overflow */
.tutorial-spotlight {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 12px rgba(127, 187, 179, 0.15) !important;
  border-radius: var(--radius);
  transition: box-shadow 0.25s;
}

#tutorial-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 0.85rem; font-weight: 700; line-height: 1;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
#tutorial-btn:hover { color: var(--text); border-color: var(--text-muted); }

