/* Цвета берутся из темы Telegram, поэтому календарь сам подстраивается под светлую/тёмную тему. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #1c1c1e; --bg2: #2c2c2e; --text: #f2f2f7; --hint: #8e8e93;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 12px 16px 96px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.tabs { display: flex; background: var(--bg2); border-radius: var(--radius); padding: 3px; margin-bottom: 12px; }
.tab { flex: 1; padding: 8px; border-radius: 9px; color: var(--hint); font-weight: 500; }
.tab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-nav h1 { font-size: 18px; margin: 0; text-transform: capitalize; }
.month-nav button { font-size: 26px; width: 40px; height: 40px; border-radius: 50%; color: var(--accent); }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.weekdays span { font-size: 12px; color: var(--hint); padding: 4px 0; }
.grid { gap: 2px; }
/* Сетку растягиваем почти до краёв экрана, чтобы имена клиентов влезали. */
.weekdays, .grid { margin: 0 -10px; }
.day {
  min-width: 0; min-height: 62px; padding: 4px 1px; display: flex; flex-direction: column;
  align-items: stretch; gap: 2px; border-radius: 8px; font-size: 14px;
}
.day .num { text-align: center; line-height: 20px; }
.day.other { color: var(--hint); opacity: .45; }
.day.today .num { color: var(--accent); font-weight: 700; }
.day.selected { background: var(--bg2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.day .chip {
  font-size: 10px; line-height: 1.2; padding: 2px 1px; border-radius: 4px;
  background: var(--accent); color: var(--accent-text); text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: normal; word-break: keep-all; letter-spacing: -.2px;
}
.day .chip.clip { display: block; white-space: nowrap; text-overflow: ellipsis; }
.day .more { font-size: 10px; line-height: 12px; color: var(--hint); text-align: center; }

.day-title { font-size: 15px; color: var(--hint); font-weight: 500; margin: 16px 0 8px; }
.group-title { font-size: 13px; color: var(--hint); font-weight: 600; margin: 16px 0 6px; letter-spacing: .03em; }
.group-title:first-child { margin-top: 4px; }

.card { display: block; width: 100%; text-align: left; background: var(--bg2); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.card .time { font-weight: 600; color: var(--accent); }
.card .client { font-weight: 600; margin-top: 2px; }
.card .desc { color: var(--hint); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.empty { color: var(--hint); text-align: center; padding: 24px 0; }

.fab {
  position: fixed; right: 20px; bottom: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 30px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-body {
  width: 100%; background: var(--bg); border-radius: 16px 16px 0 0; padding: 18px 16px 24px;
  max-height: 92vh; overflow-y: auto;
}
.sheet-body h2 { margin: 0 0 12px; font-size: 18px; }
label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 10px; }
input, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; background: var(--bg2); color: var(--text); font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 10px; }
.row label { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions button { flex: 1; padding: 12px; border-radius: 10px; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-text); }
.secondary { background: var(--bg2); }
.danger { color: var(--danger); background: var(--bg2); }
.form-error, .error { color: var(--danger); margin: 8px 0; }
.error { text-align: center; padding: 24px 0; }
