/* FILE: src/styles.css
   FinAI Pocket — візуальна система застосунку.
   Централізоване керування кольорами, відступами та типографікою
   через CSS Custom Properties (mobile-first). */

:root {
  --bg: #e9eeec;
  --surface: #ffffff;
  --surface-soft: #f4f8f7;
  --surface-sunken: #eef3f1;

  --teal: #0f766e;
  --teal-deep: #0b5f54;
  --teal-bright: #13a394;
  --teal-soft: #d8efe9;
  --teal-line: #bfe3db;

  --ink: #15302b;
  --ink-soft: #324b45;
  --muted: #6b7672;
  --faint: #95a09c;

  --coral: #e2674f;
  --gold: #e0962a;
  --green: #1f9a6d;

  --line: #e6ebe9;
  --line-strong: #d8e0dd;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --pad: 18px;

  --shadow-card: 0 1px 2px rgba(16, 48, 43, 0.05);
  --shadow-float: 0 12px 30px rgba(11, 95, 84, 0.28);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Roboto", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#app { width: 100%; max-width: 460px; }

.phone-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(16, 48, 43, 0.08);
}

.icon { width: 22px; height: 22px; display: block; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px var(--pad) 12px;
  flex-shrink: 0;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(150deg, var(--teal-bright), var(--teal-deep));
  box-shadow: 0 6px 14px rgba(11, 95, 84, 0.28);
}

.brand-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; }
.brand-subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

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

.month-select {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 28px 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7672' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-button:active { background: var(--surface-soft); }

.lang-button {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.lang-button:active { background: var(--surface-soft); }

.backup-row { display: flex; gap: 10px; }
.backup-row .secondary-button { flex: 1; }

/* ---------- Scroll view ---------- */
.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px var(--pad) 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.view-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

/* ---------- Balance panel ---------- */
.balance-panel {
  border-radius: var(--r-lg);
  padding: 20px;
  color: #fff;
  background: linear-gradient(155deg, #12907f 0%, #0c5f54 100%);
  box-shadow: 0 16px 30px rgba(11, 95, 84, 0.26);
}
.balance-label { margin: 0; font-size: 13px; opacity: 0.85; }
.balance-value { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 4px 0 16px; }
.balance-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-metric {
  background: rgba(255, 255, 255, 0.13);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mini-metric span { font-size: 11.5px; opacity: 0.85; }
.mini-metric strong { font-size: 15px; font-weight: 700; }

/* ---------- Metric grid ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-card);
}
.metric span { font-size: 11.5px; color: var(--muted); }
.metric strong { font-size: 15.5px; font-weight: 700; color: var(--ink); }

/* ---------- Section card ---------- */
.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-title { margin: 0; font-size: 16px; font-weight: 700; }
.row-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.ai-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.ai-kicker {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- Cashflow canvas ---------- */
.canvas-wrap {
  background: var(--surface-soft);
  border-radius: var(--r-md);
  padding: 8px;
}
.canvas-wrap canvas { width: 100%; height: auto; display: block; }

/* ---------- AI cards ---------- */
.insight-list, .ai-grid { display: flex; flex-direction: column; gap: 10px; }
.ai-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px;
  background: var(--surface);
}
.ai-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.ai-title { margin: 3px 0 0; font-size: 15px; font-weight: 700; line-height: 1.25; }
.ai-text { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.4; }

/* ---------- Category bars ---------- */
.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.bar-title { font-size: 13.5px; font-weight: 600; }
.bar-head strong { font-size: 13.5px; font-weight: 700; }
.bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: var(--value, 0%);
  background: var(--color, var(--teal));
  border-radius: 999px;
}

/* ---------- Transactions ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 2px; }
.search-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 13px 15px;
  font: inherit;
  font-size: 15px;
  background: var(--surface);
}
.search-input:focus { outline: none; border-color: var(--teal-line); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  padding: 4px;
}
.chip-button {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.chip-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 48, 43, 0.12);
}

.transaction-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.date-group {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--faint);
  margin: 10px 2px 2px;
}
.transaction-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 13px;
}
.category-dot {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--dot-bg, var(--teal-soft));
  color: var(--dot-color, var(--teal));
}
.plain-button {
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  flex: 1;
  font: inherit;
  padding: 0;
}
.transaction-main > div { min-width: 0; }
.transaction-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.transaction-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.transaction-item > div:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.amount { font-size: 15px; font-weight: 700; white-space: nowrap; }
.amount.income { color: var(--green); }
.amount.expense { color: var(--coral); }
.danger-button {
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #fbe4df;
  color: var(--coral);
  cursor: pointer;
}
.danger-button .icon { width: 17px; height: 17px; }

/* ---------- Budgets ---------- */
.budget-list { display: flex; flex-direction: column; gap: 12px; }
.budget-row {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  background: var(--surface);
}
.budget-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.budget-title { font-size: 15.5px; font-weight: 700; }
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: var(--value, 0%);
  background: var(--color, var(--teal));
  border-radius: 999px;
}
.budget-main .budget-input {
  width: 104px;
  text-align: right;
  flex-shrink: 0;
}
.budget-main > div:first-child { min-width: 0; }
.budget-main .progress-meta { margin-top: 4px; }

/* ---------- Form fields ---------- */
.field-input, .field-select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
}
.field-input:focus, .field-select:focus {
  outline: none;
  border-color: var(--teal-line);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

/* ---------- AI score panel ---------- */
.score-panel { display: flex; align-items: center; gap: 18px; }
.score-ring {
  --score: 0;
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(var(--teal) calc(var(--score) * 1%), var(--surface-sunken) 0);
  display: grid;
  place-items: center;
}
.score-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  background: var(--surface);
  border-radius: 50%;
}
.score-ring span {
  position: relative;
  font-size: 30px;
  font-weight: 800;
  color: var(--teal-deep);
}
.score-panel > div:last-child { display: flex; flex-direction: column; gap: 3px; }

/* ---------- Forecast tiles ---------- */
.forecast-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.forecast-tile {
  background: var(--surface-soft);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.forecast-tile span { font-size: 12.5px; color: var(--muted); }
.forecast-tile strong { font-size: 19px; font-weight: 700; color: var(--ink); }

/* ---------- Scenario ---------- */
.scenario-control { display: flex; flex-direction: column; gap: 10px; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row strong { font-size: 17px; font-weight: 700; min-width: 46px; text-align: right; }
/* Native range: accent-color fills the track up to the thumb automatically,
   so the filled portion always matches the slider value (Chrome/Edge/Firefox/Safari). */
input[type="range"] {
  flex: 1;
  height: 24px;
  margin: 0;
  accent-color: var(--teal);
  cursor: pointer;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  background: var(--surface-soft);
  border-radius: var(--r-md);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-button {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
}
.nav-button .icon { width: 21px; height: 21px; }
.nav-button.active { color: var(--teal); background: var(--teal-soft); }

/* ---------- FAB ---------- */
.fab {
  position: absolute;
  right: 18px;
  bottom: 92px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(150deg, #ec7a63, var(--coral));
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-float);
}
.fab .icon { width: 26px; height: 26px; }

/* ---------- Buttons ---------- */
.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.primary-button {
  border: none;
  background: linear-gradient(150deg, var(--teal-bright), var(--teal-deep));
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  flex: 1;
}
.primary-button:active, .secondary-button:active { transform: translateY(1px); }

/* ---------- Sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 32, 28, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  animation: fade 0.2s ease;
}
.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 92%;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 18px var(--pad) calc(22px + env(safe-area-inset-bottom));
  animation: rise 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.form-panel { display: flex; flex-direction: column; gap: 18px; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.submit-row { display: flex; gap: 10px; }

@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Wider screens: keep app phone-sized & centered ---------- */
@media (min-width: 600px) {
  body { padding: 24px 0; }
  .phone-shell {
    height: calc(100vh - 48px);
    border-radius: 30px;
  }
}
