/* =========================================================
   Моя практика — стили
   Все цвета живут в токенах ниже. Тёмная тема — это только
   переопределение переменных на [data-theme="dark"],
   правила ниже про цвета больше ничего не знают.
   ========================================================= */

:root {
  /* Светлая тема — по умолчанию */
  --bg: #F3F6F5;
  --surface: #FFFFFF;
  --ink: #16211F;
  --ink-soft: #55716C;
  --brand: #1E4B47;
  --brand-dark: #143331;
  --urgent: #DB7B34;
  --urgent-dark: #BE6526;
  --upcoming: #C9A24E;
  --line: #DCE6E3;

  /* Палитра меток клиентов — чтобы различать их в списках и календаре */
  --c-teal: #2E8C80;
  --c-sky: #3D7FB8;
  --c-violet: #7C6BC4;
  --c-rose: #C75A78;
  --c-amber: #D9922B;
  --c-lime: #6E9B3E;
  --c-clay: #B4653F;
  --c-slate: #6B7F8C;

  /* Производные величины — не цвета, а ритм интерфейса */
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 12px;
  --pad: 16px;
  --content: 480px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-head: 'Bricolage Grotesque', 'Inter', system-ui, -apple-system, sans-serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-card: 0 1px 2px color-mix(in srgb, var(--brand-dark) 8%, transparent);
  --shadow-float: 0 10px 30px color-mix(in srgb, var(--brand-dark) 22%, transparent);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
  --scrim: color-mix(in srgb, var(--brand-dark) 55%, transparent);
}

[data-theme="dark"] {
  --bg: #0F1C1A;
  --surface: #172926;
  --ink: #E8EDEB;
  --ink-soft: #93ACA7;
  --brand: #4F9990;
  --brand-dark: #397D75;
  --urgent: #E8935A;
  --urgent-dark: #D97A3D;
  --upcoming: #D6BC7C;
  --line: #26403C;

  --c-teal: #58B3A5;
  --c-sky: #6BA6DC;
  --c-violet: #A297E0;
  --c-rose: #E2879F;
  --c-amber: #E8B05A;
  --c-lime: #9BC468;
  --c-clay: #D08B66;
  --c-slate: #94A9B6;
  --shadow-card: 0 1px 2px color-mix(in srgb, #000 30%, transparent);
  --shadow-float: 0 12px 34px color-mix(in srgb, #000 55%, transparent);
  --scrim: color-mix(in srgb, #000 62%, transparent);
}

/* ---------- База ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* Приложение прячет блоки атрибутом hidden. Любой наш display: flex/grid
   перебил бы браузерное правило, поэтому фиксируем скрытие раз и навсегда. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 17px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Каркас ---------- */

.app {
  max-width: var(--content);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
}

@media (min-width: 560px) {
  .app { border-inline: 1px solid var(--line); }
}

.screen-body {
  padding: var(--pad) var(--pad) calc(var(--tabbar-h) + 40px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- Шапка экрана ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--pad) 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.header-title { flex: 1; min-width: 0; }
.header-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 6px; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.header-tools .segmented { flex: 1; }

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay-header { flex-direction: row; align-items: center; gap: 8px; }
.overlay-header .header-title h1 { font-size: 22px; }
.icon-btn-spacer { width: 40px; height: 40px; flex: none; }

/* ---------- Кнопки ---------- */

.icon-btn {
  width: 40px; height: 40px;
  flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); }
.icon-btn:active { background: color-mix(in srgb, var(--brand) 16%, transparent); }
.icon-btn--danger:hover { background: color-mix(in srgb, var(--urgent) 16%, transparent); color: var(--urgent-dark); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--surface); }
.btn-primary:hover { background: var(--brand-dark); }
[data-theme="dark"] .btn-primary { color: var(--bg); }
.btn-accent { background: var(--urgent); color: var(--surface); }
.btn-accent:hover { background: var(--urgent-dark); }
.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { color: var(--urgent-dark); }
.btn-danger:hover { border-color: var(--urgent); color: var(--urgent-dark); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row--end { justify-content: flex-end; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }

.pill-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}
.pill-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Блоки и панели ---------- */

.block { display: flex; flex-direction: column; gap: 10px; }

.block-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}
.panel-text { font-size: 15px; }
.panel-text--muted { color: var(--ink-soft); }
.panel-note { white-space: pre-wrap; }

.hint { font-size: 13px; color: var(--ink-soft); line-height: 1.4; }

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

/* ---------- Карточка со срочной полоской ---------- */

.card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 12px 18px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: border-color .15s ease, transform .1s ease;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--line);
}
.card[data-mark="urgent"]::before { background: var(--urgent); }
.card[data-mark="upcoming"]::before { background: var(--upcoming); }
.card[data-mark="quiet"]::before { background: color-mix(in srgb, var(--ink-soft) 40%, transparent); }
.card[data-mark="off"]::before { background: var(--line); }
.card[data-dim="1"] .card-title,
.card[data-dim="1"] .card-time { opacity: .6; }

button.card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
button.card:active { transform: scale(.995); }

.card-row { display: flex; align-items: flex-start; gap: 10px; }
button.card-row, button.card-main {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.card:has(button.card-row:hover) { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  color: var(--brand);
  letter-spacing: .01em;
}
[data-theme="dark"] .card-time { color: var(--brand); }
.card-title {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Заголовок задачи может быть длинным предложением — ему разрешаем перенос */
.card-title--wrap { white-space: normal; overflow: visible; }
.card-sub { font-size: 13px; color: var(--ink-soft); }
.card-note {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card-strike .card-title { text-decoration: line-through; }

.price {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price--unpaid { color: var(--urgent-dark); }
[data-theme="dark"] .price--unpaid { color: var(--urgent); }

/* ---------- Чипы статусов ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  background: color-mix(in srgb, var(--ink-soft) 14%, transparent);
  color: var(--ink-soft);
}
button.chip { border: 0; font-family: inherit; height: 26px; padding: 0 10px; }
button.chip:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.chip--done { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
[data-theme="dark"] .chip--done { color: var(--ink); }
.chip--urgent { background: color-mix(in srgb, var(--urgent) 18%, transparent); color: var(--urgent-dark); }
[data-theme="dark"] .chip--urgent { color: var(--urgent); }
.chip--upcoming { background: color-mix(in srgb, var(--upcoming) 24%, transparent); color: var(--ink); }
.chip--tag { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
[data-theme="dark"] .chip--tag { color: var(--ink); }

/* ---------- Цветная метка клиента ---------- */

.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--dot) 20%, transparent);
  color: var(--dot);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.avatar--lg { width: 40px; height: 40px; border-radius: 14px; font-size: 18px; }

.card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-head .card-title { min-width: 0; }

/* Выбор цвета в форме клиента */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--dot, var(--line));
  display: grid;
  place-items: center;
  color: var(--surface);
  transition: transform .12s ease;
}
[data-theme="dark"] .color-dot { color: var(--bg); }
.color-dot svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.color-dot[aria-pressed="true"] svg { opacity: 1; }
.color-dot[aria-pressed="true"] { transform: scale(1.06); }
.color-dot--none {
  background: transparent;
  border: 2px dashed var(--line);
  color: var(--ink-soft);
}
.color-dot--none[aria-pressed="true"] { border-color: var(--brand); border-style: solid; }

/* ---------- Экран «Сегодня» ---------- */

.money-card {
  display: flex;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: var(--surface);
  box-shadow: var(--shadow-card);
  transition: transform .1s ease;
}
[data-theme="dark"] .money-card { background: color-mix(in srgb, var(--brand) 30%, var(--surface)); color: var(--ink); }
.money-card:active { transform: scale(.99); }
.money-card-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.money-card-side {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-end;
  padding-left: 14px;
  border-left: 1px solid color-mix(in srgb, var(--surface) 30%, transparent);
}
[data-theme="dark"] .money-card-side { border-left-color: var(--line); }
.money-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .8;
}
.money-value {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money-card-side .money-value { font-size: 18px; }
.money-value--pending { color: var(--upcoming); }

/* ---------- Календарь ---------- */

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0 7px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color .15s ease, color .15s ease;
}
.day-cell:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.day-name { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.day-num {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* Точки под числом: заливка — занятие, кольцо — задача, цвет — метка клиента */
.day-dots { display: flex; gap: 3px; height: 8px; align-items: center; justify-content: center; }
.day-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dot, var(--brand));
}
.day-dot--task {
  background: transparent;
  border: 1.5px solid var(--dot, var(--upcoming));
  width: 7px; height: 7px;
}
.day-more {
  font-size: 11px;
  font-weight: 800;
  line-height: 6px;
  color: var(--ink-soft);
}

[data-today="1"] .day-num,
[data-today="1"] .day-name { color: var(--urgent-dark); }
[data-theme="dark"] [data-today="1"] .day-num,
[data-theme="dark"] [data-today="1"] .day-name { color: var(--urgent); }

/* Выбранный день — обводкой, а не заливкой: иначе цветные точки теряются */
.day-cell[aria-pressed="true"],
.month-cell[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-color: var(--brand);
}
.day-cell[aria-pressed="true"] .day-num,
.month-cell[aria-pressed="true"] .day-num { font-weight: 700; }

/* ---------- Календарь: месяц ---------- */

.month-weekdays,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.month-weekdays { margin-bottom: 4px; }
.month-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.month-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  transition: background-color .15s ease;
}
.month-cell:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.app-header[data-view="month"] { position: static; }
.month-cell[data-out="1"] .day-num { opacity: .3; }

/* ---------- Поиск, сегменты, поля ---------- */

.search {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.search::placeholder { color: var(--ink-soft); }
.search:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.segmented button {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.segmented--wide button { min-height: 38px; }

.form { gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-optional { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="date"],
.field input[type="time"],
.field input[type="number"],
.field select,
.field textarea,
.dialog textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field textarea, .dialog textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.field input::placeholder, .field textarea::placeholder, .dialog textarea::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }
.field input:focus, .field select:focus, .field textarea:focus, .dialog textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; }

.field-group {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-group legend { padding: 0 6px; }

.check-line { display: flex; align-items: center; gap: 10px; min-height: 46px; font-size: 15px; }
.check-line input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--brand);
  flex: none;
}

/* ---------- Колесо выбора ---------- */

.wheel {
  --wheel-h: 176px;
  --wheel-item: 40px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 2px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  overflow: hidden;
}

/* Планка по центру показывает, что именно выбрано */
.wheel::before {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: calc((var(--wheel-h) - var(--wheel-item)) / 2);
  height: var(--wheel-item);
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 13%, transparent);
  pointer-events: none;
}

.wheel-col {
  flex: 1;
  max-width: 140px;
  height: var(--wheel-h);
  padding-block: calc((var(--wheel-h) - var(--wheel-item)) / 2);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  z-index: 1;
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 10px; }

.wheel-item {
  height: var(--wheel-item);
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: color .12s ease;
}
.wheel-item[aria-selected="true"] {
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
}

.wheel-sep {
  align-self: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-soft);
  padding-bottom: 2px;
}

.wheel--wide .wheel-col { max-width: none; }

/* Ручной ввод вместо колеса */
.input-swap { display: flex; gap: 8px; align-items: center; }
.input-swap input { flex: 1; }

.wheel-hint {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wheel-hint .wheel { flex: 1; }

/* ---------- Чекбокс задачи ---------- */

.task-check {
  width: 26px; height: 26px;
  flex: none;
  margin-top: 2px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  color: transparent;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.task-check svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.task-check:hover { border-color: var(--brand); }
.task-check[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--surface); }
[data-theme="dark"] .task-check[aria-pressed="true"] { color: var(--bg); }

/* ---------- Доходы ---------- */

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-label {
  flex: 1;
  text-align: center;
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 600;
}

.totals { display: flex; gap: 10px; }
.total-card {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-card);
}
[data-theme="dark"] .total-card { background: color-mix(in srgb, var(--brand) 30%, var(--surface)); color: var(--ink); }
.total-card--pending {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 5px solid var(--upcoming);
}
[data-theme="dark"] .total-card--pending { background: var(--surface); }
.total-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; opacity: .85;
}
.total-value {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Статистика клиента ---------- */

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-value { font-family: var(--font-head); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
.stat--warn .stat-value { color: var(--urgent-dark); }
[data-theme="dark"] .stat--warn .stat-value { color: var(--urgent); }

/* ---------- Пустые состояния ---------- */

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.empty-title { font-family: var(--font-head); font-size: 16px; color: var(--ink); }
.empty-sub { font-size: 13px; }

/* ---------- Нижняя навигация ---------- */

.chrome {
  position: fixed;
  inset: 0;
  max-width: var(--content);
  margin: 0 auto;
  pointer-events: none;
  z-index: 30;
}
.chrome[hidden] { display: none; }

.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tabbar-h);
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: color .15s ease;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-selected="true"] { color: var(--brand); }
[data-theme="dark"] .tab[aria-selected="true"] { color: var(--brand); }
.tab[aria-selected="true"] svg { stroke-width: 2; }

.fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  pointer-events: auto;
  width: 56px; height: 56px;
  border-radius: 20px;
  border: 0;
  background: var(--urgent);
  color: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-float);
  transition: transform .12s ease, background-color .15s ease;
}
[data-theme="dark"] .fab { color: var(--bg); }
.fab:hover { background: var(--urgent-dark); }
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* ---------- Экраны поверх ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  max-width: var(--content);
  margin: 0 auto;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: slide-in .18s ease-out;
}
.overlay[hidden] { display: none; }
.overlay .screen-body { padding-bottom: calc(40px + var(--safe-b)); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Шторки и диалоги ---------- */

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-root[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade-in .18s ease-out;
}

.sheet, .dialog {
  position: relative;
  width: 100%;
  max-width: var(--content);
  background: var(--surface);
  animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
}

.sheet {
  border-radius: 22px 22px 0 0;
  padding: 8px 12px calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-grabber {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 4px auto 10px;
}
.sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  color: var(--ink);
}
.sheet-item:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.sheet-item-icon {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
}
[data-theme="dark"] .sheet-item-icon { color: var(--ink); }
.sheet-item-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sheet-item-title { display: block; font-family: var(--font-head); font-size: 17px; font-weight: 600; }
.sheet-item-sub { display: block; font-size: 13px; color: var(--ink-soft); }

.dialog {
  margin: auto var(--pad);
  width: auto;
  min-width: 0;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-float);
}
.sheet-root:has(.dialog) { align-items: center; }
.dialog h2 { font-size: 19px; }
.dialog p { color: var(--ink-soft); font-size: 14px; }

@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(var(--content) - 32px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--brand-dark);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: toast-in .2s cubic-bezier(.2, .8, .3, 1);
}
[data-theme="dark"] .toast { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.toast[hidden] { display: none; }

/* Тост сдвинут на половину своей ширины — в кадрах это надо сохранить */
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

/* ---------- Подсказка о цене занятия ---------- */

.price-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.price-note .hint { flex: 1; min-width: 0; }
.price-note .btn { flex: none; }

/* ---------- Что нового ---------- */

.dialog--news {
  max-width: 400px;
  max-height: min(80dvh, 600px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.news-head { display: flex; flex-direction: column; }
.dialog--news .eyebrow { font-size: 12px; }

.news-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.news-item { display: flex; align-items: flex-start; gap: 12px; }
.news-icon {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
}
[data-theme="dark"] .news-icon { color: var(--ink); }
.news-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.news-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.news-title { font-family: var(--font-head); font-size: 15px; font-weight: 600; color: var(--ink); }
.news-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

/* =========================================================
   Движение
   Три общих кадра на всё приложение: rise-in (появление
   блока), lift-in (карточка подъезжает снизу) и парные
   уходы для слоёв, которые прячет ui.js.
   ========================================================= */

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes lift-in { from { transform: translateY(6px); } to { transform: none; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes slide-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes sheet-down { to { opacity: 0; transform: translateY(16px); } }
@keyframes slide-next { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

/* ---------- Уход слоёв: класс ставит ui.js перед hidden ---------- */

.overlay.is-closing { animation: slide-out .18s ease-in forwards; }
.sheet-root.is-closing .sheet-backdrop { animation: fade-out .18s ease-in forwards; }
.sheet-root.is-closing .sheet,
.sheet-root.is-closing .dialog { animation: sheet-down .18s ease-in forwards; }
.toast.is-closing { animation: toast-out .18s ease-in forwards; }

/* ---------- Вход экрана вкладки ---------- */

.screen.is-entering .screen-body > * { animation: rise-in .3s cubic-bezier(.2, .8, .3, 1) both; }
.screen.is-entering .screen-body > *:nth-child(2) { animation-delay: .04s; }
.screen.is-entering .screen-body > *:nth-child(3) { animation-delay: .08s; }
.screen.is-entering .screen-body > *:nth-child(n+4) { animation-delay: .12s; }

/* Карточки внутри блока только подъезжают: гасить их ещё и прозрачностью
   поверх прозрачности блока — уже перебор */
.screen.is-entering .stack > * { animation: lift-in .32s cubic-bezier(.2, .8, .3, 1) both; }
.screen.is-entering .stack > *:nth-child(2) { animation-delay: .04s; }
.screen.is-entering .stack > *:nth-child(3) { animation-delay: .08s; }
.screen.is-entering .stack > *:nth-child(n+4) { animation-delay: .12s; }

/* ---------- Календарь: шаг периода ---------- */

.is-slide-next { animation: slide-next .24s cubic-bezier(.2, .8, .3, 1); }
.is-slide-prev { animation: slide-prev .24s cubic-bezier(.2, .8, .3, 1); }
.is-fade-in { animation: rise-in .22s ease-out; }

/* Свайп листает период — горизонталь забираем себе,
   вертикальную прокрутку и щипок для увеличения оставляем браузеру */
#screen-calendar { touch-action: pan-y pinch-zoom; }

/* ---------- Шторки и диалоги: содержимое подъезжает следом ---------- */

.sheet-root:not(.is-closing) .sheet-item,
.sheet-root:not(.is-closing) .news-item { animation: lift-in .3s cubic-bezier(.2, .8, .3, 1) both; }
.sheet-item:nth-child(3), .news-item:nth-child(2) { animation-delay: .05s; }
.sheet-item:nth-child(4), .news-item:nth-child(3) { animation-delay: .1s; }
.news-item:nth-child(n+4) { animation-delay: .15s; }

/* ---------- Отклик на нажатие ---------- */

.icon-btn { transition: background-color .15s ease, color .15s ease, transform .12s ease; }
.icon-btn:active { transform: scale(.9); }

.pill-btn { transition: border-color .15s ease, color .15s ease, transform .12s ease; }
.pill-btn:active { transform: scale(.96); }

.segmented button { transition: background-color .18s ease, color .18s ease, transform .12s ease; }
.segmented button:active { transform: scale(.97); }

.day-cell, .month-cell {
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}
.day-cell:active, .month-cell:active { transform: scale(.93); }
.day-cell .day-num, .month-cell .day-num { transition: font-weight .15s ease, color .15s ease; }

/* Карточка нажимается вместе со своей кнопкой внутри */
.card:has(button:active) { transform: scale(.995); }

.sheet-item { transition: background-color .15s ease, transform .12s ease; }
.sheet-item:active { transform: scale(.985); }

.color-dot:active { transform: scale(.92); }
.task-check { transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .12s ease; }
.task-check:active { transform: scale(.88); }

.money-card, .total-card { transition: transform .12s ease, box-shadow .2s ease; }

/* Иконка выбранной вкладки чуть приподнимается */
.tab svg { transition: transform .22s cubic-bezier(.2, .8, .3, 1), stroke-width .15s ease; }
.tab[aria-selected="true"] svg { transform: translateY(-2px) scale(1.06); }
.tab:active svg { transform: scale(.9); }

/* Плюс превращается в крестик, пока открыта шторка «что добавить» */
.fab svg { transition: transform .24s cubic-bezier(.2, .8, .3, 1); }
.fab.is-open svg { transform: rotate(45deg); }

/* ---------- Уважение к настройкам движения ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
}
