/* ============================================================
   ZeusVN Brain — Thư Ký Siêu Việt
   Giao diện: Hồn trống đồng · Sức Rồng bay
   Font: Be Vietnam Pro (Google Fonts)
   ============================================================ */


/* ─── Biến màu sắc ─── */
:root{--bg:#05070e;--panel:#111827;--code:#1a2235;--text:#e8edf5;--muted:#7a8db0;--ok:#58d68d;--warn:#f0c050;--bad:#ff6060;--bad-btn:#c0392b;--accent:#e8b04f}
:root {
  --bad-btn: #c0392b;
  /* Nền */
  --bg:         #05070e;
  --bg2:        #0d1117;
  --panel:      #111827;
  --panel2:     #1a2235;
  --border:     #1e2a3a;
  --border2:    #2a3a50;

  /* Chữ */
  --text:       #e8edf5;
  --text2:      #a8b5cc;
  --muted:      #7a8db0;
  --muted2:     #4a5568;

  /* Nhấn mạnh */
  --gold:       #e8b04f;
  --gold-soft:  rgba(232,176,79,0.12);
  --red:        #ff6a45;
  --red-soft:   rgba(255,106,69,0.12);
  --blue:       #46e0ff;
  --blue-soft:  rgba(70,224,255,0.10);
  --purple:     #7b93ff;
  --purple-soft:rgba(123,147,255,0.10);
  --green:      #58d68d;
  --green-soft: rgba(88,214,141,0.10);

  /* Trạng thái */
  --ok:         #58d68d;
  --ok-soft:    rgba(88,214,141,0.12);
  --warn:       #f0c050;
  --warn-soft:  rgba(240,192,80,0.12);
  --bad:        #ff6060;
  --bad-soft:   rgba(255,96,96,0.12);
  --info:       #46e0ff;
  --info-soft:  rgba(70,224,255,0.10);

  /* Gradient */
  --grad:       linear-gradient(135deg, #e8b04f 0%, #ff6a45 100%);
  --grad-blue:  linear-gradient(135deg, #46e0ff 0%, #7b93ff 100%);
  --grad-green: linear-gradient(135deg, #58d68d 0%, #46e0ff 100%);

  /* Glow */
  --glow-gold:  0 0 24px rgba(232,176,79,0.25);
  --glow-red:   0 0 24px rgba(255,106,69,0.20);
  --glow-blue:  0 0 24px rgba(70,224,255,0.20);

  /* Khoảng cách & bo tròn */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Bóng */
  --shadow:     0 2px 12px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.6);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.6);

  /* Sidebar */
  --sidebar-w: 240px;
  --topbar-h:  58px;

  /* Chế độ sáng (fallback) */
  --accent: #e8b04f;  /* = --gold */
  --accent-t: #05070e;
  --code: #1a2235;
  --side: var(--panel);
  --line: var(--border);
}

/* Chế độ sáng */
[data-theme="light"] {
  --bg: #f5f7fa; --bg2: #edf0f5; --panel: #ffffff; --panel2: #f0f3f8;
  --border: #d1d9e6; --border2: #b8c4d8;
  --text: #1a2235; --text2: #3d4f6b; --muted: #6b7a99; --muted2: #8fa0b8;
  --shadow: 0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --code: #f0f3f8; --side: #ffffff; --line: #d1d9e6;
  --gold-soft: rgba(232,176,79,0.15); --red-soft: rgba(255,106,69,0.12);
  --ok-soft: rgba(88,214,141,0.15); --warn-soft: rgba(240,192,80,0.15);
  --bad-soft: rgba(255,96,96,0.12);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }  /* không scroll-behavior:smooth: cuộn mượt làm trình kiểm tra/AT đo vị trí giữa chừng và làm 'nhảy' khi tới ô nhập */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── Typography ─── */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.6rem; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0.8rem 0 0.4rem; }
a { color: var(--gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--red); text-decoration: none; }
code, pre { font-family: 'JetBrains Mono', monospace; background: var(--code); border-radius: var(--r-sm); }
code { padding: 2px 6px; font-size: 0.85em; }
pre { padding: 14px; overflow: auto; font-size: 0.85rem; }
.muted { color: var(--muted); font-size: 0.88em; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ─── Skip link ─── */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 9999;
  background: var(--grad); color: #fff; padding: 8px 16px;
  border-radius: var(--r); font-weight: 600; transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ─── Thanh trên (Topbar) ─── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: linear-gradient(90deg, #080c18 0%, #0d1420 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

/* Logo thương hiệu */
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; flex-shrink: 0;
}
.brand-icon {
  width: 34px; height: 34px;
  background: var(--grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-gold);
  flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-size: 1.05rem; font-weight: 800; letter-spacing: 0.05em;
  background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.04em; margin-top: 1px; }

/* Compat: logo icon dạng text */
.zb-logo { display: none; }
.zb-brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.05em; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.zb-brand-vn { /* inline */ }
.zb-brand-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.04em; margin-left: 8px; }

.spacer { flex: 1; }

/* Nút icon trên topbar */
.icon-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
  font-size: 14px;
}
.icon-btn:hover { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.icon-btn svg { width: 18px; height: 18px; }
#nav-toggle { display: none; }

/* Nút thoát */
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2); font: inherit; font-size: 0.85rem;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-logout:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-logout svg { width: 15px; height: 15px; }
.who { color: var(--muted); font-size: 0.78rem; }
.inline { display: inline; margin: 0; }

/* ─── Bố cục chính ─── */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

/* ─── Thanh bên (Sidebar) ─── */
.side {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #0a0f1e 0%, #080c18 100%);
  border-right: 1px solid var(--border);
  padding: 12px 8px 80px;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 0;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.side::-webkit-scrollbar { width: 4px; }
.side::-webkit-scrollbar-track { background: transparent; }
.side::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Nhóm điều hướng */
.nav-group { margin-bottom: 6px; }
.nav-h {
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted2); padding: 8px 12px 4px;
}

/* Liên kết trong sidebar */
.side a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--text2); font-size: 0.88rem; font-weight: 500;
  transition: all 0.18s; text-decoration: none;
  position: relative;
}
.side a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.side a:hover {
  background: rgba(232,176,79,0.08);
  color: var(--text); border-color: transparent;
}
.side a:hover svg { opacity: 1; color: var(--gold); }
.side a.on {
  background: var(--gold-soft);
  color: var(--gold); font-weight: 600;
}
.side a.on svg { opacity: 1; color: var(--gold); }
.side a.on::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--grad);
  border-radius: 0 3px 3px 0;
}

/* nav-icon compat (emoji fallback) */
.nav-icon { font-size: 15px; flex-shrink: 0; width: 16px; text-align: center; }

/* ─── Nội dung chính ─── */
main {
  flex: 1; min-width: 0;
  padding: 24px 28px 60px;
  max-width: 1400px;
}

/* Header trang */
.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin: 0; }
.zb-page-header { margin-bottom: 0; }
.zb-page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 16px; }

.page-title-icon {
  width: 40px; height: 40px;
  background: var(--gold-soft); border: 1px solid rgba(232,176,79,0.3);
  border-radius: var(--r); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-title-icon svg { width: 20px; height: 20px; color: var(--gold); }

/* ─── Thẻ (Card) ─── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin: 0 0 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border2); }
a.card:hover { border-color: var(--gold); box-shadow: var(--glow-gold); text-decoration: none; }
.card.ok { border-color: var(--ok); }
.card.bad { border-color: var(--bad); background: var(--bad-soft); }
.card.warn { border-color: var(--warn); background: var(--warn-soft); }
.card.gold { border-color: var(--gold); background: var(--gold-soft); }

/* ─── Lưới KPI ─── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.grid .card { margin: 0; }

/* Thẻ số liệu lớn */
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: block; color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.kpi:hover { border-color: var(--gold); box-shadow: var(--glow-gold); transform: translateY(-2px); }
.kpi .k { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.kpi .v { font-size: 2rem; font-weight: 800; margin: 4px 0 2px; line-height: 1; }
.kpi .s { font-size: 0.75rem; color: var(--muted); }

/* ─── Nút bấm ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; min-height: 40px;
  font: inherit; font-weight: 600; font-size: 0.9rem;
  background: var(--grad);
  color: #fff; border: none;
  border-radius: var(--r); cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(232,176,79,0.25);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232,176,79,0.35); color: #fff; }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }
.btn.ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text2); border: 1px solid var(--border2);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #ff4444, #cc0000); box-shadow: 0 4px 12px rgba(255,68,68,0.25); }
.btn.danger:hover { box-shadow: 0 6px 20px rgba(255,68,68,0.35); }
.btn.blue { background: var(--grad-blue); box-shadow: 0 4px 12px rgba(70,224,255,0.2); }
.btn.green { background: var(--grad-green); box-shadow: 0 4px 12px rgba(88,214,141,0.2); }
.btn.sm, .btn-sm { padding: 5px 12px; min-height: 32px; font-size: 0.82rem; }
.btn.lg { padding: 12px 24px; min-height: 48px; font-size: 1rem; }

/* ─── Bảng ─── */
.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  margin: 8px 0;
}
table { border-collapse: collapse; width: 100%; min-width: 480px; }
th {
  padding: 10px 14px; text-align: left;
  font-size: 0.73rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(232,176,79,0.04); }
tr.stale td { background: var(--bad-soft); }

/* ─── Nhãn trạng thái ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.state-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  border: 1px solid currentColor;
  white-space: nowrap; letter-spacing: 0.02em;
}
.st-ok { color: var(--ok); }
.st-warn { color: var(--warn); }
.st-bad { color: var(--bad); }
.st-info { color: var(--info); }
.st-unknown { color: var(--muted); }
.st-gold { color: var(--gold); }

/* Màu chữ trạng thái */
.s-SUCCEEDED, .s-APPROVED, .s-ONLINE, .s-VERIFIED_SUCCESS { color: var(--ok); border-color: var(--ok); }
.s-FAILED, .s-REJECTED, .s-OFFLINE, .s-VERIFIED_FAILURE { color: var(--bad); border-color: var(--bad); }
.s-RUNNING, .s-AWAITING_APPROVAL, .s-DEGRADED { color: var(--warn); border-color: var(--warn); }
.s-PENDING, .s-PLANNED { color: var(--info); border-color: var(--info); }
.s-CANCELLED, .s-EXPIRED { color: var(--muted); border-color: var(--muted); }
.r-R0 { color: var(--info); border-color: var(--info); }
.r-R1 { color: var(--ok); border-color: var(--ok); }
.r-R2 { color: var(--warn); border-color: var(--warn); }
.r-R3 { color: var(--bad); border-color: var(--bad); }
.h-ok, .h-BINH_THUONG { color: var(--ok); }
.h-warn, .h-SUY_GIAM { color: var(--warn); }
.h-bad, .h-SU_CO { color: var(--bad); }

/* ─── Form ─── */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.narrow { max-width: 400px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text2); }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 10px 14px; width: 100%;
  transition: all 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,176,79,0.15);
  background: var(--panel2);
}
textarea { resize: vertical; min-height: 100px; }
select { appearance: none; cursor: pointer; }

/* ─── Bộ lọc ─── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { flex: 1; min-width: 160px; width: auto; }

/* ─── Khu vực thả file ─── */
.zeus-dropzone {
  border: 2px dashed var(--border2);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg2);
}
.zeus-dropzone:hover, .zeus-dropzone.dragging {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: var(--glow-gold);
}
.zeus-dropzone-title { font-weight: 700; font-size: 1rem; margin-bottom: 6px; color: var(--text); }
.zeus-file-list { display: grid; gap: 8px; margin-top: 10px; }
.zeus-file-chip {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r); padding: 8px 12px;
  background: var(--panel2);
}
.zeus-file-thumb { width: 48px; height: 48px; border-radius: var(--r-sm); object-fit: cover; }
.zeus-file-meta { min-width: 0; display: flex; flex-direction: column; }
.zeus-file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.zeus-file-remove .btn { padding: 4px 8px; min-height: 28px; font-size: 0.78rem; }

/* ─── Thanh tiến trình (Meter/Bar) ─── */
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width 0.5s; }
.bar.warn > span { background: linear-gradient(90deg, var(--warn), #ff9000); }
.bar.bad > span { background: linear-gradient(90deg, var(--bad), #ff0000); }
meter.m { width: 100%; height: 8px; display: block; }

/* ─── DAG (Sơ đồ luồng) ─── */
.dag { overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px; }
.dag .edge { fill: none; stroke: var(--border2); stroke-width: 1.5; }
.dag .node rect { fill: var(--panel2); stroke: var(--border2); stroke-width: 1.5; }
.dag .nt { fill: var(--text); font-size: 12px; font-weight: 600; }
.dag .ns { fill: var(--muted); font-size: 11px; }
.dag .st-SUCCEEDED rect { stroke: var(--ok); }
.dag .st-FAILED rect { stroke: var(--bad); }
.dag .st-RUNNING rect, .dag .st-AWAITING_APPROVAL rect { stroke: var(--warn); }

/* ─── Phân trang ─── */
.pager { display: flex; gap: 8px; justify-content: flex-end; margin: 12px 0; }

/* ─── Trạng thái trống ─── */
.empty-state {
  text-align: center; padding: 40px 20px;
  border: 1px dashed var(--border2);
  border-radius: var(--r-lg); color: var(--muted);
  background: var(--bg2);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ─── Tab ─── */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs a {
  padding: 6px 14px; border: 1px solid var(--border2);
  border-radius: 999px; color: var(--text2); font-size: 0.85rem; font-weight: 500;
  transition: all 0.2s;
}
.tabs a:hover { border-color: var(--gold); color: var(--gold); }
.tabs a[aria-current="page"] { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); font-weight: 700; }

/* ─── Đánh dấu quan trọng ─── */
.warn-line {
  margin: 8px 0; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--warn-soft); border-left: 4px solid var(--warn);
  font-size: 0.9rem;
}
.approval-R2 { border-left: 5px solid var(--warn); }
.approval-R3 { border: 2px solid var(--bad); }

/* ─── Hiệu ứng trạng thái sống ─── */
@keyframes pulse-ok { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes pulse-bad { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow-pulse { 0%, 100% { box-shadow: 0 0 12px rgba(232,176,79,0.2); } 50% { box-shadow: 0 0 24px rgba(232,176,79,0.5); } }

.animate-in { animation: slide-in 0.3s ease both; }
.zb-fade-in { animation: slide-in 0.35s ease both; }

.life { font-weight: 700; padding: 3px 10px; border-radius: 999px; display: inline-block; }
.life-running { background: rgba(70,224,255,0.15); color: var(--info); }
.life-waiting { background: var(--panel2); color: var(--muted); }
.life-blocked_human { background: var(--warn-soft); color: var(--warn); }
.life-failed { background: var(--bad-soft); color: var(--bad); }
.life-verified { background: var(--ok-soft); color: var(--ok); }

/* ─── Code view (xem mã nguồn) ─── */
.crumbs { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); }
.code { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--r); }
.code-lines { border-collapse: collapse; width: 100%; font: 12.5px/1.5 'JetBrains Mono', monospace; }
.code-lines td { padding: 0 10px; vertical-align: top; }
.code-lines .ln { text-align: right; opacity: 0.4; min-width: 3.5rem; user-select: none; color: var(--muted); }
.code-lines pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.code-lines tr:target { background: rgba(232,176,79,0.12); }
.entries { list-style: none; padding: 0; columns: 2; column-gap: 2rem; }
.entries li { padding: 3px 0; break-inside: avoid; }
.file-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* ─── Palette tìm nhanh ─── */
.palette {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 10vh; z-index: 200;
  backdrop-filter: blur(4px);
}
.pal-box {
  background: var(--panel); color: var(--text);
  width: min(640px, 92vw);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border2); overflow: hidden;
}
.pal-box input {
  width: 100%; padding: 16px 20px; font-size: 1rem;
  border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: inherit;
  border-radius: 0;
}
.pal-box input:focus { box-shadow: none; border-color: var(--gold); }
.pal-box ul { list-style: none; margin: 0; padding: 6px; max-height: 55vh; overflow: auto; }
.pal-box li { padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; display: flex; gap: 10px; transition: background 0.15s; }
.pal-box li:hover, .pal-box li[aria-selected="true"] { background: var(--gold-soft); }
.pal-kind { font-size: 0.73rem; opacity: 0.6; min-width: 7rem; }
.pal-label { font-size: 0.9rem; }

/* ─── Quick Actions (center.html) ─── */
.zb-welcome {
  background: linear-gradient(135deg, rgba(232,176,79,0.08) 0%, rgba(255,106,69,0.06) 100%);
  border: 1px solid rgba(232,176,79,0.2);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.zb-welcome h2 { margin: 0 0 4px; font-size: 1rem; }
.zb-welcome p { margin: 0; color: var(--text2); font-size: 0.9rem; }
.zb-welcome-text { flex: 1; }
.zb-welcome-status { flex-shrink: 0; }
.zb-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0;
}
.zb-action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text2); font-size: 0.85rem; font-weight: 500;
  text-decoration: none; transition: all 0.2s;
}
.zb-action-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.zb-action-icon { font-size: 14px; }

/* ─── Điều hướng di động ─── */
.mobile-nav { display: none; }
.zb-mobile-nav { display: none; }

/* ─── Responsive Mobile ─── */
@media (max-width: 860px) {
  #nav-toggle { display: flex; }
  .side {
    position: fixed; inset: var(--topbar-h) 0 0 0;
    width: 100%; max-width: 280px;
    transform: translateX(-102%); transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
    z-index: 50; height: calc(100vh - var(--topbar-h));
  }
  body.nav-open .side { transform: none; }
  html { scroll-padding-bottom: 90px; }
  main { padding: 16px 14px 90px; }
  .brand-sub { display: none; }
  .zb-brand-sub { display: none; }
  .who { display: none; }
  .topbar .btn-logout span:not(.who) { display: none; }
  .mobile-nav, .zb-mobile-nav {
    display: flex; position: fixed;
    left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  }
  .mobile-nav a, .mobile-nav button,
  .zb-mobile-nav a, .zb-mobile-nav button {
    flex: 1; text-align: center; padding: 8px 2px;
    font: inherit; font-size: 0.72rem; color: var(--muted);
    background: none; border: 0; border-radius: var(--r-sm); min-height: 44px; max-height: 64px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transition: color 0.2s; overflow: hidden; white-space: nowrap;
  }
  .mobile-nav a svg, .mobile-nav button svg,
  .zb-mobile-nav a svg, .zb-mobile-nav button svg { width: 20px; height: 20px; }
  .mobile-nav [aria-current="page"],
  .zb-mobile-nav [aria-current="page"] { color: var(--gold); font-weight: 700; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .entries { columns: 1; }
  .zb-actions { gap: 6px; }
  .zb-welcome { flex-direction: column; }
  #palette-open, #theme-toggle { display: none; }
  .brand { min-width: 0; flex-shrink: 1; }
  .brand-text { overflow: hidden; }
  .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar { overflow-x: hidden; }
  .statusbar { min-width: 0; overflow: hidden; }

  /* Bảng → thẻ trên mobile */
  .tablewrap { overflow: visible; border: 0; background: none; box-shadow: none; }
  table { min-width: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-lg); margin-bottom: 10px; padding: 8px 14px;
  }
  tr.stale { border-color: var(--bad); }
  td, tr:last-child td {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border);
    text-align: right; overflow-wrap: anywhere;
  }
  td:last-child { border-bottom: 0; }
  td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--muted); font-size: 0.78rem; text-align: left; font-weight: 600; }
  td:not([data-label])::before { content: none; }
  td:not([data-label]) { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ─── Focus ─── */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ─── Mật độ gọn ─── */
:root[data-density="compact"] .card { padding: 10px 14px; }
:root[data-density="compact"] main { padding: 14px 16px 60px; }

/* responsive & theme */
@media (prefers-color-scheme:dark){:root{color-scheme:dark}}
[data-theme="dark"]{color-scheme:dark}

.footer-copy{text-align:center;padding:8px 16px;font-size:.72rem;color:rgba(255,255,255,.2);border-top:1px solid rgba(255,255,255,.06);line-height:1.6}

.mt-lg{margin-top:24px}
.mt-xs{margin-top:4px}
.icon-xl{font-size:2.5rem;margin-bottom:12px}
.text-sm{font-size:.82em}
.list-compact{margin:.5rem 0;padding-left:1.2rem}
.card-dashed{border-style:dashed}
.card-mt{margin-top:24px}

@media (max-width:820px){.card{padding:12px}.wc-metrics{grid-template-columns:1fr 1fr}table,tbody,tr,td{display:block}table{min-width:0}td::before{content:attr(data-label);font-weight:600}}

:root[data-theme="dark"]{color-scheme:dark;--bg:#05070e;--panel:#111827;--code:#1a2235;--text:#e8edf5;--muted:#7a8db0;--ok:#58d68d;--warn:#f0c050;--bad:#ff6060;--bad-btn:#c0392b;--accent:#e8b04f}

.row.decide{display:flex;gap:16px;align-items:center}

.btn-reject{background:var(--bad-btn);color:#fff;font-size:.8rem}


/* ═══════════════════════════════════════════════════════
   LOGIN PAGE — ZeusVN Brain · Premium Dark
   ═══════════════════════════════════════════════════════ */
.login-scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  padding: 24px 16px;
}

/* Hiệu ứng nền gradient */
.login-scene::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(232,176,79,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(255,106,69,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 50% 10%, rgba(70,224,255,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(30,42,58,0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,42,58,0.4) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
}

.login-glow {
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,176,79,0.12) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
  animation: login-pulse 4s ease-in-out infinite;
}

@keyframes login-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
}

/* Card đăng nhập */
.login-card {
  background: linear-gradient(135deg, rgba(17,24,39,0.95) 0%, rgba(13,17,35,0.98) 100%);
  border: 1px solid rgba(232,176,79,0.2);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  box-shadow:
    0 24px 64px rgba(0,0,0,0.6),
    0 0 0 1px rgba(232,176,79,0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
}

/* Brand trong login */
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.login-logo {
  width: 48px; height: 48px;
  background: var(--grad);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(232,176,79,0.4), var(--glow-gold);
  flex-shrink: 0;
}
.login-logo svg { width: 28px; height: 28px; color: #fff; }

.login-brand-text { display: flex; flex-direction: column; }
.login-brand-name {
  font-size: 1.4rem; font-weight: 800; letter-spacing: 0.06em;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.login-brand-sub {
  font-size: 0.72rem; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 3px;
}

/* Greeting */
.login-greeting {
  margin-bottom: 28px;
}
.login-greeting h1 {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text); margin: 0 0 4px;
}
.login-greeting p {
  font-size: 0.88rem; color: var(--muted);
  margin: 0;
}

/* Form */
.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text2); letter-spacing: 0.02em;
  text-transform: uppercase;
}

.login-input-wrap { position: relative; }
.login-input-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.login-input-wrap input {
  width: 100%; padding: 11px 12px 11px 38px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 0.95rem;
  transition: all 0.2s;
}
.login-input-wrap input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(232,176,79,0.06);
  box-shadow: 0 0 0 3px rgba(232,176,79,0.12);
}
.login-input-wrap input::placeholder { color: var(--muted2); }

/* Demo badge */
.login-demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(232,176,79,0.12);
  border: 1px solid rgba(232,176,79,0.3);
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; color: var(--gold);
  margin-bottom: 8px;
}
.login-demo-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Nút đăng nhập */
.login-submit {
  margin-top: 8px;
  width: 100%;
  padding: 13px;
  background: var(--grad);
  border: none;
  border-radius: var(--r-sm);
  color: #fff; font: inherit; font-size: 1rem; font-weight: 700;
  cursor: pointer; letter-spacing: 0.02em;
  transition: all 0.25s;
  box-shadow: 0 4px 20px rgba(232,176,79,0.35);
  position: relative; overflow: hidden;
}
.login-submit::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,0.1), transparent);
  pointer-events: none;
}
.login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(232,176,79,0.5);
}
.login-submit:active { transform: translateY(0); }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Alert messages */
.login-alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.login-alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.login-alert.warn { background: var(--warn-soft); border: 1px solid rgba(240,192,80,0.3); color: var(--warn); }
.login-alert.bad  { background: var(--bad-soft);  border: 1px solid rgba(255,96,96,0.3);  color: var(--bad); }
.login-alert.ok   { background: var(--ok-soft);   border: 1px solid rgba(88,214,141,0.3); color: var(--ok); }

/* Footer nhỏ */
.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.78rem; color: var(--muted2);
}
.login-footer a { color: var(--muted); }
.login-footer a:hover { color: var(--gold); }

/* ─── STATUS BAR ─── */
.statusbar {
  display: flex; align-items: center; gap: 6px;
  flex: 1; overflow: hidden;
}
.sb-health {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.sb-health .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}
.h-OK, .h-NORMAL  { color: var(--ok); border-color: rgba(88,214,141,0.25); background: var(--ok-soft); }
.h-DEGRADED, .h-PRESSURE, .h-WARN { color: var(--warn); border-color: rgba(240,192,80,0.25); background: var(--warn-soft); }
.h-CRITICAL, .h-BAD { color: var(--bad); border-color: rgba(255,96,96,0.25); background: var(--bad-soft); }
.h-UNKNOWN { color: var(--muted); border-color: var(--border2); background: var(--code); }

.sb-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  font-size: 0.74rem; color: var(--text2);
  text-decoration: none; white-space: nowrap;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.sb-chip:hover { border-color: var(--border2); color: var(--text); }
.sb-chip .k { color: var(--muted); margin-right: 2px; }
.sb-chip .v { font-weight: 600; }
.sb-chip.sb-attn { color: var(--warn); }
.sb-chip.sb-bad  { color: var(--bad); }
.sb-opt { opacity: 0.7; }
.sb-age { font-size: 0.7rem; color: var(--muted2); margin-left: auto; }

/* ─── CTA ZB button ─── */
.cta-zb {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--grad);
  border-radius: var(--r-sm);
  color: #fff;
  text-decoration: none;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(232,176,79,0.3);
}
.cta-zb:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(232,176,79,0.5);
  color: #fff;
}
.cta-zb svg { width: 18px; height: 18px; }

/* ─── DEMO BANNER ─── */
.demo-bar {
  background: linear-gradient(90deg, rgba(232,176,79,0.15) 0%, rgba(255,106,69,0.1) 100%);
  border-bottom: 1px solid rgba(232,176,79,0.25);
  text-align: center;
  padding: 6px 16px;
  font-size: 0.8rem; color: var(--gold);
  font-weight: 500;
}
.has-demo .zb-sidebar { top: calc(var(--topbar-h) + 32px) !important; }
body.has-demo .side{top:87px}  /* biểu ngữ dữ liệu mẫu 32px đẩy thanh trên xuống: ngăn kéo không được bị thanh trên che mục đầu */

/* 16/10: chip AI ở thanh đầu trang (Owner Mode, trang không phải khung chat) — cùng kiểu với khung chat /wb */
.statusbar .ws-ai { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--ws-line2, var(--line, #334)); background: var(--ws-card, transparent); color: var(--text2, inherit); font-size: .8rem; text-decoration: none; white-space: nowrap; min-width: 0; overflow: hidden; max-width: 60%; }
.statusbar .ws-ai-k { font-weight: 800; }
.statusbar .ws-ai-l.ok { color: var(--d-ok, #3fb950); }
.statusbar .ws-ai-l.no { color: var(--muted, #8b949e); }
.statusbar .ws-ai-l.no .ws-ai-why { color: var(--d-warn, #d29922); }
.statusbar .ws-ai.ai-bad { border-color: var(--d-bad, #f85149); }
@media (max-width: 819px) { .statusbar .ws-ai .ws-ai-l.no, .statusbar .ws-ai .ws-ai-sep { display: none; } .statusbar .ws-ai { max-width: none; } }
.sv-budget { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.sv-budget input[name="daily_tokens"] { width: 9em; min-height: 32px; }
.sk-inl { display: inline; }
/* 19/10: gợi ý ngôn ngữ theo trình duyệt (không tự đổi) — nút nhỏ cạnh bộ chọn */
.lp-hint { display: inline-block; margin-left: .35rem; }
.lp-hint button { font-size: .78rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line, rgba(127,127,127,.35)); background: transparent; color: inherit; cursor: pointer; }

/* 19/10 bước hiểu: «Em hiểu là: …» + sửa ý + đáp án bấm được */
.ws-und { margin-top: 2px; }
.ws-und-line .ws-mt { white-space: normal; text-align: right; }
.ws-und-plan { margin: 2px 0 0; padding-left: 1.2em; font-size: .85em; color: var(--muted, #667); text-align: left; }
.ws-und-fix { font-size: .82em; text-align: right; }
.ws-und-fix > summary { cursor: pointer; color: var(--muted, #667); list-style: none; }
.ws-und-form, .ws-und-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.ws-und-opts { justify-content: flex-start; }
.ws-und-chip, .ws-und-opt { min-height: 36px; padding: 6px 12px; border-radius: 18px; font-size: .9em; }
/* 19/10 câu hỏi lại kiểu AskUserQuestion */
.ws-und-ask { margin-top: 8px; display: grid; gap: 6px; }
.ws-und-opts { flex-direction: column; align-items: stretch; }
.ws-und-opt { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-height: 44px; padding: 8px 12px; border-radius: 10px; width: 100%;
  background: var(--panel2, var(--panel, transparent)); color: var(--text, inherit); border: 1px solid var(--border, var(--line, #ccd)); font: inherit; cursor: pointer; }
.ws-und-opt:hover, .ws-und-opt:focus-visible { border-color: var(--accent, #2b6cb0); outline: 2px solid var(--accent, #2b6cb0); outline-offset: 1px; }
.ws-und-opt.is-pre { border: 2px solid var(--accent, #2b6cb0); }
.ws-und-opt.is-ok { border: 2px solid var(--ok, #2f855a); }
.ws-und-l { font-weight: 600; }
.ws-und-d { font-size: .85em; color: var(--text2, var(--muted, #667)); font-weight: 400; }
.ws-und-chk { flex-direction: row; gap: 8px; align-items: center; flex-wrap: wrap; border: 1px solid var(--line, #dde); }
.ws-und-chk .ws-und-d { flex-basis: 100%; }
.ws-und-other > summary { cursor: pointer; color: var(--muted, #667); min-height: 32px; }
.ws-und-otherf { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ws-und-otherf input[name="other"] { flex: 1 1 200px; min-height: 40px; }
.ws-und-where { margin-left: 6px; }
@media (min-width: 640px) { .ws-und-opts { flex-direction: row; flex-wrap: wrap; } .ws-und-opt { width: auto; max-width: 48%; } }
/* 27/10 xin máy riêng: chọn hệ điều hành + cấu hình (_pv_ask_choice.html) */
.pv-pick{border:0;padding:0;margin:0 0 .6rem;display:flex;flex-wrap:wrap;gap:.4rem}
.pv-pick legend{font-weight:600;margin-bottom:.3rem;padding:0}
.pv-pick label{display:inline-flex;align-items:center;gap:.35rem;padding:.35rem .7rem;border:1px solid var(--line,#d0d0d0);border-radius:999px;cursor:pointer}
.pv-pick label:has(input:checked){border-color:var(--accent,#c0392b);background:color-mix(in srgb,var(--accent,#c0392b) 8%,transparent)}
.pv-ask-form:has(input[name=os][value=windows]:checked) label:has(input[name=cfg][value=nhe]){display:none}
/* 28/10 nhiều máy mỗi người: danh sách máy (nhãn hệ điều hành + cỡ) + «Xin thêm máy» */
.pv-list{display:flex;flex-wrap:wrap;gap:6px;margin:.4rem 0}
.pv-list .pv-mc{display:inline-flex;align-items:center;flex-wrap:wrap;gap:.35rem;max-width:100%;white-space:normal;text-align:left}
.pv-list .pv-mc .muted{color:inherit;opacity:.8}
.pv-list .is-wait{opacity:.7;cursor:default}
.pv-more{margin:.5rem 0}
.pv-more>summary{list-style:none;display:inline-flex;align-items:center;gap:.35rem;cursor:pointer}
.pv-more>summary::-webkit-details-marker{display:none}
.pv-more[open]>form{margin-top:.6rem}
