/* UDP — Quản trị. Kiểu "data-dense dashboard": nền slate nhạt, một màu nhấn xanh, trạng thái = chấm màu + chữ
   (không chỉ dựa vào màu). Không font/asset ngoài (CSP 'self'); không style inline. */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --side: #0f172a; --side-text: #cbd5e1; --side-muted: #64748b;
  --side-active: #1e293b; --text: #0f172a; --text-2: #334155; --muted: #64748b; --border: #e2e8f0; --border-2: #cbd5e1;
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: #eff6ff; --on-accent: #ffffff;
  --ok: #047857; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --danger: #b91c1c; --danger-soft: #fef2f2;
  --info: #1d4ed8; --info-soft: #eff6ff; --neutral-soft: #f1f5f9;
  --row-hover: #f8fafc; --row-selected: #eff6ff;
  --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .04);
  --radius: 10px; --radius-sm: 6px;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --side: #020617; --side-text: #cbd5e1; --side-muted: #64748b;
    --side-active: #1e293b; --text: #f1f5f9; --text-2: #cbd5e1; --muted: #94a3b8; --border: #1f2937; --border-2: #334155;
    --accent: #60a5fa; --accent-hover: #93c5fd; --accent-soft: #172554; --on-accent: #0b1120;
    --ok: #34d399; --ok-soft: #052e24; --warn: #fbbf24; --warn-soft: #2d1f05; --danger: #f87171; --danger-soft: #3b1212;
    --info: #93c5fd; --info-soft: #172554; --neutral-soft: #1e293b;
    --row-hover: #162033; --row-selected: #172554;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* thuộc tính hidden phải thắng display của class */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1 { font-size: 1.375rem; line-height: 1.3; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; font-weight: 600; }
h3 { font-size: .9rem; margin: 20px 0 8px; font-weight: 600; color: var(--text-2); }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
      stroke-linejoin: round; }
.mono, .mono-title { font-family: var(--mono); font-size: .85em; }
.mono-title { font-size: 1rem; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--on-accent); padding: 8px 12px;
        border-radius: var(--radius-sm); z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Điều khiển ─────────────────────────────────────────────────────────────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
                          padding: 8px 10px; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
                                            box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
select { cursor: pointer; padding-right: 28px; }
textarea { width: 100%; resize: vertical; min-height: 64px; }
label { font-weight: 500; font-size: .9rem; color: var(--text-2); }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
label.inline select { min-height: 36px; padding-block: 6px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
         padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
         font-weight: 500; transition: background-color .15s, border-color .15s, color .15s; }
button svg { width: 16px; height: 16px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.secondary { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
button.secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); color: var(--text); }
button.danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { button.danger { color: #1a0505; } }
button.danger:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--side-text); border-color: color-mix(in srgb, var(--side-text) 30%, transparent); }
button.ghost:hover { background: var(--side-active); color: #fff; }
button.small { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
button.block { width: 100%; min-height: 42px; }

/* ── Đăng nhập ──────────────────────────────────────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px;
         background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
                     var(--bg); }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
              box-shadow: 0 10px 30px rgb(15 23 42 / .08); padding: 28px; display: grid; gap: 10px; }
.login-card .brand { margin-bottom: 12px; color: var(--text); }
.login-card .brand span { color: var(--muted); }
.login-card input { width: 100%; font-family: var(--mono); }
.help { margin: 0 0 6px; color: var(--muted); font-size: .85rem; }

/* ── Khung ──────────────────────────────────────────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
       background: linear-gradient(to right, var(--side) 248px, transparent 248px); }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 20px;
        background: var(--side); color: var(--side-text); padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand .logo { width: 30px; height: 30px; padding: 5px; border-radius: 8px; background: var(--accent); color: #fff;
               stroke-width: 2; }
.brand div { display: grid; line-height: 1.2; }
.brand b { font-size: 1.05rem; letter-spacing: .02em; }
.brand span { font-size: .8rem; color: var(--side-muted); }
.brand-lg .logo { width: 40px; height: 40px; padding: 7px; }
.brand-lg b { font-size: 1.25rem; }
.tabs { display: grid; gap: 2px; }
.tabs button { justify-content: flex-start; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0;
               background: transparent; color: var(--side-text); font-weight: 500; text-align: left; }
.tabs button span { flex: 1; }
.tabs button:hover { background: var(--side-active); color: #fff; }
.tabs button[aria-selected="true"] { background: var(--side-active); color: #fff;
                                     box-shadow: inset 3px 0 0 var(--accent); }
.tabs button[aria-selected="true"] svg { color: var(--accent); }
.nav-badge { font-style: normal; font-size: .72rem; font-weight: 700; min-width: 20px; padding: 1px 6px; border-radius: 999px;
             text-align: center; background: var(--accent); color: #fff; font-variant-numeric: tabular-nums; }
.nav-badge.warn { background: #d97706; } .nav-badge.bad { background: #dc2626; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--side-active); }
.who-box { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: var(--side-active);
          flex: none; }
.avatar svg { width: 16px; height: 16px; }
.who { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 28px 32px 48px; min-width: 0; outline: none; }
section[role="tabpanel"] { display: grid; gap: 20px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head .sub { margin-top: 4px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: .875rem; max-width: 75ch; }

/* ── Panel / thẻ ────────────────────────────────────────────────────────────────────────────────────────────── */
.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
                box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between; }
.split { display: grid; gap: 20px; }
.detail { border-top: 3px solid var(--accent); scroll-margin-top: 16px; }
.cards { display: grid; gap: 16px; }
.cards:empty { display: none; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.card-head h3 { margin: 0; font-size: 1.05rem; color: var(--text); }
.card-head .muted { margin-right: auto; }
.card-section { margin: 16px 0 0; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
                color: var(--muted); }
.health { width: 10px; height: 10px; border-radius: 999px; background: var(--ok); flex: none;
          box-shadow: 0 0 0 3px var(--ok-soft); }
.health.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.health.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.muted { color: var(--muted); font-size: .85rem; }
.count { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* ── KPI ────────────────────────────────────────────────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis:empty { display: none; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
       padding: 16px 18px; display: grid; gap: 2px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--border-2); }
.kpi.ok::before { background: var(--ok); } .kpi.warn::before { background: var(--warn); }
.kpi.bad::before { background: var(--danger); } .kpi.info::before { background: var(--accent); }
.kpi span { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi b { font-size: 1.75rem; line-height: 1.2; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8rem; }

/* ── Bảng ───────────────────────────────────────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-wrap:has(> table[hidden]) { display: none; }
.table-wrap.tall { max-height: 560px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 600;
     font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--row-hover); }
table.pick tbody tr { cursor: pointer; }
tbody tr[aria-selected="true"] { background: var(--row-selected); box-shadow: inset 3px 0 0 var(--accent); }
td.mono { white-space: nowrap; }
.zero { color: var(--muted); }
table.data td { font-size: .85rem; white-space: nowrap; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; }
tr.changed td { background: color-mix(in srgb, var(--warn) 10%, transparent); }
tr.changed td:first-child::after { content: " • đổi"; color: var(--warn); font-size: .8rem; font-family: inherit; }
small.was { color: var(--muted); }

/* ── Nhãn trạng thái: chấm + chữ ────────────────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
         font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.s-succeeded, .s-approved, .s-applied { background: var(--ok-soft); color: var(--ok); }
.s-failed, .s-quarantined { background: var(--danger-soft); color: var(--danger); }
.s-needs_review, .s-not_converged, .s-draft, .s-pending { background: var(--warn-soft); color: var(--warn); }
.s-running { background: var(--info-soft); color: var(--info); }
.s-running::before { animation: pulse 1.2s ease-in-out infinite; }
.s-rejected, .s-aborted, .s-superseded { background: var(--neutral-soft); color: var(--muted); }
.when { color: var(--muted); font-size: .85rem; margin-left: 6px; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .3; } }
.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-sm); font-size: .78rem;
        font-weight: 500; background: var(--neutral-soft); color: var(--text-2); border: 1px solid var(--border); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ── Thông báo ──────────────────────────────────────────────────────────────────────────────────────────────── */
.msg { color: var(--muted); margin: 0; font-size: .9rem; }
.msg:empty { display: none; }
.msg.error { color: var(--danger); background: var(--danger-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.login .msg { margin-top: 4px; }
.panel > .msg, .panel-head + .msg { margin-top: 12px; }
.list-panel > .msg:first-child { margin: 0 0 4px; }
.err { color: var(--danger); font-size: .85rem; overflow-wrap: anywhere; }
p.err { background: var(--danger-soft); padding: 10px 12px; border-radius: var(--radius-sm); margin: 12px 0 0; }
.callout { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text-2);
           font-size: .875rem; border-left: 3px solid var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border-2);
         border-radius: var(--radius); background: var(--surface); }

/* ── Chi tiết ───────────────────────────────────────────────────────────────────────────────────────────────── */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 14px 0 0; font-size: .9rem; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stats div { display: grid; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2);
             border: 1px solid var(--border); }
.stats b { font-size: 1.4rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.stats b.err { font-size: 1.4rem; }
.stats span { color: var(--muted); font-size: .8rem; }
.keys { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px;
        overflow: auto; }
.keys li { font-family: var(--mono); font-size: .8rem; background: var(--danger-soft); color: var(--danger);
           padding: 3px 8px; border-radius: 4px; }
.review { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ── Publication ────────────────────────────────────────────────────────────────────────────────────────────── */
.ds-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 14px; }
.ds-list button { display: grid; justify-items: start; gap: 4px; text-align: left; padding: 12px 14px; min-height: 64px;
                  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ds-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.ds-list button .mono { font-size: .85rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.ds-list button small { color: var(--muted); font-size: .8rem; }
.layer { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
         padding: 1px 6px; border-radius: 4px; background: var(--neutral-soft); color: var(--muted); }
.layer.l-silver { background: #e2e8f0; color: #334155; }
.layer.l-gold { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) {
  .layer.l-silver { background: #334155; color: #e2e8f0; } .layer.l-gold { background: #422006; color: #fcd34d; }
}

.ds-item { display: grid; gap: 6px; align-content: start; }
.ds-list:has(> .ds-item) { align-items: start; }
.ds-list .ds-item > button.small { justify-self: start; display: inline-flex; min-height: 30px; padding: 4px 10px;
                                   background: var(--surface); border-color: var(--border-2); }

/* ── Lượt chạy ──────────────────────────────────────────────────────────────────────────────────────────────── */
.s-skipped { background: var(--neutral-soft); color: var(--muted); }
#run-target { min-height: 36px; padding-block: 6px; width: 16rem; max-width: 100%; }
.code-chip { margin-left: 6px; }
.dots { display: inline-flex; align-items: center; gap: 0; }
.dots .dot + .dot { margin-left: 10px; position: relative; }
.dots .dot + .dot::before { content: ""; position: absolute; right: 100%; top: 50%; width: 10px; height: 1px;
                            background: var(--border-2); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; flex: none; }
.dots .dot, .tl-dot { background: currentColor; }
.dots .dot.s-failed, .tl-dot.s-failed { border-radius: 2px; transform: rotate(45deg) scale(.9); }   /* lỗi = hình thoi */
.dots .dot.s-skipped, .tl-dot.s-skipped { background: transparent; border: 2px solid currentColor; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 0; }
.timeline .step { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px;
                  padding: 10px 0 14px; }
.timeline .step::before { content: ""; position: absolute; left: 10px; top: 26px; bottom: -10px; width: 2px;
                          background: var(--border); }
.timeline .step:last-child::before { display: none; }
.tl-dot { width: 12px; height: 12px; margin: 6px 0 0 5px; position: relative; z-index: 1;
          box-shadow: 0 0 0 3px var(--surface); }
.step-body { min-width: 0; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.step-head .when { margin-left: auto; }
.step-target { color: var(--text-2); overflow-wrap: anywhere; }
.step.is-failed .step-body { background: var(--danger-soft); border-left: 3px solid var(--danger); padding: 10px 12px;
                             border-radius: var(--radius-sm); }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.count-chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px 8px; border-radius: var(--radius-sm);
              background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.count-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.count-chip.bad { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.count-chip.bad b { color: var(--danger); }
.step-detail { margin-top: 8px; font-size: .85rem; }
.codes { display: inline-flex; flex-wrap: wrap; gap: 6px; }
#rd-error { margin: 12px 0 0; font-weight: 600; }

/* ── Lineage ────────────────────────────────────────────────────────────────────────────────────────────────── */
.graph-panel { padding: 12px; }
.graph-wrap { overflow-x: auto; overflow-y: hidden; max-width: 100%; }   /* rộng hơn màn hình: cuộn trong khung */
.graph-wrap:empty { display: none; }
.graph-wrap svg.graph { display: block; overflow: visible; }
.graph .ln-head { fill: var(--muted); stroke: none; font-size: 11px; font-weight: 600; letter-spacing: .06em;
                  text-transform: uppercase; }
.graph .ln-edge { fill: none; stroke: var(--border-2); stroke-width: 1.5; transition: stroke .12s, opacity .12s; }
.graph .ln-node { cursor: pointer; outline: none; }
.graph .ln-box { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 1; transition: stroke .12s, fill .12s; }
.graph .ln-stripe { stroke: none; fill: var(--muted); }
.graph .k-source .ln-stripe { fill: var(--accent); }
.graph .k-ledger .ln-stripe { fill: var(--ok); }
.graph .k-silver .ln-stripe { fill: #64748b; }
.graph .k-gold .ln-stripe { fill: #d97706; }
.graph .k-publication .ln-stripe { fill: #7c3aed; }
.graph .ln-label { fill: var(--text); stroke: none; font-size: 13px; font-family: var(--mono); dominant-baseline: central; }
.graph .ln-node:hover .ln-box { fill: var(--accent-soft); stroke: var(--accent); }
.graph .ln-node:focus-visible .ln-box { stroke: var(--accent); stroke-width: 3; }
.graph.focusing .ln-node:not(.on) { opacity: .35; }
.graph.focusing .ln-edge:not(.on) { opacity: .25; }
.graph .ln-edge.on { stroke: var(--accent); stroke-width: 2.5; }
.graph .ln-node.on .ln-box { stroke: var(--accent); }

/* ── Chi tiết Gold ──────────────────────────────────────────────────────────────────────────────────────────── */
.code-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
pre.code { margin: 8px 0 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border);
           border-radius: var(--radius-sm); overflow: auto; max-height: 420px; font-family: var(--mono); font-size: .82rem;
           line-height: 1.5; color: var(--text); tab-size: 2; }
pre.code code { font-family: inherit; white-space: pre; }
.audits { display: grid; gap: 8px; }
.audit { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface); }
.audit summary { cursor: pointer; font-weight: 500; }
.audit pre.code { margin-top: 8px; }

/* ── Màn hình hẹp ───────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
          gap: 8px 12px; padding: 10px 12px; }
  .brand div span { display: none; }
  .tabs { order: 3; width: 100%; display: flex; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { width: auto; white-space: nowrap; }
  .tabs button[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; }
  .who-box .avatar { display: none; }
  .who { max-width: 40vw; }
  main { padding: 16px 16px 40px; }
  .panel, .card { padding: 14px; }
  .card .table-wrap table, #batches, #mappings, #md-fields, #md-errors, #scans, #runs, #gd-columns, #li-mappings { min-width: 600px; }   /* cuộn ngang thay vì bóp cột */
}
@media (max-width: 480px) { .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; } .kpi b { font-size: 1.4rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Phân trang ── */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
         padding-top: 10px; border-top: 1px solid var(--border); margin-top: 8px; }
.pager[hidden] { display: none; }
.pager .range { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.pager .pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager .pages button { min-width: 36px; min-height: 36px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.pager .pages button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .875rem; }
.pager select { min-height: 36px; }

/* ── Nạp gói ASF ── */
.file-pick { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-weight: 500; }
.file-pick input[type="file"] { padding: 8px; min-height: 44px; cursor: pointer; }
.warn-box { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft, var(--danger-soft));
            border: 1px solid var(--warn, var(--danger)); }
.warn-box p { margin: 0 0 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 36px; }
.check input { width: 18px; height: 18px; }
.origin { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
          border: 1px solid var(--border-2); color: var(--text-2); }
.origin.asf { border-color: var(--accent); color: var(--accent); }
#asf-history { margin-top: 18px; }

/* ── Đăng ký YAML ── */
.issues { margin: 10px 0 0; padding: 10px 14px 10px 30px; border-radius: var(--radius-sm); background: var(--danger-soft);
          color: var(--danger); font-size: .875rem; overflow-wrap: anywhere; }
.issues[hidden] { display: none; }
#yaml-list td:first-child, #yaml-list th:first-child { width: 44px; text-align: center; }
#yaml-list input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
           white-space: nowrap; border: 0; }
#cfg-list td:first-child, #cfg-list th:first-child { width: 44px; text-align: center; }
#cfg-list input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
#cfg-list .keys { font-family: var(--mono, ui-monospace, monospace); font-size: .8125rem; overflow-wrap: anywhere; }

/* SQL/mã: tắt ligature (font mono có thể vẽ ->> thành mũi tên, dễ đọc sai) */
pre.code, .mono, .mono-title, code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* Lượt chạy: màn rộng → danh sách bên trái, chi tiết dính bên phải (không phải cuộn xuống dưới 50 dòng) */
@media (min-width: 1400px) {
  .runs-split:has(#run-detail:not([hidden])) { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .runs-split #run-detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
  /* chi tiết mở: ẩn Thời lượng / Kích hoạt (cột 6–7) — chi tiết đã có hai mục này */
  .runs-split:has(#run-detail:not([hidden])) #runs :is(th, td):nth-child(n+6) { display: none; }
}
.graph .ln-sub { fill: var(--muted); stroke: none; font-size: 11px; font-family: var(--mono); dominant-baseline: central; }
.graph .ln-sub.zero { fill: var(--warn); }
