/* ===== Дизайн-токены (Светлая по умолчанию и Тёмная темы) ===== */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #e6ecf5;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --input-bg: #f8fafc;
  --border: #c5d1e0;
  --input-border: #8fa0b8;
  --day-border: #bcc9dc;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --weekend: #fff5ed;
  --weekend-border: #f9bd93;
  --holiday-bg: #ffe9ec;
  --holiday-border: #fda4af;
  --holiday-text: #be123c;
  --select-bg: #e8f1ff;
  --select-border: #2563eb;
  --note-bg: #fef08a;
  --note-border: #eab308;
  --note-text: #713f12;
  --focus: 0 0 0 3px rgb(37 99 235 / .35);
  --shadow: 0 1px 3px rgb(15 23 42 / .08), 0 8px 24px rgb(15 23 42 / .08);
  --radius: 14px;
  --radius-sm: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1b2538;
  --input-bg: #1e293b;
  --border: #2c3a52;
  --input-border: #475569;
  --day-border: #2c3a52;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --success: #22c55e;
  --warning: #f59e0b;
  --weekend: #161d2f;
  --weekend-border: #382a33;
  --holiday-bg: #281322;
  --holiday-border: #69203d;
  --holiday-text: #fb7185;
  --select-bg: #172554;
  --select-border: #60a5fa;
  --note-bg: #362c11;
  --note-border: #a16207;
  --note-text: #fde047;
  --danger: #f87171;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 28px rgb(0 0 0 / .35);
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s, color .2s;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button:disabled, .pill:disabled, .btn:disabled { opacity: .48; cursor: not-allowed; pointer-events: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }

.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;
}
.skip-link {
  position: absolute; left: var(--s2); top: -48px; z-index: 100;
  background: var(--primary); color: var(--on-primary);
  padding: var(--s2) var(--s4); border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: var(--s2); }
.muted { color: var(--muted); }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 var(--s4);
  border: 1.5px solid var(--input-border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 13.5px; }
.btn:hover { border-color: var(--primary); }
.btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  border-color: var(--primary);
  color: var(--primary);
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border: 1.5px solid var(--input-border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 17px; line-height: 1;
}
.icon-btn.btn-xs { width: 30px; height: 30px; font-size: 15px; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.pill-group { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; max-width: 100%; }
.pill {
  min-height: 32px; padding: 0 var(--s3);
  border: 1.5px solid var(--input-border); border-radius: 999px;
  background: var(--surface-2); cursor: pointer; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; max-width: 100%; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.pill:hover { border-color: var(--primary); }
.pill[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pill-accent { border-style: dashed; border-color: var(--primary); color: var(--primary); background: var(--surface); }
.pill-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--input-border)); }
.pill-danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.pill .dot, .paint-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ===== Новая эргономичная шапка страницы ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: 10px var(--s5);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 4px 16px rgb(15 23 42 / .05);
}
.header-left {
  display: flex; align-items: center; gap: var(--s3); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: var(--on-primary);
  font-size: 20px; font-weight: 700;
  box-shadow: 0 3px 10px rgb(37 99 235 / .28);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-tag { font-size: 11px; color: var(--muted); font-weight: 500; }

/* Живая капсула итогов в шапке */
.header-kpi {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.header-kpi:hover { border-color: var(--primary); }
.header-kpi strong { color: var(--primary); font-weight: 800; }
.kpi-sep { color: var(--muted); }

/* Центральный пульт выбора месяца и года */
.month-switcher {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
}
.nav-arrow {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(15 23 42 / .06);
  cursor: pointer; font-size: 18px; font-weight: 700; line-height: 1;
}
.nav-arrow:hover { background: var(--primary); color: var(--on-primary); }

.month-picker-wrap { position: relative; flex: 1; min-width: 0; display: flex; justify-content: center; }
.month-title-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 999px;
  background: transparent; cursor: pointer;
  max-width: 100%; min-width: 0; overflow: hidden;
}
.month-title-btn:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.month-title {
  font-size: clamp(14px, 1.8vw, 18px); font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.month-caret { font-size: 12px; color: var(--muted); flex: none; }

.today-pill {
  min-height: 32px; padding: 0 12px; flex: none;
  border: 0; border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px; font-weight: 700; color: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(15 23 42 / .06);
}
.today-pill:hover { background: var(--primary); color: var(--on-primary); }

/* Выпадающая панель быстрого выбора месяца и года */
.month-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(250px, calc(100vw - 24px));
  padding: var(--s3);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: var(--s2);
  animation: pop .14s ease-out;
}
.month-dd-year {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.month-dd-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.month-dd-btn {
  min-height: 32px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.month-dd-btn:hover { border-color: var(--primary); }
.month-dd-btn.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Правая часть шапки и статус Гость / Аккаунт */
.header-right { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-controls { display: flex; align-items: center; gap: 6px; flex: none; }

.user-pill-wrap { position: relative; }
.user-pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 10px 0 12px;
  border: 1.5px solid var(--input-border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13.5px; font-weight: 700;
  max-width: 230px;
  transition: border-color .15s, box-shadow .15s;
}
.user-pill:hover { border-color: var(--primary); }
.user-pill.is-guest {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
  flex: none;
}
.user-pill.is-guest .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 24%, transparent);
}
.user-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-action-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11.5px;
  font-weight: 700;
  flex: none;
}
.user-pill:not(.is-guest) .user-action-badge {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Всплывающее уведомление при наведении на Гостя */
.guest-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  width: min(265px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--warning);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  line-height: 1.4;
  display: flex; flex-direction: column; gap: 3px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .16s, transform .16s, visibility .16s;
}
.guest-tooltip strong { color: var(--warning); font-size: 13px; }
.user-pill-wrap.is-guest-mode:hover .guest-tooltip,
.user-pill-wrap.is-guest-mode:focus-within .guest-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ===== Модальное окно Авторизации и Регистрации ===== */
.auth-dialog { width: min(460px, calc(100% - 24px)); }
.seg-tab {
  min-height: 36px; border: 0; border-radius: 6px;
  background: transparent; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.seg-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
  border: 1px solid var(--primary);
}
.auth-form {
  display: flex; flex-direction: column; gap: var(--s3);
  min-width: 0; max-width: 100%;
}
.pass-wrap { display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.pass-wrap input { flex: 1; min-width: 0; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.field-hint {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.field-hint.error { color: var(--danger); font-weight: 600; }
.field-hint.ok { color: var(--success); font-weight: 600; }
input.invalid { border-color: var(--danger) !important; }
.auth-error {
  margin: 0;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.auth-submit { width: 100%; min-height: 44px; font-size: 15px; }
.profile-foot { padding: var(--s2) 0 0; border-top: 1.5px solid var(--border); }

/* ===== Личный кабинет пользователя ===== */
.auth-dialog { width: min(520px, calc(100% - 24px)); }
.cabinet-hero {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.cabinet-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: var(--on-primary);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.cabinet-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.cabinet-name-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0;
}
.cabinet-name {
  font-size: 15px; font-weight: 800;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cabinet-role {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}
.cabinet-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.cab-stat-tile {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.cab-stat-tile span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.cab-stat-tile strong { font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-section {
  display: flex; flex-direction: column; gap: var(--s3);
  min-width: 0;
}
.cab-row-end {
  display: flex; justify-content: flex-end;
}

/* ===== Раскладка ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--s5);
  padding: var(--s5);
  max-width: 1600px;
  margin: 0 auto;
}
.calendar-wrap, .summary { min-width: 0; max-width: 100%; }

/* ===== Быстрое заполнение и его редактирование ===== */
.paint-bar {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3);
  margin-bottom: var(--s2);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0; max-width: 100%;
  overflow: hidden;
}
.paint-bar-top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  flex-wrap: wrap; min-width: 0; max-width: 100%;
}
.paint-label { font-size: 13px; color: var(--muted); font-weight: 700; min-width: 0; }
.paint-tools { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.paint-chips {
  display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center;
  min-width: 0; max-width: 100%;
}
.paint-chip-wrap {
  display: inline-flex; align-items: center;
  min-width: 0; max-width: 100%;
  border: 1.5px solid var(--input-border); border-radius: 999px;
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.paint-chip-wrap:hover { border-color: var(--c, var(--primary)); }
.paint-chip-wrap.active {
  border-color: var(--c, var(--primary));
  background: color-mix(in srgb, var(--c, var(--primary)) 20%, var(--surface));
  box-shadow: 0 0 0 1px var(--c, var(--primary)) inset;
}
.paint-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 var(--s3);
  min-width: 0; max-width: 100%;
  border: 0; border-radius: 999px;
  background: transparent; cursor: pointer; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.paint-chip > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.paint-chip .sub { font-size: 11px; color: var(--muted); font-weight: 500; flex: none; }
.paint-chip-wrap.eraser { --c: var(--danger); }
.chip-action {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; margin-right: 4px; flex: none;
  border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  color: var(--text); font-size: 12px; cursor: pointer; line-height: 1;
}
.chip-action.del { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.chip-action:hover { filter: brightness(0.92); }

/* ===== Панель мультивыбора дат ===== */
.multi-bar {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s2);
  background: var(--select-bg);
  border: 1.5px solid var(--select-border);
  border-radius: var(--radius);
}
.multi-top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}
.multi-actions {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding-top: var(--s2);
  border-top: 1px dashed color-mix(in srgb, var(--select-border) 45%, transparent);
  font-size: 13px;
}
.multi-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.paint-hint { min-height: 20px; margin: 0 0 var(--s2); font-size: 13px; color: var(--primary); font-weight: 600; }

/* ===== Календарь ===== */
.weekdays, .calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekdays { margin-bottom: 6px; }
.weekdays span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 var(--s2); }
.weekdays .we { color: var(--danger); }

.day {
  position: relative;
  appearance: none;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 122px; min-width: 0; max-width: 100%;
  padding: var(--s2);
  border: 1.5px solid var(--day-border); border-radius: var(--radius-sm);
  background: var(--surface); color: inherit; text-align: left; cursor: pointer;
  user-select: none; overflow: hidden;
  box-shadow: 0 1px 2px rgb(15 23 42 / .04);
  transition: border-color .15s, box-shadow .15s, transform .12s, background-color .15s;
}
.day:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.day:active { transform: scale(.985); }
.day.weekend {
  background: var(--weekend);
  border-color: var(--weekend-border);
}
.day.holiday {
  background: var(--holiday-bg);
  border-color: var(--holiday-border);
}
.day.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 1.5px var(--primary);
}
.day.out { opacity: .5; }
.day.out:hover { opacity: .88; }
.day.selected {
  border-color: var(--select-border);
  box-shadow: 0 0 0 2px var(--select-border) inset;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}
.day.range-anchor {
  border-style: dashed;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary) inset;
}
body.painting .day, body.multi-selecting .day { cursor: copy; }

.day-head { display: flex; align-items: center; justify-content: space-between; gap: 2px; min-width: 0; }
.day-num-wrap { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.day-num {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 4px;
  border-radius: 999px; font-weight: 700; font-size: 14px; flex: none;
}
.day.weekend .day-num, .day.holiday .day-num { color: var(--holiday-text); }
.day.today .day-num { background: var(--primary); color: var(--on-primary); }
.day.selected .day-num { background: var(--primary); color: var(--on-primary); }

.day-badges { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.hol-mark { font-size: 12px; line-height: 1; }
.note-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 6px;
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  color: var(--note-text);
  font-size: 11px; font-weight: 700; line-height: 1;
  cursor: pointer;
}
.holiday-tag {
  display: block;
  min-width: 0; max-width: 100%;
  font-size: 10px;
  line-height: 1.2;
  color: var(--holiday-text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: 100%; }
.chip {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  min-width: 0; max-width: 100%;
  padding: 2px 6px;
  border-left: 3.5px solid var(--c);
  border-radius: 5px;
  background: color-mix(in srgb, var(--c) 20%, var(--surface));
  font-size: 12px; line-height: 1.35;
}
.chip-main {
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip b { font-weight: 600; }
.chip .time { color: var(--muted); font-size: 11px; }
.chip .dur-tag {
  font-size: 10px; font-weight: 700; color: var(--muted);
  flex: none;
}
.chip sup { font-size: 9px; color: var(--muted); }
.chip-cont {
  background: color-mix(in srgb, var(--c) 10%, var(--surface-2));
  border-left-style: dashed;
  color: var(--muted);
}

/* Стек нескольких заметок в ячейке дня */
.day-notes-stack {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0; max-width: 100%;
}
.day-note-snippet {
  display: block;
  min-width: 0; max-width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--note-bg);
  border: 1px solid color-mix(in srgb, var(--note-border) 55%, transparent);
  color: var(--note-text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-note-more {
  font-size: 10px;
  font-weight: 700;
  color: var(--note-text);
  padding: 0 4px;
}

.day-foot { margin-top: auto; display: flex; justify-content: flex-end; font-size: 11px; font-weight: 700; color: var(--muted); }

/* ===== Всплывающая карточка заметок дня ===== */
.note-popover {
  position: fixed;
  z-index: 90;
  width: min(320px, calc(100vw - 24px));
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1.5px solid var(--note-border);
  border-left: 4px solid #eab308;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  animation: pop .14s ease-out;
}
.note-popover-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  font-size: 13px; color: var(--muted);
}
.note-popover-close {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 24px; height: 24px; border-radius: 4px; font-size: 13px;
}
.note-popover-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 210px; overflow-y: auto;
}
.note-popover-list li {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.note-popover-actions {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}

/* ===== Выбор дней недели в графике по циклу ===== */
.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.wd-btn {
  min-height: 38px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.wd-btn.we { color: var(--danger); }
.wd-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* ===== Боковая панель (Итоги и сгруппированные заметки по дням) ===== */
.summary { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  display: flex; flex-direction: column; gap: var(--s3);
  min-width: 0; max-width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}
.card-title { font-size: 16px; }
.card-subtitle { font-size: 13px; color: var(--muted); font-weight: 700; }
.notes-count-badge {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 22px; padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.card-subbox {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  display: flex; flex-direction: column; gap: var(--s2);
  min-width: 0;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin: 0; }
.stats div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3);
  min-width: 0;
}
.stats dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.stats dd { margin: 0; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.breakdown, .notes-list, .hol-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0; max-width: 100%;
}
.breakdown li { display: flex; align-items: center; gap: var(--s2); font-size: 13px; min-width: 0; }
.breakdown .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.breakdown .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.breakdown .val { color: var(--muted); white-space: nowrap; flex: none; }

/* ===== Блок задолженностей и плана погашения ===== */
.debts-card { transition: border-color .2s; }
.debts-card.is-active { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.debts-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  min-width: 0;
}
.debts-title-wrap {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap;
}
.debts-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-2));
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.debts-badge.paid-all {
  background: color-mix(in srgb, var(--success) 14%, var(--surface-2));
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

/* Тумблер активации */
.switch-label {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none; flex: none;
}
.switch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1.5px solid var(--input-border);
  transition: background-color .18s, border-color .18s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s, background-color .18s;
}
.switch-input:checked + .switch-track {
  background: var(--primary);
  border-color: var(--primary);
}
.switch-input:checked + .switch-track::after {
  transform: translateX(18px);
  background: var(--on-primary);
}
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch-text { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 32px; }
.switch-input:checked ~ .switch-text { color: var(--primary); }

.debts-body {
  display: flex; flex-direction: column; gap: var(--s3);
  padding-top: var(--s2);
  border-top: 1px dashed var(--border);
  min-width: 0; max-width: 100%;
}
.debt-add-box {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.debt-add-row {
  display: flex; gap: 6px; align-items: center; min-width: 0;
}
.debt-add-row input { flex: 1; min-width: 0; }

.debts-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0; max-width: 100%;
}
.debt-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  min-width: 0; max-width: 100%;
}
.debt-item.is-done {
  border-left-color: var(--success);
  opacity: .85;
}
.debt-item-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 6px;
  min-width: 0;
}
.debt-item-title {
  font-weight: 700; font-size: 13.5px;
  min-width: 0; flex: 1;
  overflow-wrap: anywhere; word-break: break-word;
}
.debt-item-nums {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.debt-item-nums strong { color: var(--text); font-size: 13px; }
.debt-bar {
  width: 100%; height: 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.debt-bar-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 999px;
  transition: width .2s;
}
.debt-pay-row {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.debt-pay-row input {
  flex: 1; min-width: 0;
  min-height: 32px !important; padding: 4px 8px !important; font-size: 13px !important;
}

.debt-rate-box {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.debt-pct-val { color: var(--primary); font-size: 14px; }
.debt-range {
  width: 100%; min-height: 24px !important; padding: 0 !important;
  border: 0 !important; background: transparent !important; box-shadow: none !important;
  accent-color: var(--primary); cursor: pointer;
}

/* Аналитическая сводка погашения */
.debts-advisor {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  font-size: 13px; line-height: 1.4;
  min-width: 0; max-width: 100%;
  overflow-wrap: anywhere; word-break: break-word;
}
.advisor-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.advisor-tile {
  padding: 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.advisor-tile span { font-size: 11px; color: var(--muted); font-weight: 600; }
.advisor-tile strong { font-size: 14px; color: var(--primary); }
.advisor-rec {
  margin: 0;
  padding-top: 6px;
  border-top: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border));
  font-size: 12.5px;
}
.advisor-rec b { color: var(--text); }

/* Отображение нескольких заметок дня в правом окне */
.note-day-group {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0; max-width: 100%;
}
.note-day-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.note-day-open {
  border: 0; background: transparent; padding: 0;
  font-size: 13.5px; font-weight: 700; color: var(--primary);
  cursor: pointer; text-align: left;
  display: inline-flex; align-items: center; gap: 6px;
}
.note-day-open:hover { text-decoration: underline; }
.note-day-cnt {
  font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 1px 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
}
.note-day-items {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0; max-width: 100%;
}
.note-sub-item {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--note-border);
  border-radius: 6px;
  min-width: 0; max-width: 100%;
}
.note-sub-body {
  flex: 1; min-width: 0; max-width: 100%;
  cursor: pointer;
}
.note-sub-badge {
  display: inline-block;
  font-size: 10.5px; color: var(--note-text); background: var(--note-bg);
  padding: 1px 6px; border-radius: 999px; font-weight: 700;
  margin-bottom: 2px;
}
.note-sub-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.35;
}
.note-sub-actions {
  display: flex; gap: 4px; flex: none;
}
.note-copy-btn,
.note-del-btn {
  flex: none;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12.5px;
  display: grid;
  place-items: center;
}
.note-copy-btn:hover { border-color: var(--primary); }
.note-del-btn { color: var(--danger); }
.note-del-btn:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-2)); }
.notes-list .empty, .empty { color: var(--muted); font-size: 13px; margin: 0; }

.hol-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 0;
}
.hol-list li > div {
  flex: 1; min-width: 0;
  overflow-wrap: anywhere; word-break: break-word;
}
.hol-list .hol-date { font-weight: 700; color: var(--holiday-text); margin-right: 6px; }
.hol-list .hol-tag { font-size: 11px; color: var(--muted); padding: 2px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm);
}
.segmented label { position: relative; min-width: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: grid; place-items: center; min-height: 36px; padding: 0 var(--s2);
  border-radius: 6px; font-size: 13px; font-weight: 600; text-align: center; cursor: pointer;
}
.segmented input:checked + span {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.segmented input:focus-visible + span { box-shadow: var(--focus); }

.total {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2);
  padding-top: var(--s3); border-top: 1.5px dashed var(--border);
}
.total strong { font-size: 22px; color: var(--primary); }
.data-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.data-actions .btn { flex: 1; }

/* ===== Поля ввода ===== */
.field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--text); font-weight: 600;
  min-width: 0;
}
.field-title { font-size: 14px; font-weight: 700; }
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea {
  width: 100%; max-width: 100%; min-height: 40px; padding: var(--s2) 10px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  box-shadow: inset 0 1px 2px rgb(15 23 42 / .05);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):hover:not(:disabled),
select:hover,
textarea:hover {
  border-color: var(--text);
}
input:disabled { opacity: .65; cursor: not-allowed; }
textarea {
  resize: vertical; min-height: 60px;
  overflow-wrap: anywhere; word-break: break-word;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; font-weight: 400; }
input[type="time"] { font-variant-numeric: tabular-nums; font-weight: 700; }
input[type="color"] {
  width: 40px; height: 40px; padding: 3px; flex: none;
  border: 1.5px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); cursor: pointer;
}
.check { display: flex; align-items: center; gap: var(--s2); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }

/* ===== Редактор нескольких заметок в диалоге дня ===== */
.note-box {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 0;
}
.note-box-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}
.note-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.day-notes-editor {
  display: flex; flex-direction: column; gap: var(--s2);
  min-width: 0;
}
.note-edit-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--note-border);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.note-edit-top {
  display: flex; align-items: flex-start; gap: 6px; min-width: 0;
}
.note-edit-top textarea { flex: 1; min-width: 0; min-height: 54px; }
.note-edit-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}
.note-char-cnt {
  font-size: 11px; color: var(--muted); font-weight: 600;
}

/* ===== Диалоги ===== */
dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0; border: 1.5px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgb(0 0 0 / .3);
}
dialog[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
dialog::backdrop { background: rgb(15 23 42 / .55); backdrop-filter: blur(2px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.dlg-head, .dlg-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5);
}
.dlg-head { border-bottom: 1.5px solid var(--border); }
.dlg-head h2 { font-size: 18px; }
.holiday-sub { margin: 2px 0 0; font-size: 13px; color: var(--holiday-text); font-weight: 600; }
.dlg-foot { border-top: 1.5px solid var(--border); flex-wrap: wrap; }
.dlg-body { padding: var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.dlg-actions { display: flex; gap: var(--s2); margin-left: auto; }
.day-total { font-weight: 700; }

.day-holiday-row {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.day-holiday-row input[type="text"] { flex: 1; min-width: 180px; min-height: 36px; }

.notice {
  margin: 0; padding: var(--s3) var(--s4);
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.add-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 14px; }
.grid-2, .hol-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); min-width: 0; }
.grid-2.inner { gap: var(--s2); }
.hol-add-opts { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }

/* ===== Карточка смены ===== */
.shift-list { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.shift-card {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4);
  border: 1.5px solid var(--border); border-left: 4px solid var(--c);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c) 6%, var(--surface));
  min-width: 0;
}
.shift-row { display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.shift-row .f-name { font-weight: 600; flex: 1; min-width: 0; }
.time-row { display: grid; grid-template-columns: 1fr auto 1fr 120px; gap: var(--s2); align-items: end; }
.time-row .arrow { padding-bottom: 10px; color: var(--muted); }
.pay-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s2); }
.quick-dur { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-dur .pill { min-height: 32px; }
.shift-info {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin: 0;
  font-size: 13px; color: var(--muted);
  overflow-wrap: anywhere; word-break: break-word;
}
.shift-info span:first-child { color: var(--text); font-weight: 700; }
.shift-info .over { color: var(--primary); font-weight: 700; }

/* ===== Мобильная нижняя панель (скрыта на ПК) ===== */
.mobile-dock { display: none; }

/* ===== Тост ===== */
.toast {
  position: fixed; left: 50%; bottom: var(--s5); z-index: 200;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
  text-align: center;
  overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Адаптив: планшеты ===== */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
  .brand-tag { display: none; }
}

/* ===== Адаптив: все модели смартфонов (iPhone SE/13/14/15/16/Pro Max, Galaxy S/A, Pixel) ===== */
@media (max-width: 720px) {
  body {
    font-size: 14px;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea {
    font-size: 16px;
  }
  .app-header {
    padding: 8px var(--s2);
    gap: 6px;
    flex-wrap: nowrap;
  }
  .header-left { display: none; }
  .month-switcher {
    flex: 1; min-width: 0;
    justify-content: space-between;
    padding: 3px;
  }
  .month-title-btn { padding: 0 4px; min-height: 30px; }
  .month-title { font-size: 14.5px; }
  .nav-arrow { width: 28px; height: 28px; font-size: 16px; }
  .today-pill { padding: 0 8px; min-height: 28px; font-size: 11.5px; }
  .month-dropdown {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
  }

  .header-actions { display: none; }
  .user-controls { gap: 4px; }
  .user-action-badge { display: none; }
  .user-pill { min-height: 34px; padding: 0 9px; font-size: 12px; max-width: 110px; }
  .user-avatar { display: none; }
  #themeBtn { width: 34px; height: 34px; font-size: 15px; }

  .layout { padding: var(--s2); gap: var(--s4); }
  .paint-bar { padding: var(--s2); gap: 8px; border-radius: var(--radius-sm); }
  .paint-bar-top { gap: 6px; }
  .paint-label { font-size: 12px; }
  .paint-tools { gap: 4px; }
  .paint-tools .pill { min-height: 28px; padding: 0 9px; font-size: 12px; }
  .paint-chips {
    flex-wrap: wrap;
    gap: 6px;
  }
  .paint-chip-wrap { max-width: 100%; }
  .paint-chip { min-height: 32px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
  .chip-action { width: 24px; height: 24px; font-size: 11px; }

  .multi-bar { padding: var(--s2) var(--s3); gap: var(--s2); }
  .multi-top .pill-group {
    width: 100%;
    flex-wrap: wrap;
    gap: 5px;
  }
  .multi-btns { width: 100%; margin-left: 0; }
  .multi-btns .btn { flex: 1; }

  .weekdays, .calendar { gap: 3px; }
  .weekdays span { padding: 0; text-align: center; font-size: 11px; }
  .day {
    min-height: 84px;
    padding: 3px 4px;
    gap: 2px;
    border-radius: 7px;
  }
  .day-head { justify-content: space-between; }
  .day-num { min-width: 21px; height: 21px; font-size: 11.5px; padding: 0 2px; }
  .hol-mark { font-size: 10px; }
  .note-trigger { min-width: 18px; height: 18px; padding: 0 2px; font-size: 9px; }
  .holiday-tag { font-size: 8.5px; }

  .chip {
    font-size: 9.5px;
    padding: 2px 3px;
    border-left-width: 2.5px;
    border-radius: 4px;
    gap: 2px;
  }
  .chip .time, .chip sup { display: none; }
  .chip .dur-tag { font-size: 8.5px; }
  .day-note-snippet { font-size: 9px; padding: 1px 3px; }
  .day-note-more { font-size: 8.5px; }
  .day-foot { font-size: 9px; }

  /* Нижняя панель навигации на телефоне */
  .mobile-dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1.5px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .dock-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 50px;
    padding: 2px;
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    min-width: 0;
  }
  .dock-btn span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dock-btn[aria-pressed="true"], .dock-btn:active {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
  }
  .dock-ico { font-size: 17px; line-height: 1; }

  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .cookie-banner {
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 8px; right: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  /* Bottom-sheet диалоги на мобильных */
  dialog,
  dialog.auth-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto 0 0 0;
    border-radius: 20px 20px 0 0;
  }
  .dlg-head, .dlg-foot { padding: var(--s3) var(--s4); }
  .dlg-body { padding: var(--s3) var(--s4); }
  .dlg-foot { padding-bottom: max(var(--s3), env(safe-area-inset-bottom)); }
  .shift-card { padding: var(--s3); }
  .time-row { grid-template-columns: 1fr 1fr; }
  .time-row .arrow { display: none; }
  .time-row .dur { grid-column: 1 / -1; }
  .pay-row { grid-template-columns: 1fr 1fr; }
  .pay-row .brk { grid-column: 1 / -1; }
  .grid-2, .hol-add-grid { grid-template-columns: 1fr; }
}

/* ===== Футер, слоты под рекламу РСЯ, Cookie-баннер и Политика конфиденциальности ===== */
.brand-link { text-decoration: none; color: inherit; }
.app-footer {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--s3) var(--s5) var(--s5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.footer-right {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
}
.visit-counter {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 2px rgb(15 23 42 / .05);
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  white-space: nowrap;
}
.visit-counter strong {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.visit-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 24%, transparent);
}
.footer-link, .cookie-banner a, .check a {
  color: var(--primary); font-weight: 600; text-decoration: none;
}
.footer-link:hover, .cookie-banner a:hover, .check a:hover { text-decoration: underline; }

.ad-slot {
  margin-top: var(--s3);
  padding: var(--s3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0; max-width: 100%; overflow: hidden;
}
.ad-slot-side { margin-top: 0; }
.ad-slot-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ad-slot-body { min-height: 90px; width: 100%; }

.cookie-banner {
  position: fixed;
  left: var(--s4);
  bottom: var(--s4);
  z-index: 80;
  max-width: 520px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: var(--s3);
  font-size: 13px; line-height: 1.4;
}
.cookie-banner p { margin: 0; flex: 1; }
@media (max-width: 720px) {
  .cookie-banner {
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 8px; right: 8px;
    max-width: none;
    flex-direction: column;
    align-items: stretch;
  }
}

.privacy-page {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s5) var(--s4);
}
.privacy-card {
  gap: var(--s3);
  padding: var(--s5);
}
.privacy-card h1 { font-size: clamp(20px, 3vw, 26px); }
.privacy-card h2 { font-size: 17px; margin-top: var(--s2); }
.privacy-card p, .privacy-card li { font-size: 14.5px; line-height: 1.6; margin: 0; }
.privacy-card ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.privacy-foot { padding-top: var(--s3); border-top: 1px solid var(--border); }

/* ===== Информационный SEO-блок и FAQ под календарём ===== */
.seo-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--s5) var(--s4);
}
.seo-card { gap: var(--s4); }
.seo-h1 { font-size: clamp(18px, 2.2vw, 22px); color: var(--text); }
.seo-lead { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.55; }
.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
}
.seo-item {
  padding: var(--s3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.seo-item h2 { font-size: 14.5px; color: var(--text); }
.seo-item p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-title { font-size: 15px; margin-bottom: 2px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 10px 12px;
}
.faq-item summary {
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "▾"; color: var(--muted); flex: none; transition: transform .15s; }
.faq-item[open] summary::after { transform: rotate(180deg); }
.faq-item p { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

@media (max-width: 900px) {
  .seo-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .seo-section { padding: 0 var(--s2) var(--s3); }
}

/* Компактные и стандартные модели телефонов (320px–420px) */
@media (max-width: 420px) {
  .user-pill { max-width: 88px; padding: 0 7px; }
  .month-title { font-size: 13.5px; }
  .today-pill { display: none; }
  .weekdays, .calendar { gap: 2px; }
  .day { min-height: 76px; padding: 2px 3px; }
  .day-num { min-width: 19px; height: 19px; font-size: 11px; }
  .chip .dur-tag { display: none; }
  .app-footer { padding: var(--s3); font-size: 12px; }
}

/* Горизонтальная ориентация смартфона */
@media (max-height: 500px) and (orientation: landscape) {
  dialog { max-height: 96dvh; }
  .dlg-head, .dlg-foot { padding: 8px 14px; }
  .dlg-body { padding: 10px 14px; }
}

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