/* Pantheon — UI в стиле Telegram: чистый плоский sans, фирменный синий,
   список-«чаты» с круглыми аватарами, светлая/тёмная (ночная) тема. */

:root {
  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --surface: #ffffff;
  --sel: #eaf3fb;
  --border: #e7e8ea;
  --divider: #eeeef0;
  --text: #1c1e21;
  --muted: #707579;
  --faint: #a2a6ab;
  --primary: #3390ec;
  --primary-hover: #2b82d9;
  --on-primary: #ffffff;
  --ok: #4dcd5e;
  --warn: #e8a13a;
  --err: #e15656;
  --r: 10px;
  --r-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", sans-serif;
}

/* Тёмная тема: по системе, если не выбрана явно светлая; и по явному выбору. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17212b;
    --bg-2: #202b36;
    --surface: #17212b;
    --sel: #2b5278;
    --border: #101921;
    --divider: #232e3c;
    --text: #ffffff;
    --muted: #7d8b99;
    --faint: #5e6b78;
    --primary: #64b5ef;
    --primary-hover: #78c1f3;
    --on-primary: #ffffff;
    --ok: #4dcd5e;
    --warn: #e8b04a;
    --err: #ec6a6a;
  }
}
:root[data-theme="dark"] {
  --bg: #17212b;
  --bg-2: #202b36;
  --surface: #17212b;
  --sel: #2b5278;
  --border: #101921;
  --divider: #232e3c;
  --text: #ffffff;
  --muted: #7d8b99;
  --faint: #5e6b78;
  --primary: #64b5ef;
  --primary-hover: #78c1f3;
  --on-primary: #ffffff;
  --ok: #4dcd5e;
  --warn: #e8b04a;
  --err: #ec6a6a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.muted { color: var(--muted); }
p { margin: 0 0 10px; }

/* Header */
.app-header { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-header .bar { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 600; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand::before { content: ""; display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); vertical-align: -4px; margin-right: 9px; }
.nav { display: flex; gap: 6px; align-items: center; }
.nav a { color: var(--muted); font-weight: 500; padding: 7px 12px; border-radius: var(--r-sm); }
.nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--sel); color: var(--primary); }
.spacer { flex: 1; }
.userbox { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

/* Layout */
.container { max-width: 1080px; margin: 20px auto; padding: 0 20px 40px; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-pad { padding: 18px 20px; }

/* Page head */
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.pagehead .cnt { color: var(--muted); font-size: 14px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1; padding: 10px 16px; border-radius: var(--r-sm); border: none; background: var(--bg-2); color: var(--text); transition: .12s; }
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--bg-2); }

/* Forms */
label { font-size: 13px; color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--bg-2);
  border: 1px solid transparent; border-radius: var(--r-sm); padding: 10px 13px; outline: none; transition: .12s;
}
input:focus, select:focus, textarea:focus { background: var(--surface); border-color: var(--primary); }
input[type=search] { border-radius: 20px; background: var(--bg-2); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* Avatar */
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 17px; }
.avatar-lg { width: 72px; height: 72px; font-size: 27px; }

/* Chat-list (список компаний) */
.chatlist { }
.chat { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r); cursor: pointer; }
.chat:hover { background: var(--bg-2); }
.chat.active { background: var(--sel); }
.chat.active .c-sub, .chat.active .c-flags { color: var(--text); }
.chat-body { flex: 1; min-width: 0; }
.c-name { font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-flags { color: var(--faint); font-size: 12px; margin-top: 1px; }
.c-flags .on { color: var(--muted); }
.pager { display: flex; gap: 14px; align-items: center; padding: 12px; font-size: 13px; color: var(--muted); }

/* Detail (профиль) */
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 20px 18px; border-bottom: 1px solid var(--divider); }
.profile-head .p-name { font-size: 20px; font-weight: 600; margin-top: 12px; }
.profile-head .p-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.info-row { display: flex; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--divider); }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); font-size: 13px; width: 96px; flex: none; }
.info-row .v a, .info-row .v { font-size: 14px; }
.info-row .v div { margin-bottom: 3px; }

/* Table */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.tbl tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Dropdown-меню с галочками (фильтр по рубрикам) */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::marker { content: ""; }
.dropdown-menu { position: absolute; z-index: 30; margin-top: 6px; min-width: 240px; max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 7px; }
.dropdown-menu .dm-item { display: flex; gap: 9px; align-items: center; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.dropdown-menu .dm-item:hover { background: var(--bg-2); }

/* Status pill (Telegram-стиль: мягкая заливка) */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; background: var(--bg-2); color: var(--muted); }
.pill-ok { background: rgba(77,205,94,.16); color: #34a94a; }
.pill-run { background: rgba(51,144,236,.16); color: var(--primary); }
.pill-warn { background: rgba(232,161,58,.18); color: #c78321; }
.pill-err { background: rgba(225,86,86,.16); color: var(--err); }

/* Index list */
.menu .item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--divider); }
.menu .item:last-child { border-bottom: none; }
.menu .item:hover { background: var(--bg-2); text-decoration: none; }
.menu .item .m-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--sel); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.menu .item .m-t { font-weight: 600; font-size: 15px; color: var(--text); }
.menu .item .m-d { color: var(--muted); font-size: 13px; }

/* Auth */
.auth { max-width: 360px; margin: 10vh auto 0; }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; margin-bottom: 20px; }

/* Notice */
.notice { background: rgba(232,161,58,.14); color: #a9781f; border-radius: var(--r-sm); padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.notice-err { background: rgba(225,86,86,.14); color: var(--err); }
