/* ProxyEarn Web — dark dashboard */
:root {
  --bg: #090e1a;
  --bg-2: #0c1322;
  --panel: #0f172a;
  --panel-2: #111827;
  --border: rgba(148, 163, 184, 0.12);
  --border-2: rgba(148, 163, 184, 0.18);
  --text: #e8eef9;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --indigo: #6366f1;
  --indigo-2: #818cf8;
  --emerald: #10b981;
  --sky: #0ea5e9;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --teal: #5eead4;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- Scrollbar tùy chỉnh ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(99,102,241,.45) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,.35); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(129,140,248,.6); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
body {
  font-family: "Segoe UI", "Inter", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
a { color: var(--indigo-2); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { color: var(--indigo-2); font-size: 26px; font-weight: 800; }
.brand-title { font-size: 17px; font-weight: 700; color: #f8fafc; }
.brand-sub { font-size: 11px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-2); background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1; border-radius: 10px; padding: 9px 15px; font-weight: 600;
  cursor: pointer; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: rgba(99,102,241,.5); color: #e0e7ff; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg,#6366f1,#4f46e5); border-color:#818cf8; color:#fff; }
.btn-primary:hover { background: linear-gradient(180deg,#818cf8,#6366f1); }
.btn-success { background: linear-gradient(180deg,#10b981,#059669); border-color:#34d399; color:#fff; }
.btn-danger { background: linear-gradient(180deg,#f43f5e,#e11d48); border-color:#fb7185; color:#fff; }
.btn-ghost { background: rgba(15,23,42,.6); }
.btn-xs { padding: 5px 10px; font-size: 12px; }

/* ---------- Inputs ---------- */
.input, input, select, textarea {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--indigo); }
label { display: block; font-size: 12px; color: var(--muted-2); margin: 10px 0 5px; }
/* native select fallback (khi JS chưa nâng cấp) */
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
select option { background: #111827; color: #e2e8f0; }

/* ---------- Custom select (thay native) ---------- */
.cs { position: relative; display: inline-block; min-width: 150px; }
.cs select { display: none; }
.cs-trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.cs-trigger:hover { border-color: rgba(99,102,241,.4); }
.cs.open .cs-trigger { border-color: var(--indigo); }
.cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-arrow { color: var(--muted-2); font-size: 10px; transition: transform .15s; }
.cs.open .cs-arrow { transform: rotate(180deg); }
.cs-panel { position: absolute; top: calc(100% + 6px); left: 0; right: auto; z-index: 60;
  min-width: 100%; width: max-content; max-width: 360px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 4px;
  max-height: 260px; overflow-y: auto; overflow-x: hidden; box-shadow: 0 12px 34px rgba(0,0,0,.45); display: none; }
.cs.open .cs-panel { display: block; }
.cs-opt { padding: 9px 12px; border-radius: 8px; font-size: 13px; color: var(--muted-2);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-opt:hover { background: rgba(99,102,241,.14); color: #e0e7ff; }
.cs-opt.sel { background: #312e81; color: #e0e7ff; }
.cs-block { display: block; width: 100%; }
/* ô tìm kiếm trong dropdown (email/quốc gia/nhóm…) — dính trên đầu khi cuộn danh sách dài */
.cs-search { position: sticky; top: -4px; z-index: 1; background: var(--panel-2); padding: 4px 4px 6px; margin: -4px -4px 2px; }
.cs-search input { width: 100%; box-sizing: border-box; background: var(--panel); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none; }
.cs-search input:focus { border-color: rgba(99,102,241,.7); }
.cs-empty { padding: 10px 12px; font-size: 12.5px; color: var(--muted-2); text-align: center; }

/* ---------- Auth ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 380px; max-width: 100%; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; }
.auth-tabs { display: flex; gap: 6px; margin: 22px 0 6px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.auth-tab { flex: 1; background: transparent; border: none; color: var(--muted-2);
  padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.auth-tab.active { background: #312e81; color: #e0e7ff; }
.auth-form { display: flex; flex-direction: column; }
.form-err { color: var(--rose); font-size: 12px; min-height: 16px; margin: 8px 0; }

/* ---------- App layout ---------- */
/* Khung app CAO ĐÚNG MÀN HÌNH -> chỉ .content cuộn, sidebar + topbar ĐỨNG YÊN.
   Trước dùng min-height nên layout nở theo nội dung => cả trang (kể cả sidebar) bị đẩy lên. */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 240px; flex: 0 0 auto; background: #0d1424; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 0; overflow-y: auto; }
.sidebar .brand { padding: 0 20px 16px; }
.nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; background: transparent; border: none;
  color: var(--muted-2); padding: 11px 14px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: 13px; text-align: left; }
.nav-item span { opacity: .8; }
.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #312e81; color: #e0e7ff; border: 1px solid #4338ca; }
.admin-only { display: none !important; }
.admin-only.show { display: flex !important; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.whoami { font-size: 12px; color: var(--muted-2); margin-bottom: 10px; }
.whoami b { color: #e2e8f0; }

/* min-width/min-height:0 = BẮT BUỘC với flex item có overflow, else nó nở theo nội dung (không cuộn) */
.content { flex: 1; padding: 22px 26px; overflow: auto; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.topbar-titles { min-width: 0; }
/* nút menu (chỉ hiện ở mobile) + nền mờ drawer */
.menu-btn { display: none; background: rgba(15,23,42,.6); border: 1px solid var(--border-2);
  color: var(--text); width: 40px; height: 40px; border-radius: 10px; font-size: 20px;
  cursor: pointer; align-items: center; justify-content: center; flex: 0 0 auto; }
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-badge { background: rgba(16,185,129,.14); border: 1px solid rgba(16,185,129,.45);
  color: #6ee7b7; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 12px; }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.ov-stats { grid-template-columns: repeat(5, 1fr); }   /* overview có thêm thẻ Earnings */
.stat-card { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--indigo);
  border-radius: 14px; padding: 16px 18px; }
.stat-label { color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.stat-value { color: #f8fafc; font-size: 24px; font-weight: 700; margin-top: 6px; }
.accent-indigo { border-left-color: var(--indigo); }
.accent-emerald { border-left-color: var(--emerald); }
.accent-sky { border-left-color: var(--sky); }
.accent-amber { border-left-color: var(--amber); }
.accent-rose { border-left-color: var(--rose); }

/* ---------- Panels / charts ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.panel.narrow { max-width: 560px; margin-bottom: 16px; }

/* ---------- Tab Tài khoản ---------- */
.user-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.user-head { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border); }
.user-avatar { width: 52px; height: 52px; border-radius: 14px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #818cf8, #4f46e5); }
.user-name { font-size: 17px; font-weight: 700; color: #f1f5f9; }
.pw-form { display: flex; flex-direction: column; }
.pw-form input { margin-bottom: 4px; }
.pw-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
@media (max-width: 760px) { .user-grid { grid-template-columns: 1fr; } }
.panel-title { font-size: 13px; font-weight: 700; color: #e2e8f0; margin-bottom: 14px; }
.chart-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.range-tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; }
.range-tab { background: transparent; border: none; color: var(--muted-2); padding: 6px 14px;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12px; }
.range-tab.active { background: #312e81; color: #e0e7ff; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Table ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: auto;
  /* giới hạn theo chiều cao màn hình -> bảng dài thì CUỘN TRONG KHUNG, header dính lại */
  max-height: calc(100vh - 210px); }
/* tab Nodes có thêm hàng thẻ thống kê -> chừa thêm chỗ để bảng không tràn màn hình */
#tab-nodes .table-wrap { max-height: calc(100vh - 320px); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
/* bảng thiết bị: mọi cột co khít nội dung, riêng cột NÚT CONTROL (cuối) nuốt hết phần
   thừa -> không còn khoảng trống ở STT/Status và nút control luôn chạm mép phải. */
#nodesTable td.acts, #nodesTable thead th:last-child { width: 100%; }
.table th { text-align: left; color: var(--muted-2); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px; padding: 8px 10px; background: var(--panel-2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; white-space: nowrap; }
.table td { padding: 7px 10px; border-bottom: 1px solid rgba(148,163,184,.12); vertical-align: middle; }
/* cắt ngắn nội dung dài (proxy/email) + hiện '…' , hover xem đầy đủ */
.cell-trunc { display: inline-block; max-width: 168px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: middle; }
.email-trunc { max-width: 108px; }   /* email hẹp ~ bằng "không liên kết", dài hơn -> '…' */
.name-trunc  { max-width: 120px; }   /* tên thiết bị gọn lại, dài hơn -> '…' */
.table tr:hover td { background: rgba(148,163,184,.04); }
/* click nền row để chọn -> con trỏ pointer + tô sáng row đang chọn */
#nodesTable tbody tr { cursor: pointer; }
/* cột STT: hẹp, canh phải, mờ */
.table th.stt, #nodesTable td.stt { width: 34px; text-align: right; color: var(--muted-2); font-variant-numeric: tabular-nums; }
#nodesTable tbody tr:has(.rowchk:checked) td { background: rgba(99,102,241,.16); }
/* Check proxy + Check block: click cả dòng để tick (giống bảng Thiết bị) + tô nền dòng đã tick */
#cpRows tr, #cbRows tr { cursor: pointer; }
#cpRows tr:has(.cpchk:checked) td,
#cbRows tr:has(.cbchk:checked) td { background: rgba(99,102,241,.16); }
/* node online -> nền xanh nhạt (joining -> xanh dương nhạt) */
.table tr.row-online td { background: rgba(16,185,129,.09); }
.table tr.row-online:hover td { background: rgba(16,185,129,.15); }
.table tr.row-join td { background: rgba(96,165,250,.08); }
.table tr.row-join:hover td { background: rgba(96,165,250,.14); }
.table tr.row-warn td { background: rgba(245,158,11,.08); }
.table tr.row-warn:hover td { background: rgba(245,158,11,.14); }
/* Online nhưng chạy >1h không ra tiền -> nền XÁM (chạy vô ích, nên đổi proxy) */
.table tr.row-dim td { background: rgba(100,116,139,.16); }
.table tr.row-dim:hover td { background: rgba(100,116,139,.24); }
.table tr.row-wait td { background: rgba(167,139,250,.08); }        /* staggered start: tím nhạt */
.table tr.row-wait:hover td { background: rgba(167,139,250,.14); }
.table tr.row-blocked td { background: rgba(239,68,68,.14); }        /* bị EarnApp chặn: nền đỏ */
.table tr.row-blocked:hover td { background: rgba(239,68,68,.2); }
/* ping: badge SỐ ping, tô màu theo ngưỡng (ping-metric.md) */
.ping-badge { display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.5; }
.ping-great { color: #34d399; background: rgba(52,211,153,.14); }
.ping-good  { color: #22c55e; background: rgba(34,197,94,.14); }
.ping-mid   { color: #eab308; background: rgba(234,179,8,.16); }
.ping-high  { color: #f97316; background: rgba(249,115,22,.16); }
.ping-vhigh { color: #ef4444; background: rgba(239,68,68,.16); }
.ping-na    { color: #9ca3af; }
/* IP: dòng số lượt xoay — 0 mờ, ít vàng, nhiều đỏ (proxy xoay nhanh không hợp EarnApp) */
.ip-rot    { font-size: 11px; margin-top: 2px; }
.iprot-ok  { color: #64748b; }
.iprot-mid { color: #eab308; font-weight: 600; }
.iprot-hi  { color: #ef4444; font-weight: 700; }
/* ảnh cờ quốc gia (flagcdn) — hiện đúng trên Windows (emoji cờ không render) */
.flag-cell { display: inline-flex; align-items: center; gap: 6px; }
.flag { width: 20px; height: 15px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.2); flex: none; }
/* GEO: nền ô country theo ghim VPS. geo-ok = cùng nước proxy (xanh, ping tối ưu); geo-diff = khác nước (vàng) */
.flag-cell.geo-ok, .flag-cell.geo-diff { padding: 2px 8px; border-radius: 7px; font-weight: 600; }
.flag-cell.geo-ok   { background: rgba(16,185,129,.16); color: #34d399; }
.flag-cell.geo-diff { background: rgba(245,158,11,.16); color: #fbbf24; }
/* IPQS: mỗi trường 1 cột — true = XANH, false = ĐỎ */
.ipqs-isp { font-size: 10px; margin-top: 2px; }
.ipqs-b { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.ipqs-b.is-true  { background: rgba(239,68,68,.18); color: #f87171; }    /* true -> đỏ */
.ipqs-b.is-false { background: rgba(16,185,129,.18); color: #34d399; }   /* false -> xanh */
.cp-table th, .cp-table td { white-space: nowrap; }
/* IP exit TRÙNG (Check proxy) hoặc IP hiện tại trùng giữa các thiết bị (bảng thiết bị) -> vàng cảnh báo */
.cp-ip-dup, .cp-ip-dup .mono, .ip-dup, .ip-dup .mono { color: #fbbf24 !important; font-weight: 700; }

/* ---------- Context menu (chuột phải bảng thiết bị) ---------- */
.ctx-menu { position: fixed; z-index: 4000; min-width: 210px; background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 6px; box-shadow: 0 12px 34px rgba(0,0,0,.55); }
.ctx-menu.hidden { display: none; }
.ctx-head { font-size: 11px; color: var(--muted-2); padding: 4px 10px 6px; }
.ctx-item { display: flex; align-items: center; gap: 4px; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 8px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.ctx-item:hover { background: rgba(148,163,184,.14); }
.ctx-sep { height: 1px; background: var(--border-2); margin: 5px 4px; }
/* icon màu cho từng mục menu */
.ci-ic { display: inline-flex; justify-content: center; width: 20px; font-size: 13px; }
.ci-green { color: #22c55e; } .ci-red { color: #f87171; } .ci-blue { color: #60a5fa; }
.ci-indigo { color: #818cf8; } .ci-amber { color: #fbbf24; } .ci-cyan { color: #22d3ee; }
.ci-emerald { color: #34d399; }
.ci-rose { color: #fb7185; } .ci-violet { color: #a78bfa; }
.ctx-item.ci-start:hover { background: rgba(34,197,94,.15); }
.ctx-item.ci-stop:hover  { background: rgba(239,68,68,.15); }

/* ---------- Dialog thông tin node ---------- */
.ni-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 18px; }
.ni-grid > div { background: rgba(148,163,184,.05); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px;
  border-left: 3px solid rgba(99,102,241,.5); }
.ni-grid .k { color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.ni-grid .v { font-size: 13px; word-break: break-all; margin-top: 3px; font-weight: 500; }
.ni-grid .v.mono { font-family: Consolas, monospace; font-size: 12px; }
.ni-grid .v.v-earn { color: #fbbf24; font-weight: 800; }
.ni-grid .v.v-traffic { color: #38bdf8; font-weight: 700; }
.ni-grid .v.v-use { color: #34d399; font-weight: 700; }
.v-use { color: #34d399; }   /* dùng chung (vd tổng credit Scamalytics còn lại) */
.ni-grid .v.v-ip { color: #a5b4fc; }
.ni-grid .v.v-warn { color: #f87171; font-weight: 800; }
/* input giới hạn node (admin) khi lưu thành công */
.ad-limit.flash-ok { border-color: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,.25); transition: box-shadow .2s, border-color .2s; }
.v-warn { color: #f87171; }
/* danh sách IP đã dùng */
.ni-iplist { margin: 2px 0 20px; }
.ni-sec-title { font-size: 12.5px; color: #cbd5e1; font-weight: 700; margin-bottom: 9px; }
.ip-chips { display: flex; flex-wrap: wrap; gap: 7px; max-height: 128px; overflow: auto; }
.ip-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 9px; border-radius: 7px;
  background: rgba(148,163,184,.1); border: 1px solid var(--border-2); }
.ip-chip.cur { background: rgba(16,185,129,.15); color: #34d399; border-color: rgba(16,185,129,.35); }
.ip-chip b { font-weight: 700; font-size: 10.5px; }
/* biểu đồ */
.ni-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ni-chart { background: rgba(148,163,184,.05); border: 1px solid var(--border-2); border-top: 3px solid var(--border-2);
  border-radius: 10px; padding: 12px; }
.ni-chart.c-up { border-top-color: #22c55e; }
.ni-chart.c-use { border-top-color: #38bdf8; }
.ni-chart.c-earn { border-top-color: #fbbf24; }
.ni-chart.c-jobs { border-top-color: #a78bfa; }
.ni-chart.c-traffic { border-top-color: #f472b6; }
.ni-chart-wide { grid-column: 1 / -1; }
.ni-chart-title { font-size: 12px; color: #e2e8f0; margin-bottom: 8px; font-weight: 700; }
.ni-canvas { position: relative; height: 190px; }
@media (max-width: 720px) { .ni-charts { grid-template-columns: 1fr; } }
/* Worker tab: GRID card ô vuông */
/* Danh sách worker CUỘN RIÊNG -> thẻ số liệu + toolbar đứng yên (trước đây grid nở ra làm cuộn
   cả vùng nội dung). overscroll-behavior: cuộn hết danh sách thì DỪNG, không đẩy tiếp trang. */
.worker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
  max-height: calc(100vh - 300px); overflow-y: auto; overscroll-behavior: contain;
  padding-right: 4px; align-content: start; }
.worker-card { background: var(--panel); border: 1px solid var(--border-2); border-left-width: 3px; border-radius: 12px; padding: 14px; }
.worker-card.wk-ok  { border-left-color: #22c55e; }
.worker-card.wk-mid { border-left-color: #eab308; }
.worker-card.wk-hi  { border-left-color: #ef4444; }
.wk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.wk-name { min-width: 0; flex: 1; }
.wk-name-main { font-size: 15px; line-height: 1.2; }
.wk-host { font-size: 11px; color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-badge { flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.wk-b-ok  { background: rgba(34,197,94,.16); color: #4ade80; }
.wk-b-mid { background: rgba(234,179,8,.16); color: #facc15; }
.wk-b-hi  { background: rgba(239,68,68,.18); color: #f87171; }
.wk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.wk-stats > div { text-align: center; }
.wk-num { font-size: 18px; font-weight: 700; line-height: 1.1; }
.wk-lbl { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; white-space: nowrap; }
.wk-pct-mid { color: #facc15; } .wk-pct-hi { color: #f87171; }
.wk-country { margin-top: 10px; font-size: 13px; }
.wk-ip { margin-top: 6px; font-size: 12px; color: #94a3b8; }
/* thanh tải capacity dùng chung */
.cap-bar { position: relative; height: 8px; border-radius: 999px; background: rgba(148,163,184,.18); overflow: hidden; }
.cap-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.cap-fill.cap-ok  { background: #22c55e; }
.cap-fill.cap-mid { background: #eab308; }
.cap-fill.cap-hi  { background: #ef4444; }
/* thanh tải TO có số liệu (đã dùng / tối đa · trống) hiển thị bên trong */
.cap-bar-lg { height: 26px; border-radius: 8px; }
.cap-bar-lg .cap-fill { border-radius: 8px 0 0 8px; opacity: .85; }
.cap-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; font-size: 11.5px; color: #f1f5f9; font-weight: 600; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.cap-text b { font-weight: 800; }
/* UDP/HTTP3: chip từng phần (pass xanh / fail đỏ) + dòng kết luận */
.udp-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.udp-chip { font-size: 11px; padding: 1px 6px; border-radius: 6px; white-space: nowrap; font-weight: 600; }
.udp-chip.ok  { color: #22c55e; background: rgba(34,197,94,.14); }
.udp-chip.bad { color: #ef4444; background: rgba(239,68,68,.16); }
.udp-note { font-size: 11px; margin-top: 3px; }
.udp-c { white-space: nowrap; }
.udp-good  { color: #22c55e; }
.udp-warn  { color: #f59e0b; }
.udp-bad   { color: #ef4444; }
.mono { font-family: Consolas, monospace; color: var(--indigo-2); font-size: 12px; }
.nowrap { white-space: nowrap; }
.cell-copy { display: inline-flex; align-items: center; gap: 6px; }
.cbtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px;
  padding: 2px 4px; border-radius: 6px; opacity: .5; transition: .15s; line-height: 1; }
.table tr:hover .cbtn { opacity: .8; }
.cbtn:hover { color: var(--indigo-2); opacity: 1; background: rgba(99,102,241,.14); }
.cbtn.ok { color: var(--emerald); opacity: 1; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
/* cột Status (#nodesTable, cột 4): pill rộng cố định = "Reconnecting" -> cột không co/giãn khi status đổi */
#nodesTable tbody td:nth-child(4) .pill { min-width: 112px; justify-content: center; }
.pill.on { background: rgba(16,185,129,.14); color: #34d399; }
.pill.off { background: rgba(100,116,139,.14); color: #94a3b8; }
.pill.join { background: rgba(96,165,250,.14); color: #60a5fa; }
.pill.warn { background: rgba(245,158,11,.15); color: #fbbf24; }
.pill.wait { background: rgba(167,139,250,.16); color: #a78bfa; }   /* đang chờ staggered start */
.pill.blocked { background: rgba(239,68,68,.2); color: #f87171; font-weight: 700; }   /* bị EarnApp chặn */
.jobs { color: var(--teal); font-weight: 600; }
.earn { color: var(--amber); font-weight: 700; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }   /* nút control chạm mép phải, căn giữa dọc */
.row-actions .btn { width: 32px; height: 32px; padding: 0; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; }
/* nút hành động admin: giữ kích thước chữ bình thường (không ép vuông) */
.admin-actions { display: flex; gap: 6px; }
.admin-actions .btn { white-space: nowrap; padding: 6px 14px; }

/* ---------- Log ---------- */
.log-view { font-family: Consolas, monospace; font-size: 12px; color: #c7d2fe; line-height: 1.7;
  max-height: 60vh; overflow: auto; }
.log-view .t { color: var(--muted); margin-right: 8px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv span { color: var(--muted-2); }

/* ---------- Gmail Account: BẢNG 1 dòng = 1 gmail, bấm ▸ mới bung danh sách device ---------- */
.gm-mail { font-size: 14px; color: #e0e7ff; }
.gm-start-row td { background: rgba(245,158,11,.10); }   /* node MỞ ĐẦU (theo proxy chỉ định) */
.gm-caret { background: transparent; border: none; color: var(--muted-2); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.gm-caret:hover { background: rgba(99,102,241,.16); color: #e0e7ff; }
/* click cả dòng để tick + tô nền dòng đã chọn (giống bảng Thiết bị) */
.gm-row { cursor: pointer; }
#gmTable tbody:has(.gmchk:checked) > .gm-row > td { background: rgba(99,102,241,.16); }
.gm-detail > td { padding: 0 10px 12px; background: rgba(15,23,42,.55); }
/* lỗi proxy (vd proxy trỏ vào thiết bị ĐÃ LINK) -> ĐỎ */
.gm-err { color: #f87171; font-weight: 700; }
.gm-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-2); cursor: pointer; }
/* Bảng device bên trong cuộn RIÊNG; overscroll-behavior chặn "scroll chaining" (không đẩy cả trang) */
.gm-sub { max-height: 300px; overflow: auto; overscroll-behavior: contain; margin: 0; }
.gm-sub thead th { position: sticky; top: 0; z-index: 2; }
/* bảng gmail ngoài cùng: cuộn riêng + tiêu đề cột dính */
#gmResult > .table-wrap { max-height: calc(100vh - 430px); overflow: auto; overscroll-behavior: contain; }
#gmResult > .table-wrap > table > thead th { position: sticky; top: 0; z-index: 3; }

/* ---------- QR Proxy (dialog) ---------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0; }
.qr-img { background: #fff; padding: 10px; border-radius: 12px; display: block; }
.qr-uri { font-size: 12px; color: #c7d2fe; word-break: break-all; text-align: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
.qr-acts { display: flex; gap: 8px; }
.qr-acts .btn { text-decoration: none; }

/* ---------- Ghi chú (notes): cột trái danh sách, cột phải soạn thảo ---------- */
.note-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
.note-side { position: sticky; top: 0; }
.note-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 260px); overflow: auto; }
.note-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  text-align: left; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 10px; cursor: pointer; transition: .15s; }
.note-item:hover { border-color: rgba(99,102,241,.5); }
.note-item.active { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.65); }
.note-item-t { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; }
.note-item-s { font-size: 11px; color: var(--muted-2); }
.note-main { display: flex; flex-direction: column; gap: 10px; }
.note-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note-title { flex: 1 1 220px; font-weight: 700; font-size: 15px; }
.note-stat { font-size: 12px; white-space: nowrap; }
.note-body { width: 100%; box-sizing: border-box; min-height: calc(100vh - 300px); resize: vertical;
  font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; white-space: pre; overflow-wrap: normal; }
@media (max-width: 900px) {
  .note-wrap { grid-template-columns: 1fr; }
  .note-side { position: static; }
  .note-list { max-height: 220px; }
  .note-body { min-height: 46vh; }
}

/* ---------- Ô tìm kiếm ---------- */
.search-box { position: relative; display: flex; align-items: center; flex: 2 1 360px; min-width: 300px; }
.search-box svg { position: absolute; left: 13px; width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.search-box input { width: 100%; padding-left: 38px; }
.search-box:focus-within svg { color: var(--indigo-2); }
/* ô search admin: không chiếm full width */
.admin-search { flex: 0 1 300px; max-width: 300px; }
@media (max-width: 640px) { .admin-search { flex: 1 1 100%; max-width: none; } }

/* ---------- Input kèm nút copy ---------- */
.inp-copy { display: flex; gap: 6px; align-items: stretch; }
.inp-copy input { flex: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 0 11px; border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--muted-2); border-radius: 10px;
  cursor: pointer; font-size: 15px; transition: .15s; }
.icon-btn:hover { border-color: rgba(99,102,241,.5); color: #e0e7ff; }
.icon-btn.ok { color: var(--emerald); border-color: rgba(16,185,129,.5); }

/* danh sách nhóm — cuộn khi dài */
.glist { max-height: 220px; overflow: auto; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; }
.glist:empty { border: none; padding: 0; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.modal-card.wide { width: 70vw; max-width: 70vw; }
.modal-card.full { width: 90vw; max-width: 90vw; height: 90vh; }
.modal-card.wide, .modal-card.tall, .modal-card.full { height: 80vh; display: flex; flex-direction: column; }
.modal-card.full { height: 90vh; }
.modal-card.wide .modal-body, .modal-card.full .modal-body { flex: 1; min-height: 0; overflow-y: auto; margin-bottom: 14px; }
/* dialog cao: thân cuộn, danh sách nhóm giãn đầy chỗ trống */
.modal-card.tall .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; margin-bottom: 14px; }
.modal-card.tall .glist { flex: 1; max-height: none; }
/* check proxy: 2 view (nhập / kết quả) đều lấp đầy dialog */
.cp-view { display: flex; flex-direction: column; }
.cp-view.hidden { display: none; }
.cp-textarea { min-height: 240px; resize: vertical; font-family: Consolas, monospace; width: 100%; box-sizing: border-box; }
.cp-bar { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex: 0 0 auto; flex-wrap: wrap; }
/* filter quốc gia: không cho chiếm full-width (ghi đè .cs-block trong modal) */
.cp-bar .cs { flex: 0 0 auto; width: auto; min-width: 170px; max-width: 240px; }
.cp-bar #cpProgress { margin-left: auto; text-align: right; white-space: nowrap; }
.cp-result-full { overflow: auto; max-height: calc(100vh - 250px); border: 1px solid var(--border); border-radius: 12px; }
.modal-card { position: relative; width: 460px; max-width: 92vw; background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 16px; padding: 22px; }
.modal-x { position: absolute; top: 12px; right: 12px; z-index: 2; width: 32px; height: 32px; display: flex;
  align-items: center; justify-content: center; border: none; background: transparent; color: var(--muted-2);
  font-size: 18px; line-height: 1; cursor: pointer; border-radius: 9px; transition: .15s; }
.modal-x:hover { background: rgba(239,68,68,.16); color: #f87171; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; padding-right: 34px; }
.modal-body { margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Responsive: tablet ---------- */
@media (max-width: 900px) {
  .stat-row, .chart-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { width: 200px; }
  .content { padding: 18px; }
}

/* ---------- Responsive: mobile (menu drawer) ---------- */
@media (max-width: 640px) {
  .menu-btn { display: inline-flex; }

  /* Sidebar -> drawer trượt từ trái */
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 50; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.55); }
  .drawer-backdrop.show { display: block; }

  .content { padding: 14px; }
  .topbar h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-titles { flex: 1; }
  .topbar-badge { flex: 0 0 auto; }

  /* Thẻ số liệu 2 cột, biểu đồ xếp dọc */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
  .chart-grid { grid-template-columns: 1fr; }

  /* Toolbar dồn, nút giãn đều, ô search full width */
  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar .btn, .toolbar #filterGroup, .toolbar .cs { flex: 1 1 auto; }
  .search-box { flex: 1 1 100%; min-width: 0; order: 10; }

  /* Panel & modal full-ish */
  .panel.narrow { max-width: 100%; }
  .modal-card { width: 96vw; padding: 18px; max-height: 88vh; overflow-y: auto; }
  .modal-card.wide { width: 96vw; max-width: 96vw; }   /* mobile: dùng gần full */

  /* Bảng: chữ gọn hơn (vẫn cuộn ngang trong .table-wrap) */
  .table th, .table td { padding: 9px 10px; }
}
