/* Оформление портала: прежняя раскладка (скруглённые карточки, системный шрифт) в цветах сайта –
   белое и чёрное, голубой акцент, малая доля оранжевого. Дневная и ночная темы. */
:root {
  color-scheme: light;
  --bg: #F4F4F4; --panel: #FFFFFF; --ink: #1A1A1A; --head: #0A0A0A; --muted: #6B6B6B; --line: #DCDCDC;
  --accent: #0077BE; --accent-ink: #FFFFFF; --mark: #00A4FF; --orange: #ED651C;
  --danger: #C62828; --ok: #1B7F3B; --warn: #C94F0E;
  --radius: 8px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0A0A; --panel: #161616; --ink: #EDEDED; --head: #FFFFFF; --muted: #9A9A9A; --line: #2B2B2B;
  --accent: #00A4FF; --accent-ink: #0A0A0A; --mark: #00A4FF; --orange: #ED651C;
  --danger: #FF6B6B; --ok: #62C85A; --warn: #F28C55;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0A0A0A; --panel: #161616; --ink: #EDEDED; --head: #FFFFFF; --muted: #9A9A9A; --line: #2B2B2B;
    --accent: #00A4FF; --accent-ink: #0A0A0A; --mark: #00A4FF; --orange: #ED651C;
    --danger: #FF6B6B; --ok: #62C85A; --warn: #F28C55;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); display: grid; grid-template-columns: 208px 1fr; }
body.center { display: grid; grid-template-columns: 1fr; place-items: center; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--head); }
h1 { font-size: 22px; margin: 0 0 12px; } h2 { font-size: 17px; margin: 20px 0 8px; } h3 { font-size: 15px; margin: 14px 0 6px; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side a { color: var(--ink); padding: 7px 10px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: var(--bg); text-decoration: none; }
.side a.on { background: var(--accent); color: var(--accent-ink); }
.side .brand { font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.side .brand img { display: block; max-width: 100%; max-height: 40px; }
.side a.brand:hover { background: none; }
.brand-logo { display: block; max-width: 100%; max-height: 48px; margin-bottom: 6px; align-self: flex-start; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
main { padding: 20px 28px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card.narrow { width: min(380px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); } .error { color: var(--danger); } .ok { color: var(--ok); } .warn { color: var(--warn); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; padding: 7px 12px; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 7px 10px; color: var(--muted); text-align: left; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
.list > li.unread { border-left: 3px solid var(--accent); }
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.badge { background: var(--orange); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.tag { display: inline-block; white-space: nowrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs a { padding: 7px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; }
.board > .col { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-width: 240px; width: 260px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--head); color: var(--panel); border-left: 4px solid var(--mark); padding: 10px 14px; border-radius: var(--radius); max-width: 320px; }
.side a.brand:hover { background: none; }
button, .button { white-space: nowrap; vertical-align: middle; }
main input, main select, main textarea { max-width: 100%; min-width: 0; }
.row > * { min-width: 0; }
.tabs { flex-wrap: wrap; }
.tabs a, .side a, th { white-space: nowrap; }
main img, main video { max-width: 100%; height: auto; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* Значки меню */
.ico { width: 20px; height: 20px; flex: 0 0 20px; }
.side a, .side button.link { justify-content: flex-start; gap: 10px; }
.side button.link { display: flex; align-items: center; }
.side .lbl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.side .brand { justify-content: flex-start; }

/* Меню одними значками: узкая полоса слева, подписи – во всплывающей подсказке */
@media (min-width: 861px) {
  :root[data-nav="icons"] body { grid-template-columns: 60px 1fr; }
  :root[data-nav="icons"] .side { padding: 12px 6px; align-items: stretch; }
  :root[data-nav="icons"] .side .lbl { display: none; }
  :root[data-nav="icons"] .side a, :root[data-nav="icons"] .side button.link { justify-content: center; padding: 9px 0; position: relative; }
  :root[data-nav="icons"] .side .brand { height: 36px; overflow: hidden; padding: 0; justify-content: center; font-size: 0; }
  :root[data-nav="icons"] .side .brand img { max-width: none; height: 30px; max-height: 30px; object-fit: cover; object-position: left center; width: 30px; }
  :root[data-nav="icons"] .side .badge { position: absolute; top: 2px; right: 4px; font-size: 10px; padding: 0 5px; }
}

/* Меню сверху по выбору человека: полоса закреплена, прокручивается содержимое */
@media (min-width: 861px) {
  :root[data-nav="top"], :root[data-nav="top"] body, :root[data-nav="top"] body { height: 100%; }
  :root[data-nav="top"] body { display: flex; flex-direction: column; height: 100dvh; }
  :root[data-nav="top"] body.center { display: grid; height: auto; min-height: 100dvh; }
  :root[data-nav="top"] .side { position: static; height: auto; flex: 0 0 auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  :root[data-nav="top"] .side a { padding: 6px 10px; font-size: 14px; }
  :root[data-nav="top"] .side .brand { margin: 0 8px 0 0; flex: 0 0 auto; padding: 4px 6px; }
  :root[data-nav="top"] .side .brand img { height: 26px; width: auto; max-width: none; max-height: none; }
  :root[data-nav="top"] .side .lbl { flex: 0 1 auto; }
  :root[data-nav="top"] .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  :root[data-nav="top"] .side-foot form { display: flex; }
  :root[data-nav="top"] .side-foot .lbl { display: none; }
  :root[data-nav="top"] .side-foot a, :root[data-nav="top"] .side-foot button.link { padding: 6px 8px; }
  :root[data-nav="top"] button.link { width: auto; }
  :root[data-nav="top"] main { flex: 1 1 auto; min-height: 0; overflow: auto; max-width: 100%; width: 100%; }
  :root[data-nav="top"] main .chats { height: 100%; }
}

/* Планшет в книжном повороте и телефон: меню всегда сверху */
@media (max-width: 860px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; height: 100dvh; }
  body.center { display: grid; height: auto; min-height: 100dvh; }
  .side { position: static; height: auto; flex: 0 0 auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side a { padding: 6px 10px; font-size: 14px; }
  .side .brand { margin: 0 8px 0 0; flex: 0 0 auto; padding: 4px 6px; }
  .side .brand img { height: 26px; width: auto; max-width: none; max-height: none; }
  .side .lbl { flex: 0 1 auto; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-foot form { display: flex; }
  .side-foot .lbl { display: none; }
  .side-foot a, .side-foot button.link { padding: 6px 8px; }
  button.link { width: auto; }
  main { flex: 1 1 auto; min-height: 0; overflow: auto; max-width: 100%; width: 100%; }
  main .chats { height: 100%; }
  main { padding: 14px; }
  .page-head { gap: 8px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .tabs a { flex: 0 0 auto; }
  main table { display: block; overflow-x: auto; max-width: 100%; }
  #toasts { right: 10px; left: 10px; bottom: 10px; }
  .toast { max-width: none; }
}

/* Телефон и низкий экран (телефон в альбомном повороте): в меню одни значки, подпись – у открытого раздела */
@media (max-width: 560px), (max-height: 480px) and (max-width: 860px) {
  .side { gap: 0; padding: 4px 6px; }
  .side .lbl { display: none; }
  .side a.on .lbl { display: inline; }
  .side a, .side button.link { padding: 8px 9px; }
  .side .brand { display: none; }
  main { padding: 10px; }
  h1 { font-size: 19px; }
  .card { padding: 10px 12px; }
  button, .button { padding: 8px 12px; }
}
