:root {
  --paper: #FAFAFA;
  --card: #FFFFFF;
  --ink: #1C1C1E;
  --muted: #6E6E73;
  --line: #E4E4E4;
  --accent: #2864A1;
  --accent-ink: #FFFFFF;
  --accent-soft: #EAF1F8;
  --danger: #B3261E;
  --warn: #8A5A12;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 0.3rem; letter-spacing: -0.2px; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }
.muted { color: var(--muted); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.top {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.layout { display: grid; grid-template-columns: 13rem 1fr; min-height: calc(100vh - 3.4rem); }
nav {
  padding: 0.8rem; border-right: 1px solid var(--line); background: #F3F3F3;
  display: flex; flex-direction: column; gap: 0.15rem;
}
nav a {
  color: var(--muted); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: 8px;
  font-size: 0.95rem;
}
nav a:hover { background: rgba(0,0,0,0.045); color: var(--ink); }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main .page { padding: 1.2rem 1.4rem 2.5rem; max-width: 68rem; width: 100%; }
.card, form.card, .grid article {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.8rem; }
label { display: block; margin: 0.7rem 0 0.25rem; font-size: 0.92rem; }
input[type="checkbox"], input[type="radio"] { width: auto; }
label.check { display: flex; gap: 0.45rem; align-items: center; margin-top: 0.8rem; }
input, select, textarea {
  width: 100%; max-width: 28rem; padding: 0.5rem 0.65rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { max-width: 40rem; min-height: 8rem; }
button, .btn {
  margin-top: 0.8rem; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 0.5rem 0.9rem; font: inherit; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
button:hover, a.btn:hover { background: #1F5083; color: var(--accent-ink); }
a.btn { display: inline-block; text-decoration: none; }
button.ghost, .top button { margin: 0; background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover, .top button:hover { background: rgba(0,0,0,0.05); }
button.danger { background: var(--danger); }
button.danger:hover { background: #8f1e17; }
.note, .error, .ok {
  padding: 0.55rem 0.7rem; border-radius: 8px; background: var(--accent-soft);
}
.zone-callout {
  margin: 0 0 0.4rem; padding: 0.75rem 0.9rem;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft);
}
.zone-callout label { margin-top: 0; font-weight: 700; }
.zone-callout p { margin: 0.15rem 0 0.45rem; }
.error { background: #F9E7E5; color: var(--danger); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.row-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: end; }
.row-form input, .row-form select { width: auto; margin: 0; }
.row-form button { margin: 0; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem; min-height: 6rem; }
.day h3 { margin: 0 0 0.4rem; font-size: 0.85rem; }
.slot { font-size: 0.85rem; padding: 0.25rem 0; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 1rem; align-items: center; margin-bottom: 0.8rem; }
.thread { display: flex; flex-direction: column; gap: 0.55rem; max-width: 40rem; }
.bubble { padding: 0.55rem 0.8rem; border-radius: 12px; max-width: 32rem; }
.bubble.in { background: var(--card); border: 1px solid var(--line); }
.bubble.out { background: var(--accent-soft); align-self: flex-end; }
.bubble .muted { font-size: 0.8rem; }
.mask { font-family: ui-monospace, monospace; letter-spacing: 0.04em; }
.login-body { display: grid; min-height: 100vh; place-items: center; }
.login-card { width: min(26rem, calc(100% - 2rem)); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.checks { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.4rem; }
.checks label { margin: 0; }
fieldset.choice {
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft);
  margin: 0.8rem 0 0.2rem; padding: 0.55rem 0.8rem 0.75rem;
}
fieldset.choice legend { font-weight: 700; padding: 0 0.25rem; }
fieldset.choice .muted { margin: 0.1rem 0 0.35rem; }
.public { max-width: 46rem; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.public h1 { font-size: 2rem; }
.lede { font-size: 1.15rem; }
.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin: 0.45rem 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.actions a { text-decoration: none; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .layout nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .week { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}
/* сайдбар шелла: пункты всегда столбиком, по одному в строке */
.sb nav { flex-direction: column; flex-wrap: nowrap; border: 0; }
.tariff-bar { padding: 0.3rem 1.2rem; font-size: 0.85rem; background: #F3F3F3; border-bottom: 1px solid var(--line); }
.tariff-bar a { color: var(--muted); text-decoration: none; }
.tariff-bar.red { background: #F9E7E5; }
.tariff-bar.red a { color: var(--danger); font-weight: 600; }
.banner { margin: 0 0 1rem; }
tr.warn td { color: var(--danger); }
.chat-form { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.chat-form input { flex: 1; }
details.about { margin-top: 1.6rem; }
details.about summary { cursor: pointer; color: var(--muted); }
/* Помощник (часть 12): плавающая кнопка и панель справа */
.assistant-fab {
  position: fixed; right: 1rem; bottom: 1rem; margin: 0; z-index: 30;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
#assistant-panel {
  position: fixed; right: 1rem; bottom: 3.8rem; width: 24rem;
  max-width: calc(100vw - 2rem); z-index: 29;
}
.assistant-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .8rem; box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
}
.assistant-head { display: flex; align-items: baseline; gap: .5rem; }
.assistant-head span { flex: 1; font-size: .8rem; }
.assistant-head button { margin: 0; }
.assistant-log { max-height: 18rem; overflow-y: auto; margin: .6rem 0; }
.assistant-form { display: flex; gap: .4rem; }
.assistant-form input { flex: 1; max-width: none; margin: 0; }
.assistant-form button { margin: 0; }
.assistant-hints { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.assistant-hints button { margin: 0; font-size: .8rem; padding: .25rem .5rem; }

/* ---------- шелл приложения: сайдбар + топбар (кабинет/админка/главная) ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sb {
  width: clamp(240px, 16vw, 292px); min-width: clamp(240px, 16vw, 292px);
  background: #F3F3F3; border-right: 1px solid var(--line);
  overflow: hidden; display: block;
  transition: width .25s ease, min-width .25s ease, border-color .25s ease;
}
.sb.collapsed { width: 0; min-width: 0; border-right-color: transparent; }
.sb-inner { width: clamp(240px, 16vw, 292px); height: 100%; display: flex; flex-direction: column; }
.sb-brand { padding: clamp(14px, 1.6vw, 20px) clamp(12px, 1.2vw, 18px) 6px; }
.sb-brand img { height: 32px; width: auto; display: block; }
.sb-business {
  padding: 0 clamp(12px, 1.2vw, 18px) 10px;
  font-size: 13px; color: var(--muted);
}
.sb nav {
  border-right: 0; background: transparent; padding: 4px clamp(8px, 1vw, 14px); gap: 2px;
  overflow-y: auto; flex: 1;
}
.sb nav a { padding: 8px 10px; font-size: 14px; border-radius: 8px; }
.sb-bottom { margin-top: auto; padding: 12px clamp(12px, 1.2vw, 18px) 14px; border-top: 1px solid var(--line); }
.sb-bottom .who { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sb-bottom .ava {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.sb-bottom .who span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.sb-bottom form { margin: 0; }
.sb-bottom button { margin: 0; }
.tb {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(10px, 1.6vw, 24px);
  background: var(--paper); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.tb-l { display: flex; align-items: center; gap: 8px; }
.tb-title { font-size: 15px; font-weight: 600; }
.tb-btn {
  width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--muted); padding: 0; margin: 0;
}
.tb-btn:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
.tb-btn svg { width: 18px; height: 18px; }
.backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.28); z-index: 35; border: none; padding: 0; cursor: default;
}
@media (max-width: 700px) {
  .sb { position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; box-shadow: 0 0 28px rgba(0,0,0,0.18); }
  .sb.collapsed { box-shadow: none; }
  .app:not(.sb-collapsed) .backdrop { display: block; }
  .main .page { padding: 1rem 0.8rem 2rem; }
}
