/* ==========================================================================
   VSF.IFC — bộ giao diện dùng chung
   Phong cách: bảng điều khiển kỹ thuật, nền tối, giàu số liệu (mục [3.2])
   ========================================================================== */

:root {
  --bg:          #0e1520;
  --bg-2:        #131c2a;
  --surface:     #17212f;
  --surface-2:   #1d2939;
  --surface-3:   #243247;
  --border:      #2a3648;
  --border-soft: #212c3d;

  --text:        #e7eef7;
  --text-dim:    #a7b6c9;
  --muted:       #7d8ea5;

  --brand:       #233145;
  --accent:      #4d9fff;
  --accent-dim:  #2b6fbd;
  --teal:        #19c6a2;
  --amber:       #eda44e;
  --danger:      #f26d72;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 8px 28px rgba(0,0,0,.34);

  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .9rem; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 22px; }
.wrap-narrow { max-width: 620px; margin: 0 auto; padding: 0 22px; }

/* ------------------------------------------------------------ thanh điều hướng */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(14,21,32,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 26px; height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; flex: 0 0 30px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--teal) 100%);
  display: grid; place-items: center; color: #08101c; font-weight: 800; font-size: .62rem;
  letter-spacing: -.02em;
}
.brand small { display: block; font-size: .68rem; color: var(--muted); font-weight: 500; letter-spacing: .04em; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  color: var(--text-dim); padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }

.lang-switch { display: flex; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-left: 6px; }
.lang-switch a { padding: 5px 9px; font-size: .76rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); border-radius: 0; }
.lang-switch a.on { background: var(--accent); color: #08101c; }

/* ------------------------------------------------------------ nút */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: .89rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #08101c; }
.btn-primary:hover { background: #6ab0ff; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #5a2d33; color: var(--danger); background: transparent; }
.btn-danger:hover { background: #2a1a1d; }
.btn-sm { padding: 5px 11px; font-size: .81rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ thẻ và lưới */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: -20px -20px 18px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-sidebar { grid-template-columns: 1fr 340px; align-items: start; }
@media (max-width: 940px) {
  .grid-2, .grid-3, .grid-4, .grid-sidebar { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ ô số liệu */

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
}
.stat.teal::before { background: var(--teal); }
.stat.amber::before { background: var(--amber); }
.stat.dim::before { background: var(--muted); }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.stat-value { font-family: var(--mono); font-size: 1.75rem; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }

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

.table-scroll { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 20px; }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th {
  text-align: left; padding: 9px 12px; background: var(--bg-2);
  border-bottom: 1px solid var(--border); color: var(--text-dim);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { font-family: var(--mono); text-align: right; }
table.data .mono { font-family: var(--mono); font-size: .82rem; color: var(--text-dim); }

/* ------------------------------------------------------------ nhãn trạng thái */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: .74rem; font-weight: 700;
  letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-pending { color: var(--muted);  background: #1b2432; border-color: #2b3648; }
.tag-running { color: var(--accent); background: #12243b; border-color: #234a73; }
.tag-done    { color: var(--teal);   background: #102b26; border-color: #1c5849; }
.tag-failed  { color: var(--danger); background: #2c1719; border-color: #5c2b30; }
.tag-role    { color: var(--text-dim); background: var(--surface-2); border-color: var(--border); }
.tag-role.host { color: var(--amber); background: #2b2214; border-color: #5a4620; }
.tag-role.admin { color: var(--accent); background: #12243b; border-color: #234a73; }

/* ------------------------------------------------------------ biểu mẫu */

.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: .8rem; font-weight: 650; color: var(--text-dim);
  margin-bottom: 5px; letter-spacing: .01em;
}
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; font-family: inherit; font-size: .9rem;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,159,255,.14);
}
textarea { min-height: 110px; resize: vertical; }
input[type=file] { padding: 8px; cursor: pointer; }
/* Hàng ô đánh dấu: nhãn nằm cạnh ô, bấm vào chữ cũng chọn được. */
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .84rem;
         color: var(--text-dim); cursor: pointer; margin-bottom: 15px; }
.check input[type=checkbox] { width: auto; margin-top: 2px; flex: 0 0 auto; accent-color: var(--accent); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 180px; }
.form-row > .btn { flex: 0 0 auto; }

/* ------------------------------------------------------------ thông báo */

.flash { border-radius: var(--radius-sm); padding: 11px 15px; margin-bottom: 14px; font-size: .89rem; border: 1px solid; }
.flash-ok    { background: #10241f; border-color: #1c5849; color: #66e0c2; }
.flash-error { background: #2a1619; border-color: #5c2b30; color: #f9a1a4; }

.notice {
  background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: .86rem; color: var(--text-dim);
}
.notice.warn { border-left-color: var(--amber); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--text-dim); }

/* ------------------------------------------------------------ trang chủ */

.hero { padding: 74px 0 60px; border-bottom: 1px solid var(--border); background:
  radial-gradient(1100px 420px at 18% -10%, rgba(77,159,255,.14), transparent 60%),
  radial-gradient(800px 380px at 88% 0%, rgba(25,198,162,.10), transparent 62%); }
.hero h1 { font-size: 2.7rem; max-width: 15ch; letter-spacing: -.025em; }
.hero p.lead { font-size: 1.05rem; color: var(--text-dim); max-width: 62ch; }
.hero-actions { display: flex; gap: 11px; margin-top: 26px; flex-wrap: wrap; }
@media (max-width: 700px) { .hero h1 { font-size: 2rem; } .hero { padding: 48px 0 40px; } }

.eyebrow {
  display: inline-block; font-family: var(--mono); font-size: .74rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--accent); border: 1px solid var(--border);
  background: var(--surface); padding: 4px 11px; border-radius: 20px; margin-bottom: 18px;
}

.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.feature-ico {
  width: 38px; height: 38px; border-radius: 9px; background: var(--surface-3);
  display: grid; place-items: center; margin-bottom: 13px; font-size: 1.1rem;
}
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--text-dim); font-size: .89rem; margin: 0; }

/* ------------------------------------------------------------ khối phụ */

.section { padding: 34px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head { padding: 26px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.page-head .crumb { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head .sub { color: var(--text-dim); font-size: .9rem; margin-top: 4px; }

.kv { display: grid; grid-template-columns: minmax(140px, 210px) 1fr; gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
.kv dt { background: var(--bg-2); padding: 8px 13px; font-size: .82rem; color: var(--text-dim); font-weight: 600; }
.kv dd { background: var(--surface); padding: 8px 13px; margin: 0; font-size: .87rem; word-break: break-word; }

.tree { list-style: none; margin: 0; padding: 0; font-size: .87rem; }
.tree ul { list-style: none; margin: 4px 0 0; padding-left: 18px; border-left: 1px dashed var(--border); }
.tree li { padding: 2px 0; }
.tree .node { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree .node.leaf { padding-left: 17px; }
.tree summary.node {
  cursor: pointer; list-style: none; padding: 3px 6px 3px 0; border-radius: var(--radius-sm);
}
.tree summary.node::-webkit-details-marker { display: none; }
.tree summary.node::before {
  content: "▸"; color: var(--muted); font-size: .78rem; width: 12px; flex: 0 0 12px;
  transition: transform .12s; display: inline-block;
}
.tree details[open] > summary.node::before { transform: rotate(90deg); }
.tree summary.node:hover { background: var(--surface-2); }
.tree .cls { font-family: var(--mono); font-size: .72rem; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.tree .cnt {
  font-family: var(--mono); font-size: .72rem; color: var(--teal);
  background: #102b26; border: 1px solid #1c5849; padding: 0 6px; border-radius: 10px;
}

.bar { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.dl-list { display: grid; gap: 9px; }
.dl-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.dl-item:hover { border-color: var(--accent-dim); text-decoration: none; }
.dl-ico { font-family: var(--mono); font-size: .7rem; font-weight: 800; padding: 5px 8px; border-radius: 5px; background: var(--surface-3); color: var(--accent); letter-spacing: .05em; }
.dl-meta { margin-left: auto; font-family: var(--mono); font-size: .78rem; color: var(--muted); }

footer.site {
  border-top: 1px solid var(--border); margin-top: 56px; padding: 26px 0;
  color: var(--muted); font-size: .84rem;
}
footer.site .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ------------------------------------------------------------ khung nhìn 3D */

#viewer-stage { position: relative; height: 68vh; min-height: 460px; background: #0a0f18;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
#viewer-canvas { width: 100%; height: 100%; display: block; }
#viewer-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10,15,24,.92); text-align: center; padding: 24px; gap: 12px;
}
#viewer-overlay .inner { max-width: 460px; }
.viewer-props {
  position: absolute; top: 12px; right: 12px; width: 330px; max-height: calc(100% - 24px);
  overflow-y: auto; overflow-x: hidden; background: rgba(19,28,42,.96);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px; font-size: .8rem;
}
.viewer-props h4 { margin: 0 0 8px; font-size: .84rem; }
.viewer-props table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.viewer-props td {
  padding: 4px 0; border-bottom: 1px solid var(--border-soft); vertical-align: top;
  word-break: break-word; overflow-wrap: anywhere; hyphens: auto;
}
.viewer-props td:first-child { color: var(--muted); padding-right: 9px; width: 45%; }
.viewer-props td:last-child { text-align: right; }
@media (max-width: 820px) {
  .viewer-props { position: static; width: auto; max-height: 260px; margin-top: 10px;
                  background: var(--surface); }
}
.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------- kết quả kiểm tra chất lượng */

/* Nhãn mức độ. Ngoài màu còn khác nhau về chữ, để người bị rối loạn phân biệt
   màu hoặc khi in trắng đen vẫn đọc được. */
.sev {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.sev-error   { color: var(--danger); background: #2c1719; border-color: #5c2b30; }
.sev-warning { color: var(--amber);  background: #2b2214; border-color: #5a4620; }
.sev-info    { color: var(--accent); background: #12243b; border-color: #234a73; }
.sev-ok      { color: var(--teal);   background: #102b26; border-color: #1c5849; }

.stat.danger::before { background: var(--danger); }
tr.row-active > td { background: #16233a; }

/* ---------------------------------------------- bản in (In → Lưu thành PDF) */

@media print {
  /* Nền tối rất tốn mực và làm chữ mờ khi in — đảo về nền trắng chữ đen. */
  :root { --bg: #fff; --bg-2: #fff; --surface: #fff; --surface-2: #fff;
          --surface-3: #f2f5f8; --border: #c8d2de; --border-soft: #dde4ec;
          --text: #101820; --text-dim: #2c3947; --muted: #5a6a7c; }
  body { background: #fff; color: #101820; }
  .topbar, .site-footer, .no-print, .flash, .notice { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 1px solid #c8d2de; box-shadow: none; break-inside: avoid; }
  .table-scroll { overflow: visible; }
  table.data { font-size: 8.5pt; }
  table.data th { background: #233145 !important; color: #fff !important;
                  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sev { border: 1px solid #8a97a6; color: #101820 !important; background: #fff !important; }
  .stat { border: 1px solid #c8d2de; break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
  /* Không lặp lại tiêu đề bảng giữa chừng thì bảng dài mất ngữ cảnh khi sang trang */
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}

.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
