/* Пульт — стили. Адаптив: <600 телефон (1 колонка, карточки), 600–1100 (2 колонки,
   прокрутка таблиц), >1100 (3–4 колонки, меню слева). Тёмная/светлая темы. */
:root {
  --bg: #10151c; --bg2: #171e28; --card: #1c2634; --line: #2a3648;
  --text: #dbe4f0; --muted: #7e8ca0; --accent: #4da3ff; --good: #35c26e;
  --warn: #e0b341; --bad: #e05c5c;
}
html.light {
  --bg: #f2f5f9; --bg2: #e8edf4; --card: #ffffff; --line: #d5dde8;
  --text: #1d2733; --muted: #67758a; --accent: #1668c7; --good: #1d9e53;
  --warn: #a97f12; --bad: #c94040;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
h2 { margin: 18px 4px 10px; font-size: 20px; }
h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; }
.upd { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.dot { font-size: 12px; } .dot.g { color: var(--good); } .dot.y { color: var(--warn); } .dot.r { color: var(--bad); }
button.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font-size: 14px; cursor: pointer; min-height: 34px;
}
button.ghost:hover { border-color: var(--accent); }
.alerts { max-width: 1400px; margin: 0 auto; }

/* меню */
.side { display: flex; gap: 2px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.side a {
  padding: 11px 16px; color: var(--muted); font-size: 14px; white-space: nowrap;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.side a.on { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 1400px; margin: 0 auto; padding: 12px 14px 60px; min-width: 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* плитки */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.t-title { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; overflow-wrap: break-word; }
.t-val { overflow-wrap: anywhere; }
.t-val { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.t-delta { font-size: 12px; min-height: 15px; }
.up { color: var(--good); } .down { color: var(--bad); }

/* карточки и таблицы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; min-width: 0; }
.card canvas { max-height: 260px; width: 100% !important; max-width: 100% !important; }
.tbl-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.tbl-search {
  flex: 1; max-width: 280px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px;
}
.tbl-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; background: var(--card); }
th:first-child, td:first-child { position: sticky; left: 0; background: var(--card); }
tr:hover td { background: var(--bg2); }
tr:hover td:first-child { background: var(--bg2); }
.hint { color: var(--muted); cursor: help; font-size: 12px; }
.nosrc { color: var(--warn); font-size: 13px; margin: 6px 2px 14px; }

/* доступ запрещён / регистрация */
.denied-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.denied { text-align: center; padding: 30px 20px; max-width: 420px; }
.denied h1 { font-size: 24px; margin-bottom: 8px; }
.denied p { color: var(--muted); }
button.big {
  margin-top: 16px; background: var(--accent); color: #fff; border: 0;
  border-radius: 10px; padding: 13px 22px; font-size: 16px; cursor: pointer;
  min-height: 48px; min-width: 240px;
}
.msg { margin-top: 12px; color: var(--warn) !important; font-size: 14px; }

/* --- телефон <600 --- */
@media (max-width: 599px) {
  body { font-size: 14px; }
  main { padding: 10px 10px 80px; }
  .grid { grid-template-columns: 1fr; }
  .t-val { font-size: 20px; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; border-top: 1px solid var(--line); border-bottom: 0; justify-content: space-around; }
  .side a { flex: 1; text-align: center; padding: 12px 4px; font-size: 13px; }
  /* таблицы -> карточки */
  .tbl-scroll { overflow-x: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  .tbl-scroll table tbody tr {
    border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px;
    padding: 8px 10px; background: var(--bg2);
  }
  .tbl-scroll table tbody td { border: 0; padding: 3px 0; background: transparent !important; }
  .tbl-scroll table tbody td::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12.5px; }
  th:first-child, td:first-child { position: static; }
  .upd { display: none; }
}

/* --- планшет 600–1100 --- */
@media (min-width: 600px) and (max-width: 1099px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .side { border-bottom: 1px solid var(--line); }
}

/* --- ноутбук >1100 --- */
@media (min-width: 1100px) {
  body { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / 3; }
  .alerts { grid-column: 1 / 3; }
  .side { flex-direction: column; border-right: 1px solid var(--line); border-bottom: 0; position: sticky; top: 51px; height: calc(100vh - 51px); }
  .side a { border-bottom: 0; border-left: 2px solid transparent; padding: 11px 18px; }
  .side a.on { border-left-color: var(--accent); }
  main { grid-column: 2; }
}

/* --- этап 2: карточка клиента, вкладки, тепловая карта --- */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(127,127,127,.12); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 3vh 12px; overflow-y: auto; }
.modal { max-width: 860px; width: 100%; max-height: 92vh; overflow-y: auto; padding: 16px 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal h4 { margin: 14px 0 6px; font-size: 14px; }
.tabbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tabbar .tab.on { border-color: var(--accent); color: var(--accent); }
table.heat { border-collapse: collapse; font-size: 11px; }
table.heat th, table.heat td { padding: 2px 3px; text-align: center; min-width: 20px; }
@media (max-width: 599px) {
  .modal { padding: 12px; }
  table.heat { font-size: 9px; }
  table.heat th, table.heat td { padding: 1px 2px; min-width: 14px; }
}
