:root {
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #1f2d26;
  --muted: #6a776e;
  --line: #e0e6de;
  --line-strong: #c8d2c6;
  --accent: #2f5d50;
  --accent-dark: #264c42;
  --danger: #b42318;
  --shadow: 0 30px 70px -40px rgba(31, 45, 38, 0.85);
  --radius: 16px;
  --time-col: 96px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, #fbfdf8 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #eef3ec 0%, transparent 55%),
    var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
strong { font-weight: 600; }

/* ---------- Вход ---------- */

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 94vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-brand p { margin: 2px 0 0; font-size: 13px; }
.login-hint { margin: 0; font-size: 12px; text-align: center; }
.login-hint b { color: var(--ink); }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #3a7261, var(--accent-dark));
  color: #fffdf8;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-mark.big { width: 52px; height: 52px; border-radius: 17px; font-size: 28px; }

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

.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.topbar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  flex-wrap: wrap;
}
.topbar-row.filters { padding-top: 0; gap: 10px 12px; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: Georgia, serif; font-size: 17px; }
.brand-text .muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }

.date-nav { display: flex; align-items: center; gap: 6px; }
.date-display { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.date-display input[type="date"] {
  width: 150px;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
}
.date-display input[type="date"]:hover { border-color: var(--line-strong); }
.date-label { font-size: 13px; text-transform: capitalize; white-space: nowrap; }

.view-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(47, 93, 80, 0.08);
  border-radius: 11px;
}
.view-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.view-btn:hover { color: var(--ink); }
.view-btn.on {
  background: #fff;
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: 0 2px 6px -3px rgba(31, 45, 38, 0.4);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: rgba(47, 93, 80, 0.08); }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 15px;
  background: rgba(47, 93, 80, 0.08);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition: background 0.15s, filter 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(47, 93, 80, 0.14); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(47, 93, 80, 0.08); }
.btn.primary {
  background: linear-gradient(160deg, #3a7261, var(--accent-dark));
  color: #fffdf8;
  box-shadow: 0 8px 18px -10px rgba(38, 76, 66, 0.9);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: rgba(180, 35, 24, 0.1); color: var(--danger); }
.btn.danger:hover { background: rgba(180, 35, 24, 0.16); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.user-box { display: flex; align-items: center; gap: 10px; }
.me { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.me-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b3bdb5;
  flex: 0 0 auto;
}
.live-dot.on { background: #3fa45b; box-shadow: 0 0 0 5px rgba(63, 164, 91, 0.1); }

/* ---------- Фильтры ---------- */

.filter-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 4px 11px 4px 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.chip.off { opacity: 0.45; background: transparent; }
.chip.on { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 8%, white); }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: 0 0 auto; }
.chip-count { font-size: 11px; color: var(--muted); min-width: 12px; }

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.filter-toggle.strong { color: var(--ink); }
.filter-toggle input { accent-color: var(--accent); }
.filter-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.filter-summary { font-size: 12px; }

.select, input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="color"], textarea, select {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 7px 9px;
  background: #fff;
  min-width: 0;
}
.select:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(47, 93, 80, 0.25);
  outline-offset: 1px;
  border-color: var(--accent);
}
.select.small { padding: 5px 9px; font-size: 13px; border-radius: 999px; }
input[type="color"] { padding: 3px; height: 38px; }

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

.calendar-card {
  flex: 1 1 auto;
  min-height: 0;
  margin: 16px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.cal-scroll { flex: 1 1 auto; overflow: auto; min-height: 0; }
.cal-inner { min-width: 1280px; }

.cal-head {
  display: grid;
  grid-template-columns: var(--time-col) repeat(5, 1fr);
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line-strong);
}
.cal-head-cell {
  padding: 9px 14px 10px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.cal-head-cell:first-child { border-left: none; }
.cal-head-cell.corner {
  justify-content: flex-end;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-bottom: 10px;
}
.day-corner { align-items: flex-start; justify-content: flex-start; gap: 0; padding: 7px 12px 8px; }
.day-corner-weekday {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.day-corner-date {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.day-corner-month {
  font-size: 10.5px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 3px;
}
.day-corner-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 3px;
  width: 100%;
}
.res-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.cal-canvas {
  position: relative;
  display: grid;
  grid-template-columns: var(--time-col) repeat(5, 1fr);
  height: 900px;
}
.time-col {
  position: relative;
  border-right: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fbfcfa, #f7f9f5);
}
.time-label {
  position: absolute;
  right: 12px;
  transform: translateY(-50%);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: #f9fbf8;
  padding: 0 3px;
}
.time-label.first { transform: translateY(0); top: 2px !important; }
.time-label.last { transform: translateY(-100%); }

.resource-cols {
  grid-column: 2 / span 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: 900px;
  position: relative;
}

.estate-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.estate-layer .block {
  pointer-events: auto;
  border-left-width: 6px;
  background: #f7faf7;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--c) 15%, #ffffff) 0%,
    color-mix(in srgb, var(--c) 7%, #ffffff) 55%,
    #ffffff 100%
  );
  box-shadow: 0 8px 26px -16px rgba(31, 45, 38, 0.8);
}
.estate-layer .block:hover { z-index: 4; }
.estate-layer .block-title { font-size: 13px; }
.estate-layer .block-time { font-size: 11px; }
.estate-layer .block-mode { color: #6b4b16; }
.resource-col {
  position: relative;
  border-left: 1px solid var(--line);
  height: 900px;
  background-image:
    repeating-linear-gradient(to bottom, rgba(200, 210, 198, 0.55) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(to bottom, rgba(224, 230, 222, 0.75) 0 1px, transparent 1px 30px);
  background-position: 0 0;
  cursor: crosshair;
  transition: background-color 0.15s;
}
.resource-col:first-child { border-left: none; }
.resource-col:hover { background-color: rgba(47, 93, 80, 0.025); }
.resource-col.estate { background-color: rgba(47, 93, 80, 0.035); }

.buffer {
  position: absolute;
  z-index: 1;
  border: 1px dashed var(--c, #8a938c);
  border-radius: 8px;
  background-image: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--c, #8a938c) 16%, transparent) 0 8px,
    transparent 8px 16px
  );
  pointer-events: none;
  opacity: 0.85;
}
.buffer-label {
  position: absolute;
  left: 5px;
  top: 1px;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: #6b776d;
  text-transform: uppercase;
}

.block {
  position: absolute;
  z-index: 2;
  border-radius: 9px;
  border-left: 4px solid var(--c, var(--accent));
  background: var(--bg, #eef3ec);
  padding: 5px 7px 5px 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 2px 5px -2px rgba(31, 45, 38, 0.25);
  transition: box-shadow 0.15s, transform 0.12s;
}
.block:hover { box-shadow: 0 8px 22px -10px rgba(31, 45, 38, 0.7); transform: translateY(-1px); z-index: 4; }
.block.has-overlap { outline: 1.5px dashed rgba(180, 35, 24, 0.55); outline-offset: -2px; }
.block.dim { opacity: 0.22; filter: saturate(0.4); }
.block.highlight { box-shadow: 0 0 0 2px var(--accent), 0 8px 22px -10px rgba(31, 45, 38, 0.7); z-index: 3; }
.block-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.block-time { font-size: 10.5px; font-weight: 600; color: #43514a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.block-warn { color: var(--danger); font-size: 11px; }
.block-discount {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
  padding: 0 4px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.block-seats {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
  color: #1d4ed8;
  background: #dbeafe;
  border-radius: 999px;
  padding: 0 4px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.block-type { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.block-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.22;
  color: #1c2822;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.block-sub {
  font-size: 10.5px;
  color: #526157;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.block-mode {
  font-size: 9.5px;
  color: #8a5a12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.block-author { font-size: 10px; color: #6d7a71; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.block.h-2 { padding: 3px 6px; gap: 0; }
.block.h-2 .block-title { -webkit-line-clamp: 1; }
.block.h-2 .block-sub { font-size: 10px; }
.block.h-2 .block-author { font-size: 9.5px; }
.block.h-1 { padding: 3px 6px; gap: 0; }
.block.h-2 .block-mode, .block.h-1 .block-mode { display: none; }
.block.h-1 .block-seats { display: none; }
.block.h-1 .block-sub, .block.h-1 .block-author, .block.h-1 .block-discount { display: none; }
.block.h-1 .block-title { font-size: 10.5px; line-height: 1.15; -webkit-line-clamp: 2; }

.now-line {
  position: absolute;
  left: var(--time-col);
  right: 0;
  height: 0;
  border-top: 2px solid rgba(180, 35, 24, 0.7);
  z-index: 5;
  pointer-events: none;
}
.now-line span {
  position: absolute;
  right: 8px;
  top: -9px;
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.empty-hint {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 14px 20px;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
  max-width: 420px;
  font-size: 13px;
  z-index: 6;
}

.day-expand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 6px 16px;
  background: #fbfcfa;
}

.legend {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 7px 16px;
  background: #fbfcfa;
}

/* ---------- Месяц ---------- */

.month-card {
  flex: 1 1 auto;
  min-height: 0;
  margin: 16px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.month-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.month-title-wrap { display: flex; flex-direction: column; line-height: 1.15; min-width: 190px; }
.month-title-wrap h2 { margin: 0; font-size: 21px; text-transform: capitalize; }
.month-hint { margin-left: auto; }
.month-weekdays {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 9px 16px 0;
}
.month-weekdays span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.month-weekdays span.weekend { color: var(--danger); opacity: 0.75; }
.month-scroll { flex: 1 1 auto; overflow: auto; min-height: 0; }
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 16px 16px;
  min-width: 760px;
}
.month-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 6px 7px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.month-cell:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 26px -18px rgba(31, 45, 38, 0.8);
  transform: translateY(-1px);
}
.month-cell.other { background: #f8faf6; }
.month-cell.other .month-cell-date,
.month-cell.other .month-cell-weekday,
.month-cell.other .month-cell-month { opacity: 0.4; }
.month-cell.today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.month-cell-head { display: flex; align-items: baseline; gap: 5px; min-width: 0; flex: 0 0 auto; }
.month-cell-weekday {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.month-cell-date {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.month-cell.today .month-cell-date {
  background: var(--accent);
  color: #fffdf8;
  border-radius: 7px;
  padding: 0 5px 1px;
}
.month-cell-month { font-size: 9.5px; color: var(--muted); text-transform: capitalize; }
.month-cell-count {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.month-cell-events {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.month-ev {
  display: flex;
  align-items: baseline;
  gap: 5px;
  width: 100%;
  border: none;
  border-left: 3px solid var(--c, var(--accent));
  border-radius: 4px;
  background: color-mix(in srgb, var(--c, var(--accent)) 12%, white);
  padding: 1px 4px;
  font-size: 10px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
}
.month-ev:hover { filter: brightness(0.97); }
.month-ev.dim { opacity: 0.28; }
.month-ev.highlight { box-shadow: 0 0 0 1.5px var(--accent); }
.month-ev-time {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  color: #43514a;
  font-variant-numeric: tabular-nums;
}
.month-ev-title { overflow: hidden; text-overflow: ellipsis; color: #1c2822; }
.month-ev-discount {
  flex: 0 0 auto;
  font-size: 8px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
  padding: 0 3px;
}
.month-more {
  font-size: 9.5px;
  color: var(--muted);
  padding-left: 4px;
  white-space: nowrap;
}
.month-empty {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: #a6b0a8;
}

/* ---------- ВК ---------- */

.vk-card {
  flex: 1 1 auto;
  min-height: 0;
  margin: 16px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.vk-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 330px 1fr;
}
.vk-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}
.vk-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
}
.vk-sidebar-head h2 { margin: 0; font-size: 18px; }
.vk-search { margin: 0 12px 8px; }
.vk-dialog-list {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vk-dialog {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 8px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font: inherit;
  color: inherit;
}
.vk-dialog:hover { background: rgba(47, 93, 80, 0.06); }
.vk-dialog.on { background: rgba(47, 93, 80, 0.1); }
.vk-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fffdf8;
  font-size: 12px;
  font-weight: 700;
}
.vk-dialog-main { min-width: 0; flex: 1 1 auto; }
.vk-dialog-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.vk-dialog-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vk-dialog-time { font-size: 10px; color: var(--muted); white-space: nowrap; }
.vk-dialog-preview { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vk-dialog-unread { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; margin-top: 5px; }
.vk-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.vk-chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.vk-chat-title { font-weight: 600; font-size: 14px; }
.vk-messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  background: #fbfcfa;
}
.vk-msg {
  max-width: 78%;
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.vk-msg.in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.vk-msg.out {
  align-self: flex-end;
  background: #e7f3ec;
  border: 1px solid #cfe3d7;
  border-bottom-right-radius: 4px;
}
.vk-msg-meta { font-size: 9.5px; color: var(--muted); margin-top: 3px; }
.vk-msg-attach { font-size: 11px; color: #526157; margin-top: 2px; }
.vk-empty {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
}
.vk-send {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.vk-send textarea { flex: 1 1 auto; resize: none; max-height: 110px; }

/* ---------- Модальные окна ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 30, 24, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 34px 16px;
}
.modal-card {
  width: min(620px, 96vw);
  margin: auto;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
}
.modal-card.wide { width: min(880px, 96vw); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-head .muted { margin-top: 2px; }
.modal-body { padding: 18px 24px 22px; display: flex; flex-direction: column; gap: 15px; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
  border-radius: 0 0 20px 20px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; color: #46544b; font-weight: 600; }
.field > span em { font-weight: 400; }
.span-2 { grid-column: 1 / -1; }
.time-row { display: flex; align-items: center; gap: 7px; }
.time-row input { flex: 1 1 0; }
.dash { color: var(--muted); }
textarea { resize: vertical; }

.field-label { font-size: 12px; color: #46544b; font-weight: 600; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.field-label em { font-weight: 400; }

.master-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.master-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 11px 5px 9px;
  cursor: pointer;
  font-size: 13px;
  background: #fff;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.master-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.master-chip.on { border-color: var(--mc, var(--accent)); background: color-mix(in srgb, var(--mc, var(--accent)) 9%, white); }
.master-chip.busy { border-color: rgba(180, 35, 24, 0.55); }
.master-chip.busy.on { background: rgba(180, 35, 24, 0.07); }
.master-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mc, var(--accent)); flex: 0 0 auto; }
.master-busy { font-size: 10.5px; color: var(--danger); background: rgba(180, 35, 24, 0.08); padding: 1px 6px; border-radius: 999px; }
.master-busy.soft { color: var(--muted); background: rgba(31, 45, 38, 0.06); }

.conflict-box {
  border: 1px solid rgba(180, 35, 24, 0.35);
  background: #fdf4f3;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.conflict-head { font-weight: 600; color: var(--danger); font-size: 13.5px; display: flex; gap: 7px; align-items: center; }
.conflict-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.conflict-list li { display: flex; gap: 8px; font-size: 12.5px; color: #4a2a26; line-height: 1.4; }
.conflict-kind { flex: 0 0 auto; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 5px; background: rgba(180, 35, 24, 0.1); height: fit-content; }
.conflict-help { font-size: 12px; color: #6b4b46; border-top: 1px dashed rgba(180, 35, 24, 0.25); padding-top: 8px; }

.resolution-box {
  border: 1px solid var(--line-strong);
  background: #f8faf6;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ev-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.ev-meta b { color: #46544b; font-weight: 600; }
.resolution-note { color: #6b4b46; }

.form-error { margin: 0; color: var(--danger); font-size: 12.5px; }

/* ---------- Записи клиентов ---------- */

.bookings-box {
  border: 1px solid var(--line-strong);
  background: #f8faf6;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bookings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.bookings-head h3 { margin: 0; font-size: 16px; }
.bookings-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}
.booking-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 9px;
}
.booking-row.paid { border-color: rgba(63, 164, 91, 0.35); background: #f2faf3; }
.booking-main { min-width: 0; }
.booking-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}
.booking-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.booking-row.paid .booking-status { color: #2f7a45; }
.booking-meta { font-size: 11.5px; color: var(--muted); }
.booking-comment { font-size: 11.5px; color: #526157; margin-top: 2px; }
.booking-actions {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.booking-form {
  border-top: 1px dashed var(--line-strong);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.booking-form-actions { display: flex; gap: 8px; }

@media (max-width: 760px) {
  .booking-row { flex-direction: column; }
  .booking-actions { justify-content: flex-start; }
}

/* ---------- Настройки мастеров ---------- */

.settings-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.users-list-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.users-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.users-table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8faf6;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
.users-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table tr.inactive td { opacity: 0.55; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-cell .muted.tiny { margin-left: 4px; white-space: nowrap; }
.user-cell .master-dot { width: 10px; height: 10px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 6px;
  font-size: 12px;
}
.link-btn:hover { background: rgba(47, 93, 80, 0.08); }
.link-btn.danger { color: var(--danger); }

.user-form {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fbfcfa;
}
.user-form h3 { margin: 0; font-size: 17px; }
.user-form-actions { display: flex; gap: 8px; }
.settings-note { margin: -2px 0 0; line-height: 1.5; }

/* ---------- История ---------- */

.audit-list { display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow: auto; }
.audit-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audit-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.audit-who { font-weight: 600; font-size: 13px; }
.audit-when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.audit-what { font-size: 12.5px; }
.audit-details { color: var(--muted); font-size: 11.5px; }

/* ---------- Умное добавление ---------- */

.smart-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 18px 12px 15px;
  background: linear-gradient(160deg, #3a7261, var(--accent-dark));
  color: #fffdf8;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 18px 40px -18px rgba(31, 45, 38, 0.85);
  transition: transform 0.15s, filter 0.15s;
}
.smart-fab:hover { transform: translateY(-2px); filter: brightness(1.05); }
.smart-fab-icon { font-size: 17px; line-height: 1; }

.smart-panel {
  position: fixed;
  right: 24px;
  bottom: 82px;
  z-index: 46;
  width: min(400px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 34px 80px -30px rgba(18, 30, 24, 0.65);
  overflow: hidden;
}
.smart-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.smart-head-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.smart-head h2 { margin: 0; font-size: 16px; }
.smart-head .muted { font-size: 10.5px; }

.smart-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fbfcfa;
}
.smart-msg {
  max-width: 90%;
  padding: 8px 11px;
  border-radius: 13px;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.smart-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}
.smart-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fffdf8;
  border-bottom-right-radius: 4px;
}
.smart-msg.error {
  border-color: rgba(180, 35, 24, 0.4);
  background: #fdf4f3;
  color: #6b2a24;
}
.smart-msg.done {
  border-color: rgba(63, 164, 91, 0.4);
  background: #f2faf3;
}
.smart-msg .smart-summary-line { display: block; }
.smart-msg b { font-weight: 700; }

.smart-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px;
  background: #fbfcfa;
}
.smart-chips:not(:empty) { padding-bottom: 8px; }
.smart-chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.smart-chip:hover { border-color: var(--accent); background: rgba(47, 93, 80, 0.06); }
.smart-chip.primary { border-color: var(--accent); background: var(--accent); color: #fffdf8; }
.smart-chip.primary:hover { filter: brightness(1.05); }
.smart-chip.danger { border-color: rgba(180, 35, 24, 0.5); color: var(--danger); }

.smart-form {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 9px 12px 11px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.smart-form input { flex: 1 1 auto; min-width: 0; }
.smart-form .btn { padding: 7px 13px; }

@media (max-width: 760px) {
  .smart-fab { right: 14px; bottom: 14px; }
  .smart-panel {
    right: 8px;
    left: 8px;
    bottom: 74px;
    width: auto;
    height: min(72vh, 600px);
  }
}

/* ---------- Тост и подсказка ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2d26;
  color: #fffdf8;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 80;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  font-size: 13px;
  max-width: min(560px, 92vw);
  text-align: center;
}
.toast.error { background: #8f1d14; }

.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 340px;
  background: rgba(26, 38, 31, 0.98);
  color: #f3f6f2;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tooltip .tt-title { font-weight: 700; font-size: 12.5px; }
.tooltip .tt-muted { color: #b9c6bc; font-size: 11px; }
.tooltip .tt-type { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.tooltip .tt-dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- Адаптив ---------- */

@media (max-width: 1000px) {
  .settings-layout { grid-template-columns: 1fr; }
  .calendar-card, .month-card, .vk-card { margin: 12px; }
  .topbar-row { padding: 9px 14px; }
  .brand-text .muted { display: none; }
}

@media (max-width: 760px) {
  .app { height: auto; overflow: visible; }
  .calendar-card, .month-card, .vk-card { height: 72vh; min-height: 460px; }
  .vk-layout { grid-template-columns: 1fr; }
  .vk-sidebar { max-height: 38%; }
  .vk-chat { min-height: 0; }
  .topbar-row { gap: 8px 12px; }
  .month-hint { display: none; }
  .month-grid { min-width: 640px; padding: 8px 10px 12px; }
  .month-weekdays { padding: 8px 10px 0; }
  .month-title-wrap { min-width: 0; }
  .month-title-wrap h2 { font-size: 18px; }
  .date-label { display: none; }
  .user-box { gap: 6px; }
  .me { display: none; }
  .filter-sep { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 12px 8px; }
  .modal-card { width: 100%; }
}
