﻿:root {
  --bg: #edf5ef;
  --surface: #ffffff;
  --surface-soft: #f6fbf8;
  --ink: #10221d;
  --muted: #667870;
  --line: #d9e7df;
  --brand: #195b49;
  --brand-dark: #0d352b;
  --brand-soft: #dff1e8;
  --warm: #efba58;
  --danger: #d95f54;
  --info: #2f68a1;
  --shadow: 0 18px 45px rgba(25, 91, 73, .13);
  --shadow-soft: 0 10px 28px rgba(16, 34, 29, .09);
  --radius: 26px;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101916;
  --surface: #18231f;
  --surface-soft: #22312c;
  --ink: #edf7f2;
  --muted: #aebeb7;
  --line: #31433c;
  --brand: #62c49d;
  --brand-dark: #195b49;
  --brand-soft: #203c33;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, .22);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% -12%, rgba(136, 199, 166, .58), transparent 34rem),
    radial-gradient(circle at 100% 6%, rgba(239, 186, 88, .22), transparent 24rem),
    linear-gradient(145deg, #f8fcf9 0%, #e9f1ed 100%);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 16% -12%, rgba(25, 91, 73, .38), transparent 34rem),
    radial-gradient(circle at 100% 6%, rgba(239, 186, 88, .12), transparent 24rem),
    linear-gradient(145deg, #101916 0%, #15211d 100%);
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .56; }
input, select, textarea { font-size: 16px; }
select,
option,
optgroup {
  color-scheme: light;
  background-color: var(--surface);
  color: var(--ink);
}

.hidden { display: none !important; }

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -18px -16px 8px;
  padding: max(18px, env(safe-area-inset-top)) 16px 14px;
  background: rgba(237, 245, 239, .82);
  border-bottom: 1px solid rgba(16, 34, 29, .06);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .topbar {
  background: rgba(16, 25, 22, .86);
  border-bottom-color: rgba(237, 247, 242, .08);
}

.topbar h1,
.section-title h2,
.entry-modal h2,
.auth-card h2,
.settings-card h3 { margin: 0; }

.topbar h1 {
  font-size: clamp(1.25rem, 5vw, 2rem);
  letter-spacing: -.045em;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 4px;
  color: var(--brand);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 104px;
  padding: 8px 12px 8px 8px;
  border: 1px solid rgba(16, 34, 29, .08);
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

.user-pill span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-weight: 900;
  background-size: cover;
  background-position: center;
}

.content { display: grid; gap: 18px; }

.auth-view {
  display: none;
  min-height: calc(100vh - 140px);
  align-items: center;
}

.auth-view.active-auth { display: grid; }

.auth-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid rgba(16, 34, 29, .08);
  border-radius: 30px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
}

.auth-copy {
  padding: 20px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(25, 91, 73, .96), rgba(13, 53, 43, .97)),
    var(--brand);
  color: white;
}

.auth-copy .eyebrow { color: var(--warm); }
.auth-copy h2 { font-size: clamp(1.9rem, 8vw, 3rem); line-height: .96; letter-spacing: -.06em; }
.auth-copy p { margin: 14px 0 0; color: rgba(255, 255, 255, .78); line-height: 1.55; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 20px;
  background: #edf4f0;
}

.auth-tab {
  min-height: 46px;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-tab.active {
  background: var(--brand);
  color: white;
  box-shadow: 0 12px 26px rgba(25, 91, 73, .22);
}

.auth-form { display: none; gap: 12px; }
.auth-form.active-auth-form { display: grid; }

.auth-form label,
.settings-card label,
.entry-modal label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
}

.auth-form input,
.auth-form select,
.month-input,
.filters input,
.filters select,
.entry-modal input,
.entry-modal select,
.entry-modal textarea,
.settings-card input,
.settings-card select,
.settings-card textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}

.entry-modal select,
.entry-modal select option {
  background-color: var(--surface);
  color: var(--ink);
}

.auth-form input:focus,
.auth-form select:focus,
.month-input:focus,
.filters input:focus,
.filters select:focus,
.entry-modal input:focus,
.entry-modal select:focus,
.settings-card input:focus,
.settings-card select:focus,
.settings-card textarea:focus {
  border-color: rgba(25, 91, 73, .45);
  box-shadow: 0 0 0 4px rgba(136, 199, 166, .22);
}

.full { width: 100%; }

.app-content { display: grid; gap: 18px; }

.hero-card,
.sync-card,
.settings-card,
.card-invoice,
.folder-card,
.summary-card,
.entry-card {
  border: 1px solid rgba(16, 34, 29, .08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
}

.sync-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px;
}

.sync-card strong { display: block; font-size: 1.05rem; }
.sync-card small { display: block; margin-top: 3px; color: var(--muted); }
.sync-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }

.hero-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 20px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(25, 91, 73, .96), rgba(18, 36, 31, .95)),
    var(--brand);
  color: white;
}

.muted { margin: 0 0 6px; color: var(--muted); }
.hero-card .muted { color: rgba(255, 255, 255, .72); }
.month-input { max-width: 190px; }
.hero-total { display: grid; gap: 4px; }
.hero-total span { color: rgba(255, 255, 255, .74); }
.hero-total strong,
.card-invoice strong {
  font-size: clamp(2rem, 9vw, 3.5rem);
  letter-spacing: -.06em;
}

.quick-actions,
.filters,
.two-cols { display: grid; gap: 10px; }
.quick-actions { grid-template-columns: 1fr 1fr 1fr; }

.primary-action,
.ghost-action,
.text-button {
  min-height: 48px;
  border-radius: 18px;
  font-weight: 900;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary-action:active,
.ghost-action:active,
.text-button:active,
.folder-card:active,
.nav-item:active {
  transform: translateY(1px) scale(.99);
}

.primary-action {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  box-shadow: 0 14px 32px rgba(25, 91, 73, .22);
}

.ghost-action,
.text-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .84);
  color: var(--brand);
}

:root[data-theme="dark"] .ghost-action,
:root[data-theme="dark"] .text-button {
  background: rgba(24, 35, 31, .88);
}

.ghost-action.small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
}

.file-action {
  display: grid;
  place-items: center;
  text-align: center;
}
.file-action input { display: none; }

.app-view { display: none; animation: rise .22s ease both; }
.active-view { display: grid; gap: 18px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.section-title.compact h2 { font-size: 1.2rem; }
.customize-card[hidden] { display: none; }
.dashboard-feed { margin-top: 4px; }

.section-title h2 {
  font-size: clamp(1.45rem, 6vw, 2.1rem);
  letter-spacing: -.05em;
}

.summary-grid,
.folder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-card { padding: 16px; }
.summary-card span,
.folder-card small,
.entry-card small { color: var(--muted); }
.summary-card strong { display: block; margin-top: 6px; font-size: 1.35rem; }

.insight-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(16, 34, 29, .08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-soft);
}

.insight-card strong {
  display: block;
  font-size: 1.2rem;
}

.insight-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.insight-card.positive { border-color: rgba(21, 153, 71, .22); }
.insight-card.attention { border-color: rgba(239, 186, 88, .42); }

.insight-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.insight-numbers span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

.insight-numbers b {
  color: var(--ink);
  font-size: .95rem;
}

.folder-card {
  position: relative;
  min-height: 178px;
  padding: 16px;
  overflow: hidden;
  text-align: left;
  color: var(--ink);
  background-size: cover;
  background-position: center;
}

.folder-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--brand, #195b49);
}

.folder-card::after {
  content: "";
  position: absolute;
  inset: auto -32px -44px auto;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(136, 199, 166, .2);
}

.folder-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 16px;
  background: #e7f2ed;
  color: var(--brand);
}

.folder-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.folder-card h3 { margin: 14px 0 8px; font-size: 1.05rem; }
.folder-card strong { display: block; margin: 8px 0; font-size: 1.55rem; }
.folder-card[style*="background-image"] small,
.folder-card[style*="background-image"] .topic-chips span { color: white; }
.folder-card[style*="background-image"] .folder-icon { background: rgba(255,255,255,.18); color: white !important; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.topic-chips span {
  padding: 6px 8px;
  border-radius: 999px;
  background: #eef6f2;
  color: var(--brand);
  font-size: .72rem;
  font-weight: 900;
}

.entry-list { display: grid; gap: 10px; }
.entry-card { display: grid; gap: 10px; padding: 14px; }
.entry-card header { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.entry-card h3 { margin: 0; font-size: 1rem; }
.entry-card strong { white-space: nowrap; }
.entry-card.income-entry {
  border-color: rgba(21, 153, 71, .24);
  background: linear-gradient(135deg, rgba(236, 253, 245, .92), rgba(255, 255, 255, .96));
}
.entry-card.income-entry strong { color: #137a3a; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-meta span {
  padding: 6px 8px;
  border-radius: 999px;
  background: #f1f5f2;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.surprise {
  border-color: rgba(239, 186, 88, .42);
  background: linear-gradient(135deg, #fff8e8, #ffffff);
}

.card-invoice,
.settings-card { display: grid; gap: 12px; padding: 18px; }
.card-invoice { background: linear-gradient(135deg, #fff8e8, #fff); }
.warning-card { border-color: rgba(239, 186, 88, .36); }

.bottom-nav {
  position: fixed;
  right: 14px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  max-width: 620px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(16, 34, 29, .1);
  border-radius: 26px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 18px 50px rgba(16, 34, 29, .18);
  backdrop-filter: blur(16px);
}

.nav-item {
  min-height: 44px;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 900;
}
.nav-item.active { background: var(--brand); color: white; }

.entry-modal {
  width: min(94vw, 620px);
  max-height: min(88vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 30px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(16, 34, 29, .35);
}
.entry-modal::backdrop { background: rgba(16, 34, 29, .45); backdrop-filter: blur(6px); }
.entry-modal form,
.modal-panel {
  display: grid;
  gap: 14px;
  max-height: inherit;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.modal-head {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin: -18px -18px 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}

:root[data-theme="dark"] .modal-head {
  background: rgba(24, 35, 31, .94);
}

.close-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f1f5f2;
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1;
}

.check-row { display: flex !important; align-items: center; flex-direction: row; }
.check-row input { width: 20px; min-height: 20px; }
.save-button { position: sticky; bottom: 0; }

.entry-type-hint {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
  line-height: 1.35;
}

.entry-type-hint.income {
  border-color: rgba(21, 153, 71, .2);
  background: #ecfdf5;
  color: #137a3a;
}

.entry-type-hint.expense {
  border-color: rgba(25, 91, 73, .14);
}

.detail-content {
  display: grid;
  gap: 14px;
}

.detail-hero {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
}

.detail-hero span,
.detail-hero p {
  margin: 0;
  color: rgba(255, 255, 255, .78);
}

.detail-hero strong {
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  letter-spacing: -.04em;
}

.detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-tags { margin-top: 0; }

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 80;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: #13241f;
  color: white;
  box-shadow: 0 20px 50px rgba(16, 34, 29, .22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: .2s ease;
  font-weight: 800;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #331816; }
.toast.note { background: #1f3a33; }

@media (min-width: 680px) {
  .app-shell { padding-right: 24px; padding-left: 24px; }
  .topbar { margin-right: -24px; margin-left: -24px; padding-right: 24px; padding-left: 24px; }
  .auth-card { grid-template-columns: .95fr 1.05fr; align-items: stretch; padding: 22px; }
  .auth-copy { grid-row: 1 / span 2; min-height: 100%; display: grid; align-content: center; }
  .auth-tabs { grid-column: 2; }
  .auth-form { grid-column: 2; }
  .hero-card { grid-template-columns: 1fr auto; align-items: center; padding: 26px; }
  .insight-card { grid-template-columns: 1fr minmax(240px, .55fr); align-items: center; }
  .quick-actions { grid-template-columns: 1.4fr .8fr .8fr; }
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .folder-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters, .two-cols { grid-template-columns: 1fr 1fr; }
  .entry-card { grid-template-columns: 1fr auto; align-items: center; }
}

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

@media (max-width: 480px) {
  .topbar h1 { max-width: 210px; }
  .user-pill { min-width: auto; padding-right: 8px; }
  .user-pill strong { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auth-card { padding: 12px; border-radius: 24px; }
  .auth-copy { padding: 18px; }
  .sync-card { align-items: flex-start; flex-direction: column; }
  .sync-actions { width: 100%; }
  .sync-actions .small { flex: 1; }
  .section-title { align-items: stretch; flex-direction: column; }
  .detail-summary { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .quick-actions, .summary-grid, .folder-grid { grid-template-columns: 1fr; }
  .bottom-nav { font-size: .78rem; }
}
