/* EVNX-Crawl · màn quản trị (bản dựng dữ liệu giả). Nếp: trắng phẳng, một màu nhấn, đỏ chỉ cho lỗi, bảng dày. */
:root {
  --font: "Be Vietnam Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --primary: #181818; --primary-hover: #2e2e2e; --primary-fg: #ffffff;
  --bg: #f4f4f6; --surface: #ffffff; --surface-hover: #f8f8fa; --item-hover: #f4f4f6; --secondary: #e7e8ec;
  --fg: #2c2c2c; --fg-soft: #4a4a4f; --muted: #66666b;
  --line: #eaeaea; --line-soft: #f0f0f2;
  --danger: #c10007; --danger-bg: #fef2f2; --danger-line: #ffc9c9;
  --success: #007a55; --success-bg: #ecfdf5;
  --warning: #bb4d00; --warning-bg: #fffbeb;
  --neutral: #52525c; --neutral-bg: #f4f4f5;
  --ring: rgba(24, 24, 24, .22);
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow-pop: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- khung ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-head { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.logo { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--primary); color: var(--primary-fg); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.side-head b { font-weight: 600; }
.side-head .ver { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-label { height: 32px; display: flex; align-items: flex-end; padding: 0 12px 6px; margin-top: 12px; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: var(--r); text-decoration: none; color: var(--fg-soft); }
.nav a:hover { background: var(--item-hover); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--secondary); color: var(--fg); font-weight: 500; }
.nav a svg { width: 16px; height: 16px; flex: none; }
.nav a .cnt { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav a .cnt.bad { color: var(--danger); font-weight: 500; }
.side-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 16px; font-weight: 600; }
.top .sp { flex: 1; }
.top .fresh { font-size: 12px; color: var(--muted); white-space: nowrap; }
.btn.menu-btn { display: none; }
.page { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- nút, ô nhập, nhãn ---------- */
.btn { height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; text-decoration: none; flex: none; }
.btn:hover { background: #f1f1f3; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--item-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.input, .select { height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-size: 14px; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.plain::before { display: none; }
/* công tắc: phần nhìn thấy 36x20, vùng bấm 48x32 nhờ đệm trong suốt */
.sw { position: relative; width: 36px; height: 20px; border-radius: 999px; border: 0; background-color: #cfcfd6; padding: 6px; box-sizing: content-box; background-clip: content-box; flex: none; }
.sw::after { content: ""; position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .12s; }
.sw[aria-checked="true"] { background-color: var(--primary); } /* background-color, không dùng background: dạng gộp sẽ xoá background-clip */
.sw[aria-checked="true"]::after { left: 24px; }

/* ---------- thẻ, lưới ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-head .sp { flex: 1; }
.card-head a { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 32px; padding: 0 4px; margin: -6px -4px; }
.card-head a:hover { color: var(--fg); text-decoration: underline; }
.card-body { padding: 16px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); }
.banner .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); flex: none; }
.banner.warn .dot { background: var(--warning); }
.banner.bad { border-color: var(--danger-line); background: var(--danger-bg); }
.banner.bad .dot { background: var(--danger); }
.banner b { font-weight: 600; }
.banner .sp { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.stat { padding: 16px; border-left: 1px solid var(--line-soft); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat .k { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 24px; font-weight: 600; line-height: 1.3; margin-top: 4px; }
.stat .v small { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .s.bad { color: var(--danger); }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.todo li:first-child { border-top: 0; }
.todo .t { min-width: 0; flex: 1; }
.todo .t b { font-weight: 500; display: block; }
.todo .t span { font-size: 13px; color: var(--muted); display: block; }
.bar { height: 6px; border-radius: 3px; background: var(--secondary); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.kv { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--muted); font-size: 12px; display: block; }

/* ---------- bảng ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--fg-soft); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { background: var(--secondary); }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.tabs button .n { font-size: 12px; color: var(--muted); }
.toolbar .sp { flex: 1; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--surface-hover); }
.tbl tbody tr[aria-selected="true"] td { background: var(--item-hover); }
.tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
.tbl .r { text-align: right; }
.tbl .two b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
.tbl .two span { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
/* bảng còn phải cuộn ngang thì cột đầu ghim lại */
.tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.tbl tbody tr:hover td:first-child { background: var(--surface-hover); }
.tbl tbody tr[aria-selected="true"] td:first-child { background: var(--item-hover); }
.tbl .act { white-space: nowrap; text-align: right; }
.tbl .r { white-space: nowrap; }
/* khung chi tiết đang mở: bảng bên trái chỉ giữ cột để CHỌN, phần còn lại đã có ở khung chi tiết */
.split.open .hide-open { display: none; }
@media (max-width: 1599px) { .split.open .hide-open-md { display: none; } .split.open .tbl .two b, .split.open .tbl .two span { max-width: 22ch; } }
.tbl .nowrap { white-space: nowrap; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--fg); font-weight: 600; margin-bottom: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.split.open { grid-template-columns: minmax(0, 1fr) 420px; }
.panel { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: 14px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .sp { flex: 1; }
.panel section { padding: 16px; border-top: 1px solid var(--line-soft); }
.panel section:first-of-type { border-top: 0; }
.panel h3 { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--neutral-bg); border-radius: var(--r-sm); padding: 8px 10px; overflow-wrap: anywhere; }
.skel { height: 14px; border-radius: 4px; background: var(--secondary); }

/* ---------- hộp hỏi lại ---------- */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); display: grid; place-items: center; padding: 16px; z-index: 50; }
.dialog { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(440px, 100%); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { font-size: 16px; font-weight: 600; }
.dialog .acts { justify-content: flex-end; margin-top: 4px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--primary-fg); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-pop); z-index: 60; font-size: 13px; width: max-content; max-width: calc(100vw - 32px); overflow-wrap: anywhere; }

/* ---------- đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { font-size: 18px; font-weight: 600; }
.login .btn { height: 40px; justify-content: center; }
.login .input { height: 40px; font-size: 16px; }

/* ---------- màn rộng: dùng hết khung ---------- */
@media (min-width: 1600px) {
  .page { padding: 24px 32px; }
  .split.open { grid-template-columns: minmax(0, 1fr) 520px; }
  .tbl .two b, .tbl .two span { max-width: 70ch; }
}
@media (max-width: 1535px) { .hide-lg { display: none; } }
/* ---------- màn vừa ---------- */
@media (max-width: 1279px) {
  .split.open { grid-template-columns: minmax(0, 1fr); }
  .split.open .panel { position: fixed; inset: 0 0 0 auto; width: min(460px, 100%); max-height: none; top: 0; z-index: 40; border-radius: 0; border-top: 0; border-bottom: 0; border-right: 0; box-shadow: var(--shadow-pop); }
  .hide-md { display: none; }
  .tbl .two b, .tbl .two span { max-width: 24ch; }
}
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; transform: translateX(-100%); box-shadow: var(--shadow-pop); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .top { padding: 0 16px; }
  .page { padding: 16px; }
}
/* ---------- điện thoại ---------- */
@media (max-width: 639px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .top .fresh { display: none; }
  .hide-sm { display: none; }
  /* điện thoại: bảng quản lý thành danh sách dòng, không cuộn ngang */
  .tbl:not(.keep) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl:not(.keep), .tbl:not(.keep) tbody { display: block; }
  .tbl:not(.keep) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
  .tbl:not(.keep) tr:last-child { border-bottom: 0; }
  .tbl:not(.keep) td { padding: 0 !important; border: 0; position: static !important; background: transparent !important; text-align: left; min-width: 0; }
  .tbl:not(.keep) td.hide-sm, .tbl:not(.keep) td.hide-md, .tbl:not(.keep) td.hide-lg { display: none; }
  .tbl:not(.keep) td:last-child { grid-column: 2; grid-row: 1; text-align: right; }
  .tbl:not(.keep) td:not(:first-child):not(:last-child) { grid-column: 1 / -1; }
  .tbl:not(.keep) tbody tr:hover { background: var(--surface-hover); }
  .tbl:not(.keep) tbody tr[aria-selected="true"] { background: var(--item-hover); }
  .tbl .two b, .tbl .two span { max-width: none; }
  .input, .select { font-size: 16px; }
  .toolbar .input { flex: 1 1 100%; }
  .tabs { gap: 2px; flex-wrap: nowrap; }
  .tabs button { padding: 0 8px; }
  .banner { align-items: flex-start; }
  .banner .dot { margin-top: 6px; }
  .btn.sm { height: 36px; }
}

/* ---------- v1.46.0: mục chuyển từ màn cũ (Công cụ, Cài đặt chỉnh được, Lịch chạy) ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form .acts { align-items: center; }
.form .acts .sp { flex: 1; }
.form .err, .card-body .err { font-size: 13px; color: var(--danger); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-grid.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chk { display: inline-flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; min-height: 24px; }
.chk input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.btn.danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.dialog.wide { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.pick { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); max-height: 50vh; overflow: auto; }
.pick li { padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.pick li:first-child { border-top: 0; }
.pick .chk span { display: flex; flex-direction: column; min-width: 0; }
.pick .chk b { font-weight: 500; overflow-wrap: anywhere; }
.pick .chk small { color: var(--muted); font-size: 12px; }
.changes { list-style: none; margin: 0; padding: 0; }
.changes li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.changes li:first-child { border-top: 0; }
.changes b { font-weight: 600; white-space: nowrap; }
@media (max-width: 1023px) { .grid2.even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 639px) { .form-grid, .form-grid.tight { grid-template-columns: minmax(0, 1fr); } .changes li { flex-direction: column; gap: 2px; } }
