:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1c2024;
  --dim: #6b7280;
  --sidebar: #111827;
  --sidebar-dim: #9ca3af;
  --blue: #2563eb;
  --red: #dc2626;
  --orange: #ea580c;
  --amber: #b45309;
  --green: #15803d;
}

* { box-sizing: border-box; }
/* `button { display: inline-block }` bên dưới đè mặc định của trình duyệt: không có dòng này
   thì nút gắn thuộc tính hidden vẫn hiện */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
}

/* ---------- khung dashboard ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  color: #fff;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.brand strong { display: block; font-size: 14px; }
.brand small { color: var(--sidebar-dim); font-size: 11px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 7px;
  color: #d1d5db; text-decoration: none; font-size: 13.5px;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.on { background: var(--blue); color: #fff; }
.sidebar nav .ico { width: 16px; text-align: center; opacity: .9; }
.sidebar nav .count {
  margin-left: auto; font-style: normal; font-size: 11px;
  background: rgba(255,255,255,.16); padding: 1px 7px; border-radius: 999px;
}
.side-menu { flex: 1; display: flex; flex-direction: column; gap: 18px; }
.nav-toggle { display: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.api-link { color: var(--sidebar-dim); font-size: 12px; text-decoration: none; text-align: center; }
.api-link:hover { color: #fff; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 19px; }
.topbar .sub { margin: 2px 0 0; color: var(--dim); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-actions form { margin: 0; }

main { padding: 20px 24px 60px; }

/* ---------- thành phần ---------- */

.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 12px; border-radius: 6px; margin-bottom: 6px;
  border: 1px solid var(--line); background: var(--card);
  overflow-wrap: anywhere;   /* lỗi API dài (URL, tên lớp) không có khoảng trắng để xuống dòng */
}
.flash.success { border-color: #bbf7d0; background: #f0fdf4; color: var(--green); }
.flash.error { border-color: #fecaca; background: #fef2f2; color: var(--red); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; text-decoration: none; color: inherit; display: block;
}
a.card:hover { border-color: var(--blue); }
.card .label { color: var(--dim); font-size: 12px; }
.card b { display: block; font-size: 26px; line-height: 1.25; }
.card b small { font-size: 13px; font-weight: 500; color: var(--dim); }
.card small { color: var(--dim); font-size: 11.5px; }
.card.danger b { color: var(--red); }
.card.warn b { color: var(--orange); }
.card.amber b { color: var(--amber); }
.card.good b { color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
/* ô lưới mặc định min-width: auto -> nội dung dài (pre, bảng, URL) đẩy cột rộng quá khung */
.grid-2 > * { min-width: 0; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin-bottom: 14px;
}
.panel.flush { padding: 0; overflow-x: auto; overflow-y: hidden; }
.panel h2 { margin: 0 0 10px; font-size: 14.5px; }
.panel h2.inset { padding: 14px 14px 0; margin-bottom: 8px; }
.hint { margin: 8px 0 0; color: var(--dim); font-size: 12px; }
.empty { color: var(--dim); text-align: center; padding: 24px; }

.row-form { display: flex; flex-wrap: wrap; gap: 8px; }
.row-form input { flex: 1 1 160px; min-width: 0; }

input, button, select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff; color: inherit;
}
button, .btn { cursor: pointer; text-decoration: none; display: inline-block; }
.btn { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
button.primary, .btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
button.secondary, .btn.secondary { background: #1f2937; color: #fff; border-color: #1f2937; }
button.wide { width: 100%; }

.filterbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.filterbar .search { display: flex; gap: 8px; flex: 1 1 320px; }
.filterbar .search input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--dim); text-decoration: none;
}
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.chip.expired.on { background: var(--red); border-color: var(--red); }
.chip.critical.on { background: var(--orange); border-color: var(--orange); }
.chip.warning.on { background: var(--amber); border-color: var(--amber); }
.chip.ok.on { background: var(--green); border-color: var(--green); }
.chip.available.on { background: var(--blue); border-color: var(--blue); }

/* ---------- biểu đồ cột ---------- */

.chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 190px; padding-top: 14px;
}
.bar-wrap {
  flex: 1; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; gap: 4px; min-width: 0;
}
.bar {
  width: 100%; max-width: 34px; min-height: 3px;
  background: var(--blue); border-radius: 4px 4px 0 0;
}
.bar.bad { background: var(--red); }
.bar-value { font-size: 11px; color: var(--dim); height: 14px; }
.bar-label {
  font-size: 10.5px; color: var(--dim); white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: clip;   /* cột hẹp: cắt nhãn, không đè cột bên */
}

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: none; }
.list small { display: block; color: var(--dim); font-size: 11.5px; }

/* ---------- bảng ---------- */

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f9fafb; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--dim); }
tr:last-child td { border-bottom: none; }
table.tight th, table.tight td { padding: 7px 12px; }
td.name { font-weight: 600; }
/* tên domain: link mở trang + nút copy hiện khi rê chuột */
td.name .dlink { color: inherit; text-decoration: none; }
td.name .dlink:hover { text-decoration: underline; }
td.name .name-copy {
  margin-left: 4px; padding: 0 4px; border: none; background: none; cursor: pointer;
  font-size: 13px; line-height: 1; color: var(--dim); opacity: 0; vertical-align: 0;
}
tr:hover td.name .name-copy, td.name .name-copy:focus { opacity: 1; }
td.name .name-copy:hover { color: var(--blue); }
td.dim, .note, .dim { color: var(--dim); }
td.empty { text-align: center; color: var(--dim); padding: 26px; }

tr.u-expired td.name { color: var(--red); }
tr.u-critical td.name { color: var(--orange); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.expired { background: #fee2e2; color: var(--red); }
.badge.critical { background: #ffedd5; color: var(--orange); }
.badge.warning { background: #fef3c7; color: var(--amber); }
.badge.ok { background: #dcfce7; color: var(--green); }
.badge.unknown { background: #e5e7eb; color: var(--dim); }

/* Badge trạng thái domain: class st-<status viết thường, bỏ khoảng trắng> */
.badge.st { background: #e5e7eb; color: var(--dim); }
.badge.st-available { background: #dbeafe; color: #1d4ed8; }
.badge.st-registered { background: #dcfce7; color: var(--green); }
.badge.st-onhold { background: #f3e8ff; color: #7e22ce; }
.badge.st-graceperiod { background: #fef3c7; color: var(--amber); }
.badge.st-redemption { background: #ffedd5; color: var(--orange); }
.badge.st-pendingdelete { background: #fee2e2; color: var(--red); }
.badge.st-unknown { background: #e5e7eb; color: var(--dim); }
/* Lịch sử thông báo: dòng domain Available nổi bật */
tr.n-available td { background: #eff6ff; font-weight: 600; animation: n-avail-blink 1.2s ease-in-out infinite; }
tr.n-available .badge { animation: n-avail-badge 1.2s ease-in-out infinite; }
/* chỉ đổi màu nền, không transform trên tr/td (vỡ layout bảng) */
@keyframes n-avail-blink { 50% { background: #bfdbfe; } }
@keyframes n-avail-badge { 50% { background: #1d4ed8; color: #fff; } }
@media (prefers-reduced-motion: reduce) {
  tr.n-available td, tr.n-available .badge { animation: none; }
}
tr.n-available td:first-child { box-shadow: inset 3px 0 0 #1d4ed8; }
tr.n-available td.name { color: #1d4ed8; }
.domain-table td.c-state .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

/* KHONG dat display:flex len td: o do se thoi la table-cell va lech khoi luoi cot */
td.actions { white-space: nowrap; }
td.actions form { display: inline-block; margin: 0; vertical-align: middle; }
td.actions > button { vertical-align: middle; }
.act-group { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
button.link { background: none; border: none; padding: 2px 4px; color: var(--blue); text-decoration: underline; }
button.link.danger { color: var(--red); }

.edit-row td { background: #f9fafb; }

/* ---------- màn hình hẹp ---------- */

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  /* mobile: thanh trên gọn (logo + ☰), menu là ngăn kéo trượt từ trái */
  .sidebar { width: auto; flex: none; padding: 10px 14px; position: sticky; top: 0; z-index: 50; }
  .brand small { display: none; }
  .brand > div { flex: 1; }
  .nav-toggle {
    display: block; width: 38px; height: 38px; padding: 0; border-radius: 8px;
    background: transparent; border: 1px solid rgba(255,255,255,.2); color: #fff; font-size: 18px;
  }
  .side-menu {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; max-width: 82vw; z-index: 60;
    background: var(--sidebar); padding: 18px 14px; overflow-y: auto;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.nav-open .side-menu { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.45);
  }
  body.nav-open { overflow: hidden; }
  main { padding: 14px; }
  .topbar { padding: 14px; }
  table, thead, tbody, th, td, tr { display: block; }
  table.proxy-table { min-width: 0; table-layout: auto; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  td { border: none; padding: 5px 12px; }
  td.actions { padding-bottom: 12px; }
  .act-group { justify-content: flex-start; }
  .btn-mini { flex: 0 0 auto; min-width: 62px; }
  .chart { height: 150px; }
  .bar-label { font-size: 9px; }
}

/* ---------- phân trang + ô ghi chú ---------- */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; padding: 10px 12px;
  border-top: 1px solid var(--line); background: #f9fafb; font-size: 12.5px;
}
.pg-group { display: flex; gap: 4px; flex-wrap: wrap; }
.pg {
  min-width: 30px; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; font-size: 12.5px;
}
.pg.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pg[disabled] { opacity: .4; cursor: default; }
a.pg { display: inline-block; text-align: center; color: var(--text); text-decoration: none; }
a.pg.on { color: #fff; }
a.pg.off { opacity: .4; pointer-events: none; }

/* lọc nhà đăng ký: khung tick chọn nhiều; bấm tên trên bảng = chỉ hiện nhà đó */
.chip.on-soft { border-color: var(--blue); color: var(--text); }
.reg-pick { position: relative; }
.reg-pick summary { list-style: none; cursor: pointer; display: inline-block; }
.reg-pick summary::-webkit-details-marker { display: none; }
.reg-pick summary b { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; color: var(--text); }
.reg-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 320px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); font-size: 13px;
}
/* khung chọn một (Trạng thái, Ghi chú): mỗi dòng là link lọc */
.pick-menu { width: auto; min-width: 200px; padding: 4px 0; }
.pick-opt { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 6px 12px; color: inherit; text-decoration: none; white-space: nowrap; }
.pick-opt:hover { background: #f3f4f6; }
.pick-opt.on { background: #eef2ff; font-weight: 600; }
/* trang Domain: ô tìm + chip hạn + nhà đăng ký trên 1 dòng, ô tìm co lại khi thiếu chỗ */
.filterbar .search.compact { flex: 1 1 150px; max-width: 260px; min-width: 0; }
/* ô tìm cùng dáng chip: cao bằng chip, bo tròn, icon kính lúp, Enter để tìm */
.filterbar .search.compact input {
  min-width: 0; height: 30px; padding: 0 12px 0 30px; border-radius: 999px; font-size: 12.5px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13'/%3E%3C/svg%3E") no-repeat 11px center;
}
.filterbar.packed { justify-content: flex-start; gap: 8px; }
#reg-bar .chip { height: 30px; display: inline-flex; align-items: center; gap: 4px; box-sizing: border-box; }
#reg-bar .reg-pick summary.chip { display: inline-flex; }
.reg-search { display: block; width: calc(100% - 20px); margin: 10px 10px 0; padding: 6px 9px; font-size: 13px; }
.reg-empty { padding: 6px 12px; margin: 0; }
.pager select { padding: 2px 4px; font-size: 12.5px; border-radius: 5px; }
.reg-tools, .reg-foot { display: flex; gap: 12px; padding: 8px 12px; }
.reg-tools { border-bottom: 1px solid var(--line); }
.reg-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.reg-list { max-height: 300px; overflow-y: auto; padding: 4px 0; }
.reg-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; }
.reg-item:hover { background: #f3f4f6; }
.reg-item[hidden] { display: none; }
.reg-item .reg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-item .reg-only { visibility: hidden; font-size: 12px; }
.reg-item:hover .reg-only { visibility: visible; }
.domain-table.loading tbody { opacity: .5; transition: opacity .15s; }
.domain-table .reg-link { color: inherit; text-decoration: none; }
.domain-table .reg-link:hover { color: var(--blue); text-decoration: underline; }

.note-input {
  width: 100%; min-width: 110px; padding: 4px 7px; font-size: 12.5px;
  border: 1px solid transparent; background: #f3f4f6; border-radius: 5px;
}
.note-input:focus { border-color: var(--blue); background: #fff; outline: none; }
.note-input.saved { border-color: var(--green); background: #f0fdf4; }

.chips label.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; }
.chips select { padding: 3px 6px; border-radius: 5px; font-size: 12.5px; }
/* toast nổi góc trên phải, không chiếm chỗ trong trang -> hiện/tắt không đẩy nội dung nhảy */
#toast-area {
  position: fixed; top: 16px; right: 16px; z-index: 70; width: min(380px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
#toast-area .flash {
  margin: 0; pointer-events: auto; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(-3px); } }

/* ---------- trạng thái test từng dòng ---------- */

.spinner {
  display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

tr.testing { background: #f8fafc; }
tr.testing td { opacity: .75; }
/* transform trên <tr> làm vỡ layout bảng, chỉ mờ dần rồi bỏ dòng */
tr.gone { opacity: 0; transition: opacity .3s; pointer-events: none; }

/* Khóa bề rộng cột: nội dung ô Status đổi liên tục khi Fresh mà khung không nhảy */
.proxy-table { table-layout: fixed; min-width: 900px; }
.proxy-table .c-id { width: 6%; }
.proxy-table .c-name { width: 10%; }
.proxy-table .c-ip { width: 12%; }
.proxy-table .c-svc { width: 12%; }
/* c-net phải đủ cho "RESIDENTIAL_STATIC" + mã nước, hẹp hơn là bị cắt chữ */
.proxy-table .c-net { width: 11%; }
.proxy-table .c-conn { width: 8%; }
.proxy-table .c-exp { width: 8%; }
.proxy-table .c-auto { width: 7%; }
.proxy-table .c-status { width: 11%; }
.proxy-table .c-act { width: 15%; }
.proxy-table td { overflow: hidden; text-overflow: ellipsis; }
/* Menu chọn định dạng khi bấm Copy (trang Proxy) */
.copy-menu {
  position: fixed; z-index: 50; display: flex; flex-direction: column; gap: 2px;
  width: 260px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, .16), 0 2px 6px rgba(17, 24, 39, .06);
  animation: cm-in .12s ease-out;
}
.copy-menu[hidden] { display: none; }
@keyframes cm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.copy-menu .cm-head {
  padding: 4px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--dim); border-bottom: 1px solid var(--line); margin-bottom: 2px;
}
.copy-menu button {
  display: flex; flex-direction: column; gap: 3px; width: 100%; min-width: 0;
  border: 1px solid transparent; background: none; padding: 7px 10px; text-align: left;
  cursor: pointer; color: var(--text); border-radius: 7px; transition: background .1s, border-color .1s;
}
.copy-menu button:hover { background: #eef4ff; border-color: #c7d7fe; }
.copy-menu .cm-title { font-size: 13px; font-weight: 600; }
.copy-menu button:hover .cm-title { color: var(--blue); }
.copy-menu .cm-sample {
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 11.5px ui-monospace, Consolas, monospace; color: var(--dim);
  background: var(--bg); padding: 3px 6px; border-radius: 4px;
}
.proxy-table td.svc { white-space: normal; overflow: visible; }
.proxy-table td.status { white-space: nowrap; }
.proxy-table td.status .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
/* 2 nút bằng nhau, không bao giờ xuống dòng */
.proxy-table td.actions { white-space: nowrap; overflow: visible; }
/* dòng ngoài pool của Proxyline/Geonix có 4 nút (Test, Copy, +Pool, Gia hạn): xuống dòng thay vì tràn */
.proxy-table td.actions .act-group { flex-wrap: wrap; row-gap: 4px; }
.proxy-table td.actions .act-group > .btn-mini { flex: 0 0 auto; max-width: none; padding: 4px 7px; }
.btn-mini {
  flex: 1 1 0; min-width: 0; max-width: 62px;
  padding: 4px 0; text-align: center;
  font-size: 12px; line-height: 1.35;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text);
  transition: background .12s, border-color .12s, color .12s;
}
.btn-mini:hover { border-color: var(--blue); color: var(--blue); background: #f5f8ff; }
.btn-mini:active { background: #eaf0ff; }
.btn-mini[disabled] { opacity: .55; cursor: default; }
.btn-mini.busy { color: var(--dim); border-style: dashed; }
.btn-mini.done { background: #f0fdf4; border-color: #86efac; color: var(--green); }

/* Nút Fresh đổi chữ liên tục, giữ bề rộng cố định cho thanh tiêu đề đứng yên */
#btn-fresh { min-width: 132px; }
#btn-reload { min-width: 124px; }

td.mono, .mono { font-variant-numeric: tabular-nums; }
td.status .badge + .badge { margin-left: 4px; }

/* ---------- trang cài đặt ---------- */

pre.code {
  margin: 0; padding: 12px; border-radius: 8px;
  background: #0f172a; color: #e2e8f0;
  font: 12px/1.55 ui-monospace, Consolas, monospace;
  overflow-x: auto;
}
code {
  background: #f1f5f9; padding: 1px 5px; border-radius: 4px;
  font: 12px ui-monospace, Consolas, monospace;
}
.sidebar nav .count.warn { background: var(--red); color: #fff; }

/* ---------- hướng dẫn từng bước ---------- */

ol.steps { margin: 6px 0 0; padding-left: 20px; }
ol.steps > li { margin-bottom: 16px; padding-left: 4px; }
ol.steps > li::marker { color: var(--blue); font-weight: 700; }
ol.steps b { display: inline-block; margin-bottom: 4px; }
ol.steps p { margin: 4px 0; color: var(--dim); font-size: 13px; }
ol.steps p b, ol.steps p u { color: var(--text); }
ol.steps a { color: var(--blue); }
ol.steps pre.code { margin-top: 6px; }
ol.steps .row-form { margin-top: 8px; }
#d1-result { margin-top: 10px; }
#d1-result table { border: 1px solid var(--line); border-radius: 8px; }

/* ---------- thêm hàng loạt ---------- */

textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px;
  font: 12.5px/1.6 ui-monospace, Consolas, monospace; resize: vertical;
  background: #fff; color: inherit;
}
textarea:focus { outline: none; border-color: var(--blue); }

.bulk-progress {
  height: 6px; border-radius: 999px; background: var(--line);
  overflow: hidden; margin: 10px 0 6px;
}
.bulk-progress > i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .2s; }
.bulk-lines { max-height: 260px; overflow-y: auto; margin-top: 8px; }
.bulk-line {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.bulk-line:last-child { border-bottom: none; }
.bulk-line .dom { font-weight: 600; }

/* ---------- bảng domain ---------- */

.domain-table { table-layout: fixed; min-width: 980px; }
.domain-table .c-sel { width: 36px; }
.domain-table .c-name { width: 16%; }
.domain-table .c-exp { width: 9%; }
.domain-table .c-left { width: 9%; }
.domain-table .c-status { width: 11%; }
.domain-table .c-reg { width: 15%; }
.domain-table .c-note { width: 10%; }
.domain-table .c-checked { width: 14%; }
.domain-table .c-act { width: 14%; }
/* mọi ô một dòng: hàng nào cũng cao bằng nhau, đổi nội dung không xô khung */
.domain-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.domain-table td.actions { overflow: visible; }
.domain-table td.dim { font-size: 12.5px; }

.quick-table { table-layout: fixed; min-width: 1000px; }
.quick-table .c-name { width: 19%; }
.quick-table .c-exp { width: 10%; }
.quick-table .c-left { width: 10%; }
.quick-table .c-status { width: 12%; }
.quick-table .c-reg { width: 17%; }
.quick-table .c-ns { width: 16%; }
.quick-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-mini.danger { color: var(--red); }
.btn-mini.danger:hover { border-color: var(--red); color: var(--red); background: #fef2f2; }

.chip b { font-weight: 700; color: inherit; margin-left: 2px; }
#toast-area:empty { display: none; }

@media (max-width: 820px) {
  table.domain-table { min-width: 0; table-layout: auto; }
  /* mỗi domain = 1 thẻ gọn: tên + còn lại / hết hạn + trạng thái / nhà đăng ký + tra lần cuối */
  .domain-table tbody tr[data-id] {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px;
    grid-template-areas: "name left" "exp state" "reg last" "note note" "act act";
    padding: 10px 12px;
  }
  .domain-table tbody tr[data-id] td { padding: 0; min-width: 0; font-size: 12.5px; }
  .domain-table td.name { grid-area: name; font-size: 14px; }
  .domain-table td.c-daysleft { grid-area: left; text-align: right; }
  .domain-table td.c-expiry { grid-area: exp; color: var(--dim); }
  .domain-table td.c-expiry::before { content: "Hết hạn "; }
  .domain-table td.c-state { grid-area: state; text-align: right; }
  .domain-table td.c-registrar { grid-area: reg; color: var(--dim); }
  .domain-table td.c-last { grid-area: last; text-align: right; }
  .domain-table td.note { grid-area: note; color: var(--dim); font-style: italic; }
  .domain-table td.note:empty { display: none; }
  .domain-table .dash { display: none; }
  .domain-table td.actions { grid-area: act; padding: 6px 0 0; }
  .filterbar .search.compact { flex-basis: 100%; max-width: none; }
}

#btn-check-all { min-width: 108px; }

/* ---------- chế độ tick chọn domain ---------- */
.domain-table th.c-sel, .domain-table td.c-sel { padding-right: 0; text-align: center; }
.domain-table .c-sel input { margin: 0; cursor: pointer; vertical-align: middle; }
.domain-table tbody tr.sel td { background: #eef4ff; }
.sel-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; background: #eef4ff; border-bottom: 1px solid #c7d7fe; font-size: 13px;
}
.sel-bar[hidden] { display: none; }
.sel-bar .sel-actions { margin-left: auto; display: flex; gap: 6px; }
.sel-bar button { white-space: nowrap; }
/* .btn-mini mặc định co theo cụm nút trong bảng (flex 1 1 0, max 62px, padding ngang 0) -> ở thanh
   chọn phải đủ rộng theo chữ */
.sel-bar .btn-mini { flex: 0 0 auto; max-width: none; min-width: 76px; padding: 5px 12px; }
.sel-bar #sel-copy { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.sel-bar #sel-copy:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
@media (max-width: 820px) {
  /* thẻ domain trên điện thoại: ô tick nằm góc trái, nội dung lùi vào */
  .domain-table thead th.c-sel { display: none; }
  .domain-table tbody tr[data-id] { position: relative; padding-left: 38px; }
  .domain-table tbody tr[data-id] td.c-sel {
    position: absolute; left: 12px; top: 12px; width: 18px; background: none;
  }
}

/* ---------- cấu hình riêng trong form sửa domain ---------- */

.edit-row td { white-space: normal; overflow: visible; }
.own-settings {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin: 10px 0; padding: 10px; border: 1px dashed var(--line); border-radius: 8px;
  background: #fff;
}
.own-title { flex: 1 1 100%; font-weight: 600; font-size: 12.5px; }
.own-title small { font-weight: 400; color: var(--dim); }
.own-title a { color: var(--blue); }
.field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--dim); flex: 1 1 150px; min-width: 0;
}
.field input, .field select { font-size: 13px; color: var(--text); width: 100%; }
.own-dot {
  display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px;
  border-radius: 50%; background: var(--blue);
}

/* ---------- phân quyền: ẩn thao tác ở module chỉ có quyền xem ---------- */

.ro-dashboard [data-need="dashboard"],
.ro-domains [data-need="domains"],
.ro-automation [data-need="automation"],
.ro-proxies [data-need="proxies"],
.ro-proxy_buy [data-need="proxy_buy"],
.ro-tools [data-need="tools"],
.ro-settings [data-need="settings"],
.ro-users [data-need="users"] { display: none !important; }

/* ---------- đăng nhập / thiết lập lần đầu ---------- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px 16px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; padding: 26px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.auth-brand { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.auth-brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand small { color: var(--dim); font-size: 12px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 8px; }
.auth-form .field { flex: none; }
.auth-form button.wide { margin-top: 4px; padding: 10px; }
.auth-card .hint { margin-top: 10px; }

/* ---------- người dùng ở sidebar ---------- */

.user-box {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, .06);
}
.user-link { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; min-width: 0; }
.user-link:hover strong, .user-link.on strong { text-decoration: underline; }
.avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 700; font-size: 13px;
}
.user-text { min-width: 0; }
.user-text strong, .user-text small {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-text strong { font-size: 13px; }
.user-text small { color: var(--sidebar-dim); font-size: 11px; }
.user-box form { margin: 0; }
.logout-btn {
  width: 100%; padding: 5px 8px; font-size: 12px; border-radius: 6px;
  background: transparent; color: #d1d5db; border: 1px solid rgba(255, 255, 255, .18);
}
.logout-btn:hover { color: #fff; border-color: rgba(255, 255, 255, .45); }

/* ---------- module người dùng ---------- */

.users-table { table-layout: fixed; min-width: 980px; }
.users-table .c-user { width: 15%; }
.users-table .c-full { width: 16%; }
.users-table .c-role { width: 17%; }
.users-table .c-state { width: 10%; }
.users-table .c-login { width: 15%; }
.users-table .c-act { width: 27%; }
.btn-mini.has-own { border-color: var(--blue); color: var(--blue); background: #eef4ff; font-weight: 600; }
.user-perm-table { margin-top: 8px; background: #fff; }
.user-perm-table .c-inherit { width: 18%; }
.user-perm-table tr.own td.name { color: var(--blue); }
/* cột "Theo vai trò": căn trái để nút chọn thẳng hàng dù nhãn mức dài ngắn khác nhau */
.user-perm-table td.perm-cell:nth-child(2),
.user-perm-table th.perm-cell:nth-child(2) { text-align: left; padding-left: 20px; }
.user-perm-table .inherit { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.user-perm-table .inherit span { color: var(--dim); font-size: 12px; white-space: nowrap; }
.users-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.users-table td.actions { overflow: visible; }
.inline-select { width: 100%; padding: 4px 6px; font-size: 12.5px; }
.users-table .edit-row td { white-space: normal; }

.role-card { padding-bottom: 10px; }
.role-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.role-title { display: flex; flex-direction: column; gap: 6px; flex: 1 1 320px; min-width: 0; }
.role-title h2 { margin: 0; }
.role-title .hint { margin: 0; }
.role-name { font-weight: 600; max-width: 360px; }
.role-desc { max-width: 560px; font-size: 13px; }
.role-meta { display: flex; gap: 6px; align-items: center; }
.perm-table { table-layout: fixed; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.perm-table .c-module { width: 34%; }
.perm-table td, .perm-table th { padding: 8px 12px; }
.perm-cell { text-align: center; }
.perm-cell input { width: 16px; height: 16px; padding: 0; accent-color: var(--blue); cursor: pointer; }
.perm-cell input:disabled { cursor: default; }
.btn-mini.role-del { flex: none; max-width: none; padding: 4px 10px; }

/* ---------- tab trong module ---------- */

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  /* viền dưới vẽ bằng shadow trong: overflow cắt mất phần tab tràn xuống viền (margin âm) */
  box-shadow: inset 0 -1px 0 var(--line);
  overflow-x: auto; scrollbar-width: none;   /* màn hẹp: tab cuộn ngang, không đẩy trang rộng ra */
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 14px;
  color: var(--dim); text-decoration: none; font-weight: 600; font-size: 13.5px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); }
.tab b {
  margin-left: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px;
  background: #eef2f7; color: var(--dim);
}
.tab.on b { background: #e8efff; color: var(--blue); }
.tab-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.tab-toolbar .hint { margin: 0; }
.tab-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- tab tự động & thông báo ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.switch {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.switch input { width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--blue); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* 3 ô trên một hàng trong panel nửa màn hình; màn hẹp thì xếp dọc */
.urgent-row {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); align-items: end;
}
.urgent-row .switch { min-height: 38px; }
#st-next-note, #st-last-note { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .urgent-row { grid-template-columns: 1fr; }
}
#btn-run-now { min-width: 150px; }
.chat-list { margin-top: 10px; }
.notify-table { table-layout: fixed; }
.notify-table .c-time { width: 16%; }
.notify-table .c-dom { width: 18%; }
.notify-table .c-kind { width: 11%; }
.notify-table .c-msg { width: 55%; }
.notify-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- module Tools ---------- */

.err { color: var(--red); }
/* ---- tab Tác vụ: danh sách trái | form | lượt chạy (dính khi cuộn) ---- */
.task-layout { display: grid; grid-template-columns: 180px minmax(340px, 420px) minmax(0, 1fr); gap: 14px; align-items: start; }
/* form gọn: ô nhỏ, 2 cột trong cột hẹp; nhường chỗ cho khung log */
.task-main .task-fields { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 10px; }
.task-main .field { gap: 3px; }
.task-main input, .task-main select, .task-main textarea { padding: 5px 8px; font-size: 12.5px; }
.task-main .switch { padding: 4px 8px; }
.task-main .task-head h2 { font-size: 15px; }
.task-main .task-head .hint { font-size: 12px; }
.task-main .opt-list { max-height: 160px; }
/* khung lượt chạy ở tab Tác vụ: log cao gần hết màn hình, chữ lớn hơn */
/* log hiện tối đa 10 dòng (13px × 1.6 + padding 12px×2), dài hơn thì cuộn */
.task-side pre.run-log, .run-detail pre.run-log { font-size: 13px; line-height: 1.6; max-height: calc(10 * 1.6em + 24px); }
.task-nav { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.task-nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--dim); padding: 8px 8px 4px; }
.task-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
  border: 0; background: none; text-align: left; font: inherit; font-size: 13px; padding: 7px 8px;
  border-radius: 6px; cursor: pointer; color: var(--text); }
.task-item:hover { background: #f1f5f9; }
.task-item.on { background: var(--blue); color: #fff; }
.task-item.danger .task-item-name::after { content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--red); margin-left: 6px; vertical-align: middle; }
.task-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item-meta { display: flex; gap: 4px; flex: 0 0 auto; }
.pill { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: #e5e7eb; color: var(--dim);
  display: inline-flex; align-items: center; gap: 3px; }
.pill.run { background: #fef3c7; color: var(--amber); }
.task-item.on .pill { background: rgba(255, 255, 255, .22); color: #fff; }
.task-item .spinner { width: 9px; height: 9px; }
.task-main { min-width: 0; padding-bottom: 0; }
.task-head { margin-bottom: 12px; }
.task-head h2 { margin: 0 0 2px; }
.task-head .hint { margin: 0; }
.task-foot { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  margin: 14px -14px 0; padding: 10px 14px 12px; border-radius: 0 0 10px 10px; z-index: 2; }
.task-foot .run-mode { margin: 0 0 8px; }
.task-foot .panel-actions { margin-top: 8px; }
.field-label { display: inline-flex; align-items: center; gap: 4px; }
.help { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; font-style: normal;
  font-size: 10px; font-weight: 700; background: #e5e7eb; color: var(--dim); cursor: help; }
.task-fields .field > small { display: none; }
.task-fields .field:focus-within > small { display: block; }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: max-content;
  gap: 2px 10px; flex: 0 0 auto;
  max-height: 190px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; }
.opt-list label.opt { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text);
  padding: 2px 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-list label.opt { min-height: 24px; }
.opt-list label.opt input { width: 14px; height: 14px; padding: 0; margin: 0; flex: 0 0 auto; }
.opt-bar .btn-mini { flex: 0 0 auto; }
.opt-state { font-size: 11.5px; }
.opt-state.picked { color: var(--blue); font-weight: 600; }
details.adv { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
details.adv summary { cursor: pointer; font-size: 12.5px; font-weight: 600; }
details.adv summary .dim { font-weight: 400; }
details.adv[open] summary { margin-bottom: 10px; }
details.adv .form-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
@media (max-width: 1280px) {
  .task-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .task-side { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .task-layout { grid-template-columns: 1fr; }
  .task-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .task-nav-group { width: 100%; }
  .task-item { width: auto; }
}

.task-fields .field.wide { grid-column: 1 / -1; }
.task-fields .field small { font-size: 11.5px; }
.task-fields select[multiple] { padding: 4px; }
.field .req { color: var(--red); }
.every-input { display: flex; gap: 6px; }
.every-input input { flex: 1 1 auto; min-width: 0; }
.every-input select { flex: 0 0 76px; width: 76px; }
.opt-bar { display: flex; gap: 8px; align-items: center; }
.opt-bar .opt-filter { flex: 1 1 auto; width: auto; min-width: 0; padding: 5px 8px; }
.opt-bar span { font-size: 11.5px; white-space: nowrap; }
.run-mode { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
#schedule-fields { margin-bottom: 4px; }
#btn-run { min-width: 128px; }
.ro-note { display: none; }
.ro-tools .ro-note { display: block; }

.run-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.run-head h2 { margin: 0; }
.panel h2.recent-title { margin-top: 18px; }
.run-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12.5px; color: var(--dim); }
.run-meta b { color: var(--text); }
.run-progress { display: flex; align-items: center; gap: 10px; }
.run-progress .bulk-progress { flex: 1 1 auto; }
.run-progress .run-pct { width: 38px; text-align: right; font-size: 12px; }
.run-progress .btn-mini { flex: 0 0 62px; }
.bulk-progress > i.done { background: var(--green); }
.bulk-progress > i.bad { background: var(--red); }
pre.run-log { max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
pre.run-result {
  margin-top: 4px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #f8fafc; color: var(--text); border: 1px solid var(--line);
}
.run-error { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.acct-wrap { margin-top: 10px; }
.acct-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 4px; }
/* bảng account hiện tối đa 15 dòng (33px/dòng gồm viền + tiêu đề 2 dòng), nhiều hơn thì cuộn */
.acct-scroll { max-height: calc(15 * 33px + 44px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.acct-table tbody td { height: 32px; }
.acct-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12.5px; }
.acct-table th { position: sticky; top: 0; background: #f8fafc; text-align: left; font-weight: 600; color: var(--dim); }
.acct-table th, .acct-table td { padding: 5px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-table th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
.acct-table th:first-child, .acct-table td:first-child { width: 26%; }
.acct-table th:nth-child(2), .acct-table td:nth-child(2) { width: 118px; }
.acct-table tbody tr { cursor: pointer; }
.acct-table tbody tr:hover { background: #f5f8ff; }
.acct-table tbody tr.on { background: #e8efff; }
.run-result-wrap { margin-top: 8px; font-size: 12px; }
.run-detail { padding: 2px 0 6px; }
.recent-runs li { cursor: pointer; }
.recent-runs li:hover strong { color: var(--blue); }
.recent-runs small { display: inline; margin-left: 8px; }
.badge .spinner { width: 9px; height: 9px; border-width: 2px; vertical-align: -1px; }
.btn-mini.auto { flex: 0 0 auto; max-width: none; padding: 4px 8px; }

.tool-table { table-layout: fixed; }
.tool-table th, .tool-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-table td.actions { overflow: visible; }
.tool-table .edit-row td { white-space: normal; overflow: visible; }
.run-table { min-width: 1000px; }
.run-table .c-id { width: 6%; }
.run-table .c-task { width: 17%; }
.run-table .c-state { width: 11%; }
.run-table .c-pct { width: 7%; }
.run-table .c-time { width: 10%; }
.run-table .c-user { width: 9%; }
.run-table .c-result { width: 22%; }
.run-table .c-act { width: 8%; }
.schedule-table { min-width: 1000px; }
.schedule-table .c-id { width: 5%; }
.schedule-table .c-task { width: 19%; }
.schedule-table .c-every { width: 9%; }
.schedule-table .c-count { width: 8%; }
.schedule-table .c-next { width: 11%; }
.schedule-table .c-state { width: 10%; }
.schedule-table .c-last { width: 10%; }
.schedule-table .c-act { width: 28%; }

@media (max-width: 820px) {
  table.tool-table { min-width: 0; table-layout: auto; }
}


/* ---- dịch vụ gắn với proxy ---- */
/* flex đặt ở div bên trong, không đặt lên td (td rơi khỏi lưới cột) */
.svc-cell { display: flex; align-items: center; gap: 6px; }
/* chip xuống dòng thay vì cắt chữ: tên dịch vụ ngắn, đọc được là chính */
.svc-list { display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  flex: 1; min-width: 0; }
.svc-chip {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.svc-chip small { opacity: .6; font-size: 9px; vertical-align: middle; }
/* không co chip: hết chỗ thì xuống dòng, không bóp chữ thành "wa…" */
.svc-list .svc-chip { flex: 0 0 auto; max-width: 100%; }
.svc-chip.c-blue { background: #e0ecff; color: #1d4ed8; }
.svc-chip.c-green { background: #dcfce7; color: #15803d; }
.svc-chip.c-amber { background: #fef3c7; color: #b45309; }
.svc-chip.c-red { background: #fee2e2; color: #b91c1c; }
.svc-chip.c-purple { background: #ede9fe; color: #6d28d9; }
.svc-chip.c-gray { background: #e5e7eb; color: #4b5563; }
.svc-cell .btn-mini { flex: 0 0 auto; max-width: none; padding: 4px 9px;
  white-space: nowrap; }

.chip.svc-c-blue { border-color: #bfd4ff; }
.chip.svc-c-green { border-color: #bbf7d0; }
.chip.svc-c-amber { border-color: #fde68a; }
.chip.svc-c-red { border-color: #fecaca; }
.chip.svc-c-purple { border-color: #ddd6fe; }
.chip.svc-c-gray { border-color: #d1d5db; }

/* ---- popup (dialog) gán platform cho proxy ---- */
dialog.modal {
  padding: 0; border: 1px solid var(--line); border-radius: 10px;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog.modal::backdrop { background: rgba(17, 24, 39, .45); }
.modal-box { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-x { border: 0; background: none; font-size: 22px; line-height: 1; padding: 0 4px;
  color: var(--dim); }
.modal-body { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column;
  gap: 10px; }
.modal-body .hint { margin: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--line); }
.modal-foot #svc-modal-count { flex: 0 0 auto; font-size: 12.5px; }
.modal-msg { flex: 1; min-width: 0; font-size: 12.5px; color: var(--green);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-msg.error { color: var(--red); }

dialog.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }

/* ---- popup xác nhận chạy tác vụ (Tools) ---- */
dialog.run-confirm { width: min(520px, calc(100vw - 32px)); }
.rc-icon { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: #fef3c7; color: var(--amber); }
dialog.run-confirm.danger .rc-icon { background: #fee2e2; color: var(--red); }
.rc-callout { margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
dialog.run-confirm.danger .rc-callout { background: #fef2f2; border-color: #fecaca; color: #b91c1c; font-weight: 600; }
.rc-summary { margin: 0; display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px;
  font-size: 12.5px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #f8fafc; }
.rc-summary dt { color: var(--dim); }
.rc-summary dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
dialog.run-confirm .modal-foot .btn { min-width: 84px; }
#rc-note { color: var(--dim); }

/* ---- tab Lịch chạy: thẻ dọc nhóm theo tác vụ ---- */
#schedule-search { width: 260px; padding: 6px 10px; }
.sched-chips { margin: 0 0 14px; }
.sched-list { display: flex; flex-direction: column; gap: 18px; }
.sched-group h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: baseline; gap: 10px; }
.sched-group h3 .dim { font-size: 12px; font-weight: 400; }
.sched-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px;
  transition: opacity .3s; }
.sched-card.off { border-left-color: #cbd5e1; }
.sched-card.off .sched-title strong { color: var(--dim); }
.sched-card.gone { opacity: 0; pointer-events: none; }
.sched-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sched-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-title strong { font-size: 14px; }
.sched-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; font-size: 12.5px; color: var(--dim); }
.sched-meta b { color: var(--text); font-weight: 600; }
.sched-meta .badge { font-size: 11px; padding: 1px 7px; }
.sched-config { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 18px;
  font-size: 12.5px; padding: 8px 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.sched-config > div { display: flex; flex-direction: column; min-width: 0; }
.sched-config dt { color: var(--dim); font-size: 11.5px; }
.sched-config dd { margin: 0; overflow-wrap: anywhere; }
.sched-edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 10px;
  border: 1px dashed var(--line); border-radius: 8px; }
.sched-edit .field.wide { flex-basis: 100%; }
.sched-card > footer.act-group { justify-content: flex-end; }
.sched-empty { padding: 20px 0; text-align: center; }
.ae-text { margin: 0; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }

/* ---- tab mua proxy ---- */
.buy-grid { margin-top: 12px; }
.buy-auto { display: flex; align-items: center; gap: 8px; min-height: 38px; color: var(--text);
  font-size: 13px; }
.buy-quote { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.buy-price { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.buy-sum { font-size: 22px; }
.buy-low { color: var(--red); font-weight: 600; }
#btn-buy { min-width: 110px; }
.buy-summary { list-style: none; margin: 0; padding: 0; }
.buy-summary li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; }
.buy-summary li b { text-align: right; overflow-wrap: anywhere; }
.buy-total { margin: 4px 0 0; font-size: 15px; }
#buy-result textarea { margin-top: 10px; }

/* ---- nút gạt (auto-extend proxy) ---- */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px;
  vertical-align: middle; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0;
  padding: 0; border: 0; }
.toggle .slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px;
  cursor: pointer; transition: background .15s; }
.toggle .slider::before { content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(16px); }
.toggle input:focus-visible + .slider { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle input:disabled + .slider { cursor: default; opacity: .55; }
.toggle.busy .slider { cursor: progress; }
.proxy-table td.auto { overflow: visible; }
/* proxy ngoài pool (RESIDENTIAL_STATIC...): cùng bảng, nền nhạt để phân biệt */
.proxy-table tr.off-pool td { background: #fafbfc; }

.svc-paste { display: flex; gap: 8px; align-items: flex-start; }
.svc-paste textarea { flex: 1; min-height: 44px; }
#svc-modal-q { width: 100%; }
.svc-pick-list { display: flex; flex-direction: column; gap: 4px; }
.svc-pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px; }
.svc-pick.on { border-color: #bfd4ff; background: #f5f8ff; }
.svc-pick label { display: flex; align-items: center; gap: 8px; flex: 0 0 180px;
  min-width: 0; cursor: pointer; }
.svc-pick label input { padding: 0; margin: 0; }
.svc-pick label .svc-chip { max-width: 130px; }
.svc-pick .note-input { flex: 1; min-width: 0; }
@media (max-width: 520px) {
  .svc-pick { flex-wrap: wrap; }
  .svc-pick label { flex-basis: 100%; }
}
#svc-table .actions { white-space: nowrap; }
#svc-table select { padding: 3px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- tab Tự động: khung realtime ---------- */
.live-panel h3 { font-size: 13px; margin: 14px 0 6px; }
.live-lanes { display: flex; flex-direction: column; gap: 8px; }
.live-lane { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.live-lane.running { border-color: #c7d7fe; background: #f5f8ff; }
.live-lane .bulk-progress { margin: 8px 0 0; }
.live-grid { grid-template-columns: 2fr 3fr; }
@media (max-width: 1000px) { .live-grid { grid-template-columns: 1fr; } }
.live-grid > div { max-height: 420px; overflow-y: auto; }
.live-table { table-layout: fixed; }
.live-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-dot {
  display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px;
  border-radius: 50%; background: var(--green); animation: live-blink 1s ease-in-out infinite;
}
@keyframes live-blink { 50% { opacity: .25; } }

/* bảng khóa / giá trị (trang Cài đặt): giá trị dài (đường dẫn, danh sách bảng) xuống dòng trong ô */
.kv-table { table-layout: fixed; }
.kv-table td.mono { overflow-wrap: anywhere; }
/* lỗi báo giá (Mua proxy) có thể rất dài: badge mặc định nowrap -> cho xuống dòng trong khung */
.buy-price .badge { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; text-align: left; border-radius: 8px; padding: 6px 10px; }
/* tab Tự động: dòng đếm domain Pending Delete cạnh ô phút */
.urgent-row .pending-count { align-self: center; font-size: 12.5px; }
