:root{
  --bg: #10141c;
  --bg-soft: #161b26;
  --panel: #1b2230;
  --panel-2: #242c3d;
  --line: #3a46608c;
  --line-solid: #3d4a62;
  --text: #eef2f8;
  --muted: #93a0b5;
  --muted-2: #6e7b91;
  --blue: #4ec8e8;
  --blue-2: #3aa3c4;
  --blue-glow: #4ec8e84d;
  --green: #5fd49a;
  --green-glow: #5fd49a38;
  --amber: #e0b45c;
  --amber-glow: #e0b45c38;
  --red: #e07a7a;
  --red-glow: #e07a7a30;
  --violet: #8b7cf0;
  --violet-glow: #8b7cf028;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 36px -18px #041018aa;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
*{box-sizing:border-box;margin:0;padding:0;}
html{color-scheme:dark;}
html,body{height:100%;}
body{
  background:
    radial-gradient(1100px 560px at 92% -12%, #3ec8e838, transparent 58%),
    radial-gradient(820px 520px at -12% 112%, #4ad39a26, transparent 55%),
    radial-gradient(640px 280px at 42% -8%, #8b7cf024, transparent 52%),
    var(--bg);
  color:var(--text);
  font-family:var(--font-ui);
  font-size:13.5px;
  line-height:1.45;
  display:flex;
  -webkit-font-smoothing:antialiased;
}
::selection{background:#4ec8e855;}
html{scrollbar-gutter:stable;}
a{color:inherit;}
:focus-visible{outline:2px solid var(--blue);outline-offset:2px;}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-thumb{background:#3a4150;border-radius:8px;}
::-webkit-scrollbar-track{background:transparent;}

/* ---------- Sidebar ---------- */
.sidebar{
  width:216px;flex-shrink:0;background:var(--bg-soft);
  border-right:1px solid var(--line);padding:14px 10px 12px;
  display:flex;flex-direction:column;gap:16px;
  position:sticky;top:0;height:100vh;
}
.brand{display:flex;align-items:center;gap:9px;padding:2px 6px 4px;}
.brand-copy{min-width:0;flex:1;}
.brand-mark{
  width:32px;height:32px;border-radius:10px;
  background:linear-gradient(145deg, #6ee0ff, var(--blue-2) 55%, #6d8cff);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 0 22px -4px var(--blue-glow), 0 6px 14px -8px #0008;flex-shrink:0;
}
.brand-mark svg{width:16px;height:16px;}
.brand-name{font-weight:700;font-size:13.5px;letter-spacing:-.02em;}
.brand-sub{font-size:10.5px;color:var(--muted-2);font-family:var(--font-mono);}
.brand-more{display:none;position:relative;flex-shrink:0;}
.brand-more-btn{
  width:36px;height:36px;border:1px solid #2a3a4d;background:#17212b;color:#c8d4de;
  border-radius:10px;cursor:pointer;font:inherit;font-size:20px;font-weight:700;line-height:1;
  display:inline-flex;align-items:center;justify-content:center;
}
.brand-more-icon-menu{display:none;}
.brand-more-icon-dots{display:inline;}
.brand-more-btn.is-open,.brand-more-btn:hover{background:#2b5278;border-color:#4e8fd6;color:#fff;}
.brand-more-badge{
  position:absolute;top:-5px;right:-5px;min-width:16px;height:16px;padding:0 4px;
  background:#e53935;color:#fff;border-radius:8px;font-size:10px;font-weight:700;
  line-height:16px;text-align:center;pointer-events:none;
}
.brand-more-badge[hidden]{display:none !important;}
.brand-more-menu{
  position:absolute;right:0;top:calc(100% + 6px);z-index:80;min-width:200px;
  padding:6px;border-radius:14px;background:#17212b;border:1px solid #2a3a4d;
  box-shadow:0 16px 36px -16px #000c;display:flex;flex-direction:column;gap:2px;
}
.brand-more-menu[hidden]{display:none !important;}
.brand-more-user{
  padding:8px 10px 10px;font-size:12px;color:#8ea4b8;border-bottom:1px solid #243647;margin-bottom:4px;
}
.brand-more-user b{color:#e8eef5;font-weight:650;}
.brand-more-item{
  width:100%;border:none;background:transparent;color:#e8eef5;text-align:left;
  padding:10px 12px;border-radius:10px;font:inherit;font-size:14px;cursor:pointer;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
}
.brand-more-item:hover,.brand-more-item:active{background:#2b5278;}
.brand-more-item.is-danger{color:#f5a8a8;}
.brand-more-item.is-danger:hover{background:#5a2a2a;color:#fff;}
.brand-more-item-badge{
  min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#e53935;color:#fff;
  font-size:10px;font-weight:700;line-height:18px;text-align:center;
}
.brand-more-item-badge[hidden]{display:none !important;}
body.role-worker .brand-more-item.admin-only{display:none !important;}
body.role-admin .brand-more-item.worker-only{display:none !important;}
body.role-worker .brand-more-item.worker-only{display:block !important;}
body.role-admin .brand-more-item.admin-only{display:block !important;}
.brand-more-item[hidden]{display:none !important;}
body.role-admin .brand-more{display:none;}
body.role-worker .brand-more{display:none;}
.brand-actions{margin-left:auto;display:inline-flex;align-items:center;gap:6px;flex-shrink:0;}
.brand-chip,.logout-chip{
  display:inline-flex;align-items:center;justify-content:center;gap:5px;
  border:1px solid var(--line);background:var(--panel-2);color:var(--muted);
  border-radius:9px;padding:6px 8px;cursor:pointer;font:inherit;font-size:12px;font-weight:550;flex-shrink:0;
  position:relative;
}
.brand-chip svg,.logout-chip svg{width:15px;height:15px;flex-shrink:0;}
.brand-chip:hover,.logout-chip:hover{color:var(--text);border-color:var(--line-solid);background:var(--bg-soft);}
.brand-chip:active,.logout-chip:active{transform:scale(.97);}
.brand-chip.active{color:var(--text);border-color:var(--blue);background:#4ec8e826;}
.brand-chip .nav-icon{display:inline-flex;}
.brand-chip .nav-badge{top:-6px;right:-8px;}
body.role-worker .brand-chip.worker-only{display:inline-flex !important;}
body.role-admin .brand-chip.worker-only{display:none !important;}

.nav{display:flex;flex-direction:column;gap:2px;flex:1;}
.nav-item{
  display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:9px;
  font-size:13px;font-weight:550;color:var(--muted);cursor:pointer;
  transition:background .14s, color .14s, box-shadow .14s, transform .12s;
}
.nav-item svg{width:15px;height:15px;opacity:.85;flex-shrink:0;}
.nav-item.active{
  background:linear-gradient(90deg, #4ec8e826, var(--panel-2));
  color:var(--text);box-shadow:inset 3px 0 0 var(--blue);
}
.nav-item:not(.active):hover{background:#243044;color:var(--text);}
.nav-item.disabled{opacity:.4;cursor:not-allowed;}
.nav-icon{position:relative;display:inline-flex;align-items:center;justify-content:center;}
.nav-badge{
  position:absolute;top:-7px;right:-9px;min-width:16px;height:16px;padding:0 4px;
  background:#e53935;color:#fff;border-radius:8px;font-size:10px;font-weight:700;
  line-height:16px;text-align:center;
}
body.role-tenant.is-maintenance .nav-item[data-tab]:not([data-tab="cabinet"]){
  opacity:.38;pointer-events:none;cursor:not-allowed;
}

.sidebar-footer{
  padding:10px;border-radius:10px;
  background:var(--panel);border:1px solid var(--line);
  font-size:11px;color:var(--muted-2);line-height:1.4;
  margin-top:auto;display:flex;flex-direction:column;gap:8px;
}
.sidebar-footer .logout-chip{
  width:100%;justify-content:center;
}
.sidebar-note{margin:0 0 6px;font-size:11px;color:var(--muted-2);line-height:1.35;}
.api-status{display:flex;align-items:center;gap:6px;font-size:11px;margin-top:7px;color:var(--muted-2);}
.api-status .dot{width:6px;height:6px;border-radius:50%;background:var(--muted-2);}
.api-status.ok .dot{background:var(--green);}
.api-status.down .dot{background:var(--red);}
.user-chip{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  margin-bottom:8px;color:var(--text);font-size:12px;font-weight:550;
}

/* ---------- Main ---------- */
.main{flex:1;min-width:0;padding:16px 22px 36px;overflow:auto;overflow-anchor:none;}
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  gap:14px;margin-bottom:14px;flex-wrap:wrap;
}
.title-block h1{font-size:18px;font-weight:750;letter-spacing:-.03em;line-height:1.2;}
.title-block p{color:var(--muted);font-size:12.5px;margin-top:3px;}
.topbar-actions{display:flex;gap:8px;align-items:center;}
.settings-content{display:none;}
.settings-content.active{display:block;}
.search{
  display:flex;align-items:center;gap:7px;background:var(--panel);
  border:1px solid var(--line-solid);padding:7px 10px;border-radius:8px;width:220px;
}
.search svg{width:13px;height:13px;color:var(--muted-2);flex-shrink:0;}
.search input{
  background:none;border:none;outline:none;color:var(--text);
  font-family:var(--font-ui);font-size:13px;width:100%;
}
.search input::placeholder{color:var(--muted-2);}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  font-family:var(--font-ui);font-weight:600;font-size:13px;
  padding:7px 12px;border-radius:8px;border:none;cursor:pointer;
  transition:transform .1s ease, box-shadow .12s, background .12s, border-color .12s;
}
.btn:active{transform:translateY(1px);}
.btn-primary{
  background:linear-gradient(145deg, var(--blue), var(--blue-2));
  color:#fff;box-shadow:0 6px 14px -8px var(--blue-glow);
}
.btn-primary:hover{box-shadow:0 8px 16px -6px #5aaec655;}
.btn-ghost,.btn-secondary{
  background:var(--panel-2);color:var(--text);border:1px solid var(--line-solid);
}
.btn-ghost:hover,.btn-secondary:hover{background:#2d3340;}
.btn-danger-ghost,.btn-danger{background:transparent;color:var(--red);border:1px solid #d070703d;}
.btn-danger-ghost:hover{background:var(--red-glow);}
.btn-sm{padding:5px 9px;font-size:12px;border-radius:7px;}
.btn[disabled]{opacity:.5;cursor:not-allowed;pointer-events:none;}
.btn-ghost-sm{
  background:transparent;color:var(--muted);border:1px solid var(--line-solid);
  padding:5px 9px;border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;font-family:var(--font-ui);
}
.btn-ghost-sm:hover{color:var(--text);border-color:#4a5364;}
.btn-danger-sm{
  background:transparent;color:var(--red);border:1px solid #d070703d;
  padding:5px 9px;border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;font-family:var(--font-ui);
}
.btn-ai{background:#5aaec61f;color:#9ad4e4;border:1px solid #5aaec655;}
.btn-ai:hover{background:#5aaec633;}

/* ---------- Stats ---------- */
.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:14px;}
.stat{
  background:linear-gradient(180deg, #243044, var(--panel));
  border:1px solid var(--line);border-radius:var(--radius);
  padding:11px 13px;display:flex;flex-direction:column;gap:2px;
  transition:transform .12s, border-color .12s, box-shadow .12s;
}
.stat:hover{border-color:#5aaec655;box-shadow:0 10px 24px -16px var(--blue-glow);}
.stat-label{font-size:10.5px;color:var(--muted-2);text-transform:uppercase;letter-spacing:.05em;font-weight:600;}
.stat-value{font-size:20px;font-weight:750;font-family:var(--font-mono);letter-spacing:-.03em;line-height:1.2;}
.stat-value.green{color:var(--green);}
.stat-value.amber{color:var(--amber);}

/* ---------- Account grid ---------- */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(268px,1fr));gap:10px;}
.card{
  background:linear-gradient(180deg, #243044cc, var(--panel));
  border:1px solid var(--line);border-radius:var(--radius);
  padding:12px;display:flex;flex-direction:column;gap:9px;
  transition:border-color .12s, transform .12s, box-shadow .12s;
}
.card:hover{border-color:#5ecfe066;box-shadow:var(--shadow);}
.card-top{display:flex;align-items:center;gap:9px;}
.avatar{
  width:34px;height:34px;border-radius:9px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:12px;color:#fff;font-family:var(--font-mono);
}
.card-id{flex:1;min-width:0;}
.card-name{font-weight:650;font-size:13.5px;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.card-phone{font-family:var(--font-mono);font-size:11.5px;color:var(--muted);margin-top:1px;}

.badge{
  display:inline-flex;align-items:center;gap:5px;
  padding:2px 8px 2px 6px;border-radius:999px;
  font-size:11px;font-weight:600;white-space:nowrap;
  background:#5aaec61f;color:#9ad4e4;
}
.badge .dot{width:5px;height:5px;border-radius:50%;background:currentColor;}
.badge.active{background:var(--green-glow);color:var(--green);}
.badge.active .dot{background:var(--green);box-shadow:0 0 0 3px var(--green-glow);animation:pulse 2s infinite;}
.badge.inactive{background:var(--red-glow);color:var(--red);}
.badge.inactive .dot{background:var(--red);box-shadow:none;animation:none;}
.badge.checking{background:var(--amber-glow);color:var(--amber);}
.badge.checking .dot{background:var(--amber);animation:pulse 1s infinite;}
.badge.agent{background:#5aaec61f;color:#9ad4e4;}
.badge.agent .dot{background:var(--blue);box-shadow:0 0 0 3px var(--blue-glow);animation:pulse 2s infinite;}
.badge.suspended{background:var(--amber-glow);color:var(--amber);}
.badge.revoked{background:var(--red-glow);color:var(--red);}
@keyframes pulse{0%{opacity:1}50%{opacity:.4}100%{opacity:1}}

.card-meta{
  display:flex;justify-content:space-between;align-items:center;
  font-size:11.5px;color:var(--muted-2);
  border-top:1px solid var(--line);padding-top:8px;
}
.card-meta span b{color:var(--muted);font-weight:600;}
.account-stats{display:flex;flex-direction:column;gap:5px;border-top:1px solid var(--line);padding-top:8px;}
.account-stat{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;font-size:11.5px;color:var(--muted-2);line-height:1.3;}
.account-stat b{color:var(--text);font-weight:650;font-family:var(--font-mono);text-align:right;}
.account-stat b.on{color:var(--green);}
.account-stat b.off{color:var(--muted);}
.account-stat.typing b{font-family:var(--font-ui);font-weight:500;white-space:pre-wrap;word-break:break-word;max-height:3.6em;overflow:hidden;}
.folder-box{border-top:1px solid var(--line);padding-top:8px;display:flex;flex-direction:column;gap:6px;}
.folder-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:12px;font-weight:650;}
.folder-head b{font-family:var(--font-mono);color:var(--blue);}
.folder-hint{font-size:11.5px;color:var(--muted);line-height:1.4;}
.folder-empty{font-size:11.5px;color:var(--amber);}
.folder-chats{list-style:none;display:flex;flex-direction:column;gap:3px;margin:0;padding:0;}
.folder-chats li{font-size:12px;color:var(--text);padding:4px 7px;background:var(--panel-2);border-radius:6px;}
.card-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:0;}
.card-actions .btn{flex:1;min-width:72px;}
.agent-log{font-size:12px;color:#9ad4e4;font-weight:600;}
.agent-log.error{color:var(--red);}

.empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding:36px 12px;color:var(--muted);}
.empty svg{width:32px;height:32px;color:var(--muted-2);}
.empty h3{font-size:14.5px;font-weight:650;}
.empty p{font-size:12.5px;color:var(--muted);max-width:300px;}

/* ---------- Modal ---------- */
.overlay{
  position:fixed;inset:0;background:#0b0d12cc;backdrop-filter:blur(4px);
  display:none;align-items:center;justify-content:center;z-index:50;padding:16px;
}
.overlay.open{display:flex;}
.modal{
  width:100%;max-width:400px;background:var(--panel);border:1px solid var(--line-solid);
  border-radius:14px;padding:18px 18px 16px;box-shadow:var(--shadow);animation:rise .16s ease;
}
@keyframes rise{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:2px;}
.modal-steps{display:flex;gap:4px;margin-bottom:12px;}
.step-dot{height:3px;flex:1;border-radius:3px;background:var(--line-solid);}
.step-dot.done{background:var(--blue);}
.modal h2{font-size:16px;font-weight:700;letter-spacing:-.02em;}
.modal .close-x{
  cursor:pointer;color:var(--muted-2);background:none;border:none;
  width:24px;height:24px;border-radius:6px;display:flex;align-items:center;justify-content:center;
}
.modal .close-x:hover{background:var(--panel-2);color:var(--text);}
.modal-sub{font-size:12.5px;color:var(--muted);margin-top:4px;margin-bottom:14px;line-height:1.45;}
.modal-sub b{color:var(--text);font-family:var(--font-mono);font-weight:500;}

.field{margin-bottom:10px;}
.field label{display:block;font-size:11.5px;font-weight:600;color:var(--muted);margin-bottom:5px;}
.phone-row{display:flex;gap:6px;}
.phone-row .cc-input{flex:0 0 64px;width:64px;text-align:center;font-family:var(--font-mono);}
.phone-row #phoneInput{flex:1 1 auto;min-width:0;}
input.text-input,select.text-input,textarea.text-input{
  width:100%;background:var(--bg-soft);border:1px solid var(--line-solid);color:var(--text);
  padding:8px 10px;border-radius:8px;font-size:13.5px;outline:none;
  transition:border-color .12s, box-shadow .12s;
}
input.text-input{font-family:var(--font-mono);}
select.text-input,textarea.text-input{font-family:var(--font-ui);}
input.text-input:focus,select.text-input:focus,textarea.text-input:focus{
  border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-glow);
}
select.text-input:disabled,input.text-input:disabled{
  opacity:.45;cursor:not-allowed;background:#151a24;
}
input.text-input::placeholder,textarea.text-input::placeholder{color:var(--muted-2);font-family:var(--font-ui);}

.code-row{display:flex;gap:6px;justify-content:space-between;}
.code-box{
  width:40px;height:46px;text-align:center;font-size:18px;background:var(--bg-soft);
  border:1px solid var(--line-solid);color:var(--text);border-radius:8px;
  font-family:var(--font-mono);font-weight:600;outline:none;
}
.code-box:focus{border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-glow);}
.hint{font-size:11.5px;color:var(--muted-2);margin-top:7px;line-height:1.45;}
.hint a{color:var(--blue);cursor:pointer;text-decoration:none;}
.hint a:hover{text-decoration:underline;}
.modal-footer{display:flex;gap:8px;margin-top:14px;}
.modal-footer .btn{flex:1;}

.error-text{
  display:none;font-size:12px;color:var(--red);background:var(--red-glow);
  border:1px solid #d0707033;padding:8px 10px;border-radius:8px;margin-bottom:10px;line-height:1.35;
}
.error-text.show{display:block;}
.error-text.warn{
  color:var(--amber);background:var(--amber-glow);border-color:#e0b45c44;
}
.success-wrap{display:flex;flex-direction:column;align-items:center;text-align:center;padding:8px 0 2px;}
.success-icon{
  width:48px;height:48px;border-radius:12px;margin-bottom:12px;background:var(--green-glow);
  display:flex;align-items:center;justify-content:center;
}
.success-icon svg{width:22px;height:22px;color:var(--green);}
.success-wrap h2{margin-bottom:4px;}
.success-wrap p{font-size:12.5px;color:var(--muted);max-width:280px;line-height:1.45;margin-bottom:4px;}
.session-chip{
  margin-top:6px;font-family:var(--font-mono);font-size:11px;color:var(--muted);
  background:var(--bg-soft);border:1px solid var(--line-solid);padding:6px 9px;border-radius:7px;word-break:break-all;
}
.spinner{width:14px;height:14px;border-radius:50%;border:2px solid #ffffff55;border-top-color:#fff;animation:spin .7s linear infinite;}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-row{display:flex;align-items:center;justify-content:center;gap:8px;padding:18px 0 8px;color:var(--muted);font-size:13px;}

.toast-wrap{
  position:fixed;left:50%;bottom:24px;transform:translateX(-50%);
  display:flex;flex-direction:column;gap:8px;z-index:120;
  align-items:center;pointer-events:none;width:min(420px,92vw);
}
.toast{
  pointer-events:auto;
  background:#1e2c3af2;border:none;padding:10px 16px;border-radius:14px;
  font-size:14px;color:#fff;display:flex;align-items:center;gap:10px;
  box-shadow:0 10px 28px -12px #000a;animation:toastIn .2s ease;
  backdrop-filter:blur(8px);max-width:100%;
}
@keyframes toastIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.toast .tdot{width:8px;height:8px;border-radius:50%;flex-shrink:0;}
.toast.ok .tdot{background:#4ea4f6;}
.toast.err .tdot{background:#e53935;}
.toast.ok{box-shadow:0 10px 28px -12px #000a, inset 0 0 0 1px #4ea4f633;}
.toast.err{box-shadow:0 10px 28px -12px #000a, inset 0 0 0 1px #e5393533;}

.radio-row{display:flex;gap:14px;flex-wrap:wrap;font-size:13px;color:var(--text);}
.radio-row label{display:flex;align-items:center;gap:6px;cursor:pointer;}
.console-cmd{
  background:#12151c;border:1px solid var(--line-solid);border-radius:8px;
  padding:10px 12px;font-family:var(--font-mono);font-size:12px;color:#9ad4e4;
  overflow:auto;margin:8px 0 10px;white-space:pre-wrap;
}
.console-modal{max-width:860px;width:100%;}

.harvest-card{margin-top:12px;}
.harvest-modal{max-width:520px;}
.harvest-body{min-height:80px;}
.harvest-list{display:flex;flex-direction:column;gap:6px;max-height:360px;overflow-y:auto;padding-right:2px;}
.harvest-row{
  display:flex;align-items:center;gap:10px;width:100%;text-align:left;
  padding:10px 12px;border:1px solid var(--line-solid);background:var(--bg-soft);
  border-radius:10px;cursor:pointer;color:var(--text);
}
.harvest-row:hover{border-color:var(--blue);background:#1a2430;}
.harvest-row-main{display:flex;flex-direction:column;gap:2px;min-width:0;}
.harvest-row-main b{font-size:13.5px;font-weight:650;}
.harvest-row-main .meta{
  font-size:12px;color:var(--muted);line-height:1.35;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;
}
.harvest-empty{font-size:13px;color:var(--muted);line-height:1.45;padding:8px 2px;}
.harvest-pairs{display:flex;flex-direction:column;gap:8px;max-height:280px;overflow-y:auto;}
.harvest-pair{
  padding:8px 10px;border-radius:10px;background:var(--bg-soft);
  border:1px solid var(--line-solid);font-size:12.5px;line-height:1.4;
}
.harvest-pair .u{color:var(--muted);margin-bottom:4px;}
.harvest-pair .a{color:var(--text);}

.console-log{
  height:min(58vh,480px);overflow:auto;background:#12151c;border:1px solid var(--line-solid);
  border-radius:8px;padding:8px 10px;font-family:var(--font-mono);font-size:12px;line-height:1.4;
}
.console-line{display:grid;grid-template-columns:72px 52px minmax(72px,130px) 1fr;gap:8px;padding:2px 0;border-bottom:1px solid #ffffff08;}
.console-line .c-ts{color:#6a7180;}
.console-line .c-lvl{text-transform:uppercase;font-size:10px;padding-top:2px;}
.console-line.info .c-lvl{color:#9ad4e4;}
.console-line.warning .c-lvl,.console-line.warn .c-lvl{color:var(--amber);}
.console-line.error .c-lvl{color:var(--red);}
.console-line .c-lg{color:#8b929f;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.console-line .c-msg{color:#d6dbe4;white-space:pre-wrap;word-break:break-word;}

/* ---------- Settings ---------- */
.settings-page{max-width:1080px;}
#tabSettings .title-block p{max-width:520px;}
.settings-tabs{
  display:flex;gap:4px;margin-bottom:16px;padding:4px;
  background:var(--panel);border:1px solid var(--line);border-radius:12px;
  width:100%;
}
.settings-tab{
  border:none;background:transparent;color:var(--muted);cursor:pointer;
  font:600 13px var(--font-ui);padding:8px 12px;border-radius:8px;flex:1;
  min-width:0;white-space:nowrap;transition:background .12s, color .12s;
}
.settings-tab:hover{color:var(--text);background:#232833;}
.settings-tab.active{background:linear-gradient(180deg, #31485a, var(--panel-2));color:var(--text);box-shadow:0 0 0 1px #4ec8e833, inset 0 1px 0 #ffffff14;}
.settings-panel{display:none;}
.settings-panel.active{display:block;}
.settings-split{
  display:grid;grid-template-columns:minmax(0,1.35fr) minmax(280px,.85fr);
  gap:12px;align-items:start;
}
.settings-split-equal{grid-template-columns:1fr 1fr;}
.settings-card-narrow{max-width:480px;}
.settings-card-monitor{max-width:600px;}
.settings-card{
  background:var(--panel);border:1px solid var(--line);border-radius:12px;
  padding:16px 16px 14px;margin-bottom:0;
}
.settings-card-fill{min-height:280px;}
.card-head{
  display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  margin-bottom:12px;
}
.card-head h3,.settings-card h3{font-size:14px;font-weight:650;margin-bottom:4px;letter-spacing:-.01em;}
.card-head .desc,.settings-card .desc{font-size:12.5px;color:var(--muted);line-height:1.45;margin-bottom:0;}
.settings-card > .desc{margin-bottom:12px;}
.settings-card .desc b{color:var(--text);font-weight:600;}
.count-chip{
  flex-shrink:0;min-width:28px;height:28px;padding:0 8px;border-radius:8px;
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--bg-soft);border:1px solid var(--line-solid);
  font-family:var(--font-mono);font-size:12px;font-weight:600;color:var(--muted);
}
.active-model{
  display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;
  padding:12px 14px;margin-bottom:12px;border-radius:10px;
  background:linear-gradient(180deg, #243038, var(--bg-soft));
  border:1px solid #5aaec640;
}
.active-model-label{
  display:block;font-size:10.5px;font-weight:700;letter-spacing:.06em;
  text-transform:uppercase;color:var(--muted-2);margin-bottom:3px;
}
.active-model strong{
  display:block;font-size:13.5px;font-weight:650;letter-spacing:-.02em;
  word-break:break-all;
}
.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px 10px;margin-bottom:12px;}
.settings-grid .field{margin-bottom:0;}
.settings-grid .wide,.wide{grid-column:1 / -1;}
.upload-zone,.upload-area{
  border:1px dashed var(--line-solid);border-radius:12px;padding:22px 14px;text-align:center;
  cursor:pointer;background:var(--bg-soft);color:var(--muted);
  transition:border-color .12s, background .12s, color .12s;
}
.upload-zone:hover,.upload-zone.dragover,.upload-area:hover,.upload-area.dragover{
  border-color:var(--blue);color:var(--text);background:#1a2430;
}
.upload-zone b,.upload-area b{display:block;color:var(--text);font-weight:600;margin-bottom:4px;}
.upload-zone span,.upload-area .upload-sub{display:block;font-size:12px;color:var(--muted);}
.upload-zone input,.upload-area input{display:none;}
.upload-bar,.upload-progress{height:3px;background:#2a3140;border-radius:3px;margin-top:12px;overflow:hidden;display:none;}
.upload-bar span,.progress-fill{display:block;height:100%;width:0;background:var(--blue);}
.upload-status{margin-top:10px;font-size:12px;color:var(--muted);}
.upload-status.success{color:var(--green);}
.upload-status.error{color:var(--red);}
.upload-status.loading{color:var(--blue);}
.model-list{display:flex;flex-direction:column;gap:6px;}
.model-item{
  display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;
  padding:10px 12px;border-radius:10px;background:var(--bg-soft);border:1px solid var(--line);
}
.model-item.is-active{border-color:#5aaec655;background:#5aaec614;}
.model-info{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1;}
.model-name{font-size:13px;font-weight:600;word-break:break-word;}
.model-size{font-size:11.5px;color:var(--muted);}
.model-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center;}
.status-pill{font-size:11px;font-weight:600;padding:2px 8px;border-radius:999px;background:#5aaec61f;color:#9ad4e4;}
.row-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.row-actions select.text-input{flex:1;min-width:160px;}
.muted{font-size:12.5px;color:var(--muted);}
.howto{
  margin-top:14px;padding-top:12px;border-top:1px solid var(--line);
  font-size:12.5px;color:var(--muted);line-height:1.45;
}
.howto summary{cursor:pointer;color:var(--text);font-weight:600;list-style:none;}
.howto summary::-webkit-details-marker{display:none;}
.howto summary::after{content:"▸";float:right;color:var(--muted-2);}
.howto[open] summary::after{content:"▾";}
.howto ol{margin:8px 0 0 18px;display:grid;gap:6px;}
.kv-grid .kv,.kv{display:flex;justify-content:space-between;gap:14px;padding:9px 0;border-bottom:1px solid var(--line);font-size:13px;}
.kv-grid .kv:last-child,.kv:last-child{border-bottom:none;}
.mem-block{margin-top:14px;padding-top:12px;border-top:1px solid var(--line);}
.mem-title{font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--muted-2);margin-bottom:8px;}
.mem-list{display:flex;flex-direction:column;gap:8px;}
.mem-row{
  display:flex;flex-direction:column;gap:8px;
  padding:10px 12px;border-radius:9px;background:var(--bg-soft);border:1px solid var(--line);
}
.mem-row.is-on{border-color:#5fd49a44;}
.mem-row.is-off{border-color:#e07a7a33;}
.mem-row-head{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.mem-name{display:block;font-size:12.5px;font-weight:650;}
.mem-model{display:block;font-size:11.5px;color:var(--muted);margin-top:2px;word-break:break-all;}
.mem-status{font-size:11px;font-weight:600;color:var(--muted);white-space:nowrap;}
.mem-row.is-on .mem-status{color:var(--green);}
.mem-row.is-off .mem-status{color:var(--red);}
.load-meters{display:grid;gap:7px;}
.load-meter{display:grid;grid-template-columns:42px 1fr auto;gap:8px;align-items:center;font-size:11.5px;}
.load-label{color:var(--muted);font-weight:650;}
.load-bar{height:6px;border-radius:99px;background:var(--bg);overflow:hidden;border:1px solid var(--line);}
.load-bar > i{display:block;height:100%;border-radius:99px;background:var(--green);width:0;transition:width .35s ease;}
.load-meter.is-warn .load-bar > i{background:#e0b15a;}
.load-meter.is-hot .load-bar > i{background:var(--red);}
.load-val{font-size:11px;color:var(--muted);white-space:nowrap;}
.mem-row.is-maint{border-color:#e0b15a66;}
.mem-row.is-maint .mem-status{color:#e0b15a;}
.mem-maint-btn{align-self:flex-start;}
.kv b{font-weight:500;color:var(--muted);}
.opt-hint{font-weight:500;color:var(--muted-2);font-size:11px;}
.howto code{
  font-family:var(--font-mono);font-size:11.5px;background:var(--bg-soft);
  padding:1px 5px;border-radius:4px;color:#9ad4e4;
}
.empty-hint{font-size:12.5px;color:var(--muted);padding:18px 4px;text-align:center;}
.empty-hint[hidden]{display:none;}

body:not(.role-admin) .admin-only{display:none !important;}
body:not(.role-tenant) .tenant-only{display:none !important;}
.cab-ok{color:var(--green);font-weight:650;}
.cab-bad{color:var(--red);font-weight:650;}
.cabinet-split{grid-template-columns:1fr 1fr;}
#cabPower{font-size:16px;font-family:var(--font-ui);}
.quota-banner{
  background:var(--panel);border:1px solid var(--line);border-radius:9px;
  padding:9px 12px;margin-bottom:12px;font-size:12.5px;color:var(--muted);line-height:1.4;
}
.quota-banner b{color:var(--text);font-weight:600;}
.maint-plate{
  margin-bottom:14px;padding:16px 18px;border-radius:12px;
  border:1px solid #e0b15a77;
  background:linear-gradient(180deg, #4a3518, #2c2416);
  box-shadow:0 0 0 1px #e0b15a22, 0 14px 28px -16px #e0b15a66;
}
.maint-plate-kicker{
  font-size:16px;font-weight:800;letter-spacing:.06em;
  text-transform:uppercase;color:#ffd27a;margin-bottom:6px;
  text-shadow:0 0 18px #e0b15a66;
}
.maint-plate p{font-size:13.5px;color:var(--text);line-height:1.5;}
body.role-tenant.is-maintenance #addAccountBtn{opacity:.55;}
.tenants-layout{display:grid;grid-template-columns:minmax(260px,1fr) minmax(260px,1fr);gap:10px;}
.tenant-list{display:flex;flex-direction:column;gap:8px;}
.tenant-card{
  background:linear-gradient(180deg, #243044, var(--bg-soft));
  border:1px solid var(--line);border-radius:12px;padding:12px;
  transition:border-color .12s, transform .12s;
}
.tenant-card:hover{border-color:#5ecfe055;}
.tenant-head{display:flex;justify-content:space-between;gap:8px;align-items:flex-start;}
.tenant-meta{font-size:12px;color:var(--muted);margin:6px 0 8px;}

.login-page{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px;}
.login-card{
  width:100%;max-width:380px;background:linear-gradient(180deg, #243044, var(--panel));
  border:1px solid #4ec8e840;border-radius:16px;padding:22px 20px;
  box-shadow:0 20px 50px -24px #4ec8e855, var(--shadow);
}
.login-card h1{font-size:18px;margin-bottom:6px;letter-spacing:-.03em;}
.login-lead{color:var(--muted);font-size:13px;line-height:1.45;margin-bottom:14px;}
.login-card .error-text{margin-bottom:12px;}
.login-card .error-text.show{display:block;}

.history-modal{max-width:920px;width:100%;}
.history-layout{display:grid;grid-template-columns:220px 1fr;gap:12px;margin-top:10px;min-height:420px;}
.history-chats{
  display:flex;flex-direction:column;gap:6px;overflow:auto;max-height:min(62vh,520px);
  padding-right:2px;border-right:1px solid var(--line);
}
.history-chat{
  display:flex;flex-direction:column;gap:2px;text-align:left;width:100%;
  padding:8px 10px;border-radius:10px;border:1px solid var(--line-solid);
  background:var(--bg-soft);color:var(--text);cursor:pointer;font:inherit;
}
.history-chat b{font-size:13px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.history-chat span{font-size:11.5px;color:var(--muted);}
.history-chat:hover,.history-chat.active{border-color:var(--blue);background:#1a2430;}
.history-main{display:flex;flex-direction:column;min-width:0;min-height:0;}
.history-thread{
  flex:1;overflow:auto;min-height:360px;max-height:min(58vh,480px);
  display:flex;flex-direction:column;gap:8px;padding:8px 4px 8px 2px;
}
.history-empty{color:var(--muted);font-size:13px;padding:12px 4px;}
.bubble{
  max-width:82%;padding:8px 11px;border-radius:12px;border:1px solid var(--line-solid);
  background:var(--bg-soft);
}
.bubble.in{align-self:flex-start;}
.bubble.out{align-self:flex-end;background:#243044;border-color:#4ec8e833;}
.bubble-meta{font-size:11px;color:var(--muted);margin-bottom:3px;}
.bubble-text{white-space:pre-wrap;word-break:break-word;font-size:13.5px;line-height:1.4;}
.bubble.typing-live{border-color:var(--amber);background:#2a2418;}
.history-typing{
  margin-top:8px;padding:8px 10px;border-radius:10px;border:1px solid #e0b45c55;
  background:#2a2418;color:#ffd27a;font-size:12.5px;white-space:pre-wrap;word-break:break-word;
}
.play-layout{display:grid;grid-template-columns:240px 1fr;gap:14px;align-items:stretch;}
.play-side{display:flex;flex-direction:column;gap:10px;}
.play-side .desc,#playStatus{font-size:12.5px;color:var(--muted);line-height:1.4;}
.play-main{display:flex;flex-direction:column;min-height:0;}
.play-thread{min-height:420px;max-height:min(62vh,560px);}
.play-compose{display:flex;gap:8px;margin-top:10px;align-items:flex-end;}
.play-compose textarea{flex:1;resize:vertical;}
.mlog-line{
  display:grid;grid-template-columns:72px 150px minmax(90px,160px) 1fr;gap:8px;
  padding:4px 0;border-bottom:1px solid #ffffff08;font-family:var(--font-mono);font-size:12px;
}
.mlog-kind{font-size:11px;padding-top:1px;color:#9ad4e4;}
.mlog-peer{color:#8b929f;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.mlog-line .c-msg{color:#d6dbe4;white-space:pre-wrap;word-break:break-word;}
.mlog-line.kind-incoming .mlog-kind{color:#9ad4e4;}
.mlog-line.kind-prompt .mlog-kind{color:#8b7cf0;}
.mlog-line.kind-generate .mlog-kind,.mlog-line.kind-typing .mlog-kind{color:var(--amber);}
.mlog-line.kind-reply .mlog-kind,.mlog-line.kind-send .mlog-kind{color:var(--green);}
.mlog-line.kind-error .mlog-kind,.mlog-line.kind-skip .mlog-kind{color:var(--red);}
.mlog-line.kind-fallback .mlog-kind,.mlog-line.kind-nudge .mlog-kind{color:#e0b45c;}
.mlog-line.kind-playground .mlog-kind{color:#4ec8e8;}

@media (max-width:900px){
  .stats{grid-template-columns:repeat(2,minmax(0,1fr));}
  .tenants-layout{grid-template-columns:1fr;}
  .cabinet-split,.settings-split-equal{grid-template-columns:1fr;}
  .history-layout,.play-layout{grid-template-columns:1fr;}
  .history-chats{border-right:none;max-height:160px;flex-direction:row;flex-wrap:wrap;}
  .mlog-line{grid-template-columns:64px 1fr;gap:4px;}
  .mlog-peer{grid-column:1 / -1;}
}
.admin-only,.worker-only{display:none !important;}
body.role-admin .nav-item.admin-only{display:flex !important;}
body.role-admin .nav-item.admin-only[hidden],
body.role-admin .nav-item[data-tab="stats"]{display:none !important;}
body.role-admin .settings-content.admin-only{display:none !important;}
body.role-admin .settings-content.admin-only.active{display:block !important;}
/* Админ вошёл в аккаунт — показываем inbox работника */
body.role-admin.admin-as-account #tabInbox.worker-only.active{
  display:flex !important;
}
body.role-admin.admin-as-account .settings-content.admin-only{
  display:none !important;
}
body.role-admin.admin-as-account .main{
  padding:0;overflow:hidden;display:flex;flex-direction:column;
}
body.role-admin.admin-as-account .nav-item.admin-only{
  opacity:.55;
}
.admin-inbox-bar{
  display:flex;align-items:center;gap:10px;
  padding:8px 10px 4px;flex-shrink:0;
}
.admin-inbox-bar[hidden]{display:none !important;}
.admin-inbox-label{
  font-size:13px;font-weight:650;color:#c8d4de;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1;
}
.admin-inbox-bar .btn{flex-shrink:0;}
body.role-worker .nav-item.worker-only{display:none !important;}
body.role-worker .nav{display:none !important;}
body.role-worker .settings-content.worker-only{display:none !important;}
body.role-worker .settings-content.worker-only.active{display:flex !important;}
body.role-worker .main{
  padding:0;overflow:hidden;display:flex;flex-direction:column;
}
#tabInbox{flex:1;min-height:0;flex-direction:column;}
#tabNotices,#tabWork{flex:1;min-height:0;flex-direction:column;padding:0;background:var(--tg-bg,#0e1621);}
#tabNotices{overflow:hidden;}
#tabWork{overflow:auto;padding:16px 18px 24px;}
body.role-worker .notice-head .title-block h1,
body.role-worker .tg-page-head-text h1{color:var(--tg-text,#f5f5f5);}
body.role-worker .notice-head .title-block p,
body.role-worker .tg-page-head-text p{color:var(--tg-muted,#708499);}
body.role-worker .nav-badge{font-size:10px;top:-4px;right:-8px;}

.grant-row{display:grid;grid-template-columns:1fr 72px 1fr auto;gap:6px;align-items:center;}
.grant-row .text-input{padding:6px 8px;font-size:12px;}
.staff-form{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px;}
.staff-form .text-input{max-width:200px;}
.method-grid{display:flex;flex-direction:column;gap:8px;}
.qr-box{display:flex;justify-content:center;align-items:center;min-height:220px;background:#fff;border-radius:12px;padding:12px;}
.qr-image{width:220px;height:220px;}
.stats-table{width:100%;border-collapse:collapse;background:var(--panel);border:1px solid var(--line);border-radius:12px;overflow:hidden;}
.stats-table th,.stats-table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--line);font-size:13px;}
.stats-table th{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.04em;}

body.role-worker{
  --tg-bg:#0e1621;
  --tg-list:#17212b;
  --tg-hover:#202b36;
  --tg-active:#2b5278;
  --tg-in:#182533;
  --tg-out:#2b5278;
  --tg-search:#242f3d;
  --tg-text:#f5f5f5;
  --tg-muted:#708499;
  --tg-blue:#6ab3f3;
  --tg-unread:#4dcd5e;
  background:var(--tg-bg);
}
body.role-worker .sidebar{
  width:72px;padding:12px 10px 14px;background:#0b1219;border-right:1px solid #1a2430;
  align-items:center;gap:12px;display:flex;flex-direction:column;
}
body.role-worker .brand{
  justify-content:center;align-items:center;padding:2px 0 4px;flex-wrap:nowrap;
  flex-direction:column;gap:12px;width:100%;
}
body.role-worker .brand-copy{display:none !important;}
body.role-worker .brand-name,body.role-worker .brand-sub{display:none !important;}
body.role-worker .brand-mark{display:none !important;}
body.role-worker .brand-actions{
  margin:0;width:100%;flex-direction:column;gap:8px;align-items:center;
}
body.role-worker .brand-chip,
body.role-worker .logout-chip{
  margin:0;width:44px;height:44px;padding:0;border-radius:12px;
  background:#17212b;border:1px solid #243647;color:#9eb0c3;
  display:inline-flex;align-items:center;justify-content:center;
  transition:background .12s ease, border-color .12s ease, color .12s ease, transform .1s ease;
}
body.role-worker .brand-chip svg,
body.role-worker .logout-chip svg{
  width:20px;height:20px;stroke-width:1.85;
}
body.role-worker .brand-chip:hover,
body.role-worker .logout-chip:hover{
  background:#1e2c3a;border-color:#35506a;color:#fff;
}
body.role-worker .brand-chip:active,
body.role-worker .logout-chip:active{transform:scale(.96);}
body.role-worker .brand-chip.active{
  background:#2b5278;border-color:#4e8fd6;color:#fff;
  box-shadow:inset 0 0 0 1px rgba(106,179,243,.25);
}
body.role-worker .logout-chip span{display:none;}
body.role-worker .brand-chip .nav-icon{
  position:relative;display:inline-flex;align-items:center;justify-content:center;
}
body.role-worker .brand-chip .nav-badge{
  top:-7px;right:-8px;min-width:16px;height:16px;font-size:10px;
  border:2px solid #0b1219;
}
body.role-worker .nav-item{
  justify-content:center;padding:12px 0;font-size:0;gap:0;
}
body.role-worker .nav-item svg{width:22px;height:22px;opacity:1;}
body.role-worker .nav-item.active{
  background:#2b5278;box-shadow:none;border-radius:12px;color:#fff;
}
body.role-worker .user-chip{
  flex-direction:column;align-items:center;justify-content:center;margin:0;gap:4px;width:100%;
}
body.role-worker .user-chip span{
  display:block;font-size:10.5px;font-weight:600;color:#c8d4de;text-align:center;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.2;
}
body.role-worker .api-status{display:none !important;}
body.role-worker .sidebar-footer{
  background:transparent;border:none;padding:10px 0 0;width:100%;margin-top:auto;
  display:flex;flex-direction:column;align-items:center;gap:8px;
}
body.role-worker .sidebar-footer .logout-chip{
  margin:0;width:46px;height:46px;padding:0;border-radius:13px;
  background:#17212b;border:1px solid #243647;color:#9eb0c3;
}
body.role-worker .btn-ghost.btn-sm{padding:6px;font-size:11px;}

.inbox{display:grid;grid-template-columns:360px minmax(0,1fr);height:100%;min-height:0;flex:1;background:var(--tg-bg,#0e1621);}
.inbox:has(#inboxProfile:not([hidden])){grid-template-columns:360px minmax(0,1fr) 300px;}
.inbox-side{background:var(--tg-list,#17212b);display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden;border-right:1px solid #101921;}
.inbox-side-head{padding:8px 10px;display:flex;flex-direction:column;gap:8px;}
.inbox-accounts{
  display:flex;flex-direction:column;gap:8px;padding:2px 0 4px;min-width:0;
}
.inbox-acc-row{display:contents;}
.inbox-more-slot{display:none;}
.inbox-resize-handle{display:none;}
.inbox-search-row{display:contents;}
.inbox-acc-sheet-toggle{display:none;}
.inbox-acc-sheet{display:contents;}
.inbox-acc-sheet[hidden]{display:contents !important;}
.inbox-acc-sheet-backdrop{display:none;}
.inbox-acc-sheet-head{display:none;}
.inbox-acc-sheet-panel{display:contents;}
.inbox-acc-sheet-close{display:none;}
.inbox-account-select-wrap{
  display:flex;flex-direction:column;gap:4px;min-width:0;
}
.inbox-account-select-wrap[hidden]{display:none !important;}
.inbox-account-select-label{
  font-size:11px;color:#708499;font-weight:600;letter-spacing:.02em;
}
.inbox-account-select{
  width:100%;height:36px;border-radius:10px;border:1px solid #2a3a4d;
  background:#121c27;color:#e8eef5;font:inherit;font-size:13px;
  padding:0 10px;outline:none;cursor:pointer;
}
.inbox-account-select:focus{border-color:#4e8fd6;}
.inbox-account-chips{
  display:flex;flex-wrap:wrap;gap:6px;align-items:stretch;
  max-height:108px;overflow-y:auto;overflow-x:hidden;
  padding:1px 2px 2px;scrollbar-width:thin;min-width:0;
}
.inbox-account-folder{
  flex:0 1 auto;min-width:0;max-width:100%;
  border:1px solid #2a3a4d;background:#1a2634;color:#dce6ef;
  border-radius:999px;padding:6px 10px;text-align:left;cursor:pointer;font:inherit;
  display:inline-flex;flex-direction:row;align-items:center;gap:6px;
  position:relative;overflow:visible;line-height:1.15;
}
.inbox-account-folder .inbox-account-user{display:none;}
.inbox-account-folder.active{
  background:linear-gradient(160deg,#1e3a5f,#243b55);border-color:#4e8fd6;
  box-shadow:inset 0 0 0 1px rgba(78,143,214,.35);
}
.inbox-account-top{display:flex;align-items:center;gap:6px;width:auto;min-width:0;max-width:140px;}
.inbox-account-name{
  flex:1;min-width:0;font-size:12px;font-weight:650;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.inbox-account-user{font-size:11px;color:#8ea4b8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.inbox-account-unread{
  flex-shrink:0;min-width:18px;height:18px;padding:0 5px;border-radius:999px;
  background:#4ea4f6;color:#fff;font-size:10.5px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;
  line-height:1;box-shadow:0 0 0 1px rgba(0,0,0,.12);
}
.check-row{
  display:flex;align-items:center;gap:8px;margin:8px 0 12px;font-size:13px;color:var(--text);cursor:pointer;
}
.check-row input{width:16px;height:16px;}
.check-inline{
  display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--muted);white-space:nowrap;
}
.check-inline input{width:14px;height:14px;}
.tg-search{
  display:flex;align-items:center;gap:8px;background:var(--tg-search,#242f3d);
  border-radius:22px;padding:8px 12px;
}
.tg-search svg{width:16px;height:16px;color:var(--tg-muted,#708499);flex-shrink:0;}
.tg-search input{
  background:none;border:none;outline:none;color:var(--tg-text,#f5f5f5);
  font-family:var(--font-ui);font-size:14px;width:100%;
}
.tg-search input::placeholder{color:var(--tg-muted,#708499);}
.inbox-list{overflow-x:hidden;overflow-y:auto;flex:1;min-width:0;}
.inbox-row{
  display:flex;align-items:center;gap:10px;text-align:left;width:100%;
  padding:8px 12px;border:none;background:transparent;color:var(--tg-text,#f5f5f5);
  cursor:pointer;font:inherit;border-radius:0;max-width:100%;min-width:0;box-sizing:border-box;
  border-left:3px solid transparent;position:relative;overflow:hidden;
}
.inbox-row.has-unread{
  padding-right:44px;
  background:rgba(78,164,246,.07);
}
.inbox-row:hover{background:var(--tg-hover,#202b36);}
.inbox-row.active{background:var(--tg-active,#2b5278);border-left-color:transparent;}
.inbox-row.active .inbox-preview,.inbox-row.active .inbox-time{color:#c8d9e8;}
.inbox-row.has-unread:hover{background:rgba(78,164,246,.12);}
.inbox-row.has-unread:not(.active){border-left-color:#4ea4f6;}
.inbox-row.has-unread .inbox-row-title{font-weight:700;color:#fff;}
.inbox-row.has-unread .inbox-preview{color:#d7e3ef;font-weight:500;}
.inbox-row.has-unread .inbox-time{color:#6ab3f3;font-weight:650;}
.inbox-row.active.has-unread{background:var(--tg-active,#2b5278);}
.tg-avatar{
  width:48px;height:48px;border-radius:50%;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:16px;color:#fff;letter-spacing:.02em;
  position:relative;overflow:visible;
}
.tg-avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:50%;z-index:1;}
.tg-avatar span{position:relative;z-index:0;}
.tg-avatar.has-photo span{display:none;}
.tg-avatar.has-photo{background:#243647 !important;}
.tg-avatar.is-online::after{display:none !important;}
.inbox-row.active .tg-avatar.is-online::after{display:none !important;}
.inbox-head-btn .tg-avatar.is-online::after{display:none !important;}
.tg-avatar-lg{width:88px;height:88px;font-size:28px;margin:8px auto 12px;}
.tg-avatar-lg.is-online::after{display:none !important;}
.inbox-row-body{
  min-width:0;flex:1 1 0%;max-width:100%;display:flex;flex-direction:column;gap:3px;overflow:hidden;
}
.inbox-row-top,
.inbox-row-bottom{
  display:flex;align-items:center;gap:8px;min-width:0;width:100%;max-width:100%;overflow:hidden;
}
.inbox-row-title{
  min-width:0;flex:1 1 0%;font-size:15px;font-weight:600;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.inbox-time{
  flex:0 0 auto;font-size:12px;line-height:1.2;color:var(--tg-muted,#708499);
  font-variant-numeric:tabular-nums;white-space:nowrap;
}
.unread{
  position:absolute;right:10px;bottom:10px;z-index:2;
  min-width:22px;height:22px;border-radius:999px;background:var(--tg-unread,#4dcd5e);
  color:#fff;font-size:12px;font-weight:700;display:inline-flex;align-items:center;
  justify-content:center;padding:0 7px;box-shadow:0 0 0 1px rgba(0,0,0,.15);
  pointer-events:none;
}
.inbox-preview-line{
  min-width:0;flex:1 1 0%;max-width:100%;display:flex;align-items:baseline;gap:4px;overflow:hidden;
}
.inbox-preview-checks{
  flex:0 0 auto;font-size:12px;letter-spacing:-.12em;opacity:.85;font-weight:600;
  color:#6a8095;line-height:1;
}
.inbox-preview-checks.is-read{color:#6ab3f3;opacity:1;}
.inbox-row.active .inbox-preview-checks{color:#9ec4e6;}
.inbox-row.active .inbox-preview-checks.is-read{color:#8ec7f5;}
.inbox-preview{
  display:block;min-width:0;flex:1 1 0%;max-width:100%;
  font-size:14px;color:var(--tg-muted,#708499);line-height:1.3;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  word-break:normal;overflow-wrap:normal;
}
.inbox-empty{padding:28px 16px;color:var(--tg-muted,#708499);font-size:14px;text-align:center;}
.inbox-main{
  display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;
  background:
    radial-gradient(circle at 12% 18%, #1a334433 0 2px, transparent 3px),
    radial-gradient(circle at 72% 64%, #1a334433 0 2px, transparent 3px),
    linear-gradient(180deg, #0e1621, #0b131c);
  background-size:42px 42px, 36px 36px, auto;
}
.inbox-main.is-empty .inbox-head,
.inbox-main.is-empty .inbox-thread,
.inbox-main.is-empty .composer{display:none;}
.inbox-main:not(.is-empty) .inbox-placeholder{display:none;}
.inbox-placeholder{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;
}
.inbox-mammoth{
  width:112px;height:112px;border-radius:28px;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 35% 30%,#3a4a5c 0%,#1a2430 70%);
  box-shadow:0 12px 32px -18px #000, inset 0 1px 0 #ffffff14;
  animation:mammoth-float 4.5s ease-in-out infinite;
}
.inbox-mammoth img{
  width:80px;height:80px;object-fit:contain;display:block;
  filter:drop-shadow(0 4px 8px #0006);
  image-rendering:auto;
}
@keyframes mammoth-float{
  0%,100%{transform:translateY(0);}
  50%{transform:translateY(-6px);}
}
@media (prefers-reduced-motion:reduce){
  .inbox-mammoth{animation:none;}
}
.inbox-placeholder-card{
  background:#1e2c3aee;color:#fff;border-radius:999px;padding:8px 16px;
  font-size:14px;box-shadow:0 8px 24px -16px #000;
}
.inbox-head{padding:6px 16px;background:#17212b;border-bottom:1px solid #101921;min-height:54px;display:flex;align-items:center;gap:8px;}
.inbox-head-btn{
  display:flex;align-items:center;gap:12px;background:none;border:none;color:inherit;
  cursor:pointer;padding:4px 0;text-align:left;width:100%;font:inherit;min-width:0;flex:1;
}
.inbox-head-btn .tg-avatar{width:40px;height:40px;font-size:14px;}
.inbox-head-text{min-width:0;flex:1;display:flex;flex-direction:column;gap:1px;}
.inbox-head-title-row{
  display:flex;align-items:center;gap:8px;min-width:0;width:100%;
}
.inbox-head-text h2{
  font-size:15px;font-weight:650;color:#fff;min-width:0;flex:1;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;
}
.inbox-account-badge{
  width:26px;height:26px;font-size:10px;flex-shrink:0;
  box-shadow:0 0 0 2px #17212b,0 0 0 3px #4ea4f6;
}
.inbox-account-badge.is-online::after{display:none;}
.inbox-head-text p{color:#708499;font-size:13px;margin-top:1px;}
.inbox-head-text p.is-online{color:#708499;}
.profile-seen{color:#708499;font-size:13px;margin:0 0 4px;min-height:1em;}
.profile-seen.is-online{color:#708499;}
.profile-seen[hidden]{display:none !important;}
.inbox-thread{flex:1;overflow:auto;padding:12px 18px 8px;display:flex;flex-direction:column;gap:2px;}
.inbox-thread-status{margin:auto;color:#c8d4de;background:#1e2c3aee;border-radius:999px;padding:7px 14px;font-size:13px;}
.inbox-history-loader{
  align-self:center;margin:4px 0 10px;padding:6px 12px;border-radius:999px;
  background:#1e2c3aee;color:#c8d4de;font-size:12.5px;
}
.tg-date{display:flex;justify-content:center;margin:10px 0 8px;}
.tg-date span{background:#1e2c3acc;color:#fff;border-radius:999px;padding:4px 10px;font-size:12.5px;}
.bubble-wrap{
  display:flex;flex-direction:column;width:100%;max-width:100%;margin:2px 0;gap:4px;
}
.bubble-wrap.in{align-items:flex-start;}
.bubble-wrap.out{align-items:flex-end;}
.bubble-actions{
  position:relative;display:none;flex-shrink:0;gap:4px;align-items:center;
  padding:0 2px;
}
.bubble-wrap:hover .bubble-actions{display:inline-flex;}
.bubble-reply-quick{display:none;}
.bubble-more-btn{
  width:30px;height:28px;border:none;border-radius:8px;background:#1e2c3a;color:#c8d4de;
  cursor:pointer;font-size:18px;line-height:1;font-weight:700;
}
.bubble-more-btn:hover,.bubble-more-btn.is-open{background:#2b5278;color:#fff;}
.bubble-menu{
  position:absolute;z-index:20;top:100%;margin-top:4px;
  min-width:148px;padding:4px;border-radius:12px;
  background:#17212b;border:1px solid #2a3a4d;
  box-shadow:0 10px 28px -12px #000c;
  display:flex;flex-direction:column;gap:2px;
}
.bubble-wrap.in .bubble-menu{left:0;}
.bubble-wrap.out .bubble-menu{right:0;}
.bubble-menu.is-ctx{
  position:fixed !important;
  z-index:120;
  margin:0;
  left:0;top:0;right:auto;
}
.bubble-menu[hidden]{display:none !important;}
.bubble-menu button{
  width:100%;height:auto;min-height:36px;border:none;border-radius:8px;
  background:transparent;color:#e8eef5;cursor:pointer;font:inherit;font-size:13.5px;
  text-align:left;padding:8px 10px;line-height:1.2;
}
body.is-desktop .bubble-wrap,
body.is-tablet .bubble-wrap{
  user-select:none;
}
body.is-desktop .bubble-wrap .bubble-text,
body.is-tablet .bubble-wrap .bubble-text{
  user-select:text;
}
.bubble-menu button:hover{background:#2b5278;color:#fff;}
.bubble-menu button.is-danger{color:#f5a8a8;}
.bubble-menu button.is-danger:hover{background:#5a2a2a;color:#fff;}
.bubble-actions button{
  width:30px;height:28px;border:none;border-radius:8px;background:#1e2c3a;color:#c8d4de;
  cursor:pointer;font-size:13px;line-height:1;
}
.bubble-actions button:hover{background:#2b5278;color:#fff;}
.bubble-reply{
  border-left:2px solid #6ab3f3;padding:2px 0 4px 8px;margin:2px 0 4px;
  font-size:13px;color:#c8d4de;overflow:hidden;text-overflow:ellipsis;white-space:normal;
  max-width:100%;overflow-wrap:anywhere;word-break:break-word;
}
.reply-bar,.record-bar{
  display:flex;align-items:center;gap:10px;background:#17212b;border-radius:12px;
  padding:8px 10px;margin-bottom:8px;color:#fff;
}
.reply-bar[hidden],.record-bar[hidden]{display:none !important;}
.reply-bar{justify-content:space-between;border-left:3px solid #6ab3f3;}
.reply-bar.is-edit{border-left-color:#e0a458;}
.reply-bar-body{min-width:0;flex:1;}
.reply-bar b{color:#6ab3f3;font-size:12px;}
.reply-bar.is-edit b{color:#e0a458;}
.reply-bar p{font-size:13px;color:#c8d4de;margin:2px 0 0;max-width:420px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.reply-bar button,.record-bar button{
  background:#242f3d;border:none;color:#c8d4de;border-radius:8px;padding:5px 10px;cursor:pointer;font:inherit;
  flex-shrink:0;
}
.bubble-wrap.is-edit-target > .bubble{
  outline:1px solid rgba(224,164,88,.55);
  outline-offset:1px;
}
.record-dot{
  width:10px;height:10px;border-radius:50%;background:#e53935;flex-shrink:0;
  animation:record-pulse 1s infinite;
}
@keyframes record-pulse{0%,100%{opacity:1}50%{opacity:.35}}
.record-wave{
  flex:1;height:18px;border-radius:8px;
  background:repeating-linear-gradient(90deg,#2b5278 0 3px,transparent 3px 6px);
  animation:record-wave .6s linear infinite;
}
@keyframes record-wave{to{background-position:12px 0}}
.record-bar #recordTime{font-variant-numeric:tabular-nums;min-width:40px;}
.record-bar #recordStop{
  background:#2b5278;color:#fff;font-weight:700;min-width:72px;min-height:40px;padding:8px 14px;
}
.record-bar #recordCancel{background:#3a2a2a;color:#f5c2c2;min-height:40px;}
.composer-row.is-recording{opacity:.45;pointer-events:none;}
.composer-row.is-recording #composerVoice{pointer-events:auto;opacity:1;}
.voice-pack{display:flex;flex-direction:column;min-height:0;flex:1;overflow:hidden;max-height:320px;}
.voice-pack[hidden]{display:none !important;}
.photo-pack{display:flex;flex-direction:column;min-height:0;flex:1;overflow:hidden;max-height:320px;}
.photo-pack[hidden]{display:none !important;}
.photo-pack-bar{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:8px 10px;border-bottom:1px solid #101921;flex-shrink:0;
}
.photo-pack-bar span{font-size:12.5px;color:#8ea4b8;}
.photo-pack-bar .btn{min-height:32px;padding:6px 12px;}
.photo-lib{overflow:auto;padding:6px 8px 10px;min-height:0;flex:1;}
.photo-lib-title{font-size:12px;color:#708499;margin:8px 4px 6px;}
.photo-lib-grid{
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;
}
.photo-lib-item{
  position:relative;aspect-ratio:1;border:none;border-radius:10px;padding:0;
  overflow:hidden;cursor:pointer;background:#101921;
}
.photo-lib-item img{width:100%;height:100%;object-fit:cover;display:block;}
.photo-lib-item.is-selected{outline:2px solid #4ea4f6;outline-offset:0;}
.photo-lib-check{
  position:absolute;top:6px;right:6px;width:22px;height:22px;border-radius:50%;
  background:#0008;color:#fff;font-size:12px;font-weight:700;
  display:inline-flex;align-items:center;justify-content:center;
  border:1px solid #fff6;
}
.photo-lib-item.is-selected .photo-lib-check{background:#4ea4f6;border-color:#4ea4f6;}
.voice-lib-search{
  display:flex;align-items:center;gap:8px;margin:8px 8px 0;
  background:#242f3d;border-radius:18px;padding:7px 12px;flex-shrink:0;
}
.voice-lib-search svg{width:15px;height:15px;color:#708499;flex-shrink:0;}
.voice-lib-search input{
  flex:1;background:none;border:none;outline:none;color:#fff;
  font:inherit;font-size:14px;min-width:0;
}
.voice-lib-search input::placeholder{color:#708499;}
.voice-lib{overflow:auto;padding:4px 8px 8px;min-height:0;flex:1;}
.voice-lib[hidden]{display:none !important;}
.voice-lib-title{font-size:12px;color:#708499;margin:8px 4px 4px;}
.voice-lib-item{
  width:100%;display:flex;gap:8px;align-items:flex-start;background:transparent;border:none;
  color:#fff;text-align:left;padding:8px;border-radius:8px;cursor:pointer;font:inherit;
}
.voice-lib-item:hover,.voice-lib-item:focus{background:#202b36;outline:none;}
.voice-lib-item b mark,.voice-lib-item small mark,.voice-lib-title mark{
  background:#4ea4f666;color:#fff;border-radius:3px;padding:0 1px;
}
.voice-lib-item small{display:block;color:#708499;font-size:12px;margin-top:2px;}
.voice-lib-play{width:28px;height:28px;border-radius:50%;background:#2b5278;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;}
.voice-lib-count{color:#708499;font-size:12px;padding:6px 8px 2px;}
.voice-folder-list{display:flex;flex-direction:column;gap:6px;margin-top:12px;}
.voice-folder-item{
  display:flex;align-items:center;gap:8px;background:#202b36;border:none;color:#fff;
  border-radius:10px;padding:8px 10px;cursor:pointer;font:inherit;width:100%;
}
.voice-folder-item.active{background:#2b5278;}
.voice-folder-item span:first-child{flex:1;text-align:left;}
.voice-folder-del{opacity:.5}
.voices-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;}
.voices-import,.voices-upload{
  background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:12px;
}
.voices-import-row{display:grid;grid-template-columns:1.4fr 1.2fr 140px;gap:8px;}
.voices-import-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.voices-import-actions .hint{margin:0;}
.voices-import select.text-input{height:38px;}
.voice-clip-list{display:flex;flex-direction:column;gap:10px;}
.voice-clip-card{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  grid-template-areas:"meta actions" "audio audio";
  gap:8px 12px;
  align-items:start;
  background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px;
  overflow:hidden;isolation:isolate;
}
.voice-clip-card.is-editing{grid-template-areas:"edit edit" "audio audio";}
.voice-clip-card audio{
  grid-area:audio;width:100%;max-width:100%;min-width:0;height:40px;display:block;
}
.voice-clip-meta{grid-area:meta;min-width:0;}
.voice-clip-actions{grid-area:actions;display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;}
.voice-clip-edit{grid-area:edit;display:flex;flex-direction:column;gap:8px;min-width:0;}
.voice-clip-edit .field{margin:0;}
.voice-clip-edit textarea.text-input{min-height:64px;resize:vertical;}
.voice-clip-edit-bar{display:flex;gap:8px;flex-wrap:wrap;}
.voice-clip-meta b{display:block;margin-bottom:4px;overflow-wrap:break-word;word-break:normal;}
.voice-clip-meta p{color:var(--muted);font-size:13px;overflow-wrap:break-word;word-break:normal;margin:0;}
.composer.is-locked .sticker-panel{display:none !important;}
.bubble-edited{margin-right:4px;opacity:.8;font-style:italic;}
.bubble-edit-input{
  width:min(360px,70vw);min-height:64px;resize:vertical;border:none;border-radius:8px;
  background:#16324d;color:#fff;font:inherit;padding:8px;outline:none;
}
.bubble-edit-bar{display:flex;justify-content:flex-end;gap:6px;margin-top:8px;}
.bubble-edit-bar button{
  background:#1e2c3a;border:none;color:#c8d4de;border-radius:8px;padding:5px 10px;
  cursor:pointer;font:inherit;font-size:13px;
}
.bubble-edit-bar button.is-primary{background:#2b5278;color:#fff;}
.profile-meta{width:100%;margin:16px 0 0;text-align:left;}
.profile-meta > div{
  display:flex;justify-content:space-between;gap:12px;padding:9px 0;
  border-bottom:1px solid #101921;
}
.profile-meta dt{color:var(--tg-muted,#708499);font-size:13px;}
.profile-meta dd{color:#fff;font-size:13px;text-align:right;word-break:break-word;}
.inbox-thread .bubble{
  max-width:min(68%, 460px);padding:6px 10px 4px;border-radius:14px;border:none;
  position:relative;box-shadow:0 1px 2px #0004;min-width:0;overflow-wrap:anywhere;
}
.inbox-thread .bubble.in{align-self:auto;background:var(--tg-in,#182533);border-bottom-left-radius:5px;}
.inbox-thread .bubble.out{align-self:auto;background:var(--tg-out,#2b5278);border-bottom-right-radius:5px;}
.inbox-thread .bubble-text{
  white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;
  font-size:15px;line-height:1.35;padding-right:46px;color:#fff;max-width:100%;
}
.inbox-thread .bubble-time{
  float:right;margin:6px 0 0 10px;font-size:11px;color:#8ea4b8;line-height:1;
  position:relative;z-index:1;display:inline-flex;align-items:center;gap:4px;
}
.inbox-thread .bubble.out .bubble-time{color:#8bb8e0;}
.bubble-checks{
  font-size:11px;letter-spacing:-.12em;opacity:.85;font-weight:600;
  color:#8bb8e0;line-height:1;margin-left:1px;
}
.bubble-checks.is-read{color:#6ab3f3;opacity:1;}
.inbox-thread .bubble.media-only .bubble-time,
.bubble-voice + .bubble-time{
  float:none;display:block;clear:both;text-align:right;margin:4px 0 0;
}
.inbox-profile{
  width:300px;border-left:1px solid #101921;background:#17212b;padding:16px;
  display:flex;flex-direction:column;align-items:stretch;text-align:center;
  min-height:0;overflow:auto;
}
.inbox-profile[hidden]{display:none !important;}
.inbox-profile-card{
  display:flex;flex-direction:column;align-items:center;width:100%;min-width:0;text-align:center;
}
.inbox-profile h3{font-size:18px;margin:0 0 4px;color:#fff;}
.inbox-profile-close{
  align-self:flex-end;background:none;border:none;color:var(--tg-muted);cursor:pointer;font-size:16px;
  width:32px;height:32px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;
}
.inbox-profile-close:hover{background:#202b36;color:#fff;}
.profile-note{
  width:100%;margin-top:16px;text-align:left;display:flex;flex-direction:column;gap:8px;
}
.profile-note label{
  font-size:12.5px;color:#8ea4b8;font-weight:600;
}
.profile-note textarea{
  width:100%;min-height:96px;max-height:220px;resize:vertical;box-sizing:border-box;
  border:1px solid #2a3a4d;border-radius:12px;background:#121c27;color:#e8eef5;
  font:inherit;font-size:14px;line-height:1.4;padding:10px 12px;outline:none;
}
.profile-note textarea:focus{border-color:#4e8fd6;}
.profile-note-bar{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
}
.profile-note-status{font-size:12px;color:#708499;min-height:1em;}
.profile-note-status.is-ok{color:#4dcd5e;}
.profile-note-status.is-err{color:#f5a8a8;}
.composer{padding:8px 10px 12px;background:transparent;}
.suggest-box{
  font-size:13px;color:#c8d4de;background:#1e2c3a;border:none;border-radius:12px;
  padding:8px 10px;margin-bottom:8px;display:flex;flex-direction:column;gap:8px;
}
.suggest-box[hidden]{display:none !important;}
.suggest-toolbar{display:flex;flex-wrap:wrap;gap:6px;align-items:center;}
.suggest-toolbar .btn{min-height:32px;padding:6px 10px;font-size:12.5px;}
.suggest-text{margin:0;line-height:1.4;white-space:pre-wrap;word-break:break-word;color:#dce6ef;}
.suggest-text.is-muted{color:#708499;}
.suggest-text.is-err{color:#f5a8a8;}
.suggest-text.is-loading{color:#8ea4b8;}
.composer-row{
  display:flex;gap:4px;align-items:flex-end;background:#17212b;border-radius:16px;
  padding:6px 8px;box-shadow:0 8px 20px -16px #000;
}
.composer-row textarea{
  flex:1 1 auto;min-width:0;width:100%;resize:none;min-height:24px;max-height:140px;
  border:none;background:transparent;color:#fff;font-family:var(--font-ui);font-size:15px;
  line-height:1.4;outline:none;padding:8px 6px;overflow-x:hidden;overflow-y:auto;
  white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;
  field-sizing:content;
}
.composer-row textarea::placeholder{color:#708499;}
.tg-icon-btn{
  width:40px;height:40px;border:none;background:transparent;color:#708499;border-radius:10px;
  display:inline-flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;
}
/* display:inline-flex выше перебивает UA [hidden] — без !important кнопки остаются видимыми */
.tg-icon-btn[hidden],.tg-send[hidden],
#composerVoice[hidden],#composerVoiceChange[hidden],#composerSend[hidden]{
  display:none !important;
}
.composer-row.is-typing #composerVoice,
.composer-row.is-typing #composerVoiceChange{
  display:none !important;
}
.tg-icon-btn svg{width:22px;height:22px;}
.tg-icon-btn:hover{color:#fff;background:#202b36;}
.tg-send{color:#4ea4f6;}
.tg-send:hover{color:#6ab3f3;}
.composer-attach{cursor:pointer;}
#composerVoice.recording{color:#fff;background:#e53935;}
#composerVoiceChange{font-size:12px;font-weight:700;letter-spacing:.02em;min-width:36px;}
#composerVoiceChange.active{background:#2b5278;color:#fff;}
#composerVoiceChange:not([hidden]) + #composerVoice{margin-left:0;}
.bubble-media{max-width:280px;max-height:280px;border-radius:10px;display:block;margin:2px 0 4px;}
.bubble-media-btn{
  display:block;padding:0;margin:0;border:none;background:transparent;cursor:zoom-in;max-width:280px;
}
.bubble-media-btn .bubble-media{margin:0;}
.bubble-album{
  display:grid;gap:2px;width:min(280px,100%);max-width:100%;
  border-radius:12px;overflow:hidden;margin:2px 0 4px;background:#0e1621;
}
.bubble-album.count-1{grid-template-columns:1fr;}
.bubble-album.count-2{grid-template-columns:1fr 1fr;aspect-ratio:2/1.15;}
.bubble-album.count-3{
  grid-template-columns:1.2fr 1fr;grid-template-rows:1fr 1fr;aspect-ratio:1.05;
}
.bubble-album.count-3 .album-cell:first-child{grid-row:1 / span 2;}
.bubble-album.count-4{
  grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;aspect-ratio:1;
}
.bubble-album.count-many{
  grid-template-columns:repeat(3,minmax(0,1fr));
}
.album-cell{
  position:relative;padding:0;margin:0;border:none;background:#17212b;cursor:zoom-in;
  overflow:hidden;min-width:0;min-height:0;
}
.bubble-album.count-many .album-cell{aspect-ratio:1;}
.album-cell img{
  width:100%;height:100%;object-fit:cover;display:block;
}
.inbox-thread .bubble.album-bubble{padding:4px;max-width:min(92%,320px);}
.inbox-thread .bubble.album-bubble .bubble-text{padding:6px 8px 2px;padding-right:46px;}
.inbox-thread .bubble.album-bubble .bubble-time{margin:4px 6px 2px;}
.inbox-thread .bubble.album-bubble .bubble-reply{margin:4px 6px 2px;}
.bubble-temp-badge{
  display:inline-block;font-size:11px;font-weight:600;letter-spacing:.02em;
  color:#ffd54f;background:rgba(255,213,79,.12);border-radius:999px;padding:2px 8px;margin:2px 0 6px;
}
.bubble.is-temp{outline:1px solid rgba(255,213,79,.35);}
.voice-save{
  margin-left:auto;border:none;background:#242f3d;color:#c8d4de;border-radius:8px;
  width:28px;height:28px;cursor:pointer;font-size:13px;line-height:1;flex-shrink:0;
}
.voice-save:hover{background:#2b5278;color:#fff;}
.media-lightbox-inner{
  position:relative;max-width:min(920px,94vw);max-height:90vh;display:flex;flex-direction:column;
  align-items:center;gap:12px;
}
.media-lightbox-inner img{
  max-width:100%;max-height:78vh;border-radius:12px;object-fit:contain;background:#0e1621;
}
.media-lightbox-close{position:absolute;top:-8px;right:-8px;z-index:2;}
.media-lightbox-actions{display:flex;gap:8px;}
#mediaLightbox{background:rgba(7,12,18,.88);}
.bubble-voice{
  display:flex;align-items:center;gap:8px;
  width:min(260px,100%);min-width:180px;max-width:100%;
  margin:2px 0 4px;position:relative;z-index:0;clear:both;
}
.bubble-voice audio{position:absolute;width:0;height:0;opacity:0;pointer-events:none;}
.voice-play{
  width:36px;height:36px;border:none;border-radius:50%;flex-shrink:0;
  background:#4ea4f6;color:#fff;font-size:13px;line-height:1;cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;padding:0 0 0 2px;
}
.bubble.out .voice-play{background:#6ab3f3;color:#16324d;}
.voice-play:hover{filter:brightness(1.08);}
.bubble-voice.is-playing .voice-wave{animation:record-wave .45s linear infinite;}
.voice-wave{
  flex:1;height:18px;border-radius:8px;min-width:72px;
  background:repeating-linear-gradient(90deg,#6ab3f3 0 3px,transparent 3px 6px);
}
.bubble.out .voice-wave{background:repeating-linear-gradient(90deg,#c8d9e8 0 3px,transparent 3px 6px);}
.voice-dur{font-size:12px;color:#8ea4b8;flex-shrink:0;font-variant-numeric:tabular-nums;}
.bubble.out .voice-dur{color:#c8d9e8;}
.bubble-voice + .bubble-text{clear:both;margin-top:4px;padding-right:46px;}
.bubble-file{
  display:flex;align-items:center;gap:8px;margin:2px 0 4px;color:#fff;text-decoration:none;
  background:#ffffff10;border-radius:10px;padding:8px 10px;
}
.bubble-file-icon{font-size:18px;}
.bubble-sticker{width:160px;height:160px;object-fit:contain;display:block;margin:2px 0 4px;background:transparent;}
.sticker-panel{background:#17212b;border-radius:14px;margin-bottom:8px;overflow:hidden;max-height:380px;display:flex;flex-direction:column;}
.sticker-panel[hidden]{display:none !important;}
.sticker-toolbar{display:flex;gap:6px;align-items:center;padding:8px;border-bottom:1px solid #101921;overflow-x:auto;flex-shrink:0;}
.sticker-toolbar .sticker-set{flex:0 0 auto;}
.sticker-panel-close{
  margin-left:auto;width:28px;height:28px;border:none;background:transparent;
  color:#708499;cursor:pointer;border-radius:8px;font-size:14px;
}
.sticker-panel-close:hover{color:#fff;background:#202b36;}
.emoji-grid{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(36px,1fr));
  gap:2px;padding:8px;overflow:auto;
}
.emoji-grid[hidden]{display:none !important;}
.emoji-cell{
  background:transparent;border:none;border-radius:8px;padding:4px;cursor:pointer;
  font-size:22px;line-height:1;height:36px;
}
.emoji-cell:hover{background:#202b36;}
.sticker-sets{display:flex;gap:6px;overflow:auto;padding:8px;border-bottom:1px solid #101921;}
.sticker-sets[hidden],.sticker-grid[hidden]{display:none !important;}
.sticker-set{background:#242f3d;border:none;color:#c8d4de;border-radius:8px;padding:6px 10px;cursor:pointer;font:inherit;font-size:12px;white-space:nowrap;}
.sticker-set.active,.tg-icon-btn.active{background:#2b5278;color:#fff;}
.sticker-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(72px,1fr));gap:4px;padding:8px;overflow:auto;}
.sticker-cell{background:transparent;border:none;border-radius:8px;padding:4px;cursor:pointer;}
.sticker-cell:hover{background:#202b36;}
.sticker-cell img,.sticker-cell video{width:64px;height:64px;object-fit:contain;display:block;}

.admin-split{display:grid;grid-template-columns:280px 1fr;gap:16px;align-items:start;}
.admin-side-col{display:flex;flex-direction:column;gap:12px;}
.admin-side-card .hint{margin:0 0 12px;}
#noticeBody{min-height:88px;resize:vertical;}

/* ---- Telegram-like notices page ---- */
.notices-page{
  background:
    radial-gradient(circle at 12% 18%, #1a334433 0 2px, transparent 3px),
    radial-gradient(circle at 72% 64%, #1a334433 0 2px, transparent 3px),
    linear-gradient(180deg, #0e1621, #0b131c);
  background-size:42px 42px, 36px 36px, auto;
}
.tg-page-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:10px 16px;min-height:56px;flex-shrink:0;
  background:#17212b;border-bottom:1px solid #0e1621;
}
.tg-page-head-text{min-width:0;flex:1;}
.tg-page-head-text h1{font-size:16px;font-weight:700;margin:0;color:#f5f5f5;letter-spacing:-.02em;}
.tg-page-head-text p{margin:2px 0 0;font-size:13px;color:#708499;}
.tg-chip-btn{
  border:none;background:#242f3d;color:#c8d4de;border-radius:18px;
  padding:7px 12px;font:inherit;font-size:13px;font-weight:600;cursor:pointer;
}
.tg-chip-btn:hover,.tg-chip-btn:active{background:#2b5278;color:#fff;}
.notice-head{margin-bottom:0;}
.notice-head-actions{display:flex;gap:8px;align-items:center;flex-shrink:0;flex-wrap:wrap;}

.notice-list{
  overflow:auto;flex:1;display:flex;flex-direction:column;gap:10px;
  min-height:0;padding:14px 12px 20px;
  max-width:760px;width:100%;margin:0 auto;box-sizing:border-box;
}

.notice-card{
  display:flex;align-items:flex-end;gap:8px;
  background:transparent;border:none;padding:0;cursor:pointer;
  max-width:100%;
}
.notice-avatar{
  width:36px;height:36px;border-radius:50%;flex-shrink:0;
  display:inline-flex;align-items:center;justify-content:center;
  background:linear-gradient(145deg,#5ba4d9,#2b6cb0);
  color:#fff;font-size:14px;font-weight:700;
}
.notice-bubble{
  flex:1;min-width:0;max-width:min(560px, calc(100% - 44px));
  background:#182533;border-radius:6px 16px 16px 16px;
  padding:8px 11px 7px;
  box-shadow:0 1px 1px #0003;
  position:relative;
}
.notice-card.is-unread .notice-bubble{
  background:#1a2d42;
  box-shadow:0 1px 1px #0003, inset 0 0 0 1px #4ea4f655;
}
.notice-card.is-unread .notice-title{color:#fff;}
.notice-card-top{
  display:flex;justify-content:space-between;gap:10px;align-items:flex-start;
}
.notice-title{
  font-size:14px;font-weight:650;color:#6ab3f3;margin:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;
}
.notice-card-actions{display:inline-flex;align-items:center;gap:6px;flex-shrink:0;}
.notice-card-actions time{
  color:#708499;font-size:12px;white-space:nowrap;
}
.notice-del{
  width:22px;height:22px;border:none;border-radius:50%;
  background:transparent;color:#708499;cursor:pointer;font-size:12px;line-height:1;
  display:inline-flex;align-items:center;justify-content:center;padding:0;
}
.notice-del:hover{background:#243647;color:#fff;}
.notice-body{
  margin:4px 0 6px;white-space:pre-wrap;word-break:break-word;line-height:1.4;
  font-size:14.5px;color:#e8eef5;
}
.notice-meta{
  display:flex;align-items:center;justify-content:flex-end;gap:8px;
  color:#708499;font-size:12px;
}
.notice-meta .notice-new{
  color:#4ea4f6;font-weight:650;margin-right:auto;
}
.notice-empty{
  margin:auto;padding:48px 20px;text-align:center;
  display:flex;flex-direction:column;align-items:center;gap:8px;
  color:#708499;max-width:280px;
}
.notice-empty-icon{
  width:64px;height:64px;border-radius:50%;
  background:#17212b;display:flex;align-items:center;justify-content:center;
  font-size:28px;margin-bottom:4px;
  box-shadow:inset 0 0 0 1px #243647;
}
.notice-empty b{color:#e8eef5;font-size:16px;font-weight:650;}
.notice-empty span{font-size:14px;line-height:1.4;}

.notice-sent-title{
  font-size:13px;margin:16px 0 10px;color:#708499;font-weight:650;
  text-transform:uppercase;letter-spacing:.04em;
}
.notice-sent-list{display:flex;flex-direction:column;gap:10px;margin-bottom:8px;}
.notice-sent-item{
  background:transparent;border:none;padding:0;
  display:flex;justify-content:flex-end;
}
.notice-bubble.is-out{
  background:#2b5278;border-radius:16px 6px 16px 16px;max-width:100%;
}
.notice-bubble.is-out .notice-title{color:#9fd0ff;}
.notice-bubble.is-out .notice-body{color:#fff;}
.notice-bubble.is-out .notice-meta,
.notice-bubble.is-out time{color:#a8c5de;}

.notice-modal{
  max-width:480px;max-height:min(92vh,760px);overflow:auto;
  background:#17212b;border:1px solid #243647;border-radius:16px;
}
.notice-modal #noticeSentBox{margin-top:14px;}
.notice-modal .notice-sent-title{margin-top:4px;}
.notice-modal .modal-footer{display:flex;gap:8px;flex-wrap:wrap;}
.notice-modal .modal-footer .btn{flex:1;min-width:120px;}
.notice-modal .text-input{
  background:#242f3d;border-color:#2a3a4d;border-radius:12px;
}
.notice-modal .text-input:focus{border-color:#4e8fd6;}

.admin-side-card{
  background:#17212b;border:1px solid #243647;border-radius:14px;padding:16px;
}
.admin-side-card h3{margin-bottom:6px;font-size:15px;color:#e8eef5;}
.admin-main{min-width:0;}
.admin-table{width:100%;border-collapse:collapse;background:#17212b;border:1px solid #243647;border-radius:12px;overflow:hidden;}
.admin-table th,.admin-table td{padding:10px 12px;text-align:left;border-bottom:1px solid #243647;font-size:13px;vertical-align:top;}
.admin-table th{color:#708499;font-size:11px;text-transform:uppercase;letter-spacing:.04em;}
.admin-table tr.is-disabled{opacity:.55;}
.admin-table .muted{color:#708499;font-size:12px;margin-top:2px;}
.admin-table .mono{font-family:var(--font-mono);font-size:12px;}
.admin-table .nowrap{white-space:nowrap;}
.staff-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px;}

.staff-tile{
  background:#17212b;border:1px solid #243647;border-radius:14px;padding:14px;
  display:flex;flex-direction:column;gap:12px;cursor:pointer;
  transition:border-color .12s, box-shadow .12s, background .12s;
}
.staff-tile:hover{border-color:#2b5278;background:#1a2634;box-shadow:none;}
.staff-tile.is-off{opacity:.72;}
.staff-tile-top{display:flex;align-items:center;gap:10px;}
.staff-tile-who{flex:1;min-width:0;}
.staff-tile-who b{display:block;font-size:14.5px;letter-spacing:-.02em;color:#e8eef5;}
.staff-tile-who span{display:block;color:#708499;font-family:var(--font-mono);font-size:12px;margin-top:1px;}
.staff-tile-note{color:#708499;font-size:12.5px;line-height:1.4;margin:0;}
.staff-tile-stats{
  display:grid;grid-template-columns:repeat(3,1fr);gap:8px;
  border-top:1px solid #243647;padding-top:10px;
}
.staff-tile-stats div{display:flex;flex-direction:column;gap:2px;min-width:0;}
.staff-tile-stats b{font-size:16px;font-weight:750;letter-spacing:-.03em;color:#e8eef5;}
.staff-tile-stats span{font-size:11px;color:#708499;}
.staff-tile-actions{display:flex;gap:6px;flex-wrap:wrap;}
.staff-tile-actions .btn{flex:1;min-width:72px;}

.staff-avatar{
  width:42px;height:42px;border-radius:50%;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  font-weight:750;font-size:14px;color:#fff;letter-spacing:.02em;
  background:linear-gradient(145deg,#5ba4d9,#2b6cb0);
}
.staff-modal{
  max-width:760px;max-height:min(92vh,860px);overflow:auto;
  padding:18px 18px 20px;display:flex;flex-direction:column;gap:14px;
}
.staff-card-top{display:flex;align-items:center;gap:12px;}
.staff-card-top .staff-avatar{width:52px;height:52px;font-size:18px;border-radius:14px;}
.staff-card-who{flex:1;min-width:0;}
.staff-card-who-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.staff-card-who h2{font-size:18px;margin:0;letter-spacing:-.03em;}
.staff-card-login{color:var(--muted);font-size:13px;margin-top:3px;}
.staff-section{
  background:var(--bg-soft);border:1px solid var(--line);border-radius:12px;padding:12px 12px 10px;
}
.staff-section h3{font-size:13px;font-weight:650;margin:0 0 8px;letter-spacing:-.01em;}
.staff-section > .hint{margin:-2px 0 10px;}
.staff-edit-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.staff-edit-grid .field{margin:0;}
.staff-card-actions{display:flex;gap:8px;margin-top:10px;}
.staff-grant{display:grid;grid-template-columns:1.4fr 100px 1fr auto;gap:8px;align-items:end;}
.staff-grant .field{margin:0;}
.staff-grant .btn{height:38px;padding:0 14px;}
.staff-detail{display:flex;flex-direction:column;gap:12px;}
.staff-metrics{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;}
.staff-metric{
  background:var(--bg-soft);border:1px solid var(--line);border-radius:12px;padding:10px 12px;
  display:flex;flex-direction:column;gap:4px;
}
.staff-metric span{font-size:11px;color:var(--muted-2);font-weight:600;}
.staff-metric b{font-size:18px;font-weight:750;letter-spacing:-.03em;}
.staff-access-card,.staff-chat-row{
  background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:8px;
}
.staff-access-card:last-child,.staff-chat-row:last-child{margin-bottom:0;}
.staff-access-top,.staff-chat-row{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.staff-access-top b,.staff-chat-row b{display:block;font-size:13.5px;}
.staff-access-top small,.staff-chat-row small{display:block;color:var(--muted);font-size:12px;margin-top:2px;}
.staff-bar{height:6px;border-radius:999px;background:#2a3344;overflow:hidden;margin:8px 0 5px;}
.staff-bar i{display:block;height:100%;background:linear-gradient(90deg,#4ec8e8,#5fd49a);border-radius:inherit;}
.staff-access-cap{font-size:11.5px;color:var(--muted-2);}
.work-root{display:flex;flex-direction:column;gap:14px;max-width:920px;padding-bottom:20px;}
.work-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;}
.work-metric,.work-card{
  background:#17212b;border:1px solid #243647;border-radius:14px;padding:12px 14px;color:var(--tg-text,#f5f5f5);
}
.work-metric span,.work-card h3{display:block;font-size:11.5px;font-weight:650;color:var(--tg-muted,#708499);margin:0 0 6px;}
.work-card h3{font-size:13px;color:#dbe6f0;margin-bottom:10px;}
.work-metric b{display:block;font-size:24px;font-weight:750;letter-spacing:-.03em;line-height:1.1;}
.work-metric small,.work-cap{display:block;margin-top:6px;color:var(--tg-muted,#708499);font-size:12px;}
.work-quality{display:flex;gap:16px;align-items:flex-start;}
.work-score{
  width:76px;height:76px;border-radius:50%;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  font-size:24px;font-weight:800;border:3px solid #3d4f63;color:#93a0b5;
}
.work-score.is-good{border-color:#4dcd5e;color:#4dcd5e;}
.work-score.is-ok{border-color:#6ab3f3;color:#6ab3f3;}
.work-score.is-mid{border-color:#e0b45c;color:#e0b45c;}
.work-score.is-low{border-color:#e07a7a;color:#e07a7a;}
.work-quality-text{min-width:0;flex:1;}
.work-quality-text h3{font-size:16px;color:#f5f5f5;margin:2px 0 6px;}
.work-quality-text p,.work-quality-text li{color:#8ea0b3;font-size:13px;line-height:1.45;}
.work-quality-text ul{margin:8px 0 0;padding-left:18px;}
.work-split{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.work-bar{height:6px;border-radius:999px;background:#243647;overflow:hidden;margin:8px 0 6px;}
.work-bar i{display:block;height:100%;background:linear-gradient(90deg,#6ab3f3,#4dcd5e);border-radius:inherit;}
.work-slots{display:flex;flex-direction:column;gap:8px;margin-top:10px;}
.work-slot{background:#13202c;border:1px solid #243647;border-radius:10px;padding:8px 10px;}
.work-slot span,.work-slot small{color:#708499;font-size:12px;}
.work-kv{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:10px;}
.work-kv span{display:block;color:#708499;font-size:11.5px;margin-bottom:3px;}
.work-kv b{font-size:16px;}
.work-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px;}
.work-pills span{
  background:#13202c;border:1px solid #243647;border-radius:999px;
  padding:4px 8px;font-size:12px;color:#c8d9e8;
}
.work-days{display:grid;grid-template-columns:repeat(7,1fr);gap:8px;align-items:end;height:84px;margin:8px 0 12px;}
.work-day-col{display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:6px;height:100%;}
.work-day-col i{width:100%;max-width:28px;background:#2b5278;border-radius:5px 5px 2px 2px;display:block;}
.work-day-col em{font-style:normal;font-size:10px;color:#708499;}
.work-mix{display:flex;flex-direction:column;gap:7px;}
.work-mix-row{display:grid;grid-template-columns:88px 1fr 36px;gap:8px;align-items:center;}
.work-mix-row span{color:#8ea0b3;font-size:12px;}
.work-mix-row .work-bar{margin:0;}
.work-mix-row b{text-align:right;font-size:13px;}
.grant-inline{display:grid;grid-template-columns:1fr 80px 1fr auto;gap:6px;margin-bottom:12px;}
.block-title{font-size:13px;margin:14px 0 8px;}
.compact-stats{grid-template-columns:repeat(4,minmax(0,1fr));margin:0 0 8px;}
@media (max-width:900px){
  .admin-split,.staff-edit-grid,.grant-inline,.staff-grant,.staff-metrics,.voices-import-row,.work-grid,.work-split,.work-kv{grid-template-columns:1fr;}
}

@media (max-width:1100px){
  .inbox{grid-template-columns:300px 1fr;}
  .inbox:has(#inboxProfile:not([hidden])){grid-template-columns:300px 1fr;}
  .inbox-profile:not([hidden]){
    display:flex !important;
    position:fixed;inset:0;z-index:90;width:auto;border:none;
    background:rgba(8,14,22,.62);backdrop-filter:blur(3px);
    padding:max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
    align-items:center;justify-content:center;
    overflow:auto;-webkit-overflow-scrolling:touch;
  }
  .inbox-profile-card{
    width:min(100%,420px);max-height:min(88dvh,680px);overflow:auto;
    background:#17212b;border:1px solid #243647;border-radius:18px;
    padding:14px 14px 16px;box-shadow:0 22px 48px -18px #000c;
    animation:rise .16s ease;
  }
  .inbox-profile-close{
    width:36px;height:36px;font-size:18px;background:#121c27;border:1px solid #243647;
  }
  .profile-note textarea{font-size:16px;min-height:110px;}
}
@media (max-width:760px){
  html,body{
    -webkit-text-size-adjust:100%;
    touch-action:manipulation;
    overflow-x:hidden;
    max-width:100%;
    height:100%;
    height:100dvh;
    max-height:100%;
    max-height:100dvh;
  }
  body{
    flex-direction:column;
    min-height:0;
    overscroll-behavior-y:none;
    width:100%;
    overflow:hidden;
  }
  *{ -webkit-tap-highlight-color:transparent; }
  .sidebar,.main,.inbox,.settings-content,.topbar,.grant-row,.nav,.brand{
    max-width:100%;
    min-width:0;
  }

  .sidebar{
    width:100%;height:auto;min-height:0;position:sticky;top:0;z-index:50;
    flex-direction:column;gap:8px;
    padding:calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    border-right:none;border-bottom:1px solid var(--line);
    flex-shrink:0;overflow-x:hidden;
    transition:transform .2s ease, opacity .16s ease;
    will-change:transform, opacity;
  }
  body.sidebar-collapsed .sidebar{
    transform:translateY(calc(-100% - 4px));
    opacity:0;pointer-events:none;
    max-height:0;overflow:hidden;
    border-bottom-color:transparent;padding-top:0;padding-bottom:0;margin:0;
  }
  .mobile-menu-fab{
    display:none;position:fixed;top:calc(8px + env(safe-area-inset-top, 0px));right:10px;z-index:60;
    width:40px;height:40px;border:1px solid #2b5278;border-radius:12px;background:#17212b;
    color:#fff;font-size:18px;line-height:1;cursor:pointer;
    box-shadow:0 8px 20px -10px #000a;
  }
  body.sidebar-collapsed .mobile-menu-fab{display:inline-flex;align-items:center;justify-content:center;}
  body:has(#tabInbox.inbox-chat-open) .mobile-menu-fab{display:none !important;}

  body.role-worker .sidebar{
    width:100%;padding:calc(6px + env(safe-area-inset-top, 0px)) 10px 8px;background:#0e1621;border-bottom:1px solid #243647;
  }
  .brand{
    width:100%;padding:0;gap:8px;justify-content:flex-start;align-items:center;
  }
  .brand-copy{min-width:0;flex:1;}
  .brand-mark{width:28px;height:28px;}
  .brand-name{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .brand-sub{display:none !important;}
  body.role-worker .brand{justify-content:flex-start;width:100%;padding:0;flex-wrap:nowrap;}
  body.role-worker .brand-copy,
  body.role-worker .brand-name,
  body.role-worker .brand-sub,
  body.role-worker .brand-mark{display:none !important;}
  body.role-worker .brand-actions{margin:0;width:auto;flex-direction:row;gap:5px;}
  body.role-worker .brand-chip,
  body.role-worker .logout-chip{
    margin:0;width:36px;height:36px;padding:0;
    border:1px solid #2a3a4d;background:#17212b;color:#c8d4de;border-radius:10px;
  }
  body.role-worker .brand-chip .nav-badge{top:-5px;right:-6px;}

  .brand-actions{gap:5px;}
  .brand-chip,.logout-chip{
    margin-left:0;width:36px;height:36px;padding:0;border-radius:10px;
    border:1px solid #2a3a4d;background:#17212b;color:#c8d4de;
  }
  .logout-chip span{display:none;}
  .brand-chip svg,.logout-chip svg{width:17px;height:17px;}
  body.role-admin .logout-chip{background:var(--panel-2);border-color:var(--line);color:var(--muted);}

  .nav{
    display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;
    flex:none;width:100%;max-width:100%;overflow:hidden;
  }
  body.role-admin .nav{grid-template-columns:repeat(3,minmax(0,1fr));}
  body.role-worker .nav{display:none !important;}
  .nav-item{
    flex-direction:column;justify-content:center;align-items:center;gap:4px;
    aspect-ratio:auto;min-height:56px;padding:8px 4px;font-size:11px;font-weight:600;
    text-align:center;line-height:1.15;border-radius:12px;
    background:#1a2433;border:1px solid var(--line-solid);color:var(--muted);
    box-shadow:none;transition:transform .1s,background .12s,border-color .12s;
    min-width:0;overflow:hidden;
  }
  .nav-item:active{transform:scale(.97);}
  .nav-item svg{width:22px;height:22px;opacity:1;flex-shrink:0;}
  .nav-item.active{
    background:#2b5278;border-color:#4e8fd6;color:#fff;
    box-shadow:none;
  }
  body.role-worker .nav-item{
    font-size:11px;gap:4px;padding:8px 4px;min-height:54px;
    background:#17212b;border-color:#243647;color:#93a0b5;
  }
  body.role-worker .nav-item.active{
    background:#2b5278;border-color:#6ab3f3;color:#fff;
  }
  .nav-item .nav-icon{display:flex;flex-direction:column;align-items:center;gap:4px;position:relative;}
  .nav-item .nav-badge{top:-6px;right:-8px;}
  .nav-item[data-tab="stats"]{display:none !important;}

  .sidebar-footer{
    display:flex;flex-direction:row;align-items:center;justify-content:flex-end;
    gap:6px;padding:0;margin:0;background:transparent;border:none;border-radius:0;
    max-width:none;flex-shrink:0;width:auto;
  }
  body.role-worker .sidebar{
    display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;gap:8px;
    width:100%;padding:calc(6px + env(safe-area-inset-top, 0px)) 10px 8px;
  }
  body.role-worker .brand{
    flex:1;min-width:0;margin:0;width:100%;
  }
  body.role-worker .brand-actions{
    margin:0 0 0 auto;width:auto;flex-direction:row;gap:0;
  }
  body.role-worker .brand-chip,
  body.role-worker .brand-chip.worker-only,
  body.role-worker .sidebar-footer{
    display:none !important;
  }
  body.role-worker .brand-more{display:inline-flex !important;}
  body.role-admin .brand-more{display:inline-flex !important;}
  body.role-admin .nav{display:none !important;}
  body.role-admin .sidebar-footer{display:none !important;}
  body.role-admin .brand-actions .brand-chip{display:none !important;}
  .brand-more-btn{width:40px;height:40px;font-size:22px;border-radius:12px;}
  .mobile-menu-fab{display:none !important;}

  /* при скролле оставляем только поиск — шапка скрывается в layout-mobile */
  body.chrome-collapsed.role-worker .sidebar,
  body.sidebar-collapsed.role-worker .sidebar{
    display:none !important;
  }
  .inbox-side{position:relative;}
  .inbox-scroll-top{
    display:none;position:absolute;right:14px;bottom:16px;z-index:8;
    width:44px;height:44px;border:1px solid #2b5278;border-radius:14px;
    background:#17212bcc;backdrop-filter:blur(6px);color:#fff;font-size:20px;line-height:1;
    box-shadow:0 10px 24px -14px #000a;cursor:pointer;
    align-items:center;justify-content:center;
  }
  .inbox-scroll-top:not([hidden]){display:inline-flex;}
  .inbox-scroll-top:active{background:#2b5278;}

  .main{padding:0;flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column;max-width:100%;}
  body.role-admin .main{padding:12px 12px calc(16px + env(safe-area-inset-bottom,0px));overflow:auto;overflow-x:hidden;}
  body.role-worker .main{padding:0;overflow-x:hidden;}

  .topbar{flex-direction:column;align-items:stretch;gap:10px;}
  .topbar-actions{width:100%;flex-wrap:wrap;}
  .topbar-actions .search{width:100%;}
  .topbar-actions .btn{flex:1;min-width:120px;min-height:40px;}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr));}
  .grid{grid-template-columns:1fr;}
  .staff-grid{grid-template-columns:1fr;}
  .staff-modal,.modal,.notice-modal{
    max-width:100%;max-height:min(92dvh,92vh);margin:0;border-radius:16px 16px 0 0;
  }
  .overlay{align-items:flex-end;padding:0;}
  .overlay.open{padding:0;}
  .material-tabs{overflow:auto;flex-wrap:nowrap;-webkit-overflow-scrolling:touch;scrollbar-width:none;}
  .material-tabs::-webkit-scrollbar{display:none;}
  .material-tab{white-space:nowrap;flex-shrink:0;min-height:36px;}
  .materials-split,.admin-split{grid-template-columns:1fr;}
  .mat-card{
    grid-template-columns:1fr !important;
    grid-template-areas:"thumb" "meta" "actions" "audio" !important;
  }
  .mat-item-list .mat-card:has(> audio){
    grid-template-areas:"meta" "actions" "audio" !important;
  }
  .mat-thumb{max-width:100%;max-height:220px;}
  .grant-row{grid-template-columns:1fr;}

  /* ---- Inbox ---- */
  .inbox{grid-template-columns:1fr;height:100%;min-height:0;flex:1;}
  #tabInbox:not(.inbox-chat-open) .inbox-main{display:none;}
  #tabInbox.inbox-chat-open .inbox-side{display:none;}
  #tabInbox.inbox-chat-open .inbox-main{display:flex;flex:1;min-height:0;}
  .inbox-side{border-right:none;}
  .inbox-side-head{padding:8px 10px 6px;gap:8px;position:sticky;top:0;z-index:5;background:#17212b;}
  .inbox-accounts{
    gap:8px;padding:0 0 2px;
  }
  .inbox-account-chips{
    max-height:96px;-webkit-overflow-scrolling:touch;
  }
  .inbox-account-select{height:40px;font-size:16px;border-radius:12px;}
  .inbox-account-folder{
    min-width:0;max-width:100%;padding:8px 12px;border-radius:999px;min-height:36px;
  }
  .inbox-account-name{font-size:13px;}
  .inbox-account-unread{min-width:20px;height:20px;font-size:11px;}
  .tg-search{padding:10px 12px;border-radius:14px;}
  .tg-search input{font-size:16px;}
  .inbox-list{overflow-x:hidden;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;min-width:0;}
  .inbox-row{
    padding:10px 12px 10px 10px;gap:10px;min-height:64px;align-items:flex-start;
  }
  .inbox-row.has-unread{padding-right:46px;}
  .inbox-row:active{background:#202b36;}
  .inbox-row.has-unread:active{background:rgba(78,164,246,.16);}
  .tg-avatar{width:48px;height:48px;font-size:16px;margin-top:2px;}
  .inbox-row-body{gap:4px;}
  .inbox-row-top,.inbox-row-bottom{gap:8px;}
  .inbox-row-title{font-size:15px;}
  .inbox-time{font-size:11.5px;}
  .inbox-preview{
    font-size:13.5px;line-height:1.3;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
    max-height:none;min-width:0;flex:1 1 0%;max-width:100%;
  }
  .unread{right:10px;bottom:12px;min-width:24px;height:24px;font-size:12.5px;padding:0 8px;}
  .inbox-empty{padding:40px 20px;text-align:center;color:#708499;font-size:14px;}

  .inbox-back{
    display:inline-flex !important;align-items:center;justify-content:center;gap:4px;
    width:auto;min-width:40px;height:40px;padding:0 10px 0 8px;border:none;border-radius:12px;
    background:#243647;color:#fff;font:inherit;font-size:14px;font-weight:600;cursor:pointer;flex-shrink:0;
  }
  .inbox-back-icon{font-size:18px;line-height:1;}
  .inbox-back-label{line-height:1;}
  .inbox-back:active{background:#2b5278;}
  .inbox-head{
    padding:6px 10px;gap:6px;min-height:56px;
    padding-top:calc(6px + env(safe-area-inset-top, 0px));
    position:sticky;top:0;z-index:4;
  }
  .inbox-head-btn{flex:1;min-width:0;padding:4px 2px;gap:10px;}
  .inbox-head-text h2{font-size:16px;}
  .inbox-account-badge{width:28px;height:28px;font-size:11px;}
  .inbox-head-text p{font-size:12.5px;}

  .inbox-thread{
    padding:10px 10px 8px;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  }
  .bubble-wrap{margin:4px 0;gap:5px;}
  .bubble-actions{
    display:inline-flex !important;opacity:1;gap:0;
    background:transparent;border:none;border-radius:0;padding:0;
  }
  .bubble-more-btn{
    width:36px;height:32px;font-size:20px;border-radius:10px;background:#121c27;border:1px solid #243647;
  }
  .bubble-menu{
    min-width:160px;padding:6px;
  }
  .bubble-menu button{
    min-height:40px;font-size:15px;padding:10px 12px;
  }
  .bubble-menu button:active{background:#2b5278;color:#fff;}
  .inbox-thread .bubble{
    max-width:min(92vw,360px);width:fit-content;font-size:16px;line-height:1.4;
    padding:8px 12px 6px;border-radius:16px;
  }
  .inbox-thread .bubble-text{
    font-size:16px;line-height:1.42;padding-right:52px;letter-spacing:.01em;
    overflow-wrap:anywhere;word-break:break-word;white-space:pre-wrap;
  }
  .inbox-back-label{display:inline;}
  .inbox-thread .bubble-time{font-size:12px;margin-top:8px;}
  .bubble-reply{max-width:min(78vw,300px);font-size:13.5px;white-space:normal;line-height:1.3;}
  .bubble-media,.bubble-media-btn{max-width:min(84vw,320px);}
  .bubble-media{max-height:280px;border-radius:12px;}
  .bubble-album{width:min(84vw,320px);}
  .inbox-thread .bubble.album-bubble{max-width:min(92vw,340px);}
  .bubble-voice{width:min(78vw,280px);min-width:170px;}

  .composer{
    padding:6px 8px calc(8px + env(safe-area-inset-bottom, 0px) + var(--kb-offset, 0px));
    background:#0e1621;border-top:1px solid #101921;
    position:relative;bottom:auto;z-index:6;
  }
  .composer-row{
    gap:6px;align-items:flex-end;border-radius:20px;padding:8px 8px 8px 6px;
  }
  .composer-row textarea{
    font-size:16px;line-height:1.45;min-height:44px;max-height:168px;
    padding:10px 10px;border-radius:0;background:transparent;
    /* не «кубик»: текст растёт многострочно внутри общей плашки */
    box-sizing:border-box;
  }
  .composer-row .tg-icon-btn,.composer-row .tg-send{
    width:42px;height:42px;border-radius:12px;flex-shrink:0;
  }
  .sticker-panel{max-height:min(42dvh,320px);}
  .voice-pack,.photo-pack{max-height:min(40dvh,300px);}
  .photo-lib-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;}
  .reply-bar,.record-bar{margin-bottom:6px;padding:8px 10px;}
  .reply-bar p{max-width:60vw;}

  .notice-head{flex-wrap:wrap;}
  .notice-head-actions{width:100%;}
  .notice-head-actions .tg-chip-btn{flex:1;min-height:40px;}
  #tabNotices,#tabWork{padding:0;}
  #tabWork{padding:12px 12px calc(18px + env(safe-area-inset-bottom,0px));}
  .work-days{height:72px;gap:4px;}
  .media-lightbox-inner{max-width:100vw;padding:12px;}
  .media-lightbox-inner img{max-height:70dvh;border-radius:8px;}
}
@media (min-width:761px){
  .inbox-back{display:none !important;}
  .mobile-menu-fab{display:none !important;}
}
.material-tabs{
  display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap;
}
.material-tab{
  background:var(--panel);border:1px solid var(--line);color:var(--muted);
  border-radius:999px;padding:8px 14px;font:inherit;font-size:13px;font-weight:600;cursor:pointer;
}
.material-tab.active{background:#2b5278;border-color:#6ab3f3;color:#fff;}
.mat-item-list .mat-card{
  display:grid;
  grid-template-columns:120px minmax(0,1fr) auto;
  grid-template-areas:"thumb meta actions";
  gap:12px;
  align-items:start;
}
.mat-item-list .mat-card .mat-thumb{grid-area:thumb;width:120px;height:120px;}
.mat-item-list .mat-card .voice-clip-meta{grid-area:meta;min-width:0;}
.mat-item-list .mat-card .voice-clip-actions{grid-area:actions;}
/* Голосовые: без узкой колонки 120px — текст на всю ширину, плеер снизу */
.mat-item-list .mat-card:has(> audio){
  grid-template-columns:minmax(0,1fr) auto;
  grid-template-areas:
    "meta actions"
    "audio audio";
}
.mat-item-list .mat-card:has(> audio) audio{
  grid-area:audio;
  width:100%;
  max-width:100%;
  min-width:0;
}
.mat-thumb{
  width:120px;height:120px;object-fit:cover;border-radius:12px;background:#101921;
}
.mat-thumb.mat-round{border-radius:50%;object-fit:cover;}
.notice-head-actions{display:flex;gap:8px;align-items:center;}
.notice-card-actions{display:flex;align-items:center;gap:8px;}
.notice-card-actions time{white-space:nowrap;}
.inbox-back{
  display:none;align-items:center;justify-content:center;gap:4px;
  width:auto;min-width:36px;height:36px;padding:0 10px 0 8px;border:none;border-radius:12px;
  background:#242f3d;color:#fff;font:inherit;font-size:13px;font-weight:600;cursor:pointer;flex-shrink:0;
}
.inbox-back-icon{font-size:18px;line-height:1;}
.inbox-back-label{display:none;}

/* �� Message selection (Telegram-like) �� */
.bubble-wrap.is-selected{
  position:relative;
  z-index:2;
  background:rgba(64,136,196,.2);
  border-radius:0;
  margin-left:-12px;margin-right:-12px;
  padding-left:12px;padding-right:12px;
}
.bubble-wrap.is-selected > .bubble{
  box-shadow:0 0 0 1px rgba(106,179,243,.35);
}
.msg-action-sheet{
  position:fixed;inset:0;z-index:1200;
  pointer-events:none;
}
.msg-action-sheet[hidden]{display:none !important;}
.msg-action-sheet:not([hidden]){pointer-events:auto;}
.msg-action-sheet-backdrop{
  position:absolute;inset:0;border:none;padding:0;margin:0;
  background:rgba(0,0,0,.28);cursor:pointer;
}
.msg-action-sheet-card{
  position:fixed;z-index:1;min-width:220px;max-width:min(320px,92vw);
  display:flex;flex-direction:column;gap:2px;
  background:#17212b;border:1px solid #243447;border-radius:14px;
  padding:6px;box-shadow:0 12px 40px rgba(0,0,0,.45);
  pointer-events:auto;
}
.msg-action-sheet-card button{
  width:100%;border:none;border-radius:10px;background:transparent;
  color:#e8eef5;font:inherit;font-size:15px;text-align:left;
  padding:12px 14px;cursor:pointer;display:flex;align-items:center;gap:10px;
}
.msg-action-sheet-card button:hover,
.msg-action-sheet-card button:focus-visible{background:#2b5278;outline:none;}
.msg-action-sheet-card button.is-danger{color:#f5a8a8;}
.msg-action-sheet-card button.is-danger:hover{background:#5a2a2a;color:#fff;}
.msg-action-sheet-card .msg-action-ico{
  width:22px;text-align:center;opacity:.9;flex-shrink:0;
}

/* Hide legacy ? / quick-reply chrome � selection sheet replaces it */
.bubble-actions{display:none !important;}

/* �� Chat list long-press preview �� */
.inbox-row.is-pressing{background:#2b5278 !important;}
.inbox-row.is-preview-open{outline:1px solid rgba(106,179,243,.5);}
.chat-preview{
  position:fixed;inset:0;z-index:1300;
  display:flex;align-items:center;justify-content:center;
  padding:16px;
}
.chat-preview[hidden]{display:none !important;}
.chat-preview-backdrop{
  position:absolute;inset:0;border:none;padding:0;margin:0;
  background:rgba(0,0,0,.55);cursor:pointer;
}
.chat-preview-card{
  position:relative;z-index:1;
  width:min(440px,96vw);height:min(72vh,680px);
  display:flex;flex-direction:column;overflow:hidden;
  background:#0e1621;border:1px solid #1c2a38;border-radius:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.55);
}
.chat-preview-head{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-bottom:1px solid #101921;background:#17212b;flex-shrink:0;
}
.chat-preview-head .tg-avatar{width:40px;height:40px;font-size:14px;flex-shrink:0;}
.chat-preview-head-text{min-width:0;flex:1;}
.chat-preview-head-text h3{
  margin:0;font-size:15px;font-weight:700;color:#fff;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.chat-preview-head-text p{margin:2px 0 0;font-size:12px;color:#8ea4b8;}
.chat-preview-close{
  width:34px;height:34px;border:none;border-radius:10px;
  background:#242f3d;color:#c8d4de;cursor:pointer;font:inherit;flex-shrink:0;
}
.chat-preview-close:hover{background:#2b5278;color:#fff;}
.chat-preview-thread{
  flex:1;min-height:0;overflow:auto;-webkit-overflow-scrolling:touch;
  padding:10px 12px;background:#0e1621;overscroll-behavior:contain;
}
.chat-preview-thread .bubble{max-width:min(86%,300px);pointer-events:none;}
.chat-preview-thread .bubble-wrap{margin:4px 0;}
.chat-preview-thread .tg-date{
  display:flex;justify-content:center;margin:10px 0 8px;pointer-events:none;
}
.chat-preview-thread .tg-date span{
  background:#1a2634;color:#8ea4b8;font-size:12px;font-weight:600;
  padding:4px 10px;border-radius:999px;
}
.chat-preview-thread .bubble-time{font-size:11px;opacity:.9;}
.chat-preview-loader{
  text-align:center;color:#8ea4b8;font-size:12px;padding:10px 8px;
}
.chat-preview-thread .inbox-thread-status,
.chat-preview-empty{
  text-align:center;color:#8ea4b8;font-size:13px;padding:24px 12px;
}
.chat-preview-foot{
  display:flex;gap:8px;justify-content:flex-end;
  padding:10px 12px;border-top:1px solid #101921;background:#17212b;flex-shrink:0;
}
.chat-preview-foot .btn{min-height:36px;padding:8px 14px;}

/* Perf: skip offscreen layout/paint for long lists/threads */
.inbox-row{
  content-visibility:auto;
  contain-intrinsic-size:72px;
}
.bubble-wrap{
  content-visibility:auto;
  contain-intrinsic-size:auto 56px;
}
.bubble-media,.tg-avatar img{
  content-visibility:auto;
}
