:root {
  --bg:#eef2f5; --surface:#fff; --surface-2:#f4f7f9; --text:#16212c; --text-muted:#5b6b78;
  --border:#d7dfe4; --accent:#bf5b04; --brand-red:#d3232a;
  --ok:#3f7d58; --ok-soft:#e1efe6; --warn:#b7791f; --warn-soft:#f6ecd8;
  --crit:#b3261e; --crit-soft:#fae3e1; --fixed:#3b6e91; --fixed-soft:#e2ecf1;
  --maxp:#6a4fa8; --maxp-soft:#ece7f7; --tg:#1f8fd6; --tg-soft:#dcf0fa;
  --grid-line:#e3e9ed; --grid-off:#f0f3f6;
  --shadow:0 1px 2px rgba(22,33,44,.06),0 4px 14px rgba(22,33,44,.05);
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --bg:#11161b; --surface:#1a2129; --surface-2:#212a33; --text:#e7ecf0; --text-muted:#93a3af;
  --border:#2b3540; --accent:#e2954a; --brand-red:#d8352f;
  --ok:#6fb98a; --ok-soft:#1c2c22; --warn:#e0b158; --warn-soft:#332b17;
  --crit:#f2867c; --crit-soft:#3a1e1b; --fixed:#7bb0d4; --fixed-soft:#1b2a33;
  --maxp:#b09ee0; --maxp-soft:#2a2438; --tg:#6ec3ef; --tg-soft:#16303c;
  --grid-line:#2b3540; --grid-off:#1e262e;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 4px 16px rgba(0,0,0,.25);
}}
:root[data-theme="dark"]{
  --bg:#11161b; --surface:#1a2129; --surface-2:#212a33; --text:#e7ecf0; --text-muted:#93a3af;
  --border:#2b3540; --accent:#e2954a; --brand-red:#d8352f;
  --ok:#6fb98a; --ok-soft:#1c2c22; --warn:#e0b158; --warn-soft:#332b17;
  --crit:#f2867c; --crit-soft:#3a1e1b; --fixed:#7bb0d4; --fixed-soft:#1b2a33;
  --maxp:#b09ee0; --maxp-soft:#2a2438; --tg:#6ec3ef; --tg-soft:#16303c;
  --grid-line:#2b3540; --grid-off:#1e262e;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 4px 16px rgba(0,0,0,.25);
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);
     font-family:"Segoe UI","Helvetica Neue",system-ui,sans-serif;line-height:1.45}
.page{max-width:1400px;margin:0 auto;padding:26px 20px 60px}

h1{font-size:22px;font-weight:650;margin:0}
.logo{height:34px;width:auto;display:block}
.brand{display:flex;flex-direction:column;line-height:1.2}
.brand-sub{font-size:12.5px;font-weight:500;color:var(--text-muted)}
.head{display:flex;align-items:center;gap:14px;margin-bottom:18px;flex-wrap:wrap}
.who{margin-left:auto;font-size:13px;color:var(--text-muted)}

/* вход */
.gate{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:var(--bg);padding:20px;z-index:900}
.gate[hidden]{display:none}
.gate form{display:flex;flex-direction:column;gap:12px;width:100%;max-width:340px;
           background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:30px 28px;box-shadow:var(--shadow)}
.gate h2{margin:0;font-size:17px;text-align:center}
.gate-sep{display:flex;align-items:center;gap:10px;color:var(--text-muted);font-size:12px;margin:2px 0}
.gate-sep::before,.gate-sep::after{content:"";flex:1;height:1px;background:var(--border)}
#bitrixLoginBtn{display:block;text-align:center;text-decoration:none}
.gate .sub{margin:0 0 4px;font-size:12.5px;color:var(--text-muted);text-align:center}
#passwordLoginToggle{width:100%}
#passwordLoginFields:not([hidden]){display:flex;flex-direction:column;gap:12px}
.fld{display:flex;flex-direction:column;gap:5px}
label{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--text-muted);font-weight:600}
input,select,textarea{font:inherit;font-size:14px;color:var(--text);background:var(--surface-2);
             border:1px solid var(--border);border-radius:8px;padding:8px 10px;width:100%}
input:disabled{opacity:.55;cursor:not-allowed}
input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.btn{font:inherit;font-size:14px;font-weight:600;border-radius:8px;padding:9px 16px;cursor:pointer;border:1px solid var(--border);background:var(--surface);color:var(--text)}
.btn:hover{border-color:var(--accent)}
.btn-primary{background:var(--brand-red);border-color:var(--brand-red);color:#fff}
.btn-primary:hover{filter:brightness(1.08);border-color:var(--brand-red)}
.btn-danger{background:none;border-color:var(--brand-red);color:var(--brand-red)}
.btn-danger:hover{background:var(--crit-soft)}
.btn-logout{padding:6px 12px;font-size:13px;background:none;border-color:var(--brand-red);color:var(--brand-red)}
.btn-logout:hover{background:var(--crit-soft);border-color:var(--brand-red)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn-sm{padding:6px 11px;font-size:12.5px;border-radius:7px}
.err{margin:0;font-size:12.5px;color:var(--crit)}
.warn-box{display:flex;flex-direction:column;gap:5px;font-size:12.5px;line-height:1.5;
          background:var(--warn-soft);color:var(--warn);border:1px solid var(--warn);
          border-radius:8px;padding:11px 13px}
.warn-box[hidden]{display:none}
.divider-top{margin-top:14px;border-top:1px solid var(--border);padding-top:14px;display:flex;flex-direction:column;gap:10px}
.inline-row{display:flex;gap:8px}
.wa-pair-code{font-size:28px;font-weight:700;letter-spacing:3px;text-align:center;margin:0;
              font-family:ui-monospace,monospace;color:var(--brand-red)}
.warn-box code{background:rgba(0,0,0,.08);padding:1px 5px;border-radius:4px;font-size:12px}

/* запись аудиосообщения: мигающая точка + индикатор уровня — чтобы было видно, что запись правда идёт */
.rec-live{display:flex;align-items:center;gap:10px}
.rec-live[hidden]{display:none}
.rec-dot{width:10px;height:10px;border-radius:50%;background:var(--brand-red);flex:0 0 auto;animation:recPulse 1.1s ease-in-out infinite}
.rec-dot.paused{animation:none;background:var(--text-muted)}
@keyframes recPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.7)}}
.rec-live .mono{font-size:15px;font-weight:600;min-width:56px;font-variant-numeric:tabular-nums}
.level-meter{width:120px;height:8px;border-radius:4px;background:var(--surface-2);border:1px solid var(--border);overflow:hidden;flex:0 0 auto}
.level-fill{display:block;height:100%;width:0;background:var(--ok);border-radius:4px;transition:width 70ms linear}

/* вкладки — прокрутка вбок вместо переноса: 6 вкладок в одну строку не влезают ни на
   планшете, ни тем более на телефоне, а перенос в 2-3 строки выглядит рвано */
.tabs{display:flex;gap:4px;flex-wrap:nowrap;overflow-x:auto;background:var(--surface-2);
     border:1px solid var(--border);border-radius:11px;padding:4px;margin-bottom:16px;
     scrollbar-width:none;-webkit-overflow-scrolling:touch}
.tabs::-webkit-scrollbar{display:none}
.tab-btn{font:inherit;font-size:14px;font-weight:600;color:var(--text-muted);background:transparent;
         border:1px solid transparent;border-radius:8px;padding:9px 16px;cursor:pointer;
         flex:0 0 auto;min-width:106px;text-align:center;white-space:nowrap}
.tab-btn:hover{color:var(--text);background:var(--surface)}
.tab-btn[aria-selected="true"]{background:var(--brand-red);color:#fff;border-color:var(--brand-red)}
.tab-panel[hidden]{display:none}
.tabs[hidden]{display:none}
/* «Каналы» — под-вкладки (Почта/Битрикс24/MAX/Telegram/WhatsApp) чуть компактнее головных,
   чтобы визуально читались как второй уровень, а не дублировали головную строку вкладок */
.sub-tabs{margin-top:-10px}
.sub-tabs .tab-btn{padding:7px 14px;font-size:13px;min-width:0}

.card{background:var(--surface);border:1px solid var(--border);border-radius:12px;
      box-shadow:var(--shadow);overflow:hidden;margin-bottom:14px}
.card-pad{padding:16px 18px;display:flex;flex-direction:column;gap:10px}
.card-h{font-size:14px;font-weight:650;margin:0;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em}
.card-h.lg{font-size:15px;color:var(--text);text-transform:none;letter-spacing:0}
.card-note{font-size:12.5px;color:var(--text-muted);line-height:1.5;margin:0}
.section-title{margin:0 0 0 6px;font-size:18px;font-weight:650}

.actions{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:14px;align-items:center}
.status{font-size:13px;color:var(--text-muted);margin-bottom:12px;min-height:20px}
.status.busy{color:var(--accent)}
.status.bad{color:var(--crit)}
.status.good{color:var(--ok)}

.tag{display:inline-block;font-size:10.5px;font-weight:600;padding:2px 7px;border-radius:5px;white-space:nowrap}
.tag+.tag{margin-left:4px}
.t-crit{background:var(--crit-soft);color:var(--crit)}
.t-warn{background:var(--warn-soft);color:var(--warn)}
.t-info{background:var(--fixed-soft);color:var(--fixed)}
.t-ok{background:var(--ok-soft);color:var(--ok)}
.empty{padding:24px;text-align:center;color:var(--text-muted);font-size:14px}

/* почта */
.mail-layout{display:grid;grid-template-columns:200px 1fr;gap:14px}
@media (max-width:900px){ .mail-layout{grid-template-columns:1fr} }

/* вкладка «Почта»: именованные области — на мобильном блок «Администрирование» уходит
   под список писем, а не выше него (на десктопе остаётся в левой колонке) */
#tabMail .mail-layout{
  grid-template-columns:200px 1fr;
  grid-template-areas:"accounts main" "folders main" "admin main";
  align-content:start;
}
#tabMail .ml-accounts{grid-area:accounts}
#tabMail .ml-folders{grid-area:folders;margin-top:0}
#tabMail .ml-admin{grid-area:admin}
#tabMail .ml-main{grid-area:main;min-width:0}
@media (max-width:900px){
  #tabMail .mail-layout{grid-template-columns:1fr;grid-template-areas:"accounts" "folders" "main" "admin"}
}
/* левая колонка на вкладках мессенджеров (Битрикс24/MAX/Telegram/WhatsApp) — переключатель
   подключений, статус, список диалогов и карточка администрирования одним ритмом отступов */
.messenger-sidebar{display:flex;flex-direction:column;gap:12px}
.messenger-sidebar .status{margin:0}
.messenger-sidebar .folder-list{margin:0}
.mail-accounts{display:flex;flex-direction:column;gap:6px}
.acct-btn{font:inherit;font-size:13.5px;font-weight:600;text-align:left;color:var(--text-muted);background:var(--surface);
          border:1px solid var(--border);border-radius:8px;padding:9px 12px;cursor:pointer}
.acct-btn:hover{color:var(--text);border-color:var(--accent)}
.acct-btn[aria-pressed="true"]{background:var(--brand-red);color:#fff;border-color:var(--brand-red)}
.folder-list{display:flex;flex-direction:column;gap:3px;margin-top:10px}
.folder-btn{font:inherit;font-size:13px;text-align:left;color:var(--text-muted);background:transparent;
            border:1px solid transparent;border-radius:6px;padding:6px 10px;cursor:pointer;display:flex;justify-content:space-between;gap:6px}
.folder-btn>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.folder-btn:hover{color:var(--text);background:var(--surface-2)}
.folder-btn[aria-pressed="true"]{background:var(--surface-2);color:var(--text);font-weight:650}
.folder-badge{font-size:11px;font-weight:700;color:var(--brand-red)}

.mail-toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:12px}
.mail-search{flex:1;min-width:200px}

table.mail-list{width:100%;border-collapse:collapse;font-size:13px}
table.mail-list thead th{position:sticky;top:0;background:var(--surface-2);text-align:left;font-size:11px;
      text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);font-weight:600;
      padding:9px 10px;border-bottom:1px solid var(--border);white-space:nowrap;z-index:2}
table.mail-list td{padding:9px 10px;border-bottom:1px solid var(--grid-line);vertical-align:middle}
table.mail-list tbody tr{cursor:pointer}
table.mail-list tbody tr:hover{background:var(--surface-2)}
table.mail-list tbody tr:last-child td{border-bottom:none}
table.mail-list tr.unread td{font-weight:650}
.msg-from{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.msg-subject{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:1px}
.msg-date{font-family:ui-monospace,monospace;font-variant-numeric:tabular-nums;color:var(--text-muted);white-space:nowrap}

/* правила обработки */
.rules-layout{display:grid;grid-template-columns:280px 1fr;gap:14px;align-items:start}
@media (max-width:900px){ .rules-layout{grid-template-columns:1fr} }
.tree-list{display:flex;flex-direction:column;gap:1px}
.tree-item{display:flex;align-items:center;gap:6px;padding:5px 6px;border-radius:6px;font-size:13px;color:var(--text)}
.tree-item .ic{opacity:.55;flex:0 0 auto}
.tree-item .path{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rule-cond{font-size:13px}
.rule-cond b{font-weight:650}
.cond-options{display:flex;flex-direction:column;gap:8px;border:1px solid var(--border);border-radius:8px;padding:10px 12px}
.chk{display:flex;align-items:center;gap:8px;font-size:13.5px;text-transform:none;letter-spacing:0;font-weight:500;color:var(--text);cursor:pointer}
.chk input{width:auto;accent-color:var(--brand-red)}

/* Битрикс24 */
.bx-messages{display:flex;flex-direction:column;gap:10px;max-height:60vh;overflow-y:auto;padding-right:2px}
.bx-msg{max-width:78%;padding:8px 12px;border-radius:12px;background:var(--surface-2);align-self:flex-start}
.bx-msg.own{align-self:flex-end;background:var(--fixed-soft)}
.bx-msg .author{font-size:11px;font-weight:650;color:var(--text-muted);margin-bottom:2px}
.bx-msg .text{font-size:14px;line-height:1.5;white-space:pre-wrap;word-break:break-word}
.bx-msg .time{font-size:10.5px;color:var(--text-muted);margin-top:3px;text-align:right}
.bx-composer{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--border)}
.bx-composer input{flex:1}
.bx-user-result{display:flex;flex-direction:column;text-align:left;width:100%;font:inherit;
       background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:8px 10px;
       cursor:pointer;margin-bottom:4px}
.bx-user-result:hover{border-color:var(--accent)}
.bx-user-result .name{font-size:13px;font-weight:600}
.bx-user-result .pos{font-size:11.5px;color:var(--text-muted)}

.bx-group{margin-bottom:8px;border:1px solid var(--border);border-radius:10px;background:var(--surface);
       box-shadow:var(--shadow);overflow:hidden}
.bx-group summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:9px;
       padding:11px 13px;font-size:14px;font-weight:650;color:var(--text)}
.bx-group summary::-webkit-details-marker{display:none}
.bx-group summary::before{content:"\25b8";font-size:12px;color:var(--text-muted);flex:0 0 auto;transition:transform .15s}
.bx-group[open] summary::before{transform:rotate(90deg)}
.bx-group summary:hover{background:var(--surface-2)}
.bx-group .ic{font-size:15px;flex:0 0 auto}
.bx-group-count{margin-left:auto;background:var(--surface-2);color:var(--text-muted);font-size:11.5px;font-weight:700;
       padding:2px 9px;border-radius:999px;font-variant-numeric:tabular-nums;flex:0 0 auto}
.bx-group-count.has-unread{background:var(--brand-red);color:#fff}
.bx-group-items{display:flex;flex-direction:column;gap:1px;max-height:340px;overflow-y:auto;
       border-top:1px solid var(--border);padding:5px}

/* Дашборд */
.dash-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px;align-items:start}
@media (max-width:900px){ .dash-cols{grid-template-columns:1fr} }
.dash-cols .card.drag-over{outline:2px dashed var(--accent);outline-offset:2px}
.dash-cols .card.dragging{opacity:.4}
.dash-card-h{display:flex;align-items:center;gap:9px;padding:14px 18px;border-bottom:1px solid var(--border);cursor:grab}
.dash-card-h:active{cursor:grabbing}
.dash-card-h h2{font-size:14.5px;font-weight:650;margin:0;flex:1}
.dash-ic{flex:0 0 auto;width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center}
.dash-ic.mail{background:var(--fixed-soft);color:var(--fixed)}
.dash-ic.bx{background:var(--warn-soft);color:var(--warn)}
.dash-ic.maxp{background:var(--maxp-soft);color:var(--maxp)}
.dash-ic.tg{background:var(--tg-soft);color:var(--tg)}
.dash-ic.wa{background:var(--ok-soft);color:var(--ok)}
.dash-count{font-size:12px;font-weight:700;color:#fff;background:var(--brand-red);border-radius:999px;
       padding:2px 9px;font-variant-numeric:tabular-nums}
.dash-count.good{background:var(--ok)}
.dash-item{display:flex;flex-direction:column;gap:3px;padding:13px 18px;border-bottom:1px solid var(--grid-line);cursor:pointer}
.dash-item:last-child{border-bottom:none}
.dash-item:hover{background:var(--surface-2)}
.dash-item .row1{display:flex;align-items:center;gap:8px}
.dash-item .who2{flex:1;min-width:0;font-size:13.5px;font-weight:650;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-item .tag{flex:0 0 auto}
.dash-item .snippet{font-size:13px;color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-item .time{font-size:11px;color:var(--text-muted);font-variant-numeric:tabular-nums;margin-top:1px}

/* ящики (админ-панель) */
table.plain{width:100%;border-collapse:collapse;font-size:13px}
table.plain thead th{background:var(--surface-2);text-align:left;font-size:11px;
      text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);font-weight:600;
      padding:9px 10px;border-bottom:1px solid var(--border);white-space:nowrap}
table.plain td{padding:9px 10px;border-bottom:1px solid var(--grid-line);vertical-align:middle}
table.plain tbody tr:last-child td{border-bottom:none}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 14px}

/* просмотр письма */
.msg-view{display:flex;flex-direction:column;gap:10px}
.msg-head{display:flex;flex-direction:column;gap:4px;padding-bottom:12px;border-bottom:1px solid var(--border)}
.msg-head h3{margin:0;font-size:16px}
.msg-meta{font-size:12.5px;color:var(--text-muted)}
.msg-body{font-size:14px;line-height:1.6;white-space:pre-wrap;word-break:break-word}
.msg-attachments{display:flex;flex-direction:column;gap:6px;margin-top:14px;padding-top:12px;border-top:1px solid var(--border)}
.msg-attachments .attach-row{padding:6px 8px;border-radius:8px;background:var(--surface-2);text-decoration:none}
.msg-attachments .attach-row:hover{background:var(--border)}
.msg-attachments .attach-row .name{color:var(--text)}

/* модальное окно */
.modal{position:fixed;inset:0;background:rgba(10,16,22,.45);display:flex;align-items:center;justify-content:center;
       padding:20px;z-index:1000}
.modal[hidden]{display:none}
.dlg{background:var(--surface);border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.3);
     width:100%;max-width:640px;max-height:92vh;
     display:flex;flex-direction:column;overflow:hidden}
.dlg-h{flex:0 0 auto;display:flex;align-items:flex-start;gap:12px;padding:20px 24px 14px;border-bottom:1px solid var(--border)}
.dlg-h h3{margin:0;font-size:17px;font-weight:650;flex:1}
.x{background:none;border:none;font-size:22px;line-height:1;color:var(--text-muted);cursor:pointer;padding:0 4px}
.x:hover{color:var(--text)}
.dlg-b{flex:1 1 auto;overflow:auto;padding:18px 24px;min-height:0;display:flex;flex-direction:column;gap:14px}
.dlg-f{flex:0 0 auto;display:flex;align-items:center;gap:12px;padding:14px 24px 20px;border-top:1px solid var(--border);flex-wrap:wrap}
.spacer{margin-left:auto}
.dlg-err{flex:0 0 auto;margin:10px 24px 0;padding:10px 12px;border-radius:8px;background:var(--crit-soft);color:var(--crit);font-size:13px}
.dlg-err[hidden]{display:none}
.hint{font-size:12px;color:var(--text-muted);margin:6px 0 0}

.move-tree{margin-top:14px;border-top:1px solid var(--border);padding-top:14px}
.move-tree .tree-item{cursor:pointer;border-radius:6px}
.move-tree .tree-item:hover{background:var(--surface-2);color:var(--text)}
#cAttachList{display:flex;flex-direction:column;gap:4px;margin-top:6px}
.attach-row{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--text-muted)}
.attach-row .name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attach-row button{background:none;border:none;color:var(--brand-red);cursor:pointer;font-size:16px;line-height:1;padding:0 2px}

/* таблицы внутри .card сами скроллятся по горизонтали, а не обрезаются overflow:hidden карточки */
#mailListWrap,#accountsListWrap,#rulesListWrap{overflow-x:auto}

/* ===== мобильная адаптация ===== */
@media (max-width:640px){
  .page{padding:16px 12px 40px}
  .head{gap:10px;margin-bottom:14px}
  .logo{height:28px}
  h1{font-size:17px}
  .brand-sub{font-size:11px}
  .who{width:100%;order:3;margin-left:0}
  .btn-logout{padding:6px 10px;font-size:12.5px}

  .gate form{padding:24px 18px;max-width:100%}

  .tabs{width:100%;margin-left:-12px;margin-right:-12px;width:calc(100% + 24px);border-radius:0;
        border-left:none;border-right:none;padding-left:12px;padding-right:12px}
  .tab-btn{flex:0 0 auto;min-width:auto;padding:10px 14px;font-size:13px;text-align:center}
  .sub-tabs .tab-btn{padding:9px 13px;font-size:12.5px}

  .card-pad{padding:13px 14px}
  .actions{gap:8px}
  .actions .btn{flex:1 1 auto}

  .mail-toolbar{gap:8px}
  .mail-search{width:100%;min-width:0}
  .mail-toolbar .btn{flex:1 1 auto}

  table.mail-list,table.plain{font-size:12.5px}
  table.mail-list th,table.mail-list td,table.plain th,table.plain td{padding:7px 8px}
  .msg-from{max-width:120px}
  .msg-subject{max-width:1px}

  table.plain td[style*="white-space:nowrap"]{white-space:normal!important}
  table.plain td .btn{margin:2px 4px 2px 0}

  .dlg{max-width:100%;border-radius:12px}
  .dlg-h{padding:16px 16px 12px}
  .dlg-b{padding:14px 16px}
  .dlg-f{padding:12px 16px 16px}
  .dlg-err{margin:10px 16px 0}
  .grid2{grid-template-columns:1fr;gap:12px 0}

  .tree-item .path{font-size:12.5px}

  .dash-item{padding:11px 14px}
  .bx-composer{padding:10px 12px}
  .bx-composer .btn{padding:9px 12px;font-size:13px}
  .bx-msg{max-width:88%}

  .max-msg{padding:9px 12px}
}

/* ---- вкладка «Здоровье» ---- */
.health-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;margin-top:12px}
.h-card{border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--surface-2);min-width:0}
.h-title{font-size:13px;color:var(--text-muted);font-weight:600}
.h-val{font-size:24px;font-weight:700;margin:4px 0;line-height:1.15}
.h-val small{font-size:13px;font-weight:500;color:var(--text-muted)}
.h-sub{font-size:12.5px;color:var(--text-muted)}
.h-spark{width:100%;height:32px;display:block;margin-top:6px}
.h-spark polyline{fill:none;stroke:var(--brand-red);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.h-spark circle{fill:var(--brand-red)}
.h-sleep{border:1px solid var(--border);border-radius:12px;padding:14px;background:var(--surface-2);margin-top:12px}
.h-bar{display:flex;height:16px;border-radius:8px;overflow:hidden;margin:10px 0;background:var(--border)}
.h-bar span{display:block;height:100%}
.h-legend{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:13px}
.h-legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:baseline}
.h-nights{display:flex;align-items:stretch;gap:4px;margin-top:10px}
.h-nights .hn{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;text-align:center}
.h-nights .hn span{display:block;width:100%;background:var(--brand-red);opacity:.75;border-radius:3px 3px 0 0;min-height:2px}
.h-nights .hn em{font-style:normal;font-size:11px;line-height:1.2;margin-bottom:2px}
.h-nights .hn b{font-weight:500;font-size:10px;line-height:1.25;margin-top:3px;color:var(--muted)}
.h-conn{border:1px dashed var(--border);border-radius:12px;padding:12px;margin-top:10px}
.h-conn code,.h-conn pre{word-break:break-all;white-space:pre-wrap;font-size:12.5px}
.h-conn ol{margin:8px 0 0;padding-left:20px;font-size:13.5px;line-height:1.55}

.hp-att{border-left:3px solid var(--brand-red);padding:6px 12px;margin:8px 0;background:var(--surface-2);border-radius:0 8px 8px 0;font-size:13.5px;line-height:1.5}
.hp-att b{display:block}
.hp-g{margin-top:16px}
.hp-g>h4{margin:0 0 6px;font-size:14px}
.hp-it{border:1px solid var(--border);border-radius:10px;margin:6px 0;background:var(--surface-2)}
.hp-it summary{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;cursor:pointer;list-style:none;font-size:13.5px}
.hp-it summary::-webkit-details-marker{display:none}
.hp-it.done .hp-w{text-decoration:line-through;color:var(--text-muted)}
.hp-who{display:block;font-size:12px;color:var(--text-muted);margin-top:2px}
.hp-prep{padding:0 12px 10px 38px;font-size:13px;line-height:1.5}
.hp-it summary input[type=checkbox]{flex:0 0 20px;width:20px;height:20px;min-width:0;padding:0;margin:1px 0 0}
.hp-w{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}

.h-foot{margin:14px 2px 4px;text-align:center}
.h-foot .btn{opacity:.7}

.hm-row{margin-top:12px}
.hm-row>.h-sub{margin-bottom:6px}
.hm-opts{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.hm-opts button{border:1px solid var(--border);background:var(--surface-2);border-radius:10px;padding:10px 4px;font:inherit;font-size:13px;color:var(--text);cursor:pointer}
.hm-opts button.on[data-v="1"]{background:#ffe3e3;border-color:#e03131;color:#a61e1e;font-weight:600}
.hm-opts button.on[data-v="2"]{background:#fff3bf;border-color:#f08c00;color:#8a5a00;font-weight:600}
.hm-opts button.on[data-v="3"]{background:#d3f9d8;border-color:#40c057;color:#1f7a2f;font-weight:600}
.hm-opts button.on[data-v="4"]{background:#b2f2bb;border-color:#2f9e44;color:#1b5e20;font-weight:700}
.hm-note{width:100%;margin-top:12px;min-height:64px;resize:vertical}
.hm-days{display:flex;gap:4px;margin-top:12px;align-items:flex-end}
.hm-days i{flex:1;height:22px;border-radius:4px;background:var(--border)}
.hm-days i[data-v="1"]{background:#e03131}.hm-days i[data-v="2"]{background:#f08c00}.hm-days i[data-v="3"]{background:#40c057}.hm-days i[data-v="4"]{background:#2f9e44}
.hm-saved{font-size:12px;color:var(--text-muted);margin-top:4px;min-height:16px}
.h-sleepfacts{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px;margin:10px 0}
.h-sleepfacts div{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:8px 10px}
.h-sleepfacts b{display:block;font-size:18px}

.hm-date{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin-top:6px}
.hm-date b{font-size:15px}
.hm-date input{width:auto;padding:4px 8px}
.hm-days i{cursor:pointer}
.hm-days i.sel{outline:2px solid var(--text);outline-offset:1px}
.hm-saved{margin:0 0 0 10px}

.ph-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:8px;margin-top:8px}
.ph-th{border:1px solid var(--border);background:var(--surface-2);border-radius:10px;padding:4px;cursor:pointer;font:inherit;color:var(--text);display:block;text-align:center}
.ph-th img{width:100%;aspect-ratio:3/4;object-fit:cover;border-radius:8px;display:block}
.ph-th span{display:block;font-size:11.5px;margin-top:3px;color:var(--text-muted)}
.ph-prev{width:100%;max-width:320px;border-radius:12px;display:block;margin-top:10px}
.ph-ov{position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:1000;display:flex;align-items:center;justify-content:center;padding:16px}
.ph-box{background:var(--surface);border-radius:14px;padding:12px;max-width:min(92vw,520px);max-height:92vh;overflow:auto}
.ph-box img{width:100%;border-radius:10px;display:block}

.psy-opt{display:flex;gap:8px;align-items:flex-start;margin:6px 0;font-size:13.5px;line-height:1.4}
.psy-opt input{flex:0 0 18px;width:18px;height:18px;min-width:0;padding:0;margin:1px 0 0}

.psy-opts{grid-template-columns:repeat(2,1fr)}
.psy-opts button{padding:10px 6px;line-height:1.25}

.obs-syms{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.obs-sym{border:1px solid var(--border);background:var(--surface-2);border-radius:999px;padding:8px 12px;font:inherit;font-size:13px;color:var(--text);cursor:pointer}
.obs-sym.l1{background:#fff3bf;border-color:#f08c00}.obs-sym.l2{background:#ffd8a8;border-color:#e8590c}.obs-sym.l3{background:#ffc9c9;border-color:#e03131;font-weight:600}
.obs-chip{display:inline-block;border-radius:999px;padding:2px 9px;font-size:12px;margin:3px 4px 0 0;background:var(--surface-2);border:1px solid var(--border)}
.obs-chip.l1{background:#fff3bf}.obs-chip.l2{background:#ffd8a8}.obs-chip.l3{background:#ffc9c9}
.obs-item{border-top:1px solid var(--border);padding:8px 0}
.obs-note{font-size:13.5px;line-height:1.5;margin-top:4px;white-space:pre-wrap}
.obs-del{float:right;border:0;background:none;font-size:20px;line-height:1;color:var(--text-muted);cursor:pointer;padding:0 4px}
.h-group{margin:18px 0 0;font-weight:600;font-size:14px;color:var(--muted)}
.h-card.off{opacity:.5}
.h-hide{float:right;font-size:12px;padding:2px 8px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:inherit}

/* Личные финансы */
.fin-groups{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:12px 0 4px}
.fin-groups button{border:1px solid var(--border);background:var(--surface-2);border-radius:10px;padding:10px 4px;font:inherit;font-size:14px;color:var(--text);cursor:pointer}
.fin-groups button.on{background:var(--brand-red);border-color:var(--brand-red);color:#fff;font-weight:600}
.fin-h{margin:16px 0 4px;font-size:14px}
.fin-total{margin:2px 0 8px;font-size:26px;font-weight:700}
.fin-t{width:100%;border-collapse:collapse;font-size:13px;margin-top:6px}
.fin-t th{text-align:left;font-weight:500;color:var(--muted);padding:4px 4px 4px 0;border-bottom:1px solid var(--border)}
.fin-t td{padding:6px 4px 6px 0;border-bottom:1px solid var(--border);vertical-align:top}
.fin-t .n{text-align:right;white-space:nowrap;padding-left:8px}
.fin-bad{color:#c92a2a}
.fin-good{color:#2b8a3e}
.fin-kpis{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0 4px}
.fin-kpi{border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:var(--surface-2);display:flex;flex-direction:column;gap:2px;min-width:0}
.fin-kpi small{color:var(--muted);font-size:12px}
.fin-kpi b{font-size:18px;font-weight:700;white-space:nowrap}
.fin-kpi span{font-size:12px;min-height:15px}
.fin-svg{width:100%;height:auto;display:block;margin-top:4px}
.fin-bar{fill:var(--border)}
.fin-bar.hl{fill:var(--brand-red)}
.fin-bv{font-size:9px;fill:var(--text)}
.fin-bl{font-size:9px;fill:var(--muted)}
.fin-avg{stroke:var(--brand-red);stroke-width:1;stroke-dasharray:3 3;opacity:.7}
.fin-struct{display:flex;flex-direction:column;gap:8px;margin-top:6px}
.fin-st{display:flex;justify-content:space-between;gap:8px;font-size:13px}
.fin-st b{font-weight:500;white-space:nowrap;color:var(--muted)}
.fin-sb{height:6px;background:var(--border);border-radius:3px;margin-top:3px;overflow:hidden}
.fin-sb i{display:block;height:100%;background:var(--brand-red);opacity:.8}
.fin-det{margin-top:14px}
.fin-det summary{cursor:pointer;font-weight:600;font-size:14px}
.vh{position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;pointer-events:none}
label.btn{display:inline-block;text-align:center;cursor:pointer}
/* Мониторинг конкурентов */
.comp-row{display:grid;grid-template-columns:1fr auto;grid-template-areas:"name name" "main btn";gap:4px 10px;align-items:start;padding:10px 0;border-bottom:1px solid var(--border)}
.comp-row .comp-name{grid-area:name;justify-self:start}
.comp-row .comp-main{grid-area:main;min-width:0}
.comp-row .btn{grid-area:btn;align-self:center}
.comp-row.old{grid-template-columns:1fr auto;grid-template-areas:"name name" "main btn";opacity:.75}
.comp-name{font-size:12px;font-weight:600;background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:3px 8px;white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis}
.comp-main a{color:var(--text);font-size:14px;font-weight:500;text-decoration:none}
.comp-meta{font-size:12px;color:var(--muted);margin-top:2px}
.comp-src{display:flex;justify-content:space-between;gap:8px;align-items:center;padding:6px 0;border-bottom:1px solid var(--border);font-size:13px}

.sg-asset{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:8px 0;font-size:14px}
.sg-assets summary{cursor:pointer;margin:12px 0 4px;font-weight:600}
.sg-form{margin-top:12px}.sg-ck{display:block;margin:8px 0;font-size:15px}
.sg-row select,.sg-row input,.sg-ck input[type=text]{font:inherit;padding:8px;border:1px solid var(--border);border-radius:8px;background:var(--surface-2);color:var(--text);max-width:100%}
.sg-prev{width:100%;border:1px solid var(--border);border-radius:8px;margin:8px 0;background:#fff}
.sg-nudge{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
.sg-tbl{width:100%;border-collapse:collapse;margin-top:10px;font-size:14px}.sg-tbl td{padding:8px 4px;border-bottom:1px solid var(--border);vertical-align:top}
.sg-act{white-space:nowrap;text-align:right}

.fin-row{cursor:pointer}.fin-row .fin-arr{display:inline-block;width:12px;color:var(--muted);transition:transform .15s}
.fin-row.open .fin-arr{transform:rotate(90deg)}
.fin-drow td{background:var(--surface-2);padding:6px 8px}
.fin-dl{display:flex;flex-direction:column;gap:5px}
.fin-di{display:grid;grid-template-columns:34px 1fr auto;gap:8px;align-items:baseline;font-size:12.5px}
.fin-dd{color:var(--muted)}.fin-dt i{color:var(--muted);font-style:normal;font-size:11px;margin-left:4px}
.fin-dsum{border-top:1px solid var(--border);padding-top:5px;font-weight:600}

.fin-chips{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.fin-chip{min-height:40px;padding:0 14px;border-radius:20px;border:1px solid #d9dde5;background:#fff;font:inherit;font-weight:600}
.fin-chip.on{background:#d3222a;border-color:#d3222a;color:#fff}

.fin-nav{display:grid;grid-template-columns:48px 1fr 48px;gap:8px;margin:12px 0 8px}
.fin-nav select,.fin-nb{min-height:46px;border:1px solid var(--border);border-radius:12px;background:var(--surface-2);font:inherit;font-size:16px;font-weight:600;color:var(--text);text-align:center}
.fin-nb{font-size:24px;line-height:1}.fin-nb:disabled{opacity:.35}
.fin-hero{display:flex;flex-direction:column;gap:2px;padding:14px;border-radius:14px;background:var(--surface-2);border:1px solid var(--border);margin-bottom:8px}
.fin-hero small{color:var(--muted);font-size:13px}.fin-hero b{font-size:30px;font-weight:700}.fin-hero span{font-size:13px;min-height:16px}
.fin-sec{margin-top:12px;padding:12px 14px;border:1px solid var(--border);border-radius:14px}
.fin-sec>summary{cursor:pointer;font-weight:700;font-size:16px;min-height:28px;display:flex;justify-content:space-between;align-items:center}
.fin-sec>.fin-h{margin:0 0 2px;font-size:16px}
.fin-t td{padding:11px 4px 11px 0}
.fin-ly{margin-top:10px}.fin-lyh{display:flex;justify-content:space-between;font-size:14px;border-bottom:1px solid var(--border);padding-bottom:4px}
.fin-li{display:grid;grid-template-columns:1fr auto 32px;gap:8px;align-items:center;font-size:13.5px;padding:6px 0}
.fin-li i{color:var(--muted);font-style:normal;font-size:11.5px}
.fin-x{border:0;background:none;font-size:20px;color:var(--muted);min-height:32px}
.fin-lf{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:12px}
.fin-lf input{min-height:44px;border:1px solid var(--border);border-radius:10px;padding:0 10px;font:inherit;font-size:16px;min-width:0}
.fin-lf input[name=title],.fin-lf input[name=note],.fin-lf button{grid-column:1/-1}
.fin-lf button{min-height:44px}
.fin-hit{fill:transparent;cursor:pointer}.fin-svg[data-kind]:not([data-kind=""]) .fin-bar{cursor:pointer}
.fin-warn{background:#fff4e5;border:1px solid #f3c98b;border-radius:10px;padding:8px 10px;margin:8px 0;font-size:13px}.fin-warn p{margin:3px 0}.fin-lf select{min-height:44px;border:1px solid var(--border);border-radius:10px;padding:0 8px;font:inherit;font-size:16px;min-width:0;grid-column:1/-1}
