/* Domain Gateway — giao diện lấy cảm hứng từ Cloudflare Dashboard (dark) */

:root {
  color-scheme: dark;

  --bg: #0f0f11;
  --sidebar: #141416;
  --panel: #1a1a1d;
  --panel-2: #202024;
  --panel-3: #26262b;
  --border: #2b2b31;
  --border-soft: #232327;
  --border-strong: #3a3a41;
  --row-hover: rgba(255, 255, 255, .022);

  --text: #dcdcdf;
  --text-strong: #ffffff;
  --text-dim: #9a9aa2;
  --text-mute: #86868f;

  --accent: #f6821f;
  --accent-ink: #f6821f;
  --accent-dim: rgba(246, 130, 31, .14);
  --accent-line: rgba(246, 130, 31, .42);

  --green: #4ec97e;
  --green-ink: #4ec97e;      /* du dam tren nen green-dim toi: 6.51:1 */
  --green-dim: rgba(78, 201, 126, .13);
  --green-line: rgba(78, 201, 126, .35);

  --amber: #e9a13b;
  --amber-ink: #f0c07a;
  --amber-dim: rgba(233, 161, 59, .14);
  --amber-line: rgba(233, 161, 59, .3);

  --red: #f0616d;
  --red-ink: #f5a3a9;
  --red-dim: rgba(240, 97, 109, .14);
  --red-line: rgba(240, 97, 109, .34);

  --blue: #4b8df8;
  --blue-ink: #8fb8fb;
  --blue-dim: rgba(75, 141, 248, .14);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Giao diện sáng. app.js luôn ghi data-theme là một giá trị cụ thể (dark|light),
   kể cả khi người dùng chọn "theo hệ thống" — nhờ vậy CSS không phải khai báo
   trùng bảng màu cho @media prefers-color-scheme. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f3f3f5;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f2f5;
  --panel-3: #e5e5ea;
  --border: #d9d9e0;
  --border-soft: #e9e9ee;
  --border-strong: #b9b9c4;
  --row-hover: rgba(20, 20, 35, .028);

  --text: #1c1c21;
  --text-strong: #000000;
  --text-dim: #54545e;
  --text-mute: #67677a;

  --accent: #f6821f;
  --accent-ink: #a9540a;
  --accent-dim: rgba(246, 130, 31, .15);
  --accent-line: rgba(199, 105, 20, .5);

  --green: #10804a;
  --green-ink: #0d6b3e;      /* --green tren green-dim sang chi duoc 4.30:1 */
  --green-dim: rgba(16, 128, 74, .11);
  --green-line: rgba(16, 128, 74, .35);

  --amber: #a86505;
  --amber-ink: #7d4a02;
  --amber-dim: rgba(168, 101, 5, .12);
  --amber-line: rgba(168, 101, 5, .32);

  --red: #c1262f;
  --red-ink: #96131c;
  --red-dim: rgba(193, 38, 47, .1);
  --red-line: rgba(193, 38, 47, .32);

  --blue: #1d4ed8;
  --blue-ink: #1a3fa8;
  --blue-dim: rgba(29, 78, 216, .1);

  --shadow: 0 12px 30px rgba(20, 20, 40, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; }
button { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-dim); }

/* SVG icon: dùng stroke, không fill */
.ico { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w, 292px) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .16s ease;
}
body.sidebar-collapsed { --sidebar-w: 66px; }

/* ============================== SIDEBAR ============================== */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sb-top { padding: 14px 14px 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.brand-mark {
  width: 26px; height: 26px; flex: 0 0 auto;
  fill: none; stroke: var(--accent); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.brand-mark .bm-globe { opacity: .42; }
.brand-mark .bm-arc { stroke-width: 2.6; }
.account {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: none; border: 0; color: var(--text); cursor: pointer;
  padding: 5px 7px; border-radius: 6px; min-width: 0;
}
.account:hover { background: var(--panel-2); }
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 14px; height: 14px; fill: none; stroke: var(--text-dim); stroke-width: 1.6; stroke-linecap: round; }

.quick-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 9px; color: var(--text-mute);
}
.quick-search:focus-within { border-color: var(--accent); }
.quick-search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--text); font-size: 13px;
}
.quick-search input::placeholder { color: var(--text-mute); }
kbd {
  font-family: var(--font); font-size: 10.5px; color: var(--text-mute);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; white-space: nowrap;
}

.sb-nav { padding: 10px 10px 20px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: var(--text-dim); text-decoration: none; font-size: 13.5px;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-3); color: var(--text-strong); font-weight: 500; }
.nav-group { margin-top: 14px; }
.nav-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; color: var(--text); font-size: 13.5px; font-weight: 500;
}
.nav-badge {
  margin-left: auto; background: var(--amber-dim); color: var(--amber);
  border-radius: 20px; padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px;
}
.nav-badge[data-zero="1"] { background: var(--panel-2); color: var(--text-mute); }

.sb-foot { border-top: 1px solid var(--border-soft); padding: 12px 18px; font-size: 12px; color: var(--text-mute); }
.sb-foot-row { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.dot[data-state="stale"] { background: var(--amber); }
.dot[data-state="busy"] { background: var(--blue); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* =============================== MAIN =============================== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--border-soft);
}
.topbar-title { display: flex; align-items: center; gap: 10px; color: var(--text-dim); }
.topbar-title h1 { font-size: 19px; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 6px; padding: 7px 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 13px; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--panel-2); border-color: var(--border-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1000; font-weight: 600; }
.btn.primary:hover { background: #ff9433; border-color: #ff9433; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red-line); background: transparent; }
.btn.danger:hover { background: var(--red-dim); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.spinning { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

.progress-bar { height: 2px; background: var(--panel-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.view { padding: 22px 28px 8px; flex: 1; min-width: 0; }

/* ---------------------------- stat cards ---------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 13px 15px;
}
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); }
.stat-value { font-size: 25px; font-weight: 650; margin-top: 3px; line-height: 1.15; letter-spacing: -.02em; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat.is-warn .stat-value { color: var(--amber); }
.stat.is-danger .stat-value { color: var(--red); }
.stat.is-ok .stat-value { color: var(--green); }

/* ----------------------------- search ------------------------------- */
.search-hero {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 15px; margin-bottom: 16px;
  color: var(--text-mute);
}
.search-hero:focus-within { border-color: var(--accent); }
.search-hero input {
  flex: 1; min-width: 220px; background: none; border: 0; outline: none;
  color: var(--text); font-size: 14px; padding: 3px 0;
}
.search-hero input::placeholder { color: var(--text-mute); }
.search-hero input::-webkit-search-cancel-button { filter: invert(.6); }

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 20px; padding: 3px 11px; font-size: 12.5px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-ink); }

/* ------------------------------ table ------------------------------- */
.table-wrap {
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  overflow-x: auto; background: var(--panel);
}
table.grid { width: 100%; border-collapse: collapse; min-width: 940px; }
table.grid th {
  text-align: left; font-size: 12.5px; font-weight: 500; color: var(--text-dim);
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--panel); position: sticky; top: 0; z-index: 1;
}
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--text); }
.sort-ico { display: inline-block; width: 9px; margin-left: 3px; color: var(--accent); }
table.grid td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--row-hover); }
.col-menu { width: 44px; }

.cell-domain { display: flex; align-items: center; gap: 8px; min-width: 0; }
.domain-link {
  color: var(--text); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border-strong); cursor: pointer; background: none; border: 0; padding: 0;
  font-size: 13.5px; font-family: inherit; text-align: left;
}
.domain-link:hover { color: var(--text-strong); text-decoration-color: var(--accent); }
.lock-ico { color: var(--text-mute); width: 12px; height: 12px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.status .ico { width: 14px; height: 14px; }
.status[data-s="active"] { color: var(--green); }
.status[data-s="expiring"] { color: var(--amber); }
.status[data-s="critical"] { color: var(--red); }
.status[data-s="expired"] { color: var(--red); font-weight: 600; }
.status[data-s="unknown"] { color: var(--text-mute); }

.runway { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.runway-track { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; min-width: 60px; }
.runway-fill { height: 100%; border-radius: 3px; background: var(--green); }
.runway-fill[data-s="expiring"] { background: var(--amber); }
.runway-fill[data-s="critical"], .runway-fill[data-s="expired"] { background: var(--red); }
.runway-num { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 52px; text-align: right; white-space: nowrap; }

.pill {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.pill.is-empty { border-style: dashed; color: var(--text-mute); cursor: pointer; }
.pill.is-empty:hover { color: var(--text); border-color: var(--accent); }
.tag {
  display: inline-block; background: var(--blue-dim); color: var(--blue-ink);
  border-radius: 4px; padding: 1px 7px; font-size: 11.5px; margin-right: 4px; white-space: nowrap;
}
.ns-cell { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.ns-cell .more { color: var(--text-mute); }
.dash { color: var(--text-mute); }

.row-menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 30px; z-index: 40; min-width: 190px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px;
}
.menu-pop button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text); padding: 7px 10px;
  border-radius: 5px; cursor: pointer; font-size: 13px;
}
.menu-pop button:hover { background: var(--panel-3); }
.menu-pop button.danger { color: var(--red); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 4px 0; font-size: 12.5px; color: var(--text-dim);
}
.empty-state { padding: 46px 20px; text-align: center; color: var(--text-dim); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* --------------------------- group headers -------------------------- */
tr.group-row td {
  background: var(--panel-2); font-size: 12px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-dim); padding: 8px 16px;
}
tr.group-row .count { color: var(--text-dim); text-transform: none; letter-spacing: 0; }

/* ------------------------------ panels ------------------------------ */
.panel {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 20px 22px; max-width: 900px;
}
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.lookup-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.lookup-row input {
  flex: 1; min-width: 240px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px; color: var(--text); outline: none; font-size: 14px;
}
.lookup-row input:focus { border-color: var(--accent); }
.lookup-result { margin-top: 18px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.mono { font-family: var(--mono); font-size: 12px; }

/* --------------------------- registry view -------------------------- */
/* minmax(0,1fr): cột ngầm mặc định là max-content, một dòng nowrap bên trong
   (đoạn hé của phần điều kiện) sẽ kéo cả thẻ rộng ra ngoài màn hình. */
.registry-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.reg-card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 18px 20px; min-width: 0; }
.reg-card > h2 { font-size: 16px; display: flex; align-items: center; gap: 9px; }
.reg-flag {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--accent-ink); background: var(--accent-dim);
  border: 1px solid var(--accent-line); border-radius: 4px; padding: 2px 7px;
}
.reg-meta { margin: 10px 0 14px; font-size: 13px; color: var(--text-dim); }
.reg-meta strong { color: var(--text); font-weight: 600; }
/* Đoạn điều kiện/lưu ý: gập lại còn một dòng, bấm để mở */
.reg-fold {
  background: var(--amber-dim); border: 1px solid var(--amber-line);
  border-radius: var(--radius); font-size: 12.5px; color: var(--amber-ink); margin-bottom: 8px;
}
.reg-fold > summary {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  cursor: pointer; user-select: none; list-style: none;
}
.reg-fold > summary::-webkit-details-marker { display: none; }
.reg-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.reg-fold > summary strong { font-weight: 600; flex: 0 0 auto; }
.reg-fold .chev { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
.reg-fold[open] > summary .chev { transform: rotate(90deg); }
/* Chỉ hé một dòng khi đóng — đủ để biết bên trong nói gì mà không chiếm chỗ */
/* .88 chứ không mờ hơn: dưới mức này chữ hé rớt xuống 3.7:1 ở nền sáng, trượt AA */
.fold-peek { flex: 1 1 auto; min-width: 0; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-fold[open] .fold-peek { display: none; }
.fold-body { margin: 0; padding: 0 12px 11px 34px; line-height: 1.55; }
.reg-tlds { display: flex; flex-wrap: wrap; gap: 5px; margin: 14px 0; }
.reg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 10px; }
.reg-item { border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 11px 13px; background: var(--panel-2); }
.reg-item a { color: var(--blue); text-decoration: none; font-weight: 500; }
.reg-item a:hover { text-decoration: underline; }
.reg-item p { margin: 5px 0 0; font-size: 12px; color: var(--text-dim); }
/* --text-dim chứ không phải --text-mute: trên nền .reg-item (panel-2) mute chỉ
   được 4.50:1, sát mép AA tới mức làm tròn xuống là trượt. */
.reg-item .api-tag { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--text-dim); font-family: var(--mono); word-break: break-all; }

/* ------------------------------ drawer ------------------------------ */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 94vw); z-index: 51;
  background: var(--sidebar); border-left: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .4 } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border-soft);
}
.drawer-head h2 { font-size: 17px; word-break: break-all; }
.drawer-sub { font-size: 12.5px; color: var(--text-dim); }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); margin-bottom: 9px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hist-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--border-soft); }
.hist-row .mono { font-family: var(--mono); color: var(--text-dim); }
.err-box {
  background: var(--red-dim); border: 1px solid var(--red-line);
  border-radius: var(--radius); padding: 9px 12px; font-size: 12.5px; color: var(--red-ink); word-break: break-word;
}

/* ------------------------------- modal ------------------------------ */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: min(560px, 100%); background: var(--sidebar); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); max-height: 92vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { font-size: 16px; }
/* minmax(0,1fr) — y hệt lý do ở .registry-grid: cột ngầm mặc định là max-content,
   nên đoạn hé nowrap của khối "Tuỳ chọn" kéo cả thân hộp thoại rộng 426px trong
   khung 390px. Không sinh thanh cuộn trang vì .modal-body tự cuộn ngang, chỉ lộ
   ra khi nhìn ảnh: chữ cụt mất một đoạn bên phải. */
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border-soft); }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--text-dim); }
.field > span em { font-style: normal; color: var(--text-mute); font-size: 11.5px; }
.field input, .field textarea, .field select {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 11px; color: var(--text); outline: none; font-family: inherit; font-size: 13.5px; width: 100%;
}
.field textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* Dòng nói rõ registry tự điền những gì — xanh lá vì đây là tin tốt, không phải
   cảnh báo. Đặt ngay dưới ô tên miền để đọc được trước khi đi tìm ô khác. */
.auto-note {
  display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 10px;
  background: var(--green-dim); border: 1px solid var(--green-line);
  border-radius: var(--radius); padding: 9px 12px;
  font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.auto-note .ico { width: 14px; height: 14px; margin-top: 2px; color: var(--green); }

/* Dùng lại đúng kiểu gập của trang danh bạ, chỉ đổi màu sang trung tính: trong
   hộp thoại thì đây là tuỳ chọn bình thường, không phải cảnh báo màu hổ phách. */
.modal-fold {
  background: var(--panel-2); border-color: var(--border); color: var(--text-dim);
  margin-bottom: 0;
}
.modal-fold > summary strong { color: var(--text); }
/* Chữ chú thích trong ngoặc nằm trên nền panel-2 sáng hơn nền của modal, để
   --text-mute là rơi đúng 4.5:1 — sát mép AA tới mức làm tròn xuống là trượt. */
.modal-fold .field > span em { color: var(--text-dim); }
/* Icon do JS chèn vào một span bọc; không cho span co lại thì mũi tên bị bóp */
.modal-fold > summary > span:first-child { display: inline-flex; flex: 0 0 auto; }
.modal-fold .fold-body { padding: 2px 12px 12px 12px; display: grid; gap: 13px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ------------------------------ toasts ------------------------------ */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 9px; max-width: 380px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 11px 15px; font-size: 13px;
  box-shadow: var(--shadow); animation: slideIn .16s ease;
}
.toast[data-kind="ok"] { border-left-color: var(--green); }
.toast[data-kind="err"] { border-left-color: var(--red); }

.page-foot {
  padding: 22px 28px 26px; font-size: 12px; color: var(--text-mute);
  display: flex; gap: 9px; flex-wrap: wrap; border-top: 1px solid var(--border-soft); margin-top: 24px;
}
.page-foot .sep { color: var(--border-strong); }

/* Nút hamburger + lớp phủ, chỉ dùng ở khổ hẹp (xem phần responsive cuối file) */
.nav-toggle { display: none; margin-right: 2px; }
.nav-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 55; }

/* ======================= SIDEBAR THU GỌN ======================= */
.nav-item { position: relative; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-left: auto; flex: 0 0 auto; }

.collapse-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: 0 0 auto; padding: 0;
  background: none; border: 0; border-radius: 6px;
  color: var(--text-mute); cursor: pointer;
}
.collapse-btn:hover { background: var(--panel-2); color: var(--text); }
/* Chi mui ten lat huong, khung van dung yen -> nguoi dung doc duoc chieu thao tac */
.collapse-btn .cb-arrow { transition: transform .16s ease; transform-origin: 9.8px 8px; }
.collapse-btn .cb-spine { opacity: .75; }

body.sidebar-collapsed .sb-top { padding: 14px 8px 6px; }
body.sidebar-collapsed .brand { flex-direction: column; gap: 8px; justify-content: center; padding: 4px 0 12px; }
body.sidebar-collapsed .account { display: none; }
body.sidebar-collapsed .quick-search { justify-content: center; padding: 8px 0; cursor: pointer; }
body.sidebar-collapsed .quick-search input,
body.sidebar-collapsed .quick-search kbd,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group-head span { display: none; }

/* Tiêu đề nhóm co lại thành một đường kẻ phân cách */
body.sidebar-collapsed .nav-group-head {
  height: 1px; padding: 0; margin: 12px 14px; background: var(--border);
}
body.sidebar-collapsed .nav-group:first-child .nav-group-head { margin-top: 4px; }

body.sidebar-collapsed .sb-nav { padding: 10px 8px 20px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }

/* Số đếm biến thành chấm nhỏ trên icon */
body.sidebar-collapsed .nav-badge {
  position: absolute; top: 5px; right: 13px;
  width: 7px; height: 7px; min-width: 0; padding: 0;
  border-radius: 50%; font-size: 0; line-height: 0; background: var(--amber);
}
body.sidebar-collapsed .nav-badge[data-zero="1"] { display: none; }
body.sidebar-collapsed .nav-dot { position: absolute; top: 5px; right: 13px; margin: 0; }

body.sidebar-collapsed .sb-foot { padding: 12px 8px; }
body.sidebar-collapsed .sb-foot-row { justify-content: center; }
body.sidebar-collapsed .collapse-btn .cb-arrow { transform: rotate(180deg); }

/* ========================= TRANG CÀI ĐẶT ========================= */
.settings-grid { display: grid; gap: 18px; max-width: 860px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.panel > .muted { margin: 0 0 16px; }

.conn-badge {
  font-size: 12px; padding: 3px 10px; border-radius: 20px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim);
}
.conn-badge[data-state="on"] { background: var(--green-dim); border-color: var(--green-line); color: var(--green); }
.conn-badge[data-state="err"] { background: var(--red-dim); border-color: var(--red-line); color: var(--red); }

.steps { margin: 0 0 18px; padding-left: 20px; color: var(--text-dim); font-size: 13px; }
.steps li { margin-bottom: 6px; }
.steps a { color: var(--blue); }
.steps code, .hint code, .panel p code {
  font-family: var(--mono); font-size: 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.hint { font-size: 12px; color: var(--text-mute); margin: 8px 0 16px; min-height: 16px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }

.pending-list { display: grid; gap: 7px; margin-bottom: 16px; }
.pending-row {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  padding: 9px 13px; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--panel-2); font-size: 13px;
}
.pending-row .pd-domain { font-family: var(--mono); font-size: 12.5px; }
.pending-row .pd-days { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.pending-row[data-b="critical"] { border-left: 3px solid var(--red); }
.pending-row[data-b="expired"] { border-left: 3px solid var(--red); }
.pending-row[data-b="expiring"] { border-left: 3px solid var(--amber); }
.pd-flag { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--panel-3); color: var(--text-dim); }
.pd-flag[data-sent="1"] { background: var(--green-dim); color: var(--green); }

.code-block {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; overflow-x: auto; margin: 0 0 16px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-all;
}


/* ============================================================== */
/*                          RESPONSIVE                            */
/*  ≤1120px  thu hẹp khoảng đệm                                   */
/*  ≤900px   sidebar thành ngăn kéo trượt, có hamburger           */
/*  ≤760px   bảng chuyển thành thẻ                                */
/*  ≤560px   nút chỉ còn icon, khoảng đệm tối thiểu               */
/* ============================================================== */

@media (max-width: 1120px) {
  .view, .topbar, .page-foot { padding-left: 20px; padding-right: 20px; }
  .layout { grid-template-columns: var(--sidebar-w, 248px) 1fr; }
}

@media (max-width: 900px) {
  /* Sidebar rời khỏi luồng, trượt vào từ trái khi bấm hamburger */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 56;
    width: 272px; height: 100dvh;
    transform: translateX(-100%);
    transition: transform .2s ease;
    border-right: 1px solid var(--border);
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  /* Ở khổ này luôn hiện đầy đủ nhãn, bỏ qua chế độ thu gọn của desktop */
  body.sidebar-collapsed { --sidebar-w: 272px; }
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .account,
  body.sidebar-collapsed .quick-search input,
  body.sidebar-collapsed .nav-group-head span { display: revert; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 7px 10px; }
  body.sidebar-collapsed .nav-group-head { height: auto; padding: 7px 10px; margin: 0; background: none; }
  body.sidebar-collapsed .nav-badge { position: static; width: auto; height: auto; font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: 20px; }
  body.sidebar-collapsed .brand { flex-direction: row; gap: 10px; justify-content: flex-start; padding: 4px 6px 14px; }
  body.sidebar-collapsed .quick-search { justify-content: flex-start; padding: 7px 9px; }
  .collapse-btn { display: none; }

  .nav-toggle { display: inline-flex; }
  .topbar { padding-top: 14px; padding-bottom: 14px; }
  .topbar-title .globe { display: none; }

  .view { padding-top: 18px; }
  .panel { padding: 18px 16px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .drawer { width: min(460px, 100vw); }
}

@media (max-width: 760px) {
  /* Bảng ngang không dùng được trên điện thoại -> mỗi dòng thành một thẻ */
  .table-wrap { border: 0; background: none; overflow-x: visible; }
  table.grid { min-width: 0; display: block; }
  table.grid thead { display: none; }
  table.grid tbody { display: block; }

  table.grid tr {
    display: block; position: relative;
    background: var(--panel); border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg); padding: 13px 15px; margin-bottom: 10px;
  }
  table.grid tbody tr:hover { background: var(--panel); }
  table.grid td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    width: auto; padding: 4px 0; border: 0; text-align: right;
  }
  table.grid td::before {
    content: attr(data-label);
    color: var(--text-mute); font-size: 12px; white-space: nowrap; text-align: left;
  }
  table.grid td.td-domain {
    display: block; padding: 0 40px 8px 0; margin-bottom: 6px;
    border-bottom: 1px solid var(--border-soft);
  }
  table.grid td.td-domain::before { content: none; }
  table.grid td.td-domain .domain-link { font-size: 15px; overflow-wrap: anywhere; }
  table.grid td.col-menu { position: absolute; top: 10px; right: 10px; width: auto; padding: 0; }
  table.grid td.col-menu::before { content: none; }
  .runway { min-width: 0; width: 100%; max-width: 220px; }
  .ns-cell { white-space: normal; word-break: break-all; }

  /* Giá trị bên phải phải co được, nếu không tên registrar dài sẽ đẩy tràn trang */
  table.grid td > :last-child { min-width: 0; }
  table.grid td .pill { white-space: normal; text-align: right; overflow-wrap: anywhere; }
  .cell-domain { min-width: 0; }

  tr.group-row { padding: 0; margin: 16px 0 8px; background: none; border: 0; }
  tr.group-row td { display: block; text-align: left; background: none; padding: 0 2px; }
  tr.group-row td::before { content: none; }

  .stat-row { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
  .search-hero input { min-width: 140px; }
  .table-foot { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (max-width: 560px) {
  .view, .topbar, .page-foot { padding-left: 14px; padding-right: 14px; }

  /* Chỉ giữ icon cho nút phụ, nút chính vẫn có chữ */
  .topbar-actions { gap: 6px; }
  .btn.ghost .btn-label { display: none; }
  .btn.ghost { padding: 7px 10px; }

  /* Tiêu đề co lại và cắt bằng dấu ba chấm thay vì xuống dòng làm cao topbar */
  .topbar { gap: 8px; }
  .topbar-title { flex: 1 1 auto; min-width: 0; gap: 6px; }
  .topbar-title h1 {
    font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
}

/* Hẹp hơn nữa (điện thoại dựng, 390px): giữ chữ cho nút chính thì tiêu đề trang
   bị cắt còn "Tên ...", tức là đánh đổi nhầm chỗ — nút cam có dấu + và màu nhấn
   đã tự nói nó là hành động chính, còn tiêu đề là thứ duy nhất cho biết đang ở
   màn nào. Bỏ chữ ở nút, trả chỗ cho tiêu đề. */
@media (max-width: 430px) {
  .btn.primary .btn-label { display: none; }
  .btn.primary { padding: 7px 11px; }
  .topbar-actions { flex: 0 0 auto; }
  .stat-value { font-size: 21px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 10px; font-size: 12px; }
  .kv dt:first-child { margin-top: 0; }

  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal { max-height: 94dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .drawer { width: 100vw; }
  .drawer-actions .btn { flex: 1 1 auto; justify-content: center; }
  .filter-chips { width: 100%; }
  .reg-list { grid-template-columns: 1fr; }
  .toast-stack { left: 14px; right: 14px; max-width: none; }
}

/* Máy có màn hình cảm ứng: vùng chạm tối thiểu 40px */
@media (hover: none) and (pointer: coarse) {
  /* flex: none là bắt buộc — .icon-btn nằm trong flex ngang, đặt width: 40px
     không thôi thì flex-shrink vẫn bóp còn 30px. Đo mới thấy, nhìn không ra. */
  .icon-btn { width: 40px; height: 40px; flex: none; }
  .nav-item { padding-top: 10px; padding-bottom: 10px; }
  .menu-pop button { padding: 10px; }

  /* Nút, chip, ô nhập cũng phải đủ tầm ngón tay, không riêng gì icon */
  .btn, .chip, .vt-btn, select { min-height: 40px; min-width: 40px; }
  .search-hero input { min-height: 40px; }
  /* Nhãn của checkbox mới là vùng chạm thật (bấm vào chữ cũng tick), nhưng cả
     dòng chỉ cao 21px. Nới nhãn chứ không phóng to ô vuông cho khỏi xấu. */
  .check { min-height: 40px; }
  .chip { padding-top: 0; padding-bottom: 0; }

  /* Tên miền là thao tác chính trên thẻ mà chỉ cao 20px. Cho display flex để
     min-height ăn — nút <button> mặc định inline-block vẫn nhận min-height,
     nhưng có flex thì chữ nằm giữa thay vì dính mép trên. */
  .domain-link { display: inline-flex; align-items: center; min-height: 40px; }
}

/* ========================= CHUYỂN KIỂU HIỂN THỊ ========================= */
.view-toggle {
  display: inline-flex; margin-left: auto; flex: 0 0 auto;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 2px; gap: 2px;
}
.vt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 26px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-mute); cursor: pointer;
}
.vt-btn:hover { color: var(--text); }
.vt-btn.active { background: var(--panel-3); color: var(--accent-ink); }

/* ============================ DẠNG LƯỚI ============================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 12px; }

/* .runway-track dùng chung với hàng trong bảng, ở đó nó nằm trong flex NGANG nên
   flex:1 kéo dài chiều rộng. Thẻ lưới là flex CỘT: flex:1 biến flex-basis thành
   chiều cao, thanh tụt về 0 ở thẻ có tên nhà cung cấp xuống hai dòng và phình
   lên 18px ở thẻ còn dư chỗ. Phải khoá lại đúng 5px. */
.dcard .runway-track { flex: none; }

.dcard {
  position: relative; display: flex; flex-direction: column; gap: 11px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 15px 16px;
  transition: border-color .12s;
}
.dcard:hover { border-color: var(--border); }
.dcard[data-s="critical"], .dcard[data-s="expired"] { border-left: 3px solid var(--red); }
.dcard[data-s="expiring"] { border-left: 3px solid var(--amber); }

.dcard-head { display: flex; align-items: flex-start; gap: 8px; padding-right: 26px; }
.dcard-head .domain-link { font-size: 14.5px; overflow-wrap: anywhere; }
.dcard-head .lock-ico { margin-top: 4px; }
.dcard .row-menu { position: absolute; top: 11px; right: 10px; }

.dcard-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dcard-days { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-dim); white-space: nowrap; }

.dcard-meta { display: grid; gap: 6px; margin: 0; font-size: 12.5px; }
.dcard-meta > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dcard-meta dt { color: var(--text-mute); white-space: nowrap; }
.dcard-meta dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.dcard-meta dd.mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.dcard-meta .pill { white-space: normal; text-align: right; }

.dcard-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.grid-group {
  grid-column: 1 / -1; margin: 8px 2px 0;
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim);
}
.grid-group:first-child { margin-top: 0; }
.grid-group .count { color: var(--text-dim); text-transform: none; letter-spacing: 0; }

@media (max-width: 760px) {
  .view-toggle { margin-left: 0; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ===================== ICON MANG THÔNG TIN ===================== */
/* Icon tiêu đề đổi theo trang, để biết đang ở đâu mà không cần đọc chữ */
.page-icon { display: inline-flex; align-items: center; color: var(--text-dim); flex: 0 0 auto; }
.page-icon .ico { width: 17px; height: 17px; }

/* Icon thẻ thống kê ăn màu theo mức độ khẩn, không phải trang trí */
.stat-head { display: flex; align-items: center; gap: 7px; }
.stat-head .ico { width: 14px; height: 14px; color: var(--text-mute); }
.stat.is-warn .stat-head .ico { color: var(--amber); }
.stat.is-danger .stat-head .ico { color: var(--red); }
.stat.is-ok .stat-head .ico { color: var(--green); }

.empty-state .ico {
  width: 34px; height: 34px; color: var(--text-mute);
  stroke-width: 1.1; margin-bottom: 12px;
}

/* ============================ PHÂN TRANG ============================ */
.table-foot { align-items: center; }
.tf-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }

.pager { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.page-size { display: flex; align-items: center; gap: 7px; color: var(--text-mute); font-size: 12.5px; }
.page-size select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: 12.5px; padding: 4px 7px; cursor: pointer;
}
.page-size select:focus { outline: none; border-color: var(--accent); }

.pager-nav { display: flex; align-items: center; gap: 3px; }
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 7px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-dim); font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.pg-btn:hover:not(:disabled):not(.active) { background: var(--panel-2); color: var(--text); }
.pg-btn.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-ink); font-weight: 600; }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }
.pg-gap { padding: 0 2px; color: var(--text-mute); user-select: none; }

@media (max-width: 760px) {
  .table-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .pager { justify-content: space-between; }
}
@media (max-width: 460px) {
  .page-size span { display: none; }
  .pager-nav { flex-wrap: wrap; justify-content: flex-end; }
}

/* ============================ THANH CUỘN ============================ */
/* Kỹ thuật: ray rộng ~10px để vùng bấm vẫn dễ trúng, nhưng con trượt đeo viền
   trong suốt + background-clip: padding-box nên nhìn chỉ còn 4px. Vừa mảnh vừa
   không khó kéo.

   Dùng background-color chứ không dùng shorthand background: shorthand sẽ reset
   background-clip về border-box và làm mất luôn phần viền trong suốt.

   Chrome 121+ bỏ qua ::-webkit-scrollbar nếu phần tử có scrollbar-width khác
   auto, nên phần chuẩn hoá cho Firefox được bọc trong @supports mà chỉ Firefox
   lọt vào — tránh hai cơ chế đá nhau. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--panel-3);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox: không hiểu selector ::-webkit-scrollbar nên chỉ nó lọt vào đây */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
}

/* Thanh cuộn ngang của bảng chỉ hiện khi trỏ vào — lúc khác nó chỉ là nhiễu */
.table-wrap::-webkit-scrollbar-thumb { background-color: transparent; transition: background-color .15s; }
.table-wrap:hover::-webkit-scrollbar-thumb,
.table-wrap:focus-within::-webkit-scrollbar-thumb { background-color: var(--panel-3); }

/* Vùng cuộn phụ: hẹp hơn và không kéo theo trang nền khi cuộn hết */
.sidebar, .drawer-body, .modal-body, .code-block, .menu-pop { overscroll-behavior: contain; }
.sidebar::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.code-block::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.code-block::-webkit-scrollbar-thumb { border-width: 2px; }

/* Tiện ích: ẩn hẳn thanh cuộn nhưng vẫn vuốt/cuộn được */
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { width: 0; height: 0; }

/* Màn hình cảm ứng đã có thanh cuộn nổi của hệ điều hành, không vẽ thêm.
   Phải liệt kê lại các selector cụ thể ở trên, vì chúng có độ ưu tiên cao hơn
   và sẽ thắng quy tắc chung dù quy tắc chung nằm sau. */
@media (hover: none) and (pointer: coarse) {
  ::-webkit-scrollbar,
  .sidebar::-webkit-scrollbar,
  .drawer-body::-webkit-scrollbar,
  .modal-body::-webkit-scrollbar,
  .code-block::-webkit-scrollbar,
  .table-wrap::-webkit-scrollbar { width: 0; height: 0; }
  * { scrollbar-width: none; }
}

/* ========================= ĐỔI GIAO DIỆN ========================= */
.theme-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-top: 8px; padding: 7px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text-mute); cursor: pointer; font-size: 12.5px;
}
.theme-btn:hover { background: var(--panel-2); color: var(--text); }
.theme-ico { display: inline-flex; flex: 0 0 auto; }
body.sidebar-collapsed .theme-btn { justify-content: center; padding: 7px 0; }

/* Bộ chọn 3 trạng thái trong trang Cài đặt */
.seg {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
  flex-wrap: wrap;
}
.seg-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 13px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--panel); border-color: var(--border);
  color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.seg-btn.active .ico { color: var(--accent-ink); }

@media (max-width: 460px) {
  .seg { width: 100%; }
  .seg-btn { flex: 1 1 auto; justify-content: center; padding: 8px 6px; }
  .seg-btn span { display: none; }
}

/* Số đếm kết quả trong ô tìm kiếm danh bạ */
.hero-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; margin-left: auto; }
.reg-count { font-size: 12.5px; white-space: nowrap; }
.fold-all { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; white-space: nowrap; }
.fold-all .ico { width: 14px; height: 14px; color: var(--text-mute); }
.fold-all:hover .ico { color: var(--text); }
/* Màn hẹp: cả cụm xuống dòng và trải hết chiều ngang, số đếm bên trái nút bên phải */
@media (max-width: 560px) { .hero-right { width: 100%; margin-left: 0; justify-content: space-between; } }
.reg-note { font-size: 12.5px; margin: 0 0 12px; }

/* Số kết quả trên chip lọc khu vực */
.chip-count {
  display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 5px;
  /* --text-mute được chỉnh cho nền panel, đặt lên panel-3 sáng hơn thì rớt còn
     4.17:1 ở nền tối. Dùng --text-dim: 5.39 (tối) / 5.96 (sáng). */
  border-radius: 20px; background: var(--panel-3); color: var(--text-dim);
  font-size: 11px; font-variant-numeric: tabular-nums; line-height: 16px; text-align: center;
}
/* Chip đang chọn đã có nền accent-dim rồi; đắp thêm một lớp accent-dim nữa cho
   riêng con số là tô hai lần, nền sáng lên và tương phản rớt còn 4.09:1. Để
   trong suốt, chữ thừa hưởng luôn màu của chip. */
.chip.active .chip-count { background: transparent; color: inherit; }
/* Khu vực không còn kết quả với từ khoá hiện tại: làm mờ chứ không ẩn,
   để người dùng vẫn thấy khu vực đó tồn tại và bấm sang được */
.chip[data-empty="1"] { opacity: .45; }

/* ===================== MENU CHỌN ĐỊNH DẠNG XUẤT ===================== */
.export-wrap { position: relative; }
.menu-pop.formats { min-width: 244px; }
.menu-pop.formats button {
  flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 11px;
}
.menu-pop.formats .fmt-name { font-size: 13px; color: var(--text); }
/* --text-mute trên nền panel-2 chỉ được 4.50:1, sát mép AA tới mức làm tròn
   xuống là trượt. Giống hệt trường hợp .api-tag. */
.menu-pop.formats .fmt-hint { font-size: 11.5px; color: var(--text-dim); }

/* ---------------- trạng thái site đọc từ Cloudflare ---------------- */
.cf-result { margin-top: 14px; }
.cf-tong { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cf-tong li {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 7px 11px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--border-soft);
}
.cf-tong li strong { font-variant-numeric: tabular-nums; min-width: 22px; }
.cf-tong li[data-muc="ok"]   { background: var(--green-dim); border-color: var(--green-line); color: var(--green); }
.cf-tong li[data-muc="warn"] { background: var(--amber-dim); border-color: var(--amber-line); color: var(--amber-ink); }
.cf-tong li[data-muc="err"]  { background: var(--red-dim); border-color: var(--red-line); color: var(--red-ink); }
.cf-canh-bao {
  display: flex; align-items: flex-start; gap: 8px; margin: 10px 0 0;
  font-size: 12.5px; color: var(--red-ink);
}
.cf-canh-bao .ico { width: 14px; height: 14px; margin-top: 2px; flex: 0 0 auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------- cột "Site" (đọc từ Cloudflare) ------------------- */
/* Ẩn cho tới khi thực sự có dữ liệu: app không dùng Cloudflare thì bảng
   giữ nguyên như cũ, không thừa một cột toàn dấu gạch ngang. */
#domainTable:not(.co-site) .col-site { display: none; }
#domainTable:not(.co-whmcs) .col-whmcs { display: none; }

.site-badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; white-space: nowrap;
  background: var(--panel-3); color: var(--text-dim);
  border: 1px solid var(--border);
}
.site-badge[data-muc="ok"]   { background: var(--green-dim); border-color: var(--green-line); color: var(--green-ink); }
.site-badge[data-muc="warn"] { background: var(--amber-dim); border-color: var(--amber-line); color: var(--amber-ink); }
.site-badge[data-muc="err"]  { background: var(--red-dim);   border-color: var(--red-line);   color: var(--red-ink); font-weight: 600; }
