/* ---------- Base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e6e9f1;
  --text: #1a2233;
  --text-soft: #5b6478;
  --text-muted: #8a93a6;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --primary-hover: #4338ca;
  --income: #10b981;
  --income-soft: #ecfdf5;
  --expense: #ef4444;
  --expense-soft: #fef2f2;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 30, 60, 0.06);
  --shadow-lg: 0 12px 32px rgba(20, 30, 60, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, button {
  font-family: inherit;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.brand h1 {
  font-size: 17px;
  line-height: 1.2;
}
.brand h1 span {
  color: var(--primary);
}
.tagline {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.nav-item.active .dot {
  opacity: 1;
}

.balance-card {
  margin-top: auto;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: white;
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.balance-label {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 6px;
}
.balance-amount {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.balance-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.balance-meta div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-label {
  font-size: 11px;
  opacity: 0.7;
}
.meta-value {
  font-size: 14px;
  font-weight: 600;
}
.meta-value.income { color: #6ee7b7; }
.meta-value.expense { color: #fca5a5; }

.sidebar-foot {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

/* ---------- Main ---------- */
.main {
  padding: 28px 36px;
  max-width: 1200px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h2 {
  font-size: 24px;
}
.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-ghost.danger:hover {
  background: var(--expense-soft);
  color: var(--expense);
  border-color: #fecaca;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-danger {
  padding: 9px 16px;
  background: var(--expense);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
}
.btn-danger:hover { background: #dc2626; }

.link-btn {
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Views ---------- */
.view {
  display: none;
  flex-direction: column;
  gap: 20px;
}
.view.active { display: flex; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.income { color: var(--income); }
.expense { color: var(--expense); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 {
  font-size: 15px;
}
.muted {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ---------- Form ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg-btn[data-type="income"].active { color: var(--income); }
.seg-btn[data-type="expense"].active { color: var(--expense); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}
.field input,
.field select {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Transaction list ---------- */
.tx-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
}
.tx-list.full {
  max-height: none;
}
.tx-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  transition: background 0.15s;
}
.tx-item:hover { background: var(--surface-2); }
.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.tx-icon.income { background: var(--income-soft); color: var(--income); }
.tx-icon.expense { background: var(--expense-soft); color: var(--expense); }

.tx-main { min-width: 0; }
.tx-desc {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.tx-amount {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-delete {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.tx-item:hover .tx-delete { opacity: 1; }
.tx-delete:hover { background: var(--expense-soft); color: var(--expense); }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px;
  font-size: 13px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.filters {
  display: flex;
  gap: 6px;
}
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { background: var(--surface-2); }
.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

#searchInput {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 240px;
  color: var(--text);
}
#searchInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- Analytics ---------- */
.category-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  gap: 12px;
}
.bar-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  transition: width 0.5s ease;
}
.bar-fill.income { background: linear-gradient(90deg, #10b981, #34d399); }
.bar-fill.expense { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 40, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade 0.15s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: min(380px, 90vw);
  box-shadow: var(--shadow-lg);
}
.modal-card h3 {
  font-size: 16px;
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

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

/* ---------- Scrollbar ---------- */
.tx-list::-webkit-scrollbar { width: 6px; }
.tx-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.tx-list::-webkit-scrollbar-thumb:hover { background: #d0d5e0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
  }
  .balance-card { margin-top: 0; }
  .main { padding: 20px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-item { white-space: nowrap; }
  .toolbar { flex-direction: column; align-items: stretch; }
  #searchInput { width: 100%; }
  .bar-row { grid-template-columns: 90px 1fr 70px; }
}

/* ---------- Auth screen ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(79, 70, 229, 0.15), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(124, 58, 237, 0.18), transparent 60%),
    var(--bg);
  padding: 24px;
  gap: 18px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.auth-brand h1 {
  font-size: 18px;
}
.auth-brand h1 span {
  color: var(--primary);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  padding: 9px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-msg {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  background: var(--surface-2);
  color: var(--text-soft);
}
.auth-msg.err {
  background: var(--expense-soft);
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.auth-msg.ok {
  background: var(--income-soft);
  color: #047857;
  border: 1px solid #a7f3d0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.auth-foot {
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-legal {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.display-ccy {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
}
.display-ccy label { opacity: 0.7; }
.display-ccy select {
  flex: 1;
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.display-ccy select option { color: black; }
.rate-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.rate-status.live { color: #6ee7b7; }
.rate-status.stale { color: #fbbf24; }

.tx-amount-wrap {
  text-align: right;
  white-space: nowrap;
}
.tx-converted {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.muted-inline {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
}

/* ---------- Chat bot ---------- */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover { transform: scale(1.05); box-shadow: 0 12px 28px rgba(79, 70, 229, 0.5); }
.chat-fab[hidden] { display: none; }

.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 130px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(20, 30, 60, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 51;
  animation: chat-slide-in 0.18s ease;
}
@keyframes chat-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
}
.chat-title { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
}
.chat-head h4 { font-size: 14px; font-weight: 600; }
.chat-sub { font-size: 11px; opacity: 0.85; margin-top: 1px; }
.chat-close {
  width: 28px; height: 28px;
  border-radius: 8px;
  color: white;
  font-size: 20px;
  display: grid; place-items: center;
  transition: background 0.15s;
}
.chat-close:hover { background: rgba(255,255,255,0.15); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
}

.chat-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}
.chat-msg.error {
  align-self: center;
  background: var(--expense-soft);
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 12px;
}
.chat-msg.typing {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.typing::after {
  content: '???';
  letter-spacing: 2px;
  animation: chat-blink 1s infinite;
}
@keyframes chat-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 4px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.chat-starters[hidden] { display: none; }
.starter {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.starter:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s;
}
.chat-input input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.chat-input button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 18px;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-input button:hover { background: var(--primary-hover); }
.chat-input button:disabled { background: var(--border); cursor: not-allowed; }

@media (max-width: 480px) {
  .chat-panel {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
  }
}

/* =============================================================
   POLISH � toasts, dark mode, skeletons, transitions
   ============================================================= */

/* ---------- Dark mode ---------- */
:root {
  --bg:        #f5f7fb;
  --surface:   #ffffff;
  --surface-2: #f9fafc;
  --border:    #e6e9f1;
  --text:      #1a2233;
  --text-soft: #5b6478;
  --text-muted:#8a93a6;
}
[data-theme="dark"] {
  --bg:        #0f1115;
  --surface:   #1a1d24;
  --surface-2: #14171d;
  --border:    #2a2f3a;
  --text:      #e8eaf0;
  --text-soft: #a0a6b3;
  --text-muted:#6b7180;
  --primary-soft: #2a2451;
  --expense-soft: #3a1d1d;
  --income-soft:  #14352a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.4);
}
html.theme-transition, html.theme-transition * { transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.theme-toggle:hover { background: var(--primary-soft); color: var(--primary); transform: rotate(20deg); }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  min-width: 240px;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}
.toast.success { border-left-color: var(--income); }
.toast.error   { border-left-color: var(--expense); }
.toast.info    { border-left-color: var(--primary); }
.toast .toast-icon { font-size: 18px; flex-shrink: 0; }
.toast .toast-msg { flex: 1; line-height: 1.4; }
.toast .toast-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 0; line-height: 1;
}
.toast .toast-close:hover { color: var(--text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}
.toast.leaving { animation: toast-out 0.2s ease forwards; }

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
  height: 14px;
}
.skeleton-line { margin: 8px 0; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 96px;
  height: 96px;
  margin-bottom: 14px;
  opacity: 0.5;
}
.empty-state h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 13px;
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto;
}

/* ---------- View transitions ---------- */
.view {
  animation: view-fade 0.25s ease;
}
@keyframes view-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- List item entry animation ---------- */
.tx-item {
  animation: list-in 0.2s ease;
}
@keyframes list-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Stat card lift on hover ---------- */
.stat-card {
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ---------- Keyboard shortcut hint ---------- */
.kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: var(--text-soft);
}

/* ---------- Refined stat icons ---------- */
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Sidebar brand subtle hover ---------- */
.brand .logo { transition: transform 0.2s; }
.brand:hover .logo { transform: rotate(-5deg) scale(1.05); }

/* ---------- Card subtle hover ---------- */
.card {
  transition: box-shadow 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* ---------- Chat attach button + image preview ---------- */
.chat-attach-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.chat-attach-btn:hover { background: var(--surface-2); color: var(--primary); transform: scale(1.05); }
.chat-attach-btn.has-file { color: var(--primary); }

.chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 4px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  animation: chat-attach-in 0.2s ease;
}
.chat-attach-preview img {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.chat-attach-preview[hidden] { display: none; }
.chat-attach-meta {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.chat-attach-meta span {
  font-size: 12px; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-attach-clear {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.chat-attach-clear:hover { background: var(--expense-soft); color: var(--expense); }
@keyframes chat-attach-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Inline image in chat history ---------- */
.chat-msg img.chat-img {
  max-width: 220px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 6px;
  display: block;
  border: 1px solid var(--border);
}
.chat-msg.assistant img.chat-img { border-color: var(--border); }

/* ---------- Suggested transaction card ---------- */
.chat-suggestion {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-suggestion-row {
  display: flex; justify-content: space-between; gap: 12px;
}
.chat-suggestion-row b { color: var(--text); }
.chat-suggestion-actions {
  display: flex; gap: 6px; margin-top: 2px;
}
.chat-suggestion-actions button {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chat-suggestion-actions button.primary { background: var(--primary); color: white; border-color: var(--primary); }
.chat-suggestion-actions button:hover { background: var(--primary-soft); color: var(--primary); }
.chat-suggestion-actions button.primary:hover { background: var(--primary-hover); color: white; }
