/* KUDRI nails. Мир Glow: насыщенное фиолетовое поле, белые панели с крупным скруглённым углом,
   округлый логотип с искрой и широкие заголовки. Фиолетовый — бренд и действия; данные — спокойные.
   Раскладка: телефон — фиолетовая шапка, белая панель, нижние вкладки; от 900px — фиолетовая боковая колонка. */

@font-face {
  font-family: "Onest";
  src: url("fonts/onest-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Unbounded";
  src: url("fonts/unbounded-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  src: url("fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Comfortaa";
  src: url("fonts/comfortaa-latin.woff2") format("woff2");
  font-weight: 500 700;
  font-display: block;
}

:root {
  color-scheme: light;
  --brand: #B05AEE;
  --bg: #F8F5FC;
  --surface: #FFFFFF;
  --surface-2: #EFE8F8;
  --ink: #221730;
  --ink-2: #574A68;
  --muted: #73668A;
  --line: #E6DEF1;
  --line-strong: #D0C3E2;
  --violet: #A24BE6;
  --violet-deep: #8237C9;
  --violet-soft: #F1E4FD;
  --violet-tint: #FAF5FE;
  --on-brand: #FFFFFF;
  /* лаковый глянец: светлее сверху, глубже снизу + тонкий блик по верхней кромке */
  --gloss: linear-gradient(180deg, #BE77F6 0%, #A64EE8 48%, #9441DC 100%);
  --gloss-hover: linear-gradient(180deg, #B56BF2 0%, #9A43E0 50%, #8737CF 100%);
  --gloss-edge: inset 0 1px 0 rgba(255, 255, 255, .42), inset 0 -2px 5px rgba(60, 14, 110, .22);
  --gloss-lift: 0 6px 16px rgba(130, 55, 201, .28), 0 1px 2px rgba(80, 20, 140, .2);
  --brand-sheen: radial-gradient(120% 85% at 0% 0%, rgba(255, 255, 255, .20), rgba(255, 255, 255, 0) 55%),
                 linear-gradient(155deg, #BA6AF3 0%, #AB55EC 45%, #9542DC 100%);
  --on-brand-2: #F0E2FF;
  --good: #2C7350;
  --bad: #B0372C;

  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-wide: "Unbounded", "Onest", -apple-system, sans-serif;
  --font-logo: "Comfortaa", "Onest", sans-serif;
  --t-xs: 0.78rem;
  --t-sm: 0.875rem;
  --t-md: 1rem;
  --t-lg: 1.2rem;
  --t-xl: 1.45rem;
  --t-2xl: 1.75rem;

  --r-sm: 12px;
  --r-md: 18px;
  --r-blob: 36px;
  --shadow-sheet: 0 -8px 32px rgba(60, 20, 100, 0.16);
  --shadow-pop: 0 10px 30px rgba(60, 20, 100, 0.14), 0 2px 6px rgba(60, 20, 100, 0.06);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-h: 64px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-md)/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--violet-soft); color: var(--violet-deep); }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 650; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- shell */

/* фиолетовое поле сверху, светлая панель снизу — при оттяжке страницы цвета не рвутся */
html { background: var(--bg); }
body { background: linear-gradient(var(--brand) 0 40vh, var(--bg) 40vh); }

.logo { display: inline-flex; flex-direction: column; gap: 3px; color: var(--on-brand); text-decoration: none; }
.logo-word { font: 700 30px/1 var(--font-logo); letter-spacing: -0.01em; white-space: nowrap; }
.logo-i { position: relative; display: inline-block; }
/* искра вместо точки над i */
.logo-i svg { position: absolute; left: 50%; top: -0.2em; width: 0.46em; height: 0.46em; transform: translateX(-46%); fill: currentColor; }
.logo-sub { font: 500 8.5px/1 var(--font-wide); letter-spacing: 0.24em; text-transform: uppercase; color: var(--on-brand-2); padding-left: 2px; }

.brandbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) var(--gutter-r) 22px var(--gutter-l);
  background: var(--brand); color: var(--on-brand);
}
.byline { margin: 0; font: 500 var(--t-xs)/1.35 var(--font); color: var(--on-brand-2); text-align: right; }
.nav-brand .byline { text-align: left; margin-top: 16px; font-size: var(--t-sm); padding-left: 2px; }

.app { min-height: 100dvh; }
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px var(--gutter-r) calc(6px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; min-height: 52px; border-radius: var(--r-sm);
  color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 500;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav a[aria-current="page"] { color: var(--violet-deep); }
.nav a[aria-current="page"] svg.i { stroke-width: 2.1; }
.nav-foot { display: none; }

/* светлая панель с крупным скруглением в левом верхнем углу — как у Glow */
main {
  position: relative; z-index: 1;
  min-height: calc(100dvh - 80px);
  margin-top: -14px;
  background: var(--bg);
  border-top-left-radius: var(--r-blob);
  padding-block: 20px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom, 0px));
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
}
.view { display: flex; flex-direction: column; gap: 18px; max-width: 720px; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.page-head h1 { font: 600 1.45rem/1.15 var(--font-wide); letter-spacing: -0.01em; }

@media (min-width: 900px) {
  body { background: var(--brand); }
  .brandbar { display: none; }
  .nav {
    inset: 0 auto 0 0; width: 240px;
    display: flex; flex-direction: column; gap: 4px;
    padding: 34px 16px 24px; border-top: 0;
    background: var(--brand); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .nav-brand { display: block; padding: 0 12px 36px; }
  .nav-brand .logo-word { font-size: 38px; }
  .nav-brand .logo-sub { font-size: 9.5px; }
  .nav a { flex-direction: row; gap: 12px; min-height: 46px; padding: 0 14px; font-size: var(--t-sm); color: var(--on-brand-2); border-radius: 999px; }
  .nav a:hover { color: var(--on-brand); background: rgba(255, 255, 255, .14); }
  .nav a[aria-current="page"] { background: var(--surface); color: var(--violet-deep); box-shadow: 0 4px 14px rgba(60, 20, 100, .18); }
  .nav-foot { display: block; margin-top: auto; padding: 0 4px; }
  .nav-foot .btn { color: var(--on-brand-2); }
  .nav-foot .btn:hover { background: rgba(255, 255, 255, .14); color: var(--on-brand); }
  main {
    margin: 0 0 0 240px; min-height: 100dvh;
    border-top-left-radius: 48px;
    padding-block: 36px 64px; padding-left: max(44px, var(--gutter-l)); padding-right: max(44px, var(--gutter-r));
  }
  .view { max-width: 760px; margin: 0; }
  .view.wide { max-width: 980px; }
}

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 550; font-size: var(--t-sm); white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.primary:hover { background: var(--violet-deep); border-color: var(--violet-deep); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); border-color: transparent; background: transparent; padding: 0 12px; }
.btn.danger.armed { background: var(--bad); color: #fff; }
.btn.small { min-height: 36px; padding: 0 14px; }
.btn.icon { width: 44px; padding: 0; }
.btn.is-busy { pointer-events: none; opacity: .7; }

.pager { display: flex; align-items: center; gap: 4px; }
.pager .label { min-width: 0; flex: 1; text-align: center; font-weight: 600; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; }
.seg button {
  min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font-weight: 550; font-size: var(--t-sm); transition: background .18s var(--ease), color .18s var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(60,20,100,.12); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: var(--t-sm); color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: var(--t-xs); color: var(--muted); font-weight: 400; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.input::placeholder { color: #9C90AE; }
.money { position: relative; }
.money .input { padding-right: 36px; font-weight: 600; font-size: 1.15rem; }
.money::after { content: "₽"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-height: 44px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); text-align: left;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.chip small { font-size: var(--t-xs); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--violet-soft); border-color: var(--violet); color: var(--violet-deep); }
.chip[aria-pressed="true"] small { color: var(--violet-deep); }
.chip.big { min-width: 132px; padding: 12px 16px; font-weight: 600; }

/* ---------------------------------------------------------------- лента дней (записи) */

.head-actions { display: flex; gap: 8px; }
.strip-wrap { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 4px; margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l)); }
.strip-arrow { display: none; }
.strip {
  display: flex; gap: 6px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* снизу запас под тень выбранного дня — иначе её срезает край прокрутки */
  padding: 16px var(--gutter-r) 22px var(--gutter-l); margin-bottom: -16px; margin-top: -12px;
  scroll-padding-inline: var(--gutter-l) var(--gutter-r);
  position: relative;
  /* края гаснут — видно, что ленту можно листать */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 18px, #000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 18px, #000 calc(100% - 18px), transparent);
}
.strip::-webkit-scrollbar { display: none; }
.day {
  position: relative; flex: none;
  width: 50px; min-height: 68px; padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; color: var(--ink);
  /* силуэт ногтя: скруглённый верх, почти прямой низ */
  border-radius: 50% 50% 14px 14px / 34% 34% 14px 14px;
}
.day .dow { font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.day.we .dow { color: var(--violet); }
.day .num { font-size: 1.22rem; font-weight: 650; line-height: 1.1; }
.day .dots { display: flex; gap: 3px; height: 7px; align-items: center; }
.day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--violet); }
.day .dots b { font-size: 0.66rem; font-weight: 700; color: var(--violet-deep); line-height: 7px; }
.day .mon {
  position: absolute; top: -15px; left: 50%; transform: translateX(-50%);
  padding: 1px 7px; border-radius: 999px; background: var(--violet-soft); color: var(--violet-deep);
  font: 600 0.62rem/1.4 var(--font-wide); letter-spacing: 0.03em; white-space: nowrap;
}
.day.first::before { content: ""; position: absolute; left: -4px; top: 10px; bottom: 10px; width: 1px; background: var(--line-strong); }
.day:hover { background: var(--violet-tint); }
.day.is-today { box-shadow: inset 0 0 0 1.5px var(--violet); }
.day.is-today .num { color: var(--violet-deep); }
.day[aria-selected="true"] { background: var(--violet); color: #fff; box-shadow: 0 6px 16px rgba(130, 55, 201, .32); }
.day[aria-selected="true"] .dow, .day[aria-selected="true"] .num { color: #fff; }
.day[aria-selected="true"] .dots i { background: #fff; }
.day[aria-selected="true"] .dots b { color: #fff; }
.day:focus-visible { outline: 2px solid var(--violet-deep); outline-offset: 2px; }

/* мышь: стрелки листают ленту; на сенсорных экранах их нет — листают пальцем */
@media (hover: hover) and (pointer: fine) {
  .strip-wrap { grid-template-columns: 40px minmax(0, 1fr) 40px; margin: 0; }
  .strip { padding-left: 4px; padding-right: 4px; scroll-padding-inline: 4px; }
  .strip-arrow {
    display: grid; place-items: center; width: 40px; height: 40px; margin-top: 8px;
    border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2);
    transition: border-color .15s, color .15s;
  }
  .strip-arrow:hover { border-color: var(--violet); color: var(--violet-deep); }
  .day { width: 56px; }
}

.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 4px; }
.day-head h2 { font: 600 var(--t-lg)/1.25 var(--font-wide); letter-spacing: -0.01em; }
.day-head h2::first-letter { text-transform: uppercase; }
.day-sum { color: var(--ink-2); font-size: var(--t-sm); margin-top: 2px; }
.day-sum b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- списки */

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  width: 100%; min-height: 64px; padding: 12px 16px; border: 0; background: transparent; text-align: left;
  transition: background .15s;
}
.item:hover { background: var(--violet-tint); }
.item .when { font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); min-width: 44px; }
.item .when.none { color: var(--line-strong); }
.item .what { min-width: 0; }
.item .what strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item .what span { display: block; font-size: var(--t-sm); color: var(--muted); overflow-wrap: anywhere; }
.item .amount { font-weight: 650; white-space: nowrap; }
.item.fresh { animation: fresh 1.2s var(--ease); }
@keyframes fresh { from { background: var(--violet-soft); } to { background: transparent; } }

.group-title { display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-sm); color: var(--ink-2); font-weight: 600; padding: 0 4px 8px; }
.group-title span:first-letter { text-transform: uppercase; }
.groups { display: flex; flex-direction: column; gap: 20px; }

.empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  padding: 22px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-2);
}
.empty p { max-width: 42ch; }

.quick { display: flex; flex-direction: column; gap: 10px; }
.quick-title { font-size: var(--t-sm); color: var(--ink-2); font-weight: 600; }

.skeleton { height: 64px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* закреплённая главная кнопка над панелью вкладок (только телефон) */
.dock {
  position: fixed; z-index: 25; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 10px var(--gutter-r) 12px var(--gutter-l);
  background: linear-gradient(to top, var(--bg) 55%, color-mix(in srgb, var(--bg) 0%, transparent));
  pointer-events: none;
}
.dock .btn { width: 100%; min-height: 54px; font-size: var(--t-md); pointer-events: auto; box-shadow: 0 6px 18px rgba(130, 55, 201, .32); }
@media (min-width: 900px) { .dock { display: none; } }
.desk-only { display: none; }
@media (min-width: 900px) { .desk-only { display: inline-flex; } }

/* ---------------------------------------------------------------- расходы */

.cat-bars { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.cat-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: var(--t-sm); }
.cat-bar .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.cat-bar .fill { height: 100%; border-radius: 3px; background: var(--ink-2); }
.cat-bar b { font-weight: 600; }
.total-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.total-line .big { font: 600 var(--t-xl)/1.1 var(--font-wide); letter-spacing: -0.01em; }
.total-line .cap { color: var(--ink-2); font-size: var(--t-sm); }

/* ---------------------------------------------------------------- аналитика: «чек» */

.receipt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 18px; }
.receipt-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 14px; padding: 12px 0; }
.receipt-row + .receipt-row { border-top: 1px dashed var(--line); }
.receipt-row .k { color: var(--ink-2); }
.receipt-row .v { font-weight: 600; text-align: right; white-space: nowrap; }
.receipt-row .d { grid-column: 1 / -1; font-size: var(--t-xs); color: var(--muted); }
.receipt-row .d .up { color: var(--good); }
.receipt-row .d .down { color: var(--bad); }
.receipt-row.total { border-top: 1.5px solid var(--ink) !important; padding-top: 14px; }
.receipt-row.total .k { color: var(--ink); font-weight: 650; }
.receipt-row.total .v { font: 600 var(--t-lg)/1.2 var(--font-wide); letter-spacing: -0.01em; color: var(--violet-deep); }
.receipt-row.total .v.neg { color: var(--bad); }
.receipt-row.sub .k, .receipt-row.sub .v { font-size: var(--t-sm); }
.receipt-note { font-size: var(--t-xs); color: var(--muted); padding: 0 4px; max-width: 70ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h3 { font-size: var(--t-md); }
.panel-grid { display: grid; gap: 18px; }
@media (min-width: 900px) {
  .stats-top { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
  .panel-grid { grid-template-columns: 1fr 1fr; }
}
.stats-top { display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 900px) { .stats-top { display: grid; } }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: url(#barGloss); }
.chart .bar.dim { fill: var(--violet-soft); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.on { fill: var(--violet-deep); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  padding: 10px 12px; border-radius: 10px; background: var(--ink); color: #fff;
  font-size: var(--t-xs); line-height: 1.5; box-shadow: var(--shadow-pop);
  transform: translate(-50%, calc(-100% - 10px));
}
.tip b { display: block; font-size: var(--t-sm); margin-bottom: 2px; }
.tip span { display: flex; justify-content: space-between; gap: 14px; color: #E5DAF2; }
.tip em { font-style: normal; font-weight: 600; color: #fff; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.t th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.t tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- настройки */

.svc-list { display: flex; flex-direction: column; gap: 10px; }
.svc {
  display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px; align-items: end;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.svc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.svc-fields .field:first-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .svc-fields { grid-template-columns: minmax(0, 2fr) 1fr 1fr; } .svc-fields .field:first-child { grid-column: auto; } }
.svc .margin { grid-column: 1 / -1; font-size: var(--t-xs); color: var(--muted); }
.section { display: flex; flex-direction: column; gap: 12px; }
.section h2 { font-size: var(--t-lg); }
.section > p { color: var(--ink-2); font-size: var(--t-sm); max-width: 62ch; }
.cat-edit { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-tag { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 6px 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); }
.cat-tag button { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 50%; color: var(--muted); display: grid; place-items: center; }
.cat-tag button:hover { background: var(--surface-2); color: var(--bad); }
.cat-tag svg.i { width: 16px; height: 16px; }
.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; min-width: 0; }
.save-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.save-bar .status { font-size: var(--t-sm); color: var(--muted); }

/* ---------------------------------------------------------------- календарь и подсказки */

.dp, .cb, .jump { position: relative; }
.dp-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; font-weight: 500; }
.dp-btn .dp-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-btn .dp-text::first-letter { text-transform: uppercase; }
.dp-btn svg.i { color: var(--violet-deep); width: 20px; height: 20px; }
.dp-btn[aria-expanded="true"] { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }

.dp-panel {
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 14px 12px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 24px 24px 24px 8px;
  box-shadow: var(--shadow-pop);
  animation: pop .2s var(--ease);
}
.dp.align-right .dp-panel, .jump .dp-panel { left: auto; right: 0; border-radius: 24px 24px 8px 24px; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.cal-title { font: 600 0.92rem/1.2 var(--font-wide); letter-spacing: -0.01em; }
.cal-nav { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); }
.cal-nav:hover { background: var(--violet-tint); color: var(--violet-deep); }
.cal-nav svg.i { width: 20px; height: 20px; }
.cal-quick { display: flex; gap: 6px; padding: 10px 2px 8px; }
.cal-quick button {
  min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2);
}
.cal-quick button:hover { border-color: var(--violet); color: var(--violet-deep); }
.cal-quick button[aria-pressed="true"] { background: var(--violet-soft); border-color: var(--violet); color: var(--violet-deep); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { padding: 6px 0 4px; text-align: center; font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-dow.we { color: var(--violet); }
.cal-day {
  height: 40px; border: 0; border-radius: 50%; background: transparent;
  font-size: 0.95rem; font-weight: 500; color: var(--ink);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.cal-day:hover { background: var(--violet-tint); color: var(--violet-deep); }
.cal-day.out { color: #B7ABC8; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--violet); color: var(--violet-deep); font-weight: 650; }
.cal-day[aria-selected="true"] { background: var(--violet); color: #fff; font-weight: 650; box-shadow: 0 4px 12px rgba(130, 55, 201, .3); }

.cb-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  max-height: 252px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-pop);
  animation: pop .18s var(--ease);
}
.cb-list li { padding: 11px 12px; border-radius: 12px; cursor: pointer; color: var(--ink); overflow-wrap: anywhere; }
.cb-list li:hover, .cb-list li[aria-selected="true"] { background: var(--violet-tint); color: var(--violet-deep); }
.cb-list mark { background: none; color: var(--violet-deep); font-weight: 700; }
#vf-time-list { max-height: 216px; }

/* ---------------------------------------------------------------- шторка формы */

dialog.sheet {
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sheet);
}
dialog.sheet::backdrop { background: rgba(34, 16, 56, .42); }
dialog.sheet[open] { animation: sheet-in .32s var(--ease); }
dialog.sheet[open]::backdrop { animation: fade-in .25s ease-out; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade-in { from { opacity: 0; } }
.sheet form { display: flex; flex-direction: column; max-height: 92dvh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--gutter-r) 6px var(--gutter-l); }
.sheet-head::before { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-strong); }
.sheet-head h2 { font-size: var(--t-lg); padding-top: 14px; }
.sheet-body { display: flex; flex-direction: column; gap: 18px; padding: 8px var(--gutter-r) 18px var(--gutter-l); overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px var(--gutter-r) calc(12px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  border-top: 1px solid var(--line); background: var(--surface);
}
.sheet-foot .btn.primary { flex: 1; min-height: 52px; font-size: var(--t-md); max-width: 320px; margin-left: auto; }
.form-error { padding: 10px 12px; border-radius: var(--r-sm); background: #FCEDEB; color: var(--bad); font-size: var(--t-sm); }
@media (min-width: 640px) {
  dialog.sheet { max-width: 520px; margin: auto; border-radius: 20px; max-height: 88dvh; }
  .sheet form { max-height: 88dvh; }
  .sheet-head::before { display: none; }
  .sheet-head { padding: 18px 24px 4px; }
  .sheet-head h2 { padding-top: 0; }
  .sheet-body { padding: 12px 24px 20px; }
  .sheet-foot { padding: 14px 24px; }
  dialog.sheet[open] { animation: pop-in .26s var(--ease); }
  @keyframes pop-in { from { transform: translateY(12px) scale(.98); opacity: 0; } }
}

/* ---------------------------------------------------------------- тосты */

.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); inset-block-start: auto; inset-inline-end: auto; margin: 0; border: 0;
  bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: var(--t-sm);
  box-shadow: var(--shadow-pop); animation: toast-in .3s var(--ease);
}
.toast.error { background: var(--bad); }
.toast button { border: 0; background: transparent; color: #E2C2FF; font-weight: 650; padding: 4px; }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% + 116px); } }

.offline { padding: 10px 14px; border-radius: var(--r-sm); background: #FCEDEB; color: var(--bad); font-size: var(--t-sm); }

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

/* узкие телефоны (iPhone SE и уже) */
@media (max-width: 370px) {
  .item { gap: 10px; padding: 12px 12px; }
  .item .when { min-width: 34px; }
  .page-head h1 { font-size: 1.3rem; }
  .byline { font-size: 0.7rem; }
}

/* ---------------------------------------------------------------- аналитика: быстрые периоды */

.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.presets {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l));
  padding: 2px var(--gutter-r) 4px var(--gutter-l);
}
.presets::-webkit-scrollbar { display: none; }
.presets button {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--t-sm); font-weight: 550; color: var(--ink-2); white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.presets button:hover { border-color: var(--violet); color: var(--violet-deep); }
.presets button[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: 0 4px 12px rgba(130, 55, 201, .25); }
@media (min-width: 900px) { .presets { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
.range-label { font: 600 var(--t-lg)/1.25 var(--font-wide); letter-spacing: -0.01em; }
.range-label::first-letter { text-transform: uppercase; }
.receipt-note a { color: var(--violet-deep); font-weight: 600; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- клиенты */

.search { position: relative; display: block; }
.search svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 44px; }
.list-count { font-size: var(--t-sm); color: var(--muted); margin-top: -6px; }
.client-item { grid-template-columns: auto minmax(0, 1fr) auto; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--violet-soft); color: var(--violet-deep); font: 600 1rem/1 var(--font-wide);
}
.item .what .note { color: var(--ink-2); font-size: var(--t-xs); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.client-hint { font-size: var(--t-xs); color: var(--violet-deep); font-weight: 600; }
.client-hint.new { color: var(--good); }
.client-stats { padding: 12px 14px; border-radius: var(--r-sm); background: var(--violet-tint); color: var(--ink-2); font-size: var(--t-sm); }
.client-stats b { color: var(--ink); font-weight: 650; }
.client-history { display: flex; flex-direction: column; gap: 8px; }
.client-history .item { min-height: 56px; padding: 10px 14px; }
.client-history .when { min-width: 74px; font-size: var(--t-xs); }
.cb-list li small { display: block; margin-top: 2px; font-size: var(--t-xs); color: var(--muted); }
.cb-list li.create { display: flex; align-items: center; gap: 8px; color: var(--good); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; margin-top: 4px; }
.cb-list li.create svg.i { width: 18px; height: 18px; }
.sheet-foot #cf-book { margin-left: auto; }
.sheet-foot #cf-book + .btn.primary { margin-left: 0; }
@media (max-width: 480px) {
  #cf-delete:not(.armed) { width: 44px; padding: 0; }
  #cf-delete:not(.armed) span { display: none; }
  #cf-delete.armed + #cf-book { display: none; }
}

/* заметка из карточки клиента — отдельной строкой со значком, чтобы не путать с заметкой к записи */
.client-note { display: flex !important; align-items: flex-start; gap: 5px; color: var(--violet-deep) !important; font-weight: 500; }
.client-note svg.i { width: 13px; height: 13px; flex: none; margin-top: 2px; }
.client-hint .client-note { margin-top: 4px; font-size: var(--t-xs); }

/* ---------------------------------------------------------------- отменённые записи */

.item.cancelled { min-height: 0; padding-block: 9px; }
.item.cancelled .when, .item.cancelled .amount { color: var(--muted); font-weight: 500; font-size: var(--t-sm); }
.item.cancelled .amount { text-decoration: line-through; }
.item .what .off-line { color: var(--muted); font-size: var(--t-sm); }
.item .what .off-why { color: var(--bad); font-size: var(--t-xs); opacity: .85; }
/* шаг отмены: видна только сводка и причина; в подвале — «Назад» и «Отменить запись» */
.cancel-box { display: none; flex-direction: column; gap: 14px; }
#visit-form.cancelling .cancel-box { display: flex; }
#visit-form.cancelling .sheet-body > :not(.cancel-box):not(.form-error) { display: none !important; }
#visit-form.cancelling #vf-delete, #visit-form.cancelling #vf-cancel, #visit-form.cancelling #vf-save { display: none !important; }
#visit-form:not(.cancelling) #vf-cancel-no, #visit-form:not(.cancelling) #vf-cancel-yes { display: none; }
#visit-form.cancelling #vf-cancel-yes { flex: 1; max-width: 320px; min-height: 52px; font-size: var(--t-md); margin-left: auto; }
.cancel-sum { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-md); background: var(--violet-tint); }
.cancel-sum b { font-weight: 650; }
.cancel-sum span { color: var(--muted); font-size: var(--t-sm); }
.cancel-q { font-weight: 600; }
.cancel-note { font-size: var(--t-xs); color: var(--muted); }
.btn.cancel-confirm { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.cancel-confirm:hover { background: #962D23; border-color: #962D23; }
.cancelled-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: #FCEDEB; color: var(--bad); font-size: var(--t-sm); }
.cancelled-banner b { font-weight: 650; }
@media (max-width: 480px) {
  #vf-delete:not(.armed) { width: 44px; padding: 0; }
  #vf-delete:not(.armed) span { display: none; }
  #vf-delete.armed ~ #vf-cancel { display: none !important; }
}

/* деньги дня: выручка · прибыль · себестоимость — сразу под датой */
.day-money { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; }
.day-money span { white-space: nowrap; }
.day-money .profit { color: var(--violet-deep); }

/* ---------------------------------------------------------------- расходы: расчётная себестоимость */

.estimate { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--r-md);
  background: var(--violet-tint); border: 1px solid var(--violet-soft); }
.estimate-k { font-size: var(--t-sm); color: var(--ink-2); font-weight: 600; }
.estimate-v { font: 600 var(--t-xl)/1.15 var(--font-wide); color: var(--violet-deep); letter-spacing: -0.01em; }
.estimate-d { font-size: var(--t-xs); color: var(--muted); max-width: 62ch; }
.estimate-d b { color: var(--ink-2); font-weight: 600; }

.recalc-ask { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--r-md); background: var(--violet-tint); border: 1px solid var(--violet-soft); }
.recalc-list { margin: 0; padding-left: 18px; font-size: var(--t-sm); }
.recalc-help { font-size: var(--t-sm); color: var(--ink-2); }
.recalc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.presets-sep { flex: none; align-self: center; width: 1px; height: 24px; margin: 0 6px; background: var(--line-strong); }

/* ---------------------------------------------------------------- аналитика: по месяцам */

.m-grid { display: flex; flex-direction: column; margin: 0 -8px; }
.m-head, .m-row {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .7fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 8px; align-items: center; padding: 10px 8px;
}
.m-head { padding-block: 4px 8px; font-size: var(--t-xs); color: var(--muted); border-bottom: 1px solid var(--line); }
.m-row { border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; font-size: var(--t-sm); border-radius: 10px; }
.m-row:last-child { border-bottom: 0; }
.m-row:hover { background: var(--violet-tint); }
.m-grid .num { text-align: right; white-space: nowrap; }
.m-name { font-weight: 600; min-width: 0; }
.m-name em { font-style: normal; color: var(--muted); font-weight: 500; }
.m-name small { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--violet-soft); color: var(--violet-deep); font-size: 0.68rem; font-weight: 600; vertical-align: 1px; }
.m-profit { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.m-profit b { color: var(--violet-deep); font-weight: 650; }
.m-profit i { display: block; height: 4px; border-radius: 2px; background: var(--violet); min-width: 0; }
@media (max-width: 400px) { .m-row, .m-head { font-size: 0.8rem; gap: 6px; } }
.m-grid.three .m-head, .m-grid.three .m-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr) minmax(0, 1.2fr); }
.m-row[aria-current="true"] { background: var(--violet-tint); }
.m-spent b { color: var(--ink); }
.m-spent i { background: var(--ink-2); }

/* кнопка месяца в строке заголовка и всплывающий календарь поверх страницы */
.head-actions { align-items: center; }
.month-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink); white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.month-btn svg.i { width: 18px; height: 18px; color: var(--violet-deep); }
.month-btn:hover, .month-btn[aria-expanded="true"] { border-color: var(--violet); color: var(--violet-deep); }
.jump-panel {
  position: fixed; z-index: 100; width: min(340px, calc(100vw - 24px));
  padding: 14px 12px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 18px 50px rgba(40, 14, 70, .22), 0 2px 8px rgba(40, 14, 70, .08);
  animation: pop .16s var(--ease);
}

/* ---------------------------------------------------------------- глянец (бьюти-акценты на фиолетовом) */

.brandbar, .help-top { background: var(--brand-sheen); }
@media (min-width: 900px) { .nav { background: var(--brand-sheen); } }

/* кнопки — ровный цвет, только тонкая светлая кромка сверху */
.btn.primary, .presets button[aria-pressed="true"] { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22); }
.dock .btn { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 18px rgba(130, 55, 201, .26); }

/* выбранный день — лёгкий глянец без блика */
.day[aria-selected="true"] {
  background: linear-gradient(180deg, #AE5DEB 0%, #A24BE6 60%, #9C46E1 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 4px 10px rgba(130, 55, 201, .2);
}

.chip[aria-pressed="true"] { background: linear-gradient(180deg, #F8EEFF, #EFDFFD); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9); }
.avatar { background: linear-gradient(150deg, #F7EDFF 0%, #E9D5FC 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9); }
.m-profit i { background: linear-gradient(90deg, #C27DF6, #9442DC); }
.receipt-row.total .v, .day-money .profit, .m-profit b { color: var(--violet-deep); }

/* искра в логотипе один раз мерцает при входе — единственная анимация «для красоты» */
.login-logo .logo-i svg { animation: twinkle 1.6s var(--ease) .3s 1 both; transform-origin: 50% 50%; }
@keyframes twinkle {
  0% { transform: translateX(-46%) scale(.4) rotate(-30deg); opacity: 0; }
  55% { transform: translateX(-46%) scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: translateX(-46%) scale(1) rotate(0); opacity: 1; }
}

/* NAILS — шампань-золото на фиолетовом (пожелание пользователя) */
.logo-sub {
  color: #EBCB7E;
  background: linear-gradient(100deg, #F8E7B4 0%, #E2BD66 38%, #F6E2A8 58%, #C9993F 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  font-weight: 600;
}
