:root {
  --bg: #f3f6f8; --card: #fff; --text: #2b3440; --muted: #8a96a3; --line: #e3e8ee;
  --head: #dbe3ea; --accent: #2a8fd0; --green: #18a058; --red: #e5484d; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
h1 { font-size: 26px; font-weight: 500; margin: 0; color: #3a6f98; }
.crumbs { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }

.top { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; z-index: 5; background: var(--bg); }
.pill { background: var(--card); border-radius: 20px; padding: 6px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 3px #0001; }
.pill.title { font-weight: 600; }
.clock { display: flex; flex-direction: column; font-size: 12px; line-height: 1.2; text-align: right; }
.clock b { font-size: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
:root[data-theme="dark"] { --bg: #161b22; --card: #212830; --text: #d6dde5; --muted: #8b97a5; --line: #303a45; --head: #2a3440; }
:root[data-theme="dark"] .btn { background: var(--card); color: var(--text); }
:root[data-theme="dark"] .side a:hover, :root[data-theme="dark"] .side a.active { background: #26323f; }
:root[data-theme="dark"] .side a.active { background: #2b3a4a; }
:root[data-theme="dark"] .cal .d { background: var(--card); }
:root[data-theme="dark"] .sched tr.grp td { background: #1d2a36; }
:root[data-theme="dark"] .form input, :root[data-theme="dark"] .form select, :root[data-theme="dark"] .form textarea { background: var(--bg); }
.logo { color: var(--accent); font-size: 18px; }
.balance { font-weight: 600; white-space: nowrap; }
.balance::before { content: "💳 "; }
.icon { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--text); }
.icon:hover { background: var(--bg); }

/* меню как в CRMpro: всегда на экране (на компьютере), группы на цветных подложках,
   активный пункт — белая карточка с полоской слева; на телефоне выезжает по ☰ */
.side { position: fixed; top: 0; left: 0; bottom: 0; width: 256px; display: flex; flex-direction: column; z-index: 6; background: var(--card); border-right: 1px solid var(--line); transition: transform .2s; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 700; color: var(--text); flex: none; }
.side .brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.side .brand .mark svg { width: 18px; height: 18px; }
.side .brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.side .nav { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.ng { border-radius: 12px; padding: 4px; background: var(--g-bg); box-shadow: inset 0 0 0 1px var(--g-ring); transition: background-color .2s, box-shadow .2s; }
.ng-work  { --g-bg: #ECF5FC; --g-ring: rgb(160 205 238 / .7); --g-title: #1D6FA5; }
.ng-stats { --g-bg: #EDF5EF; --g-ring: rgb(167 213 180 / .55); --g-title: #3F6B4C; }
.ng-admin { --g-bg: #F2F4F7; --g-ring: rgb(203 213 225 / .7); --g-title: #64748B; }
.ng.cur { filter: saturate(1.35) brightness(.985); box-shadow: inset 0 0 0 1px var(--g-ring), 0 8px 18px -12px rgb(15 23 42 / .35); }
.ng-title { padding: 3px 8px 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--g-title); }
.side a.ni { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 8px 9px 10px; border-radius: 9px; font-size: 15px; font-weight: 600; color: #475569; transition: background-color .18s, color .18s; }
.side a.ni .ic { width: 20px; height: 20px; flex: none; display: inline-flex; color: #94A3B8; transition: transform .18s, color .18s; }
.side a.ni .ic svg { width: 19px; height: 19px; }
.side a.ni .t { min-width: 0; line-height: 1.3; }
@media (hover: hover) and (pointer: fine) {
  .side a.ni:hover { background: rgb(255 255 255 / .85); color: #0F172A; box-shadow: 0 1px 2px rgb(15 23 42 / .05); }
  .side a.ni:hover .ic { color: var(--accent); transform: translateX(2px); }
}
.side a.ni.active { background: #fff; color: #0F172A; box-shadow: 0 1px 2px rgb(15 23 42 / .06); }
.side a.ni.active .ic { color: var(--accent); }
.side a.ni.active::before { content: ""; position: absolute; left: 0; top: 50%; width: 4px; height: 20px; margin-top: -10px; border-radius: 0 4px 4px 0; background: var(--accent); }
.side .nb { position: static; margin-left: auto; font-size: 12px; padding: 1px 7px; line-height: 18px; border-radius: 10px; }
.side .me { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.side .me .ava { width: 34px; height: 34px; flex: none; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #1D6FA5); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.side .me .who { flex: 1; min-width: 0; }
.side .me .who b, .side .me .who small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side .me .who b { font-size: 14px; }
.side .me .who small { font-size: 12px; color: var(--muted); }
.side .me button { border: 0; background: none; color: #94A3B8; padding: 7px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.side .me button:hover { background: var(--bg); color: var(--text); }
.side .me button svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .ng-work  { --g-bg: #1b2a38; --g-ring: #27445c; --g-title: #7cc0ec; }
:root[data-theme="dark"] .ng-stats { --g-bg: #1c2b22; --g-ring: #2c4a37; --g-title: #8fc9a1; }
:root[data-theme="dark"] .ng-admin { --g-bg: #222a33; --g-ring: #333e4a; --g-title: #9aa7b6; }
:root[data-theme="dark"] .side a.ni { color: #c4ced9; }
:root[data-theme="dark"] .side a.ni.active, :root[data-theme="dark"] .side a.ni:hover { background: #2b3642; color: #fff; }
.backdrop { display: none; }
#menuBtn { display: none; }
.top .logo { display: none; }

main { padding: 68px 28px 40px 284px; max-width: 1960px; }
.top { left: 256px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 4px #0000000f; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 8px; }
.bar input, .bar select { border: 0; border-bottom: 1px solid var(--line); padding: 5px 4px; background: none; font: inherit; min-width: 120px; flex: 1; }
.bar .sp { flex: 1; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 14px; cursor: pointer; font: inherit; color: var(--text); }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.green { border-color: var(--green); color: var(--green); }
.btn.red { border-color: var(--red); color: var(--red); }
.btn.sm { padding: 4px 11px; font-size: 13px; }
.chips { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-bottom: 8px; }
.chips a { font-weight: 600; }
.chips a.on { text-decoration: underline; }
.meta { font-size: 13px; color: var(--muted); margin: 4px 2px 8px; }

table { width: 100%; border-collapse: collapse; }
th { background: var(--head); text-align: left; padding: 9px 10px; font-weight: 600; font-size: 14px; }
td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; }
tr.total td { background: var(--head); font-weight: 600; }
td.num, th.num { text-align: center; }
.tbl { overflow: auto; }
.badge { display: inline-block; color: #fff; border-radius: 10px; padding: 2px 10px; font-size: 12px; }
.small { font-size: 13px; color: var(--muted); }
.lead-info .msg { margin: 4px 0; }
.lead-row td:first-child { border-left: 3px solid var(--accent); }
.fav { cursor: pointer; color: #c9d1d9; font-size: 18px; }
.fav.on { color: #e5484d; }
.time-big { color: #8a3ffc; font-weight: 600; font-size: 16px; }
.overdue { color: var(--red); }

.row-card { display: flex; align-items: center; gap: 16px; padding: 12px 16px; margin-bottom: 8px; }
.row-card .who { flex: 2; }
.row-card .bal { flex: 1; }
.row-card input { width: 140px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { padding: 16px; margin-bottom: 16px; }
.panel h3 { text-align: center; font-weight: 500; margin: 0 0 12px; }
.rating { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.rating .card { padding: 14px 18px; min-width: 260px; }

.pager { display: flex; justify-content: center; gap: 6px; margin: 12px; }
.tabs { display: flex; gap: 20px; margin-bottom: 12px; }
.tabs a { color: var(--muted); padding-bottom: 4px; }
.tabs a.on { color: var(--accent); border-bottom: 2px solid var(--accent); }
.sched td.cell { text-align: center; color: var(--accent); cursor: pointer; }
.sched td.cell.off { color: var(--muted); }
.sched td.cell.custom { background: #fff7e0; }
.sched tr.grp td { background: #e8f3fb; text-align: center; font-weight: 600; }
.online { background: var(--green); color: #fff; border-radius: 4px; padding: 2px 10px; font-size: 13px; }
.idle { background: #6b7785; color: #fff; border-radius: 4px; padding: 2px 10px; font-size: 13px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .d { min-height: 90px; background: #fff; border-radius: 6px; padding: 4px; font-size: 13px; }
.cal .d.today { outline: 2px solid var(--accent); }
.cal .ev { background: #8cc63f; color: #fff; border-radius: 3px; padding: 1px 4px; margin-top: 2px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.switch { cursor: pointer; width: 34px; height: 18px; border-radius: 9px; background: #ccc; display: inline-block; position: relative; }
.switch::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 18px; }

.modal { position: fixed; inset: 0; background: #0006; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 20; overflow: auto; }
.modal-box { width: 100%; max-width: 760px; padding: 20px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 3px; }
.form label.wide { grid-column: 1 / -1; }
.form input, .form select, .form textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.log { max-height: 200px; overflow: auto; font-size: 13px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.toast { position: fixed; top: 60px; right: 16px; background: var(--green); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 30; }
.toast.err { background: var(--red); }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.login-card { padding: 30px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.err { color: var(--red); font-size: 13px; min-height: 16px; }

@media (max-width: 1000px) {
  main { padding: 64px 12px 40px 12px; }
  .top { left: 0; }
  #menuBtn { display: inline-flex; }
  .top .logo { display: inline; }
  .side { width: 280px; max-width: 86vw; transform: translateX(-100%); z-index: 21; }
  body.menu-open .side { transform: none; box-shadow: 4px 0 24px #0003; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: #0f172a66; z-index: 20; }
}
@media (max-width: 800px) {
  .grid2, .form { grid-template-columns: 1fr; }
  .row-card { flex-wrap: wrap; }
  .pill.title { display: none; }
  #clockDate { display: none; }
}

/* счётчики, чат */
.side .ic { position: relative; }
.nb { position: absolute; top: -6px; right: -10px; background: var(--red); color: #fff; font-style: normal; font-weight: 600; font-size: 11px; border-radius: 9px; padding: 0 5px; min-width: 18px; text-align: center; line-height: 18px; }
.chat-list .nb { position: static; margin-left: 4px; }
.chat-btn { position: fixed; right: 18px; bottom: 18px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px #0003; z-index: 6; }
.chat-btn .nb { top: 0; right: 0; }
.chat { position: fixed; right: 18px; bottom: 76px; width: min(560px, calc(100vw - 36px)); height: min(460px, calc(100vh - 140px)); display: flex; flex-direction: column; z-index: 15; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-body { flex: 1; display: flex; min-height: 0; }
.chat-list { width: 180px; overflow: auto; border-right: 1px solid var(--line); font-size: 14px; }
.chat-list a { display: block; padding: 7px 10px; color: var(--text); }
.chat-list a.on, .chat-list a:hover { background: #e2ecf4; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-msgs { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.chat-msgs .msg { background: var(--bg); border-radius: 8px; padding: 6px 9px; max-width: 85%; align-self: flex-start; word-wrap: break-word; }
.chat-msgs .msg.me { background: #dcefff; align-self: flex-end; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; background: var(--card); color: var(--text); }
:root[data-theme="dark"] .chat-msgs .msg.me { background: #1f3b55; }
:root[data-theme="dark"] .chat-list a.on { background: #26323f; }
@media (max-width: 600px) { .chat-list { width: 110px; } }
