/* СлотМастер — консоль главного админа.
   Палитра «диспетчерская расписаний»: чернила на белом листе, зелёный слот — включено,
   янтарь — внимание, красный — выключено/ошибка. Системный шрифт, табличные цифры. */
:root {
  --ink: #1F2A44;
  --ink-soft: #4A5672;
  --ink-faint: #8A93A8;
  --paper: #FAFBFC;
  --sheet: #FFFFFF;
  --line: #E3E7EE;
  --rail: #EEF1F6;
  --slot: #2F7D5B;
  --slot-bg: #E7F3EC;
  --amber: #B7791F;
  --amber-bg: #FBF1DF;
  --red: #B23B3B;
  --red-bg: #F8E5E5;
  --focus: #3B5BDB;
  --r-sm: 4px;
  --r-md: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* раскладка: левая «карта бизнеса» + рабочая область */
.layout { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.rail { background: var(--rail); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; margin: 0 6px 18px; }
.brand small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-soft); }
.nav { display: grid; gap: 2px; margin-bottom: 22px; }
.nav a { display: block; padding: 7px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink-soft); }
.nav a:hover { background: #E2E7F0; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.map h2 { font-size: 13px; color: var(--ink-faint); font-weight: 600; margin: 0 8px 6px; }
.map details { margin: 0 0 2px; }
.map summary { cursor: pointer; padding: 5px 8px; border-radius: var(--r-sm); list-style: none; display: flex; justify-content: space-between; gap: 8px; }
.map summary::-webkit-details-marker { display: none; }
.map summary:hover { background: #E2E7F0; }
.map .niche { display: flex; justify-content: space-between; padding: 3px 8px 3px 22px; color: var(--ink-soft); text-decoration: none; border-radius: var(--r-sm); font-size: 14px; }
.map .niche:hover { background: #E2E7F0; color: var(--ink); }
.count { color: var(--ink-faint); font-size: 13px; }
.count.has { color: var(--slot); font-weight: 600; }

main { padding: 28px 36px 60px; max-width: 1280px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.015em; }
.sub { color: var(--ink-soft); margin: 0 0 22px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

/* таблицы — основной носитель информации */
table { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--ink-soft); background: #F5F7FA; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F5F7FA; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

/* состояния */
.state { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.state.on { background: var(--slot-bg); color: var(--slot); }
.state.off { background: var(--red-bg); color: var(--red); }
.state.warn { background: var(--amber-bg); color: var(--amber); }
.state.muted { background: var(--rail); color: var(--ink-soft); }
.why { color: var(--ink-soft); font-size: 13px; margin: 4px 0 0; padding-left: 16px; }

/* формы и кнопки */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 14px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
input, select, textarea { border: 1px solid #CBD2DE; border-radius: var(--r-sm); padding: 7px 9px; background: #fff; min-width: 0; }
input[type="number"] { width: 110px; }
textarea { width: 100%; min-height: 72px; }
button { border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: 7px 14px; cursor: pointer; }
button:hover { background: #2C3A5C; }
button.ghost { background: transparent; color: var(--ink); border-color: #CBD2DE; }
button.ghost:hover { background: var(--rail); }
button.danger { background: var(--red); border-color: var(--red); }
button.small { padding: 3px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--slot-bg); color: var(--slot); padding: 2px 4px 2px 10px; border-radius: 999px; font-size: 13px; }
.chip button { background: transparent; border: 0; color: var(--slot); padding: 0 6px; }

.branch { background: var(--sheet); border: 1px solid var(--line); border-left: 4px solid var(--slot); border-radius: var(--r-md); padding: 14px 16px; margin: 0 0 16px; }
.branch header { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.branch .addr { font-weight: 600; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; margin: 0 0 18px; }
.meta div span { display: block; font-size: 13px; color: var(--ink-faint); }

.notice { padding: 10px 14px; border-radius: var(--r-md); margin: 0 0 16px; }
.notice.info { background: #EAF0FB; color: #24407A; }
.notice.warn { background: var(--amber-bg); color: #7A5214; }
.notice.err { background: var(--red-bg); color: #7E2525; }
.empty { color: var(--ink-soft); padding: 18px 0; }

.login { max-width: 380px; margin: 14vh auto; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-md); padding: 28px; }
.login h1 { font-size: 22px; }

dialog { border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; max-width: 520px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(31, 42, 68, .35); }
dialog h2 { margin-top: 0; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-md); }

/* содержимое никогда не шире экрана: широкие таблицы прокручиваются внутри себя */
.layout > * { min-width: 0; }

/* ---------- мобильная версия консоли ---------- */
.topbar { display: contents; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  :root { font-size: 16px; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }

  /* верхняя панель: название и кнопка «Меню»; разделы — полным списком по нажатию */
  .rail { position: sticky; top: 0; z-index: 5; height: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
  .brand { margin: 0; }
  .brand small { display: none; }
  .menu-btn { display: inline-block; min-height: 44px; padding: 8px 16px; }
  .nav, .map, .logout { display: none; }
  body.menu-open .nav { display: grid; gap: 0; padding: 4px 8px 8px; margin: 0; border-top: 1px solid var(--line); max-height: calc(100vh - 70px); overflow: auto; }
  body.menu-open .nav a { padding: 13px 12px; font-size: 17px; border-radius: var(--r-sm); }
  body.menu-open .logout { display: block; margin: 0 16px 14px; min-height: 44px; }

  main { padding: 16px 14px 56px; }
  h1 { font-size: 23px; }
  h2 { font-size: 18px; margin-top: 24px; }
  .sub { font-size: 15px; }

  /* крупные цели для пальца */
  button { min-height: 44px; padding: 10px 16px; }
  button.small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }   /* 16px — iOS не увеличивает страницу при вводе */
  .row { flex-direction: column; align-items: stretch; }
  .row > * { width: 100%; }
  .meta { grid-template-columns: 1fr 1fr; gap: 10px 14px; }

  /* таблицы — карточками с подписями полей */
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  table { border: 0; background: transparent; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-md); margin: 0 0 10px; padding: 6px 0; }
  td { border: 0; padding: 6px 14px; display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px; align-items: start; text-align: left; }
  td.num { text-align: left; }
  td::before { content: attr(data-label); color: var(--ink-faint); font-size: 13px; padding-top: 2px; }
  td:not([data-label])::before, td[data-label=""]::before { content: none; }
  td:not([data-label]), td[data-label=""] { display: block; }
  td input, td select { width: 100%; }
  tr.click:hover td { background: transparent; }
  tr.click { box-shadow: inset 4px 0 0 var(--slot); }

  .branch { padding: 12px; border-left-width: 4px; }
  .branch header { flex-direction: column; align-items: stretch; }
  .chips { margin: 6px 0; }

  /* окна подтверждения — снизу экрана */
  dialog { margin: auto 0 0; max-width: none; width: 100%; border-radius: 14px 14px 0 0; max-height: 92vh; overflow: auto; }
  dialog .actions { flex-direction: column-reverse; }
  dialog .actions button { width: 100%; }
  .toast { left: 14px; right: 14px; bottom: 14px; text-align: center; }
  .login { margin: 8vh 14px; padding: 22px; }
}
pre.code { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.45; white-space: pre; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; width: 100%; }
h2 { font-size: 18px; margin: 26px 0 8px; }


/* Секция «Боты и каналы» в паспорте тенанта */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px 18px; margin: 16px 0; }
.card h2 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.card .sub { color: #6b7280; font-size: 13px; margin: 0 0 12px; }
.card .row { margin: 12px 0 0; }
.card table code { font-size: 11px; background: #f3f4f6; padding: 2px 5px; border-radius: 3px; word-break: break-all; }
