*{box-sizing:border-box}
html,body{margin:0;background:#081522;color:#e0f4ff;font-family:"Segoe UI",Arial,sans-serif}
body{padding:12px}
.phone{max-width:430px;margin:auto}

.header{position:relative;min-height:108px;border:1px solid rgba(39,204,255,.78);border-radius:14px;overflow:hidden;padding:18px 14px;background:url('assets/nexus_header.jpg') center/cover;box-shadow:0 14px 34px rgba(0,0,0,.28)}
.header:after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,rgba(1,7,18,.78),rgba(2,11,24,.24),rgba(2,12,25,.02));pointer-events:none}
.logo,.title,.date,.db-badge,.role-label{position:relative;z-index:1}
.logo{width:48px;height:48px;float:left;margin-right:10px}
.title{font-size:22px;font-weight:800;color:#f4fcff}
.date{font-size:10px;color:#9fc0d5;margin-top:3px;display:flex;align-items:center;gap:5px}
.date img{width:14px;height:14px}
.role-label{display:none}
.db-badge{position:absolute;right:12px;bottom:9px;border:1px solid rgba(47,227,184,.82);border-radius:18px;background:rgba(4,24,39,.82);padding:5px 10px;font-size:8px;font-weight:700}
.db-badge span{color:#5ff0ad;margin-right:5px}

.panel{background:rgba(12,40,68,.78);border:1px solid rgba(30,111,255,.35);border-radius:14px;margin-top:10px;padding:12px}
.panel h2{font-size:12px;color:#5eb8ff;margin:0 0 9px;font-weight:700}

.btn-row{display:flex;gap:8px}
.btn-row button{flex:1;min-height:38px;border-radius:10px;font-weight:800;color:#fff;font-size:9px;cursor:pointer}
.start{background:linear-gradient(90deg,#00c6ff,#0072ff);border:1px solid #5ed0ff}
.stop{background:#3a1520;border:1px solid #ef5350;color:#ffcdd2!important}

/* Анимация Старт / Стоп */
.start.is-running{
  background:linear-gradient(90deg,#00e676,#00c853)!important;
  border-color:#69f0ae!important;
  animation:pulse-run 1.4s ease-in-out infinite;
}
.start.is-running::after{content:" · ИДЁТ"}
.stop.is-stopping{
  background:linear-gradient(90deg,#ef5350,#c62828)!important;
  border-color:#ff8a80!important;
  animation:pulse-stop .8s ease-in-out 2;
}
@keyframes pulse-run{
  0%,100%{box-shadow:0 0 0 0 rgba(0,230,118,.45)}
  50%{box-shadow:0 0 0 8px rgba(0,230,118,0)}
}
@keyframes pulse-stop{
  0%,100%{box-shadow:0 0 0 0 rgba(239,83,80,.5)}
  50%{box-shadow:0 0 0 6px rgba(239,83,80,0)}
}

.progress h2{font-size:13px!important;color:#7de8ff!important;letter-spacing:.03em}
.progress .bar,.bar{height:28px;border:1px solid #1e6fff;border-radius:8px;background:rgba(10,30,52,.4);position:relative;overflow:hidden}
.bar div{height:100%;width:0;background:linear-gradient(90deg,#00c6ff,#0072ff);transition:width .3s ease}
.bar span{position:absolute;inset:0;display:grid;place-items:center;font-size:9px;color:#b5dcf2;font-weight:700}

.db-panel{display:grid;gap:8px}
.db-btn{width:100%;min-height:38px;border-radius:10px;background:linear-gradient(90deg,#0a3d7a,#1a8cff);border:1px solid #3db4ff;color:#e8f6ff;font-weight:800;font-size:9px}
.db-btn.secondary{background:linear-gradient(90deg,#0d3459,#126fa8);border-color:#2a8fc7}
.admin-tools{display:grid;grid-template-columns:1fr;gap:7px}

.status{display:flex;gap:12px;align-items:flex-start}
.status strong{color:#3dffb0;font-size:12px;white-space:nowrap}
.status span{color:#9ec4e0;font-size:9px;line-height:1.35}
.muted{color:#7aa8c8;font-size:8px;margin:0 0 8px}
.empty-card{padding:14px;border:1px solid #1a5a9a;border-radius:10px;background:rgba(10,30,52,.35);font-size:9px}

.metrics{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.metrics>div{border:1px solid #173e5d;background:rgba(10,30,52,.38);border-radius:8px;padding:7px;min-width:0}
.metrics span{display:block;color:#8ec4e0;font-size:9px;font-weight:600;line-height:1.25;margin-bottom:3px}
.metrics b{display:block;color:#e8f6ff;font:600 11px/1.3 "Segoe UI",Arial,sans-serif;word-break:break-word;overflow-wrap:anywhere}
.token{margin-top:9px;color:#9ec4e0;font-size:8px}

.coverage-head{display:flex;justify-content:space-between;gap:8px;margin:9px 0 6px;color:#7ec8ff;font-size:8px;font-weight:800}
.coverage-head b{color:#e8f6ff}

.log-text{max-height:140px;overflow:auto;font:7px/1.45 "DejaVu Sans Mono",Consolas,monospace;color:#a9cde2;background:rgba(4,17,29,.38);border:1px solid #173e5d;border-radius:9px;padding:7px}
.log-entry{padding:2px 0;border-bottom:1px solid rgba(38,94,130,.25)}
.hidden{display:none!important}

.notification-overlay{position:fixed;inset:0;z-index:5000;display:flex;align-items:flex-start;justify-content:center;padding:12px;pointer-events:none}
.notification-card{pointer-events:auto;width:min(406px,calc(100vw - 24px));background:linear-gradient(145deg,#09233b,#071523);border:1px solid #2ed7ff;border-radius:14px;box-shadow:0 18px 55px rgba(0,0,0,.55),0 0 28px rgba(0,191,255,.16);padding:14px;animation:notif-in .22s ease}
.notification-topline{display:flex;justify-content:space-between;margin-bottom:6px}
.notification-badge{font-size:8px;color:#6de7ff;font-weight:900;letter-spacing:.12em}
.notification-title{font-size:14px;font-weight:900;color:#f2fbff}
.notification-body{font-size:11px;line-height:1.5;color:#c9e8f8;white-space:pre-wrap;margin:7px 0}
.notification-meta{font-size:8px;color:#6f9db3}
.notification-close{width:100%;margin-top:10px;min-height:34px;border-radius:10px;border:1px solid #5ed0ff;background:linear-gradient(90deg,#00bff0,#0879ff);color:#fff;font-weight:900;font-size:10px}
.notification-hide{animation:notif-out .2s ease forwards}
@keyframes notif-in{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:none}}
@keyframes notif-out{to{opacity:0;transform:translateY(-8px)}}

.mode-bar{display:flex!important;align-items:center;gap:8px;margin:0 0 10px;padding:8px;border:1px solid rgba(46,215,255,.55);border-radius:10px;background:rgba(6,28,46,.85)}
.mode-toggle{flex:0 0 auto;border:1px solid #2ed7ff;border-radius:10px;background:linear-gradient(90deg,#0a3d7a,#126fa8);color:#e8f6ff;font-size:12px;font-weight:800;padding:9px 12px;cursor:pointer}
.mode-toggle.user-view{border-color:#e0b34f;background:linear-gradient(90deg,#473617,#6a4e1a);color:#ffe5a4}
.mode-hint{font-size:11px;color:#9ec4e0;font-weight:600}

/* Level selector SUPER / ADMIN */
.grant-level-row{display:flex;gap:8px;margin:10px 0 8px;flex-wrap:wrap}
.level-btn{
  flex:1;min-width:110px;min-height:38px;border-radius:10px;
  border:1px solid #2a5a7a;background:rgba(10,30,52,.6);
  color:#9ec4e0;font-size:12px;font-weight:800;cursor:pointer;
  transition:all .15s ease;
}
.level-btn.active{
  border-color:#2ed7ff;
  background:linear-gradient(90deg,#0a3d7a,#126fa8);
  color:#e8f6ff;
  box-shadow:0 0 12px rgba(46,215,255,.25);
}
.level-btn:disabled{opacity:.45;cursor:not-allowed}

/* Users admin list */
.users-admin-list{display:flex;flex-direction:column;gap:8px;max-height:320px;overflow:auto;-webkit-overflow-scrolling:touch}
.user-row{
  display:grid;
  grid-template-columns:1fr auto;
  grid-template-areas:"id btn" "name btn" "badges btn";
  gap:4px 10px;align-items:center;padding:10px 12px;
  border-radius:12px;border:1px solid rgba(46,215,255,.28);
  background:rgba(6,28,46,.85);font-size:12px;
}
.user-row .uid{grid-area:id;font-family:Consolas,ui-monospace,monospace;color:#9ec4e0;font-size:11px;word-break:break-all}
.user-row .uname{grid-area:name;font-weight:800;color:#e8f6ff;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.user-row .badges{grid-area:badges;display:flex;flex-wrap:wrap;gap:4px}
.user-row .badge{padding:3px 8px;border-radius:6px;font-size:10px;font-weight:800;line-height:1.2;white-space:nowrap}
.user-row .badge.admin{background:#1a5c3a;color:#7dffb0}
.user-row .badge.user{background:#3a3a1a;color:#e0d070}
.user-row .badge.online{background:#0a4a6a;color:#7dcaff}
.user-row .badge.offline{background:#2a2a2a;color:#aaa}
.user-row .row-btn{
  grid-area:btn;padding:8px 12px;font-size:11px;font-weight:700;
  border-radius:8px;cursor:pointer;border:1px solid #2a5a7a;
  background:#0d3a5a;color:#e8f6ff;white-space:nowrap;min-width:72px;text-align:center;align-self:center;
}
.user-row .row-btn.danger{border-color:#8a3030;background:#4a1515}
.user-row .row-btn:disabled{opacity:.55;cursor:default}

#pauseBtn,.btn-pause,.pause{display:none!important}

@media(max-width:430px){
  body{padding:8px}
  .header{min-height:108px}
  .title{font-size:20px}
  .db-badge{right:8px;font-size:7px}
  .btn-row{display:grid;grid-template-columns:1.4fr 1fr}
  .btn-row button{font-size:8px}
}

/* Более заметная анимация Старт/Стоп */
.start.is-running {
  background: linear-gradient(90deg, #00e676, #00c853) !important;
  border-color: #69f0ae !important;
  color: #003d1f !important;
  font-weight: 900;
  animation: pulse-run 1.1s ease-in-out infinite;
  box-shadow: 0 0 18px rgba(0, 230, 118, 0.55);
}
.start.is-running::after {
  content: " · СБОР ИДЁТ";
  font-size: 9px;
}
.stop.is-stopping {
  background: linear-gradient(90deg, #ff1744, #d50000) !important;
  border-color: #ff8a80 !important;
  animation: pulse-stop 0.7s ease-in-out 3;
  box-shadow: 0 0 16px rgba(255, 23, 68, 0.5);
}
@keyframes pulse-run {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0,230,118,.6); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 10px rgba(0,230,118,0); }
}
@keyframes pulse-stop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}


/* admin tabs */
.admin-tabs-bar { padding: 8px 10px !important; }
.admin-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-tab {
  flex: 1;
  min-width: 88px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid #2a5a7a;
  background: #0a1a2e;
  color: #9ec9e8;
  font-weight: 600;
  font-size: 12px;
}
.admin-tab.active {
  background: #106a9a;
  border-color: #7be7ff;
  color: #e8f6ff;
}

/* === sites tab (additive) === */
.site-row{display:flex;gap:8px;align-items:center}
.site-row input{min-width:0;flex:1;background:rgba(10,30,52,.4);color:#e8f6ff;border:1px solid #1a5a9a;border-radius:10px;padding:9px 11px;font-size:13px}
.site-row input:focus{outline:none;border-color:#3db4ff}
.site-row .small{padding:0 12px;min-height:36px;font-size:11px;font-weight:700;width:auto}
.site-active{margin-top:8px;border:1px solid #1a5a9a;border-radius:10px;padding:8px 10px;background:rgba(8,24,40,.45);font-size:10px;color:#9ec4e0;line-height:1.45}
.table-wrap{overflow-x:auto;border:1px solid #1e6fff;border-radius:10px}
.sites-table{width:100%;border-collapse:collapse;font-size:10px;min-width:340px}
.sites-table th{background:#0d2138;color:#7ec8ff;padding:8px 6px;text-align:left;font-weight:700;border-bottom:1px solid #1a4a7a;white-space:nowrap}
.sites-table td{padding:8px 6px;border-bottom:1px solid #123050;vertical-align:middle;color:#d0e8ff}
.sites-table .empty-row td{text-align:center;color:#6a90a8;padding:16px}
.sites-table .url-cell{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sites-table .act-btns{display:flex;gap:4px;flex-wrap:wrap}
.sites-table .act-btns button{font-size:9px;padding:4px 7px;min-height:auto;border-radius:6px;width:auto}
.modal{position:fixed;inset:0;background:rgba(0,8,18,.75);display:flex;align-items:flex-end;justify-content:center;z-index:100;padding:12px}
.modal.hidden{display:none}
.modal-card{background:#0c2844;border:1px solid #1e6fff;border-radius:16px 16px 0 0;width:100%;max-width:430px;max-height:80vh;display:flex;flex-direction:column}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid #1a4a7a}
.modal-head h3{margin:0;font-size:14px;color:#5eb8ff}
.modal-body{padding:12px 14px;overflow:auto;font-size:11px;flex:1}
.modal-body table{width:100%;border-collapse:collapse}
.modal-body th,.modal-body td{padding:6px 4px;border-bottom:1px solid #123050;text-align:left}
.modal-body th{color:#7ec8ff}
.modal-foot{display:flex;gap:8px;padding:10px 14px;border-top:1px solid #1a4a7a}

/* site row select */
.sites-table tr.site-selected td{background:rgba(0,120,255,.22)!important;outline:1px solid #3db4ff}
.sites-table tbody tr{cursor:pointer}
.sites-table tbody tr:hover td{background:rgba(30,111,255,.12)}

/* === token tables (desktop-like) === */
.token-block{margin-top:4px}
.token-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.token-count{font-size:11px;font-weight:700;color:#7ec8ff}
.token-actions{display:flex;gap:6px;flex-wrap:wrap}
.token-btn{width:auto!important;min-height:34px!important;padding:0 12px!important;font-size:10px!important}
.token-table-wrap{overflow-x:auto;border:1px solid #1e6fff;border-radius:10px;background:rgba(8,24,40,.45)}
.token-table{width:100%;border-collapse:collapse;font-size:10px;min-width:320px}
.token-table thead th{background:#0d2138;color:#7ec8ff;padding:8px 6px;text-align:left;font-weight:700;border-bottom:1px solid #1a4a7a;white-space:nowrap;position:sticky;top:0}
.token-table td{padding:7px 6px;border-bottom:1px solid #123050;vertical-align:middle;color:#d0e8ff}
.token-table tbody tr:nth-child(even) td{background:rgba(12,40,68,.35)}
.token-table tbody tr:hover td{background:rgba(30,111,255,.12)}
.token-table .empty-row td{text-align:center;color:#6a90a8;padding:14px}
.token-table .tok-prefix{font-family:Consolas,ui-monospace,monospace;color:#9ec4e0;max-width:90px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.token-table .tok-num{font-variant-numeric:tabular-nums;font-weight:700;color:#e8f6ff}
.token-table .st-active{color:#7dffb0;font-weight:800}
.token-table .st-other{color:#e0d070;font-weight:700}
.token-table .st-bad{color:#ff8a80;font-weight:700}

/* nexus-db-modal */
.nx-overlay{position:fixed;inset:0;z-index:99999;background:rgba(2,10,22,.92);display:flex;align-items:stretch;justify-content:center;padding:10px;box-sizing:border-box}
.nx-card{width:100%;max-width:720px;max-height:96vh;background:linear-gradient(180deg,#0a1f38,#081522);border:1px solid rgba(30,111,255,.45);border-radius:16px;display:flex;flex-direction:column;overflow:hidden;color:#e0f4ff}
.nx-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid rgba(30,111,255,.28)}
.nx-head h3{margin:0;font-size:15px;font-weight:800;color:#5eb8ff}
.nx-x{border:1px solid #2a6a9a;background:rgba(12,40,68,.8);color:#c8e8ff;border-radius:10px;padding:7px 12px;font-weight:700;font-size:11px;cursor:pointer}
.nx-tabs{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px;max-height:120px;overflow:auto}
.nx-tab{border:1px solid rgba(61,180,255,.35);background:rgba(10,50,100,.35);color:#b8dcf0;border-radius:999px;padding:6px 11px;font-size:11px;font-weight:700;cursor:pointer}
.nx-tab.active,.nx-tab:hover{background:linear-gradient(90deg,#0a3d7a,#1a8cff);border-color:#5eb8ff;color:#fff}
.nx-meta{padding:8px 14px;font-size:11px;color:#7aa8c8}
.nx-body{flex:1;overflow:auto;padding:0 8px 8px}
.nx-table{width:100%;border-collapse:collapse;font-size:11px}
.nx-table th{position:sticky;top:0;background:#0c2844;color:#7ec8ff;text-align:left;padding:8px 6px}
.nx-table td{padding:7px 6px;border-bottom:1px solid rgba(18,48,80,.85);word-break:break-word}
.nx-table a{color:#7fe7ff}
.nx-foot{display:flex;flex-wrap:wrap;gap:8px;padding:10px 12px;border-top:1px solid rgba(30,111,255,.28)}
.nx-btn{border:1px solid #3db4ff;border-radius:10px;background:linear-gradient(90deg,#0a3d7a,#1a8cff);color:#e8f6ff;font-weight:800;font-size:11px;padding:9px 14px;cursor:pointer}
.nx-btn.ghost{background:rgba(12,40,68,.7);border-color:#2a6a9a}
.nx-btn.ok{background:linear-gradient(90deg,#00a88a,#00c6ff);border-color:#3dffb0}
.nx-check-row{display:flex;justify-content:space-between;gap:10px;padding:9px 12px;border-bottom:1px solid rgba(18,48,80,.9);font-size:12px}
.nx-check-row label{display:flex;align-items:center;gap:8px;flex:1}
.nx-count{color:#8ec4e0;min-width:48px;text-align:right}
.nx-hint{padding:8px 14px;font-size:11px;color:#7aa8c8}


/* =========================================================
   FINAL SESSION METRICS
   ========================================================= */

.github-coverage-metric{
  min-width:0;
}

.github-coverage-metric > span{
  display:block;
  color:#8ec4e0;
  font-size:9px;
  font-weight:600;
  line-height:1.25;
  margin-bottom:4px;
}

.github-coverage-metric > b{
  display:block;
  color:#e8f6ff;
  font:700 12px/1.25 "Segoe UI",Arial,sans-serif;
}

.github-coverage-metric > small{
  display:block;
  margin-top:4px;
  color:#7faec6;
  font-size:8px;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.contacts-metric{
  grid-column:1 / -1;
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
  padding:7px!important;
}

.contact-stat{
  min-width:0;
  text-align:center;
  border:1px solid #173e5d;
  background:rgba(10,30,52,.38);
  border-radius:8px;
  padding:6px 4px;
}

.contact-stat span{
  display:block;
  color:#8ec4e0;
  font-size:8px;
  font-weight:700;
  line-height:1.2;
  margin-bottom:3px;
}

.contact-stat b{
  display:block;
  color:#e8f6ff;
  font:700 11px/1.2 "Segoe UI",Arial,sans-serif;
  word-break:break-word;
  overflow-wrap:anywhere;
}

@media(max-width:360px){
  .contacts-metric{
    gap:5px;
    padding:6px!important;
  }

  .contact-stat{
    padding:5px 2px;
  }

  .contact-stat span{
    font-size:7px;
  }

  .contact-stat b{
    font-size:10px;
  }
}


/* =========================================================
   GLOBAL SYSTEM — COLLECTED TODAY
   ========================================================= */

.daily-system-card{
  margin-top:9px;
  border:1px solid #173e5d;
  background:rgba(10,30,52,.38);
  border-radius:8px;
  padding:8px 10px;
  min-width:0;
}

.daily-system-title{
  color:#7ec8ff;
  font-size:8px;
  font-weight:800;
  line-height:1.2;
  margin-bottom:5px;
  text-transform:uppercase;
}

.daily-system-value-row{
  display:flex;
  align-items:center;
  gap:7px;
  min-width:0;
}

.daily-system-value-row > b:first-child{
  color:#e8f6ff;
  font:700 13px/1.2 "Segoe UI",Arial,sans-serif;
}

.daily-system-value-row > span{
  color:#5f91ad;
  font-size:11px;
}

.daily-system-value-row > b:last-child{
  color:#9ed5ef;
  font:600 10px/1.2 "Segoe UI",Arial,sans-serif;
  white-space:nowrap;
}


/* LIVE API TOKEN STATES */

.token-table .st-working {
    font-weight: 800;
}

.token-table .st-inuse {
    font-weight: 800;
}

.token-table .st-active {
    font-weight: 700;
}

.token-table .st-bad {
    font-weight: 800;
}


/* === FIX v3: скролл Excel по назначению + ровные 8 колонок в Просмотре по назначению === */
#nxExModal .nx-check-list{flex:1 1 0;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}
#nxDbModal .nx-card{max-width:1100px}
#nxDbModal .nx-table{min-width:1080px}
#nxDbModal .nx-table td:nth-child(5),
#nxDbModal .nx-table td:nth-child(6){max-width:220px;overflow-wrap:anywhere}

/* === FIX v4: просмотр базы/назначения + скролл Excel по назначению === */
#nxDbModal .nx-card{max-width:1100px}
#nxDbModal .nx-body{overflow:auto}
#nxDbModal .nx-table{width:100%;min-width:1080px;font-size:12px}
#nxDbModal .nx-table th{white-space:nowrap;padding:9px 8px}
#nxDbModal .nx-table td{padding:8px;vertical-align:top;word-break:normal;overflow-wrap:normal}
#nxDbModal .nx-table td:nth-child(1){font-weight:700;white-space:nowrap}
#nxDbModal .nx-table td:nth-child(2),
#nxDbModal .nx-table td:nth-child(3),
#nxDbModal .nx-table td:nth-child(4){white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}
#nxDbModal .nx-table td:nth-child(5),
#nxDbModal .nx-table td:nth-child(6){max-width:240px;overflow-wrap:anywhere}
#nxDbModal .nx-table td:nth-child(7),
#nxDbModal .nx-table td:nth-child(8){white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}
#nxExModal .nx-check-list{flex:1 1 0;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}
