:root {
  --canvas: #fff7f3;
  --surface: #fffaf8;
  --surface-strong: #ffffff;
  --ink: #2e174d;
  --muted: #756881;
  --line: #eadff0;
  --green: #7c3aed;
  --green-soft: #f1e8ff;
  --navy: #5b21b6;
  --coral: #ff6b5f;
  --coral-soft: #ffe8e2;
  --gold: #ff9f43;
  --blue: #a855f7;
  --purple: #7c3aed;
  --pink: #ec4899;
  --orange: #ff8a3d;
  --shadow: 0 18px 55px rgba(103, 57, 154, 0.11);
  --radius: 26px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 92% 2%, rgba(168, 85, 247, .18), transparent 27rem),
    radial-gradient(circle at 8% 44%, rgba(255, 138, 61, .16), transparent 25rem),
    linear-gradient(145deg, #fffaf8 0%, #fff5ee 47%, #f7efff 100%);
  color: var(--ink);
  font-family: Arial, "Noto Sans Hebrew", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  inset: 8px auto auto 8px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { transform: translateY(0); }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 12% 82%, rgba(255,138,61,.24), transparent 24rem),
    radial-gradient(circle at 88% 10%, rgba(124,58,237,.22), transparent 28rem),
    linear-gradient(145deg, #fff9f5, #f7efff);
}
.auth-card {
  width: min(520px, 100%);
  overflow: hidden;
  border: 1px solid rgba(210,212,203,.9);
  border-radius: 28px;
  background: rgba(251,250,246,.94);
  box-shadow: 0 28px 80px rgba(23,52,47,.13);
}
.auth-brand { display: flex; align-items: center; gap: 12px; padding: 25px 30px 20px; border-bottom: 1px solid var(--line); }
.auth-brand .brand-mark { flex: 0 0 auto; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 20px; }
.auth-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-panel { padding: 31px 30px 24px; }
.auth-panel h1 { font-size: clamp(30px, 7vw, 39px); }
.auth-intro { margin-bottom: 23px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  border: 1px solid #cfd4d1;
  border-radius: 13px;
  background: white;
  color: #2c3532;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 5px 13px rgba(23,52,47,.06);
}
.google-button:hover { border-color: #aebbb6; background: #fdfdfb; }
.allowed-accounts { display: grid; gap: 5px; margin-top: 20px; padding: 14px 16px; border-radius: 13px; background: var(--green-soft); }
.allowed-accounts span { color: #51756b; font-size: 10px; }
.allowed-accounts strong { direction: ltr; text-align: right; color: #315e52; font-size: 11px; }
.oauth-help { margin-top: 17px; color: var(--muted); font-size: 11px; }
.oauth-help summary { cursor: pointer; }
.text-button { border: 0; padding: 7px 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; }
.setup-steps { display: grid; gap: 12px; margin: 0 0 23px; padding: 0 21px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.setup-steps a { color: var(--green); font-weight: 800; }
.setup-steps code { display: block; overflow-wrap: anywhere; margin-top: 5px; direction: ltr; text-align: left; color: var(--ink); font-size: 10px; }
.auth-form label { display: grid; gap: 7px; margin-top: 13px; color: var(--ink); font-size: 11px; font-weight: 800; }
.auth-form input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 11px; padding: 0 13px; background: white; direction: ltr; text-align: left; color: var(--ink); }
.auth-form input:focus { border-color: var(--green); }
.auth-security { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; padding: 13px; border-radius: 12px; background: #efefe9; color: var(--muted); }
.auth-security > span { color: var(--green); font-size: 18px; }
.auth-security p { margin: 0; font-size: 10px; line-height: 1.55; }
.auth-security code { direction: ltr; }
.auth-message { margin: 0 30px 23px; padding: 12px 14px; border: 1px solid #edcbbd; border-radius: 12px; background: var(--coral-soft); color: #81442f; font-size: 11px; line-height: 1.55; }
.auth-footer { padding: 0 30px 25px; color: #89958f; text-align: center; font-size: 9px; }

.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px 22px 24px;
  background: linear-gradient(175deg, #5b21b6 0%, #7c3aed 45%, #a855f7 100%);
  color: white;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px 13px 13px 5px;
  background: linear-gradient(135deg, #ffb45f, #ff6b5f);
  color: white;
  font-size: 21px;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; letter-spacing: -0.03em; }
.brand small { margin-top: 2px; color: #eadcff; font-size: 12px; }

.nav-list { display: grid; gap: 7px; }
.nav-item { 
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 45px;
  padding: 0 14px;
  border-radius: 12px;
  color: #efe7ff;
  text-decoration: none;
  font-size: 14px;
  transition: 150ms ease;
}
.nav-item span { width: 20px; text-align: center; font-size: 19px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.active { background: rgba(255,255,255,.2); color: white; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }

.sidebar-foot { margin-top: auto; display: grid; gap: 18px; }
.signed-in-user { display: flex; align-items: center; gap: 9px; padding: 0 9px; }
.signed-in-user strong, .signed-in-user small { display: block; max-width: 148px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signed-in-user strong { font-size: 11px; }
.signed-in-user small { margin-top: 3px; color: #9eb7af; font-size: 9px; }
.user-avatar { color: #66d1a7; font-size: 10px; }
.privacy-note { display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: 12px; }
.privacy-note small { margin-top: 3px; color: #9eb7af; font-size: 10px; }
.privacy-dot { width: 9px; height: 9px; border-radius: 50%; background: #66d1a7; box-shadow: 0 0 0 5px rgba(102,209,167,.12); }
.plain-button { border: 0; background: transparent; color: #b9ccc6; text-align: right; padding: 4px 10px; font-size: 13px; }
.plain-button:hover { color: white; }
.logout-button { color: #d8b9ad; }

.main-content { min-width: 0; padding: 38px clamp(22px, 4vw, 58px) 30px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(26px, 3.1vw, 39px); line-height: 1.12; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.025em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.profile-picker { display: flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); color: var(--muted); font-size: 12px; }
.profile-picker select { border: 0; outline: 0; background: transparent; color: var(--ink); font-weight: 700; }
.mode-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.6); }
.mode-button { border: 0; border-radius: 9px; padding: 8px 13px; background: transparent; color: var(--muted); font-size: 12px; }
.mode-button.active { background: var(--ink); color: white; box-shadow: 0 3px 9px rgba(23,52,47,.16); }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.66); color: var(--ink); font-size: 20px; transition: transform .2s; }
.icon-button:hover { transform: rotate(30deg); }

.notice { margin: -10px 0 20px; padding: 13px 16px; border: 1px solid #edcbbd; border-radius: 13px; background: var(--coral-soft); color: #81442f; font-size: 13px; }
.notice.success { border-color: #b9d8cb; background: var(--green-soft); color: #205b4b; }

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

.chat-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(250px, .75fr);
  gap: 16px;
  margin-bottom: 18px;
}
.chat-panel,
.chat-guide {
  border: 1px solid rgba(210,212,203,.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chat-panel {
  min-width: 0;
  overflow: hidden;
  background: rgba(255,255,252,.82);
}
.chat-heading {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}
.assistant-avatar {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 14px 14px 14px 5px;
  background: var(--ink);
  color: #f2ce89;
  font-weight: 800;
  font-size: 18px;
}
.chat-heading h2 { font-size: 15px; }
.chat-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: #42a980; box-shadow: 0 0 0 4px rgba(66,169,128,.1); }
.clear-chat { border: 0; background: transparent; color: var(--muted); font-size: 10px; }
.clear-chat:hover { color: var(--ink); }
.chat-thread {
  min-height: 220px;
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  scroll-behavior: smooth;
}
.message-row { display: flex; align-items: flex-end; gap: 8px; }
.message-row.user { justify-content: flex-start; }
.message-row.assistant { justify-content: flex-end; }
.message-mini-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 9px; background: var(--ink); color: #f2ce89; font-size: 10px; font-weight: 800; }
.message-bubble {
  max-width: min(78%, 610px);
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
}
.message-row.assistant .message-bubble { border-bottom-right-radius: 4px; background: #ebefe9; color: var(--ink); }
.message-row.user .message-bubble { border-bottom-left-radius: 4px; background: var(--navy); color: white; }
.message-row.thinking .message-bubble { display: flex; gap: 4px; align-items: center; min-height: 38px; }
.thinking-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 700ms infinite alternate; }
.thinking-dot:nth-child(2) { animation-delay: 120ms; }
.thinking-dot:nth-child(3) { animation-delay: 240ms; }
.chat-suggestions { display: flex; gap: 7px; overflow-x: auto; padding: 0 22px 12px; scrollbar-width: none; }
.chat-suggestions::-webkit-scrollbar { display: none; }
.chat-suggestions button {
  flex: 0 0 auto;
  border: 1px solid #cfd9d3;
  border-radius: 20px;
  padding: 7px 11px;
  background: #f8faf7;
  color: var(--green);
  font-size: 10px;
}
.chat-suggestions button:hover { border-color: var(--green); background: var(--green-soft); }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 8px; padding: 13px 16px 16px; border-top: 1px solid var(--line); }
.chat-form input { min-width: 0; height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: white; color: var(--ink); }
.chat-form input:focus { border-color: var(--green); }
.chat-form button { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--ink); color: white; font-size: 20px; font-weight: 800; }
.chat-form button:disabled { opacity: .5; cursor: wait; }

.chat-guide {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 25px;
  overflow: hidden;
  background: linear-gradient(155deg, #e6eee9, #cfdfd8);
}
.chat-guide h2 { margin-bottom: 10px; font-size: 25px; }
.chat-guide > p:not(.eyebrow) { color: #60736d; font-size: 12px; line-height: 1.65; }
.budget-reference { margin: 3px 0 13px; padding: 13px; border: 1px solid rgba(29,118,95,.18); border-radius: 13px; background: rgba(255,255,255,.52); }
.budget-reference[hidden] { display: none; }
.budget-reference span, .budget-reference strong, .budget-reference small { display: block; }
.budget-reference span { color: var(--muted); font-size: 9px; }
.budget-reference strong { margin-top: 4px; color: var(--ink); font-size: 22px; direction: ltr; text-align: right; }
.budget-reference small { margin-top: 5px; color: #60736d; font-size: 9px; line-height: 1.45; }
.guide-prompts { display: grid; gap: 8px; margin-top: 4px; }
.guide-prompts button { border: 1px solid rgba(29,118,95,.18); border-radius: 12px; padding: 11px 12px; background: rgba(255,255,255,.56); color: var(--ink); text-align: right; font-size: 11px; font-weight: 700; }
.guide-prompts button::after { content: "←"; float: left; color: var(--green); }
.guide-prompts button:hover { border-color: rgba(29,118,95,.45); background: rgba(255,255,255,.86); }
.local-chat-note { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 20px; color: #557068; }
.local-chat-note > span:first-child { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: rgba(255,255,255,.52); }
.local-chat-note strong, .local-chat-note small { display: block; }
.local-chat-note strong { color: var(--ink); font-size: 10px; }
.local-chat-note small { margin-top: 3px; font-size: 9px; }

.details-panel { margin-top: 4px; }
.details-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding: 14px 19px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,252,.63);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.details-panel > summary::-webkit-details-marker { display: none; }
.details-panel > summary strong, .details-panel > summary small { display: block; }
.details-panel > summary strong { font-size: 13px; }
.details-panel > summary small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.details-arrow { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 18px; transition: transform .2s ease; }
.details-panel[open] .details-arrow { transform: rotate(180deg); }
.details-content { padding-top: 16px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card, .panel { border: 1px solid rgba(210,212,203,.82); background: rgba(255,255,252,.73); box-shadow: var(--shadow); backdrop-filter: blur(9px); }
.metric-card { position: relative; overflow: hidden; min-height: 154px; padding: 21px; border-radius: 18px; }
.metric-card::after { content: ""; position: absolute; width: 90px; height: 90px; left: -40px; bottom: -52px; border-radius: 50%; background: var(--green-soft); opacity: .6; }
.metric-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.metric-icon, .trend-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: var(--green-soft); color: var(--green); font-weight: 800; }
.trend-icon.negative { background: var(--coral-soft); color: var(--coral); }
.metric-value { display: block; margin-top: 15px; color: var(--ink); font-size: clamp(25px, 2.2vw, 33px); letter-spacing: -.045em; direction: ltr; text-align: right; }
.metric-card p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.balance-card { background: var(--navy); color: white; border-color: transparent; }
.balance-card .metric-heading, .balance-card p { color: #bdd0ce; }
.balance-card .metric-value { color: white; }
.balance-card .metric-icon { background: rgba(255,255,255,.11); color: #f2ce89; }
.balance-card::after { background: #2c6a63; }
.forecast-card { background: #efe1ba; }
.forecast-card .metric-icon { background: rgba(255,255,255,.47); color: #8b6b20; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.panel { border-radius: var(--radius); padding: 22px; min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 19px; }
.panel-heading .eyebrow { margin-bottom: 4px; }
.panel-total { color: var(--ink); font-size: 16px; font-weight: 800; direction: ltr; }
.category-panel { grid-column: span 7; }
.comparison-panel { grid-column: span 5; }
.list-panel { grid-column: span 4; }
.anomaly-panel { grid-column: span 4; }
.accounts-panel { grid-column: span 4; }
.rules-panel { grid-column: span 8; }
.transactions-panel { grid-column: span 12; }

.category-content { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 28px; }
.donut-wrap { display: grid; place-items: center; }
.donut { position: relative; width: 168px; height: 168px; border-radius: 50%; background: conic-gradient(var(--line) 0 100%); transition: background .3s ease; }
.donut::before { content: ""; position: absolute; inset: 25px; border-radius: 50%; background: var(--surface-strong); }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: 18px; direction: ltr; }
.donut-center span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.category-list { display: grid; gap: 12px; }
.category-row { display: grid; grid-template-columns: 9px minmax(0,1fr) auto; align-items: center; gap: 9px; font-size: 12px; }
.category-color { width: 8px; height: 8px; border-radius: 50%; }
.category-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-amount { color: var(--muted); font-weight: 700; direction: ltr; }
.category-track { grid-column: 2 / -1; height: 3px; margin-top: -4px; border-radius: 4px; background: #e9e9e3; overflow: hidden; }
.category-fill { height: 100%; border-radius: inherit; }

.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 10px; }
.chart-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 2px; }
.income-key::before { background: var(--green); }
.expense-key::before { background: var(--coral); }
.comparison-chart { height: 190px; display: flex; align-items: stretch; justify-content: space-between; gap: 10px; padding-top: 10px; }
.month-column { flex: 1; min-width: 0; display: grid; grid-template-rows: 1fr auto; gap: 9px; text-align: center; }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; min-height: 150px; border-bottom: 1px solid var(--line); }
.bar { width: min(13px, 38%); min-height: 3px; border-radius: 5px 5px 1px 1px; transition: height .35s ease; }
.bar.income { background: var(--green); opacity: .88; }
.bar.expense { background: var(--coral); opacity: .8; }
.month-label { color: var(--muted); font-size: 10px; white-space: nowrap; }
.month-column.current .month-label { color: var(--ink); font-weight: 800; }

.count-badge, .source-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 20px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; }
.item-list { display: grid; gap: 2px; }
.list-item { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #e8e8e1; }
.list-item:last-child { border-bottom: 0; }
.item-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--green-soft); color: var(--green); font-size: 14px; font-weight: 800; }
.item-copy { min-width: 0; }
.item-copy strong, .item-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-copy strong { font-size: 12px; }
.item-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.item-amount { text-align: left; direction: ltr; font-size: 12px; font-weight: 800; }
.empty-state { padding: 30px 10px; color: var(--muted); text-align: center; font-size: 12px; }

.anomaly-panel { background: linear-gradient(145deg, rgba(255,255,252,.8), rgba(247,228,220,.58)); }
.alert-dot { width: 11px; height: 11px; margin-top: 5px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 6px rgba(227,124,92,.12); }
.anomaly-panel .item-avatar { background: var(--coral-soft); color: var(--coral); }
.anomaly-panel .item-copy small { color: #a35e48; }

.account-list { display: grid; gap: 10px; }
.account-card { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.55); }
.account-card div { display: flex; justify-content: space-between; gap: 10px; }
.account-card strong { font-size: 12px; }
.account-card b { direction: ltr; font-size: 13px; }
.account-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.quality-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.quality-row span { padding: 5px 8px; border-radius: 8px; background: #efefe9; color: var(--muted); font-size: 9px; }

.rules-intro { margin: -7px 0 14px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.rules-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.rule-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.55); }
.rule-card strong, .rule-card small { display: block; }
.rule-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.rule-card small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.delete-rule { display: grid; place-items: center; width: 29px; height: 29px; border: 0; border-radius: 9px; background: var(--coral-soft); color: #a3563f; font-size: 16px; }
.rules-panel .empty-state { grid-column: 1 / -1; padding: 20px 10px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 0 10px 11px; color: var(--muted); font-size: 10px; text-align: right; font-weight: 600; }
td { padding: 13px 10px; border-top: 1px solid #e8e8e1; }
td:nth-child(4) { direction: ltr; text-align: left; font-weight: 800; }
.correction-button { border: 1px solid #cfd9d3; border-radius: 9px; padding: 6px 9px; background: #f8faf7; color: var(--green); font-size: 9px; font-weight: 700; white-space: nowrap; }
.correction-button:hover { border-color: var(--green); background: var(--green-soft); }
.correction-button:disabled { opacity: .42; cursor: not-allowed; }
.transaction-name { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.transaction-bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); flex: 0 0 auto; }
.amount-income { color: var(--green); }
.amount-expense { color: var(--ink); }

footer { padding: 28px 10px 0; color: #89958f; text-align: center; font-size: 10px; }

.settings-dialog { width: min(510px, calc(100vw - 28px)); border: 0; border-radius: 24px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 26px 80px rgba(15,35,31,.26); }
.settings-dialog::backdrop { background: rgba(15,35,31,.62); backdrop-filter: blur(4px); }
.settings-dialog form { position: relative; padding: 32px; }
.settings-dialog h2 { margin-bottom: 8px; font-size: 26px; }
.dialog-intro { margin-bottom: 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-close { position: absolute; top: 18px; left: 18px; display: grid; place-items: center; width: 33px; height: 33px; border: 0; border-radius: 10px; background: #eeeee8; color: var(--ink); font-size: 21px; }
.settings-dialog label { display: grid; gap: 7px; margin-top: 14px; color: var(--ink); font-size: 12px; font-weight: 700; }
.settings-dialog input { width: 100%; min-height: 45px; border: 1px solid var(--line); border-radius: 11px; padding: 0 13px; background: white; direction: ltr; text-align: left; color: var(--ink); }
.settings-dialog select { width: 100%; min-height: 45px; border: 1px solid var(--line); border-radius: 11px; padding: 0 13px; background: white; color: var(--ink); }
.settings-dialog input:focus, .settings-dialog select:focus { border-color: var(--green); }
.correction-transaction { margin: 8px 0 18px; padding: 12px 13px; border-radius: 12px; background: #efefe9; color: var(--ink); font-size: 12px; font-weight: 700; }
.security-box { display: flex; gap: 11px; margin-top: 18px; padding: 13px; border-radius: 12px; background: var(--green-soft); color: #315e52; }
.security-box > span { font-size: 20px; }
.security-box p { margin: 0; font-size: 11px; line-height: 1.55; }
.security-box code { direction: ltr; }
.form-message { min-height: 18px; margin: 12px 0 0; color: #a64d35; font-size: 11px; }
.form-message.success { color: var(--green); }
.primary-button { width: 100%; min-height: 47px; margin-top: 6px; border: 0; border-radius: 12px; background: var(--ink); color: white; font-weight: 800; }
.primary-button:disabled { opacity: .55; cursor: wait; }

.loading-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; background: rgba(243,241,233,.78); backdrop-filter: blur(5px); }
.loading-overlay[hidden] { display: none; }
.loading-overlay p { margin-top: 13px; color: var(--ink); font-size: 12px; font-weight: 700; }
.loader { display: flex; gap: 6px; direction: ltr; }
.loader span { width: 9px; height: 9px; border-radius: 50%; background: var(--green); animation: bounce 900ms infinite alternate; }
.loader span:nth-child(2) { animation-delay: 180ms; }
.loader span:nth-child(3) { animation-delay: 360ms; }
@keyframes bounce { to { transform: translateY(-9px); opacity: .5; } }

/* השכבה הקלילה: הצ׳ט והמספרים החשובים ראשונים, הפירוט נשאר רגוע מאחור. */
.main-content { max-width: 1500px; width: 100%; margin-inline: auto; }
.topbar h1 {
  background: linear-gradient(100deg, #5b21b6 5%, #a855f7 48%, #ff6b5f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(31px, 4vw, 52px);
}
.eyebrow { color: var(--purple); }
.mode-switch, .profile-picker, .icon-button {
  border-color: rgba(124, 58, 237, .16);
  background: rgba(255,255,255,.76);
  box-shadow: 0 8px 24px rgba(124,58,237,.06);
}
.mode-button.active {
  background: linear-gradient(135deg, var(--purple), #a855f7);
  box-shadow: 0 6px 16px rgba(124,58,237,.23);
}
.quick-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.quick-card {
  position: relative;
  min-height: 135px;
  overflow: hidden;
  padding: 21px 22px;
  border: 1px solid rgba(124,58,237,.10);
  border-radius: 25px;
  color: white;
  box-shadow: 0 18px 40px rgba(93,33,182,.17);
  isolation: isolate;
}
.quick-card::before,
.quick-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.quick-card::before { width: 130px; height: 130px; inset: -58px -35px auto auto; }
.quick-card::after { width: 80px; height: 80px; inset: auto auto -38px 16px; }
.quick-balance { background: linear-gradient(135deg, #5b21b6, #8b5cf6 58%, #c084fc); }
.quick-income { background: linear-gradient(135deg, #a855f7, #ec4899); }
.quick-expense { background: linear-gradient(135deg, #ff6b5f, #ff8a3d 62%, #ffb45f); }
.quick-card span, .quick-card small { display: block; color: rgba(255,255,255,.86); }
.quick-card span { font-size: 13px; font-weight: 800; }
.quick-card strong { display: block; margin: 12px 0 7px; direction: ltr; text-align: right; font-size: clamp(25px, 3vw, 37px); letter-spacing: -.04em; }
.quick-card small { font-size: 10px; }

.chat-hero { grid-template-columns: minmax(0, 1.7fr) minmax(270px, .7fr); gap: 18px; }
.chat-panel, .chat-guide {
  border-color: rgba(124,58,237,.12);
  box-shadow: 0 24px 70px rgba(103,57,154,.12);
}
.chat-panel { background: rgba(255,255,255,.88); }
.chat-heading {
  padding: 20px 23px;
  border-bottom-color: #eee4f5;
  background: linear-gradient(90deg, rgba(255,255,255,.98), rgba(247,239,255,.72));
}
.assistant-avatar, .message-mini-avatar {
  background: linear-gradient(145deg, #ff8a3d, #ff5f7e 48%, #8b5cf6);
  color: white;
  box-shadow: 0 7px 18px rgba(236,72,153,.22);
}
.assistant-avatar { border-radius: 16px 16px 6px 16px; }
.online-dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.chat-thread {
  min-height: 290px;
  max-height: 450px;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,138,61,.07), transparent 15rem),
    radial-gradient(circle at 85% 80%, rgba(168,85,247,.07), transparent 16rem),
    #fffdfd;
}
.message-row.assistant { flex-wrap: wrap; }
.message-row.assistant .message-bubble {
  background: linear-gradient(145deg, #f5edff, #fff1eb);
  border: 1px solid #eadcf3;
}
.message-row.user .message-bubble {
  background: linear-gradient(135deg, #6d28d9, #8b5cf6);
  box-shadow: 0 7px 18px rgba(109,40,217,.15);
}
.message-bubble { padding: 13px 16px; font-size: 14px; }
.chat-correction {
  flex: 0 0 min(78%, 610px);
  margin: 5px 34px 0 0;
  padding: 14px;
  border: 1px solid #f0d5ff;
  border-radius: 16px 5px 16px 16px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(124,58,237,.08);
}
.chat-correction strong, .chat-correction small { display: block; }
.chat-correction strong { font-size: 12px; }
.chat-correction small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.chat-correction-button {
  margin-top: 10px;
  border: 0;
  border-radius: 11px;
  padding: 9px 12px;
  background: linear-gradient(135deg, var(--purple), #a855f7);
  color: white;
  font-size: 11px;
  font-weight: 800;
}
.chat-suggestions button, .correction-button {
  border-color: #ddc9ef;
  background: #fbf7ff;
  color: var(--purple);
}
.chat-suggestions button:hover, .correction-button:hover { border-color: var(--purple); background: var(--green-soft); }
.chat-form { border-top-color: #eee4f5; background: rgba(255,250,252,.8); }
.chat-form input { height: 48px; border-radius: 15px; border-color: #ddcfea; font-size: 14px; }
.chat-form button {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: linear-gradient(135deg, #ff8a3d, #ec4899 52%, #7c3aed);
  box-shadow: 0 8px 20px rgba(236,72,153,.22);
}
.chat-guide {
  background:
    radial-gradient(circle at 90% 5%, rgba(255,255,255,.55), transparent 10rem),
    linear-gradient(155deg, #f1e7ff 0%, #ffe9f0 52%, #fff0df 100%);
}
.chat-guide > p:not(.eyebrow), .local-chat-note { color: #6d5a78; }
.budget-reference, .guide-prompts button { border-color: rgba(124,58,237,.15); background: rgba(255,255,255,.62); }
.guide-prompts button::after { color: var(--purple); }
.details-panel > summary {
  border-color: rgba(124,58,237,.13);
  background: rgba(255,255,255,.7);
  box-shadow: 0 10px 30px rgba(124,58,237,.06);
}
.details-arrow { background: linear-gradient(135deg, #f1e8ff, #ffe8e2); color: var(--purple); }
.metric-card, .panel { border-color: rgba(124,58,237,.10); background: rgba(255,255,255,.78); }
.balance-card { background: linear-gradient(135deg, #5b21b6, #8b5cf6); }
.forecast-card { background: linear-gradient(145deg, #ffe2c3, #ffd5e3); }
.metric-card::after { background: #eedfff; }
.item-avatar, .count-badge, .source-badge { background: linear-gradient(135deg, #f1e8ff, #ffe7f2); color: var(--purple); }
.bar.income { background: linear-gradient(to top, #7c3aed, #c084fc); }
.bar.expense { background: linear-gradient(to top, #ff6b5f, #ffb45f); }
.income-key::before { background: var(--purple); }
.account-card, .rule-card { border-color: #eadff0; background: rgba(255,250,253,.72); }
.primary-button { background: linear-gradient(135deg, #6d28d9, #a855f7 55%, #ec4899); box-shadow: 0 9px 22px rgba(124,58,237,.2); }
.security-box { background: linear-gradient(135deg, #f1e8ff, #ffe9ef); color: #6a3c82; }
.settings-dialog::backdrop { background: rgba(46,23,77,.62); }
.loading-overlay { background: rgba(255,247,243,.78); }
.loader span { background: var(--purple); }

@media (max-width: 1120px) {
  .chat-hero { grid-template-columns: minmax(0, 1.45fr) minmax(240px, .75fr); }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-panel, .comparison-panel { grid-column: span 12; }
  .list-panel, .anomaly-panel, .accounts-panel, .rules-panel { grid-column: span 6; }
}

@media (max-width: 790px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 15px 18px; flex-direction: row; align-items: center; }
  .brand { padding: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .brand small, .nav-list, .sidebar-foot { display: none; }
  .main-content { padding: 24px 16px; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 18px; justify-content: flex-start; }
  .chat-hero { grid-template-columns: 1fr; }
  .quick-summary { grid-template-columns: 1fr 1fr; }
  .quick-balance { grid-column: 1 / -1; }
  .chat-guide { min-height: auto; }
  .local-chat-note { margin-top: 15px; }
  .category-content { grid-template-columns: 150px 1fr; gap: 14px; }
  .donut { width: 140px; height: 140px; }
}

@media (max-width: 580px) {
  .auth-gate { padding: 12px; }
  .auth-card { border-radius: 22px; }
  .auth-brand, .auth-panel { padding-inline: 21px; }
  .auth-message { margin-inline: 21px; }
  .summary-grid { grid-template-columns: 1fr; }
  .quick-summary { grid-template-columns: 1fr; }
  .quick-balance { grid-column: auto; }
  .quick-card { min-height: 118px; }
  .metric-card { min-height: 132px; }
  .chat-thread { min-height: 245px; padding: 17px; }
  .message-bubble { max-width: 88%; font-size: 12px; }
  .chat-suggestions { padding-inline: 17px; }
  .chat-guide { padding: 21px; }
  .chat-guide h2 { font-size: 22px; }
  .list-panel, .anomaly-panel, .accounts-panel, .rules-panel { grid-column: span 12; }
  .rules-list { grid-template-columns: 1fr; }
  .category-content { grid-template-columns: 1fr; }
  .category-list { width: 100%; }
  .comparison-chart { gap: 4px; }
  .panel { padding: 18px; }
  h1 { font-size: 29px; }
  .profile-picker { order: 3; }
  th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { display: none; }
}

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