/* =====================================================================
   Finote — Design System
   Soft, rounded, pastel family-finance UI. Light & dark themes.
   Этап 0: design tokens + component classes. No page logic here.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. TOKENS
   --------------------------------------------------------------------- */
:root {
  /* spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;

  /* radii */
  --r-card: 20px;
  --r-inner: 12px;
  --r-pill: 999px;

  /* type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-display: 34px;
  --fs-h2: 20px;
  --fs-body: 15px;
  --fs-caption: 13px;

  /* elevation */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10), 0 24px 60px rgba(16, 24, 40, .14);

  /* motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: 120ms;
  --t-base: 200ms;
}

[data-theme="light"] {
  --bg: #F7F8FA;
  --bg-soft: #FBFBFD;
  --card: #FFFFFF;
  --text: #1A1A1E;
  --muted: #8A8A93;
  --border: #ECECF0;
  --border-strong: #DDDDE3;
  --accent: #7C5CFC;
  --accent-soft: #ECE7FB;
  --pos: #2FB67C;
  --neg: #E5484D;
  --track: #EFEFF3;
  --ring: rgba(124, 92, 252, .28);
  --backdrop: rgba(20, 22, 30, .42);

  --tag-mint-bg: #E3F5EC;     --tag-mint-fg: #1F9D6B;
  --tag-lavender-bg: #ECE7FB; --tag-lavender-fg: #6D4FE0;
  --tag-peach-bg: #FDEEE3;    --tag-peach-fg: #D9803B;
  --tag-blue-bg: #E5F0FD;     --tag-blue-fg: #3B7DD8;
  --tag-gray-bg: #EFEFF2;     --tag-gray-fg: #6B6B73;

  /* aliases matching the reference's inline token names */
  --mint-bg: var(--tag-mint-bg); --mint-fg: var(--tag-mint-fg);
  --lav-bg: var(--tag-lavender-bg); --lav-fg: var(--tag-lavender-fg);
  --peach-bg: var(--tag-peach-bg); --peach-fg: var(--tag-peach-fg);
  --blue-bg: var(--tag-blue-bg); --blue-fg: var(--tag-blue-fg);
  --gray-bg: var(--tag-gray-bg); --gray-fg: var(--tag-gray-fg);

  /* pastel card gradients (same in light & dark — dark text reads on them) */
  --grad-mint: linear-gradient(150deg, #CFF3DE 0%, #EAF6C6 100%);
  --grad-lavender: linear-gradient(150deg, #E6DAFB 0%, #F8D8EC 100%);
  --grad-peach: linear-gradient(150deg, #FBE2D4 0%, #F8D7E6 100%);
  --grad-blue: linear-gradient(150deg, #CDEFE8 0%, #CFE4FB 100%);
  --grad-gray: linear-gradient(150deg, #E7E7EC 0%, #F2F2F6 100%);
  --pastel-ink: #1c2b24;
  --pastel-dim: rgba(22, 38, 30, .62);
}

[data-theme="dark"] {
  --bg: #16161A;
  --bg-soft: #1A1A1F;
  --card: #1F1F25;
  --text: #F2F2F5;
  --muted: #9A9AA5;
  --border: #2B2B33;
  --border-strong: #3A3A44;
  --accent: #8B7CF6;
  --accent-soft: #262049;
  --pos: #3DCB8C;
  --neg: #F26D70;
  --track: #2A2A31;
  --ring: rgba(139, 124, 246, .35);
  --backdrop: rgba(0, 0, 0, .58);

  --tag-mint-bg: #16322A;     --tag-mint-fg: #5FD6A3;
  --tag-lavender-bg: #262049; --tag-lavender-fg: #A994FF;
  --tag-peach-bg: #3A2618;    --tag-peach-fg: #E8A06A;
  --tag-blue-bg: #172A44;     --tag-blue-fg: #74AEF0;
  --tag-gray-bg: #26262D;     --tag-gray-fg: #9A9AA5;

  /* aliases matching the reference's inline token names */
  --mint-bg: var(--tag-mint-bg); --mint-fg: var(--tag-mint-fg);
  --lav-bg: var(--tag-lavender-bg); --lav-fg: var(--tag-lavender-fg);
  --peach-bg: var(--tag-peach-bg); --peach-fg: var(--tag-peach-fg);
  --blue-bg: var(--tag-blue-bg); --blue-fg: var(--tag-blue-fg);
  --gray-bg: var(--tag-gray-bg); --gray-fg: var(--tag-gray-fg);
}

/* ---------------------------------------------------------------------
   2. BASE
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

::selection { background: var(--accent-soft); color: var(--text); }

.muted { color: var(--muted); }

/* tighter, optically-aligned numerals everywhere it matters */
.kpi-value, .progress, .badge { font-feature-settings: "tnum" 1, "cv01" 1; }

/* ---------------------------------------------------------------------
   3. LAYOUT — sidebar + content
   --------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: 22px var(--sp-4);
  background: var(--card);
  border-right: 1px solid var(--border);
}

/* logo: 30×30 gradient mark + 24px wordmark */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #7C5CFC, #A48CFF);
  box-shadow: 0 4px 10px rgba(124, 92, 252, .35);
}
.brand-word {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* user block + account switcher */
.side-user {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: 2px;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  flex: 0 0 auto;
  background: linear-gradient(135deg, #F7C6D9, #C9B7F2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}
.user-meta { min-width: 0; }
.user-name { font-size: var(--fs-body); font-weight: 600; }
.user-mail {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-inner);
  padding: 9px var(--sp-3);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.account-switch:hover { background: var(--bg); }
.account-switch .switch-faces { display: flex; }
.account-switch .switch-faces span {
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  border: 2px solid var(--bg-soft);
}
.account-switch .switch-faces span:nth-child(1) { background: linear-gradient(135deg, #F7C6D9, #C9B7F2); }
.account-switch .switch-faces span:nth-child(2) { background: linear-gradient(135deg, #9FD8C2, #7FB4F2); margin-left: -8px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px var(--sp-3);
  border-radius: var(--r-inner);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 400;
  border: none;
  background: transparent;
  text-align: left;
  letter-spacing: -0.01em;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item .nav-ic { display: inline-flex; flex: 0 0 auto; }
.nav-item > span:not(.nav-ic) { flex: 1; text-align: left; }
.nav-item:hover { background: var(--bg-soft); }
.nav-item.active {
  background: var(--text);
  color: var(--card);
  font-weight: 600;
}
.nav-item.active:hover { background: var(--text); }
.nav-item.disabled {
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}

/* theme-toggle pill inside the footer nav-item */
.theme-pill {
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 2px;
  background: var(--track);
  justify-content: flex-start;
  transition: background var(--t-fast) var(--ease), justify-content 0s;
}
[data-theme="dark"] .theme-pill {
  background: var(--accent);
  justify-content: flex-end;
}
.theme-pill::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.main {
  min-width: 0;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  padding: 6px var(--sp-8) 36px;
  min-width: 0;
  flex: 1;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------
   4. TOPBAR
   --------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: 26px var(--sp-8) 6px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.greeting {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-caption);
  font-weight: 500;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  transition: background var(--t-fast) var(--ease);
}
.topbar-btn:hover { background: var(--bg-soft); }

/* ---------------------------------------------------------------------
   5. KPI ROW
   --------------------------------------------------------------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: var(--shadow);
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.kpi-value {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-feature-settings: "tnum" 1;
}
/* secondary figure inside a KPI value, e.g. <span>/ ...</span> */
.kpi-value span {
  color: var(--muted);
  font-weight: 600;
  font-size: 22px;
}
.kpi-caption {
  font-size: var(--fs-caption);
  color: var(--muted);
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  padding: 3px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-caption);
  font-weight: 600;
}
.kpi-delta.pos {
  color: var(--tag-mint-fg);
  background: var(--tag-mint-bg);
}
.kpi-delta.pos::before { content: "↑"; font-size: 11px; }
.kpi-delta.neg {
  color: var(--neg);
  background: color-mix(in srgb, var(--neg) 14%, transparent);
}
.kpi-delta.neg::before { content: "↓"; font-size: 11px; }

/* ---------------------------------------------------------------------
   6. CARDS & GRID
   --------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-6);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 18px;
}
.card-head h2,
.card-head .title {
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
/* muted trailing arrow after a section heading */
.card-head h2 .head-arrow {
  color: var(--muted);
  display: inline-flex;
}

/* small "+ Добавить" action used in a section header */
.head-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 10px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.head-add:hover { background: var(--bg-soft); color: var(--text); }
.head-add svg { display: block; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}

/* ---------------------------------------------------------------------
   7. PROGRESS
   --------------------------------------------------------------------- */
.progress {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--track);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--pos)));
  width: 0;
  transition: width 600ms var(--ease);
}

/* ---------------------------------------------------------------------
   8. TAGS — pastel palette
   --------------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  background: var(--tag-gray-bg);
  color: var(--tag-gray-fg);
}
.tag-mint     { background: var(--tag-mint-bg);     color: var(--tag-mint-fg); }
.tag-lavender { background: var(--tag-lavender-bg); color: var(--tag-lavender-fg); }
.tag-peach    { background: var(--tag-peach-bg);    color: var(--tag-peach-fg); }
.tag-blue     { background: var(--tag-blue-bg);     color: var(--tag-blue-fg); }
.tag-gray     { background: var(--tag-gray-bg);     color: var(--tag-gray-fg); }

/* ---------------------------------------------------------------------
   9. ROWS — envelopes, payday split, transactions, goal progress
   --------------------------------------------------------------------- */

/* generic list empty state */
.list-empty {
  color: var(--muted);
  font-size: var(--fs-body);
  padding: var(--sp-4) 0 var(--sp-2);
}

/* --- envelope row ("Сколько откладывать") --- */
.env-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.env-row:last-child { border-bottom: none; }
.env-row .env-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.env-row .env-need {
  font-weight: 700;
  font-size: 15px;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  color: var(--text);
}
.env-row .env-need .per {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.env-row .overdue { color: var(--neg); }

/* --- payday split row --- */
.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.split-row:last-child { border-bottom: none; }
.split-row .split-name { font-size: 14.5px; font-weight: 500; }
.split-row .split-name .day { color: var(--muted); font-weight: 400; }
.split-row .split-amt {
  font-weight: 700;
  font-size: 15px;
  font-feature-settings: "tnum" 1;
  color: var(--text);
}

/* --- transaction row (income) --- */
.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-chip {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tx-chip.in { background: rgba(47, 182, 124, .16); color: var(--pos); }
.tx-chip.out { background: rgba(229, 72, 77, .14); color: var(--neg); }
.tx-chip.move { background: var(--accent-soft); color: var(--accent); }
.tx-chip svg { display: block; }
.tx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-name {
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-sub {
  font-size: 12.5px;
  color: var(--muted);
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-amt {
  font-weight: 700;
  font-size: 15px;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}
.tx-amt.pos { color: var(--pos); }
.tx-amt.neg { color: var(--neg); }
.tx-amt.neutral { color: var(--text); }

/* --- month navigator (журнал транзакций) --- */
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-label {
  min-width: 116px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  font-feature-settings: "tnum" 1;
}

/* --- goal progress row (savings) --- */
.goal-row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.goal-row:last-child { border-bottom: none; }
.goal-top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.goal-title {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goal-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.goal-pct {
  font-weight: 700;
  font-size: 15px;
  font-feature-settings: "tnum" 1;
}
.goal-amt {
  color: var(--muted);
  font-size: 13.5px;
  font-feature-settings: "tnum" 1;
}
.goal-amt .cur { color: var(--text); font-weight: 600; }

/* row-level edit/delete actions, revealed on hover */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.env-row:hover .row-actions,
.tx-row:hover .row-actions,
.goal-row:hover .row-actions { opacity: 1; }
@media (hover: none) {
  .row-actions { opacity: 1; }
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn-icon:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border);
}

/* ---------------------------------------------------------------------
   9b. PASTEL CARDS — obligations & planned expenses
   --------------------------------------------------------------------- */
.pastel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pastel-card {
  position: relative;
  border-radius: 16px;
  padding: 16px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  color: var(--pastel-ink);
  background: var(--grad-mint);
}
.pastel-card.fam-mint     { background: var(--grad-mint); }
.pastel-card.fam-lavender { background: var(--grad-lavender); }
.pastel-card.fam-peach    { background: var(--grad-peach); }
.pastel-card.fam-blue     { background: var(--grad-blue); }
.pastel-card.fam-gray     { background: var(--grad-gray); }

.pastel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.pastel-when { display: flex; flex-direction: column; gap: 7px; }
.pastel-date {
  font-size: var(--fs-body);
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}
.pastel-due {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--pastel-dim);
}
.pastel-due svg { opacity: .7; display: inline-flex; }
.pastel-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #26352c;
  flex: 0 0 auto;
}
.pastel-mark svg { display: block; }
.pastel-fill { flex: 1; min-height: 14px; }
.pastel-amount {
  font-size: 25px;
  font-weight: 700;
  font-feature-settings: "tnum" 1;
  margin-bottom: 7px;
  line-height: 1.05;
}
.pastel-title {
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pastel-tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, .62);
  border-radius: var(--r-pill);
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
}
/* edit/delete on pastel cards: subtle, top-right, revealed on hover */
.pastel-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.pastel-card:hover .pastel-actions { opacity: 1; }
@media (hover: none) { .pastel-actions { opacity: 1; } }
.pastel-card .btn-icon {
  color: #34463b;
  background: rgba(255, 255, 255, .5);
}
.pastel-card .btn-icon:hover {
  background: rgba(255, 255, 255, .82);
  color: #1c2b24;
  border-color: transparent;
}
/* shift the ↗ mark left when actions are present so they don't overlap */
.pastel-card.has-actions .pastel-mark { visibility: hidden; }
.pastel-card.has-actions:not(:hover) .pastel-mark { visibility: visible; }

/* ---------------------------------------------------------------------
   10. STATUS PILLS (goal lifecycle)
   --------------------------------------------------------------------- */
.status-completed,
.status-finishing,
.status-starting,
.status-monthly {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.status-completed { background: var(--tag-mint-bg);     color: var(--tag-mint-fg); }
.status-finishing { background: var(--tag-blue-bg);     color: var(--tag-blue-fg); }
.status-starting  { background: var(--tag-lavender-bg); color: var(--tag-lavender-fg); }
.status-monthly   { background: var(--tag-peach-bg);    color: var(--tag-peach-fg); }

.status-completed::before { content: "✓"; }

/* ---------------------------------------------------------------------
   11. FORMS & CONTROLS
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  border-radius: var(--r-inner);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: var(--bg); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px var(--ring);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000);
  border-color: transparent;
}

.input,
.select {
  width: 100%;
  padding: 11px var(--sp-3);
  border-radius: var(--r-inner);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-body);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--ring);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238A8A93' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
}

/* labelled field wrapper */
.fld {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.fld > label,
.fld > .label {
  font-size: var(--fs-caption);
  font-weight: 500;
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   12. MODAL
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  z-index: 100;
  animation: finote-fade var(--t-base) var(--ease);
}

.modal {
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: finote-pop var(--t-base) var(--ease);
}
#entity-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal h2,
.modal .modal-title {
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.modal-close {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--bg-soft);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: background var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--track); }
/* form fields inside the modal: label 13 muted, gap 7 */
#entity-form .fld { gap: 7px; }
#entity-form .fld > span {
  font-size: var(--fs-caption);
  color: var(--muted);
  font-weight: 500;
}
/* a checkbox row reads as an inline toggle, not a stacked field */
#entity-form .fld-check {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-2);
}
#entity-form .fld-check > span {
  order: 2;
  font-size: 14px;
  color: var(--text);
}
#entity-form .fld-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

@keyframes finote-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes finote-pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------------------------------------------------------------
   13. BANNER
   --------------------------------------------------------------------- */
.banner-warning {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--peach-bg);
  color: var(--peach-fg);
  border: 1px solid color-mix(in srgb, var(--peach-fg) 22%, transparent);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}
.banner-warning::before {
  content: "⚠";
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------------
   14. LOGIN
   --------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background:
    radial-gradient(900px 480px at 18% -8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(820px 460px at 96% 108%, color-mix(in srgb, var(--pos) 14%, transparent), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-8);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.login-card h1::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--pos));
  box-shadow: 0 2px 10px var(--ring);
}
/* style raw inputs/button inside the login card so the existing
   login.html (no utility classes) looks designed out of the box */
.login-card input {
  width: 100%;
  padding: 12px var(--sp-3);
  border-radius: var(--r-inner);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-body);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.login-card input::placeholder { color: var(--muted); }
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--ring);
}
.login-card button {
  width: 100%;
  padding: 12px var(--sp-4);
  border-radius: var(--r-inner);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--ring);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.login-card button:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.login-card button:active { transform: translateY(1px); }

.error {
  padding: 10px var(--sp-3);
  border-radius: var(--r-inner);
  background: color-mix(in srgb, var(--neg) 12%, transparent);
  color: var(--neg);
  font-size: var(--fs-caption);
  font-weight: 500;
  text-align: center;
}

/* ---------------------------------------------------------------------
   15. RESPONSIVE
   --------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-spacer { display: none; }
  .content { max-height: none; overflow: visible; padding: 6px var(--sp-4) 36px; }
  .topbar { padding: 20px var(--sp-4) 6px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .kpi-row { grid-template-columns: 1fr; }
  .pastel-grid { grid-template-columns: 1fr; }
}

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