:root {
  --bg: #0B0E14;
  --bg-panel: #12161F;
  --bg-panel-2: #171C28;
  --bg-elevated: #1D2330;
  --border: #262C3B;
  --border-soft: #1E2430;
  --text: #E7EAF0;
  --text-dim: #8891A4;
  --text-faint: #545D71;

  /* Brand / primary actions — indigo, kept separate from status colors */
  --accent: #6D6BFF;
  --accent-dim: #524FE0;
  --accent-strong: #8583FF;
  --accent-glow: rgba(109, 107, 255, 0.20);
  --accent-contrast: #0B0A2E;

  /* Secondary accent — cyan, used for info / secondary highlights */
  --accent-2: #22D3EE;
  --accent-2-dim: rgba(34, 211, 238, 0.15);

  /* Status colors — each hue is unique so state is readable at a glance */
  --ok: #2FD97F;
  --ok-dim: rgba(47, 217, 127, 0.15);
  --ok-contrast: #042013;

  --warn: #FDB833;
  --warn-dim: rgba(253, 184, 51, 0.16);
  --warn-contrast: #2B1B00;

  --danger: #FF5C7A;
  --danger-dim: rgba(255, 92, 122, 0.16);
  --danger-contrast: #2B0611;

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

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

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(109, 107, 255, 0.08), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(34, 211, 238, 0.05), transparent 45%);
  background-attachment: fixed;
}

::selection { background: var(--accent-glow); color: var(--text); }

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

button { font-family: var(--font-body); cursor: pointer; }
input, textarea, select { font-family: var(--font-body); }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black 10%, transparent 75%);
  opacity: 0.6;
}

.login-card {
  position: relative;
  width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-brand .dot-grid { display: flex; gap: 4px; }
.login-brand .dot-grid span { width: 7px; height: 7px; border-radius: 2px; background: var(--border); }
.login-brand .dot-grid span:nth-child(1),
.login-brand .dot-grid span:nth-child(4) { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.login-brand h1 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: 0.2px; margin: 0; }

.login-card h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.login-card p.sub { color: var(--text-dim); margin: 0 0 26px; font-size: 13px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 7px; letter-spacing: 0.3px; }
/* Gộp select vào cùng khai báo với input: trước đây chỉ có `.field input` nên 2 ô
   <select> "Cổng SSH" (modal Thêm VPS và modal Chuyển VPS) rơi về giao diện mặc định
   của trình duyệt — nền trắng, bo góc vuông, lệch chiều cao — nằm ngay cạnh các ô
   input đã style nên nhìn như bị lỗi. Để chung một chỗ thì sau này không lệch nữa. */
.field input,
.field select {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus { border-color: var(--accent-dim); }

/* Bỏ mũi tên mặc định của hệ điều hành rồi tự vẽ lại, nếu không trên Windows/Linux nó
   vẫn là nút xám nổi khối chẳng ăn nhập gì với theme tối. Chừa padding phải cho mũi tên. */
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%238891A4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
/* Danh sách xổ ra do hệ điều hành vẽ — ép màu để không bị chữ trắng trên nền trắng. */
.field select option { background: var(--bg-panel-2); color: var(--text); }

.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; font-size: 12.5px; color: var(--text-dim); }
.check-row input { accent-color: var(--accent); }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2px;
  box-shadow: 0 6px 18px rgba(109, 107, 255, 0.3);
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 8px 22px rgba(109, 107, 255, 0.42); }
.btn-primary:active { transform: scale(0.99); }

.login-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239, 90, 90, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 26px; }
.brand .dot-grid { display: flex; gap: 4px; }
.brand .dot-grid span { width: 7px; height: 7px; border-radius: 2px; background: var(--border); }
.brand .dot-grid span:nth-child(1),
.brand .dot-grid span:nth-child(4) { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.brand h1 { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; margin: 0; }

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 14px 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-panel-2); color: var(--text); }
.nav-item.active { background: var(--bg-elevated); color: var(--text); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  flex-shrink: 0;
}
.nav-item.active .nav-badge { background: var(--accent); color: #fff; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border-soft); }

.fleet-mini {
  padding: 12px 10px;
  background: var(--bg-panel-2);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.fleet-mini strong { color: var(--text); font-family: var(--font-mono); }

.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

/* ---------- Main content ---------- */
.main { padding: 26px 34px 60px; max-width: 1600px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 20px; }
.topbar h2 { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }
.topbar p { color: var(--text-dim); margin: 0; font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--text-faint); background: var(--bg-elevated); }
.btn:active { transform: scale(0.98); }
.btn svg { width: 14px; height: 14px; }

/* Primary action — solid indigo, the one color reserved for "main" actions */
.btn-accent {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
  color: #FFFFFF;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(109, 107, 255, 0.28);
}
.btn-accent:hover { filter: brightness(1.1); box-shadow: 0 5px 16px rgba(109, 107, 255, 0.4); }

/* Secondary / info action — cyan, visually distinct from primary indigo */
.btn-secondary {
  background: var(--accent-2-dim);
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.35);
  font-weight: 600;
}
.btn-secondary:hover { border-color: var(--accent-2); background: rgba(34, 211, 238, 0.22); }

/* Success action — green, reserved for confirm/positive actions */
.btn-success {
  background: var(--ok-dim);
  color: var(--ok);
  border-color: rgba(47, 217, 127, 0.35);
  font-weight: 600;
}
.btn-success:hover { border-color: var(--ok); background: rgba(47, 217, 127, 0.22); }

/* Destructive action — red, tinted by default so it reads as "dangerous" at rest, not just on hover */
.btn-danger-ghost {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(255, 92, 122, 0.35);
  font-weight: 600;
}
.btn-danger-ghost:hover { border-color: var(--danger); background: rgba(255, 92, 122, 0.24); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .label { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; }
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warn { color: var(--warn); }

/* ---------- Fleet grid (signature element) ---------- */
.fleet-grid-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.fleet-grid-title { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.fleet-grid-legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.online { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-dim); }
.legend-dot.offline { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-dim); }
.legend-dot.pending { background: var(--text-faint); box-shadow: 0 0 0 2px var(--bg-elevated); }

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 26px;
}
.fleet-cell {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 8px; border-radius: 6px;
  background: var(--bg-elevated); position: relative; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-dim);
  overflow: hidden; transition: transform 0.1s, box-shadow 0.15s;
}
.fleet-cell .fleet-cell-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fleet-cell:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.fleet-cell::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--text-faint);
}
.fleet-cell.online { background: var(--ok-dim); box-shadow: inset 0 0 0 1.5px var(--ok); color: var(--ok); }
.fleet-cell.online::before { background: var(--ok); animation: pulse-cell 2.4s ease-in-out infinite; }
.fleet-cell.offline { background: var(--danger-dim); box-shadow: inset 0 0 0 1.5px var(--danger); color: var(--danger); }
.fleet-cell.offline::before { background: var(--danger); }
.fleet-cell.pending { background: var(--bg-elevated); color: var(--text-faint); }
.fleet-cell.pending::before { background: var(--text-faint); }

@keyframes pulse-cell { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px;
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 13px; color: var(--text); font-size: 13px; outline: none;
}
.search-input:focus { border-color: var(--accent-dim); }
select.filter-select {
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--text-dim); font-size: 13px; outline: none;
}

/* ---------- VPS table ---------- */
.vps-table-wrap { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.vps-table { width: 100%; border-collapse: collapse; }
table.vps-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-faint); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-panel-2);
}
table.vps-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
table.vps-table tbody tr:last-child td { border-bottom: none; }
table.vps-table tbody tr:hover { background: var(--bg-panel-2); }

.vps-name { font-weight: 600; }
.vps-host { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }

/* ---------- Sap xep bang VPS (bam vao header de sort) ---------- */
table.vps-table thead th[data-sort] { cursor: pointer; user-select: none; transition: color 0.12s; }
table.vps-table thead th[data-sort]:hover { color: var(--text-dim); }
table.vps-table thead th[data-sort].sorted { color: var(--accent-2); }
table.vps-table thead th[data-sort] .sort-arrow { display: inline-block; font-size: 9px; margin-left: 2px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.online { background: var(--ok-dim); color: var(--ok); }
.status-pill.online .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-pill.offline { background: var(--danger-dim); color: var(--danger); }
.status-pill.offline .dot { background: var(--danger); }
.status-pill.pending { background: var(--bg-elevated); color: var(--text-faint); }
.status-pill.pending .dot { background: var(--text-faint); }

.service-chip {
  display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 10.5px; font-family: var(--font-mono);
  margin: 1px 3px 1px 0; background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border);
}
.service-chip.active { color: var(--ok); border-color: rgba(47, 217, 127, 0.3); }
.service-chip.inactive { color: var(--danger); border-color: rgba(255, 92, 122, 0.3); }

.provider-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px;
  border: 1px solid var(--border-soft); border-radius: 999px; background: var(--bg-panel-2);
  color: var(--text-dim); font-size: 11.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.provider-badge:hover { color: var(--text); border-color: var(--border); }
.provider-badge img { width: 16px; height: 16px; object-fit: contain; border-radius: 3px; }
.provider-badge.bkns { border-color: rgba(239, 68, 68, 0.28); }
.provider-badge.cloudfly { border-color: rgba(14, 165, 233, 0.28); }
.provider-package-cell {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.vps-package-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 48px;
  padding: 5px 8px; border-radius: 999px; border: 1px solid transparent;
  font-size: 10.5px; line-height: 1; font-weight: 800; letter-spacing: .25px; white-space: nowrap;
}
.vps-package-badge.v1 { color: #c4b5fd; background: rgba(124, 58, 237, .13); border-color: rgba(167, 139, 250, .42); }
.vps-package-badge.v2 { color: #fcd34d; background: rgba(245, 158, 11, .13); border-color: rgba(251, 191, 36, .42); }

.expired-info-card {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(239, 68, 68, .28);
  border-radius: 12px;
  background: rgba(239, 68, 68, .07);
  color: var(--text-muted);
}
.expired-info-card strong { color: #ef4444; white-space: nowrap; }
.muted { color: var(--text-faint); font-size: 12px; }

/* ---------- Row actions (table row / cell button groups) ---------- */
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Base icon button — visible tint at rest, not only on hover */
.icon-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  transition: border-color 0.12s, color 0.12s, background 0.12s, transform 0.12s, box-shadow 0.12s;
}
.icon-btn svg { width: 14px; height: 14px; }

/* Generic hover: lift + glow using whichever color the button already has */
.icon-btn:hover {
  filter: brightness(1.12);
  border-color: currentColor;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}
.icon-btn:active { transform: translateY(0) scale(0.96); }

/* ===== Nút trên thanh công cụ (topbar) ================================
   Cùng vấn đề với hàng VPS: 6 nút gần như đồng phục, hai nút nền đặc
   (Cập nhật tất cả / Thêm VPS) lại giống hệt nhau nên không rõ cái nào là
   việc chính. Ở đây phân 3 mức: primary có nền đặc, ok tô xanh lá nhạt,
   còn lại trung tính. */
.btn-top {
    gap: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 550;
    border-radius: 9px;
    white-space: nowrap;
}
.btn-top i { font-size: 13px; opacity: 0.9; }
.btn-top:hover {
    border-color: var(--text-faint);
    background: var(--bg-elevated);
    transform: translateY(-1px);
}
.btn-top:hover i { opacity: 1; }
.btn-top:active { transform: translateY(0) scale(0.985); }

.btn-top--primary {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(109, 107, 255, 0.30);
}
.btn-top--primary:hover {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
    filter: brightness(1.08);
    box-shadow: 0 5px 16px rgba(109, 107, 255, 0.42);
}
.btn-top--primary i { opacity: 1; }

.btn-top--ok { color: #0f9d58; border-color: rgba(15,157,88,0.32); background: rgba(15,157,88,0.06); }
.btn-top--ok:hover { background: rgba(15,157,88,0.13); border-color: rgba(15,157,88,0.55); }

/* Nút đang chạy: khoá tương tác + icon quay, khỏi phải đổi chữ thành
   "Đang chạy..." rồi lệch chiều rộng cả hàng. */
.btn-top[disabled], .btn-row[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-top[disabled] i.fa-spin, .btn-row[disabled] i.fa-spin { opacity: 1; }

@media (max-width: 1200px) {
    .topbar-actions .btn-top { padding: 8px 12px; font-size: 12.5px; }
}

/* ===== Nút thao tác trên hàng VPS =====================================
   Trước đây 7 nút dùng chung .btn nên gần như đồng phục: cùng nền, cùng
   viền, chỉ khác chữ — mắt phải ĐỌC mới biết bấm cái nào, và nút Xóa nguy
   hiểm lại nằm ngang hàng với Chi tiết vô hại.

   Cách phân cấp ở đây:
   - Deploy (primary): nền đặc, nổi nhất, đây là hành động chính.
   - Update / Chi tiết / Xóa: chỉ tô MÀU CHỮ + VIỀN NHẠT, không nền đặc —
     đủ để phân biệt mà không tranh chú ý với Deploy.
   - Copy SSH / Chuyển VPS / Sửa: trung tính, dùng ít nhất.
   Icon đặt trước chữ để nhận dạng bằng hình trước khi phải đọc. */
.btn-row {
    gap: 6px;
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.2;
    border-radius: 8px;
    white-space: nowrap;
}
.btn-row i {
    font-size: 12px;
    width: 13px;              /* cố định để chữ các nút thẳng hàng nhau */
    text-align: center;
    opacity: 0.85;
}
.btn-row:hover i { opacity: 1; }
.btn-row:hover {
    border-color: var(--text-faint);
    background: var(--bg-elevated);
    transform: translateY(-1px);
}
.btn-row:active { transform: translateY(0) scale(0.98); }

/* Hành động chính — nút duy nhất có nền đặc trong hàng */
.btn-row--primary {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(109, 107, 255, 0.30);
}
.btn-row--primary:hover {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent-dim));
    filter: brightness(1.08);
    box-shadow: 0 4px 14px rgba(109, 107, 255, 0.42);
}
.btn-row--primary i { opacity: 1; }

/* Các mức còn lại: tô màu chữ + viền, nền rất nhạt */
.btn-row--info   { color: var(--accent-2); border-color: rgba(14,140,147,0.32); background: rgba(14,140,147,0.06); }
.btn-row--info:hover   { background: rgba(14,140,147,0.13); border-color: rgba(14,140,147,0.55); }
.btn-row--ok     { color: #0f9d58; border-color: rgba(15,157,88,0.32);  background: rgba(15,157,88,0.06); }
.btn-row--ok:hover     { background: rgba(15,157,88,0.13);  border-color: rgba(15,157,88,0.55); }
.btn-row--danger { color: var(--danger); border-color: rgba(220,38,38,0.28); background: rgba(220,38,38,0.05); }
.btn-row--danger:hover { background: rgba(220,38,38,0.12); border-color: rgba(220,38,38,0.5); }

/* Ba sắc còn lại — mỗi nút một màu để không nút nào trơ trắng.
   Vẫn là kiểu "tô chữ + viền", chỉ Deploy mới có nền đặc. */
.btn-row--violet, .btn-top--violet { color: #a78bfa; border-color: rgba(167,139,250,0.35); background: rgba(167,139,250,0.08); }
.btn-row--violet:hover, .btn-top--violet:hover { background: rgba(167,139,250,0.16); border-color: rgba(167,139,250,0.6); }
.btn-row--amber,  .btn-top--amber  { color: #fbbf24; border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.08); }
.btn-row--amber:hover,  .btn-top--amber:hover  { background: rgba(251,191,36,0.16); border-color: rgba(251,191,36,0.6); }
.btn-row--rose, .btn-top--rose { color: #f472b6; border-color: rgba(244,114,182,0.40); background: rgba(244,114,182,0.09); }
.btn-row--rose:hover, .btn-top--rose:hover { background: rgba(244,114,182,0.18); border-color: rgba(244,114,182,0.68); }
/* "Cập nhật tất cả" và "Thêm VPS" đều là hành động chính nhưng KHÁC loại:
   một cái đẩy source lên hàng loạt VPS, một cái tạo bản ghi mới. Để cùng xanh
   dương đặc thì nhìn như hai nút giống nhau. Tách: cập nhật = lục đặc (đồng bộ
   với nhóm Update/Lên lịch vốn đã là lục), thêm mới = xanh dương đặc. */
.btn-top--solid-ok {
    background: linear-gradient(135deg, #16a34a, #0f9d58);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.30);
}
.btn-top--solid-ok:hover {
    background: linear-gradient(135deg, #16a34a, #0f9d58);
    filter: brightness(1.08);
    box-shadow: 0 5px 16px rgba(22, 163, 74, 0.42);
}
.btn-top--solid-ok i { opacity: 1; }

.btn-top--cyan { color: var(--accent-2); border-color: rgba(34,211,238,0.35); background: rgba(34,211,238,0.08); }
.btn-top--cyan:hover { background: rgba(34,211,238,0.16); border-color: rgba(34,211,238,0.6); }

/* Màn hình hẹp: giấu chữ, chỉ còn icon — 7 nút x chữ dài làm vỡ hàng.
   Vẫn giữ title nên rê chuột là biết nút gì. */
@media (max-width: 1500px) {
    .row-actions .btn-row span { display: none; }
    .row-actions .btn-row { padding: 7px 9px; }
    .row-actions .btn-row i { width: auto; }
}

/* Semantic colors by action, visible by default (row-actions groups: VPS row, proxy row) */
.icon-btn[data-action="open"],
.icon-btn[data-action="open-vps"],
.icon-btn[data-action="copy"],
.icon-btn[data-action="copy-curl"] {
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.35);
  background: var(--accent-2-dim);
}

.icon-btn[data-action="update"],
.icon-btn[data-action="edit"],
.icon-btn[data-action="restart"] {
  color: var(--accent-strong);
  border-color: rgba(109, 107, 255, 0.4);
  background: var(--accent-glow);
}

.icon-btn[data-action="deploy"],
.icon-btn[data-action="start"] {
  color: var(--ok);
  border-color: rgba(47, 217, 127, 0.35);
  background: var(--ok-dim);
}

.icon-btn[data-action="refresh-expiry"],
.icon-btn[data-action="stop"] {
  color: var(--warn);
  border-color: rgba(253, 184, 51, 0.35);
  background: var(--warn-dim);
}

.icon-btn.danger,
.icon-btn[data-action="delete"] {
  color: var(--danger);
  border-color: rgba(255, 92, 122, 0.35);
  background: var(--danger-dim);
}
.icon-btn.danger:hover { box-shadow: 0 3px 10px rgba(255, 92, 122, 0.25); }

/* ---------- Nut mau rieng biet o trang "Proxy đã tạo" (proxyListTableBody) ---------- */
/* HTTP — cyan (giong bo mau "secondary/info" mac dinh) */
#proxyListTableBody [data-action="copy-http"] {
  background: var(--accent-2-dim);
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.4);
}
#proxyListTableBody [data-action="copy-http"]:hover { border-color: var(--accent-2); background: rgba(34, 211, 238, 0.24); }

/* SOCKS5 — xanh la (success) */
#proxyListTableBody [data-action="copy-socks"] {
  background: var(--ok-dim);
  color: var(--ok);
  border-color: rgba(47, 217, 127, 0.4);
}
#proxyListTableBody [data-action="copy-socks"]:hover { border-color: var(--ok); background: rgba(47, 217, 127, 0.24); }

/* Copy lenh curl test — vang/cam (warn) */
#proxyListTableBody .icon-btn[data-action="copy-curl"] {
  color: var(--warn);
  border-color: rgba(253, 184, 51, 0.4);
  background: var(--warn-dim);
}

/* Xem chi tiet VPS — tim/indigo (accent) */
#proxyListTableBody .icon-btn[data-action="open-vps"] {
  color: var(--accent-strong);
  border-color: rgba(109, 107, 255, 0.4);
  background: var(--accent-glow);
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state h3 { font-family: var(--font-display); color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 7, 11, 0.7); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  width: 480px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 30px 80px rgba(0,0,0,0.55);
}
.modal.modal-wide { width: 900px; }
.modal.modal-xl {
  width: 70vw;
  max-width: 70vw;
}

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 16px; }
.modal-close {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-dim);
  border: 1px solid var(--border); background: var(--bg-elevated);
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.modal-close svg { width: 15px; height: 15px; }
.modal-close:hover { background: var(--danger-dim); border-color: rgba(255, 92, 122, 0.4); color: var(--danger); }

.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }
.field-hint strong { color: var(--text-dim); }

textarea.field-textarea {
  width: 100%; background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; color: var(--text); font-size: 13px; font-family: var(--font-mono); resize: vertical; min-height: 70px; outline: none;
}
textarea.field-textarea:focus { border-color: var(--accent-dim); }

/* ---------- Detail / workspace layout ---------- */

/* Modal chi tiết VPS (tabs: Trạng thái/Quản lý file/Info/Terminal/Proxy) tự
   quản lý cuộn bên trong từng phần (tab-panel), nên bỏ overflow-y:auto của
   .modal chung để tránh cả modal (kể cả cột thư mục + thanh toolbar) bị
   cuốn theo khi nội dung file dài — chỉ vùng nội dung file mới được cuộn. */
#detailModalOverlay .modal.modal-xl { overflow: hidden; }
#bulkExecModalOverlay .modal { overflow: hidden; }
#tabFiles { overflow: hidden; }

.workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 7fr); gap: 0; height: 100%; min-height: 0; }

/* Cột danh mục thư mục: luôn cố định vị trí, tự cuộn riêng bên trong khi
   danh sách file dài hơn chiều cao khung */
.file-tree-panel { border-right: 1px solid var(--border-soft); overflow-y: auto; padding: 12px 10px; min-height: 0; scrollbar-gutter: stable; }
.file-tree-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; position: sticky; top: 0; z-index: 2; background: var(--bg-panel); }
.file-tree-path { min-width: 0; flex: 1; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); padding: 7px 8px; border: 1px solid var(--border-soft); border-radius: 6px; background: var(--bg-panel-2); outline: none; }
.file-tree-path:focus { border-color: var(--accent); color: var(--text); }
.file-tree-refresh { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; justify-content: center; }
.file-tree-refresh svg { width: 15px; height: 15px; }

/* File = màu trung tính, chữ thường. Thư mục = màu vàng hổ phách, đậm hơn, để tách bạch rõ với file ngay từ cái nhìn đầu */
.file-tree-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; border: 1px solid transparent; }
.file-tree-item:hover { background: var(--bg-panel-2); color: var(--text); border-color: var(--border-soft); }
.file-tree-item.selected { background: var(--accent-2-dim); color: var(--accent-2); border-color: rgba(34, 211, 238, 0.35); font-weight: 600; }

.file-tree-item[data-isdir="true"] { color: var(--warn); font-weight: 600; }
.file-tree-item[data-isdir="true"]:hover { background: var(--warn-dim); color: var(--warn); border-color: rgba(253, 184, 51, 0.35); }
.file-tree-item[data-isdir="true"].selected { background: var(--warn-dim); color: var(--warn); border-color: rgba(253, 184, 51, 0.45); }

.file-tree-item[data-isdir="false"] { color: var(--text-dim); font-weight: 400; }

.file-tree-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.file-icon-badge-text { font-family: var(--font-mono), monospace; }

/* Cột editor: toolbar luôn cố định trên đầu (không co giãn), chỉ phần nội
   dung file (CodeMirror hoặc textarea dự phòng) mới cuộn riêng bên trong */
.editor-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.editor-toolbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); gap: 10px; }
.editor-toolbar .file-path { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.CodeMirror { flex: 1; height: 100% !important; min-height: 0; font-family: var(--font-mono) !important; font-size: 12.5px !important; }
/* Vung cuon that su nam trong .CodeMirror-scroll — danh scrollbar-gutter o
   day de thanh cuon khong de/chan mat chu cuoi dong */
.CodeMirror-scroll { scrollbar-gutter: stable; }

/* Textarea du phong (khi CodeMirror khong tai duoc) cung tu cuon rieng */
#fileEditor { min-height: 0; scrollbar-gutter: stable; }


.editor-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 13px; flex-direction: column; gap: 10px; }

/* ---------- Terminal / exec panel ---------- */
.exec-toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.lang-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.lang-toggle button { background: var(--bg-panel-2); border: none; color: var(--text-dim); padding: 7px 14px; font-size: 12.5px; }
.lang-toggle button.active { background: var(--accent); color: #FFFFFF; font-weight: 600; }

.sudo-toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.sudo-toggle input { accent-color: var(--warn); }

.terminal-output {
  flex: 1; background: #05070B; font-family: var(--font-mono); font-size: 12.5px; padding: 14px 16px;
  overflow-y: auto; white-space: pre-wrap; word-break: break-word; color: #7FF0B0; line-height: 1.55;
}
.terminal-output .line-stderr { color: var(--danger); }
.terminal-output .line-meta { color: var(--text-faint); }
.terminal-output .line-cmd { color: var(--accent); }

/* ---------- Bulk exec: chạy lệnh nhiều VPS cùng lúc ---------- */
.bulk-exec-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--radius-sm);
  font-size: 12.5px; cursor: pointer; color: var(--text-dim);
}
.bulk-exec-item:hover { background: var(--bg-elevated); }
.bulk-exec-item input { accent-color: var(--accent); flex-shrink: 0; }
.bulk-exec-item .name { color: var(--text); font-weight: 600; }
.bulk-exec-item .host { color: var(--text-faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-exec-item .meta { min-width: 0; overflow: hidden; }

.bulk-exec-panel { border-bottom: 1px solid var(--border-soft); }
.bulk-exec-panel:last-child { border-bottom: none; }
.bulk-exec-panel-head {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; user-select: none;
}
.bulk-exec-panel-head .name { font-weight: 600; font-size: 12.5px; color: var(--text); }
.bulk-exec-panel-head .host { font-size: 11.5px; color: var(--text-faint); }
.bulk-exec-panel-head .spacer { flex: 1; }
.bulk-exec-panel-head .caret { color: var(--text-faint); font-size: 11px; transition: transform 0.15s; }
.bulk-exec-panel.collapsed .bulk-exec-panel-head .caret { transform: rotate(-90deg); }
.bulk-exec-panel.collapsed .bulk-exec-panel-body { display: none; }
.bulk-exec-panel-body {
  background: #05070B; font-family: var(--font-mono), monospace; font-size: 12px; color: #7FF0B0;
  padding: 10px 14px; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; line-height: 1.5;
}
.bulk-exec-panel-body .line-stderr { color: var(--danger); }

/* .search-input dùng flex:1 để giãn NGANG trong .toolbar (hàng ngang) - nhưng
   trong sidebar chọn VPS (cột dọc), flex:1 lại khiến nó giãn theo chiều DỌC
   chiếm hết khoảng trống còn lại. Ghi đè về chiều cao tự nhiên (1 dòng). */
.bulk-exec-sidebar .search-input { flex: 0 0 auto; }

.modal.bulk-exec-modal {   width: 70vw;  max-width: 70vw; height: 86vh; max-height: 86vh; }

.xterm-wrap {
  flex: 1;
  background: #05070B;
  /* Chừa thêm khoảng đệm phía dưới bằng ~1 dòng để dòng lệnh đang gõ
     không bao giờ bị dính sát mép / bị cắt khi fitAddon tính số rows. */
  padding: 10px 14px 30px;
  min-height: 0;
  overflow: hidden;
}
.xterm-wrap .terminal.xterm { height: 100%; }

/* CHI style lai giao dien thanh cuon cho de nhin/de bam (to hon, mau accent)
   - KHONG duoc dung z-index/position de doi thu tu lop giua .xterm-viewport
   va .xterm-screen: .xterm-viewport co nen den DAC (opaque) theo mac dinh cua
   xterm.js va von nam DUOI lop .xterm-screen (noi ve chu) nho thu tu DOM tu
   nhien. Neu ep z-index cho viewport len tren se che kin toan bo chu trong
   terminal (da tung xay ra - man hinh den thui, chi con thay thanh cuon). */
.xterm-wrap .xterm-viewport::-webkit-scrollbar { width: 10px; }
.xterm-wrap .xterm-viewport::-webkit-scrollbar-track { background: transparent; }
.xterm-wrap .xterm-viewport::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 8px;
}
.xterm-wrap .xterm-viewport::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.xterm-wrap .xterm-viewport { scrollbar-width: thin; scrollbar-color: var(--accent-dim) transparent; }

.proxy-pass-cell { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; }
.proxy-pass-cell .proxy-pass-value { letter-spacing: 1px; }
.proxy-reveal-btn { background: transparent; border: none; color: var(--accent-2); cursor: pointer; padding: 2px; opacity: 0.85; transition: opacity 0.12s, color 0.12s; }
.proxy-reveal-btn:hover { color: var(--accent-2); opacity: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); padding: 0 16px; }
.tab-btn { background: transparent; border: none; color: var(--text-dim); padding: 12px 4px; font-size: 13px; border-bottom: 2px solid transparent; margin-right: 18px; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; min-width: 220px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); animation: toast-in 0.2s ease-out;
}
.toast.success { border-color: rgba(79,209,197,0.4); }
.toast.error { border-color: rgba(239,90,90,0.4); color: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

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

.metric-bar { height: 5px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.metric-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.metric-bar-fill.warn { background: var(--warn); }
.metric-bar-fill.danger { background: var(--danger); }

.detail-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }

/* ---------- Update tat ca: ket qua chay + lich su job ---------- */
.job-result-list, .job-history-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
}
.job-result-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg-panel-2); border: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.job-result-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.job-result-row.ok .dot { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-dim); }
.job-result-row.fail .dot { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-dim); }
.job-result-row.waiting .dot { background: var(--text-faint); }
.job-result-row.skipped .dot { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-dim); }
.job-result-row.running .dot {
  background: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow);
  animation: pulse-cell 1.2s ease-in-out infinite;
}
.job-result-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.job-result-row .msg { color: var(--text-faint); font-size: 11.5px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.job-history-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: var(--bg-panel-2); border: 1px solid var(--border-soft);
  font-size: 12.5px; color: var(--text-dim);
}
.job-history-row .trigger-chip {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0;
}
.job-history-row .trigger-chip.manual { color: var(--accent-2); background: var(--accent-2-dim); }
.job-history-row .trigger-chip.schedule { color: var(--accent); background: var(--accent-glow); }
.job-history-row .time { flex: 1; color: var(--text); }
.job-history-row .result { font-family: var(--font-mono); font-size: 11.5px; }
.job-history-row .result.ok { color: var(--ok); }
.job-history-row .result.fail { color: var(--danger); }

.schedule-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim);
  padding: 8px 12px; margin-bottom: 16px;
  background: var(--bg-panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
}
.schedule-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.schedule-status.active .schedule-status-dot { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-dim); animation: pulse-cell 2.4s ease-in-out infinite; }
.schedule-status.error .schedule-status-dot { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-dim); }
.schedule-status strong { color: var(--text); }

/* ---------- Cập nhật tất cả: tiến trình realtime từng VPS ---------- */
.update-progress-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 10px;
}
.update-progress-summary > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.update-progress-summary strong { color: var(--text); }
.update-progress-summary span { color: var(--text-faint); font-size: 12px; }
.update-progress-percent { color: var(--accent) !important; font-family: var(--font-mono); font-size: 19px; }
.update-progress-track {
  height: 9px; overflow: hidden; border-radius: 999px; margin-bottom: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
}
.update-progress-fill {
  height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width .3s ease;
}
.update-progress-counts { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.update-progress-counts span {
  padding: 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--bg-panel-2); border: 1px solid var(--border-soft); color: var(--text-dim);
}
.update-progress-counts .running { color: var(--accent); }
.update-progress-counts .ok { color: var(--ok); }
.update-progress-counts .fail { color: var(--danger); }
.update-progress-counts .skipped { color: var(--warn); }
.update-progress-list { max-height: 390px; }
.update-progress-note { margin-right: auto; color: var(--text-faint); font-size: 11.5px; }
.detail-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.metric-box .label { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.metric-box .val { font-family: var(--font-mono); font-size: 16px; font-weight: 600; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .modal.modal-wide, .modal.modal-xl { width: 100%; }
  .workspace { grid-template-columns: 1fr; height: auto; }
}
/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .label { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; }
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warn { color: var(--warn); }

@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MOBILE APP LAYOUT — bố cục chuẩn ứng dụng SaaS trên di động
   Cấu trúc: Topbar cố định (hamburger) → Sidebar drawer trượt
   + overlay → Nội dung full-width, hành động cuộn ngang dạng
   chip, bảng dữ liệu cuộn ngang, modal thành bottom-sheet.
   ============================================================ */

/* ---------- Mobile topbar (chỉ hiển thị trên mobile) ---------- */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 13px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.mobile-menu-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.mobile-menu-btn:active { transform: scale(0.96); }
.mobile-menu-btn svg { width: 18px; height: 18px; }

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.mobile-topbar-brand .dot-grid { display: flex; gap: 4px; }
.mobile-topbar-brand .dot-grid span { width: 6px; height: 6px; border-radius: 2px; background: var(--border); }
.mobile-topbar-brand .dot-grid span:nth-child(1),
.mobile-topbar-brand .dot-grid span:nth-child(4) { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

/* Nút đóng bên trong sidebar — chỉ xuất hiện ở chế độ drawer mobile */
.sidebar-close-btn {
  display: none;
  margin-left: auto;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  color: var(--text-dim);
  flex-shrink: 0;
}
.sidebar-close-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* Lớp phủ tối phía sau drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.6);
  backdrop-filter: blur(1px);
  z-index: 70;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }

  .app-shell { grid-template-columns: 1fr; }

  /* Sidebar -> drawer trượt từ trái, nằm trên overlay */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .brand { padding-right: 2px; }

  /* Nội dung chính chiếm toàn bộ chiều rộng, chừa khoảng cho thanh dưới nếu có */
  .main { padding: 16px 14px 90px; max-width: 100%; }

  /* Topbar: tiêu đề xếp trên, hành động cuộn ngang dạng chip (mẫu chuẩn app SaaS mobile) */
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 18px; }
  .topbar h2 { font-size: 19px; }
  .topbar p { font-size: 12.5px; }
  .topbar-actions,
  #proxyTopbarActions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -14px;
    padding: 0 14px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex-shrink: 0; white-space: nowrap; }

  /* Thẻ thống kê: lưới 2 cột, gọn hơn */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
  .stat-card { padding: 13px 14px; border-radius: 12px; }
  .stat-card .label { font-size: 11px; margin-bottom: 6px; }
  .stat-card .value { font-size: 20px; }

  /* Lưới trạng thái hạm đội: ô nhỏ hơn, khít hơn */
  .fleet-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; padding: 12px; }
  .fleet-cell { height: 30px; font-size: 10.5px; padding: 0 6px; }

  /* Thanh tìm kiếm + lọc: xếp chồng full-width */
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-input { min-width: 0; }
  select.filter-select { width: 100%; }

  /* Bảng dữ liệu: cuộn ngang trong khung bo góc thay vì bóp méo cột */
  .vps-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
  table.vps-table { min-width: 720px; }

  /* Vùng bấm icon lớn hơn cho thao tác chạm */
  .icon-btn { width: 34px; height: 34px; }
  .row-actions { gap: 8px; }

  /* Modal -> bottom sheet full-width, bo góc trên */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal,
  .modal.modal-wide,
  .modal.modal-xl {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .modal.bulk-exec-modal { height: 92vh; max-height: 92vh; }
  .bulk-exec-body { flex-direction: column; overflow-y: auto; }
  .bulk-exec-sidebar { width: 100% !important; flex: 0 0 auto !important; max-height: 180px; }
  .modal-header { padding: 16px 16px 14px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 14px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 120px; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-grid .span-2 { grid-column: span 1; }

  /* Workspace (cây file + editor): xếp chồng, giới hạn chiều cao cây file */
  .workspace { grid-template-columns: 1fr; height: auto; }
  .file-tree-panel { max-height: 170px; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .editor-panel { min-height: 340px; }

  /* Tabs: cuộn ngang thay vì vỡ dòng */
  .tabs { overflow-x: auto; padding: 0 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; margin-right: 16px; }

  .exec-toolbar { padding: 10px 12px; gap: 8px; }
  .detail-header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .detail-metrics { grid-template-columns: repeat(2, 1fr); padding: 14px 16px; gap: 10px; }

  /* Toast: full-width, neo đáy màn hình */
  .toast-wrap { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; width: 100%; }

  /* Trang đăng nhập: chừa lề an toàn trên màn hình hẹp */
  .login-card { width: 100%; max-width: 380px; padding: 30px 22px; margin: 0 16px; }
}

@media (max-width: 380px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .topbar h2 { font-size: 17px; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  .detail-metrics { grid-template-columns: 1fr 1fr; }
}

/* ---------- Debug Zalo ---------- */
.zalo-debug-page {
  display: grid;
  gap: 16px;
}

.zalo-debug-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-panel);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
}

.zalo-debug-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.zalo-debug-card-head h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text);
}

.zalo-debug-card-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.zalo-debug-agent-state {
  flex-shrink: 0;
  padding: 5px 9px;
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 999px;
  background: var(--accent-2-dim);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 600;
}

.zalo-debug-agent-state.is-error {
  border-color: rgba(255, 92, 122, 0.30);
  background: var(--danger-dim);
  color: var(--danger);
}

.zalo-debug-head-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.zalo-debug-send-stats {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(245, 158, 11, .32);
  border-radius: 999px;
  background: rgba(245, 158, 11, .10);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.zalo-debug-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(240px, 1.7fr) minmax(145px, .8fr) minmax(190px, 1fr) 92px auto;
  align-items: end;
  gap: 12px;
  padding: 16px 18px 18px;
}

.zalo-debug-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.zalo-debug-field > span {
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}

.zalo-debug-field input,
.zalo-debug-field select {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  background: var(--bg-panel-2);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.zalo-debug-field input:focus,
.zalo-debug-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-panel);
}

.zalo-debug-field select:disabled {
  cursor: wait;
  opacity: .65;
}

.zalo-debug-field input::placeholder { color: var(--text-faint); }
.zalo-debug-field select option { background: var(--bg-panel); color: var(--text); }
.zalo-debug-lines-field input { text-align: center; font-family: var(--font-mono); }

.zalo-debug-actions {
  display: flex;
  align-items: end;
}

.zalo-debug-actions .btn {
  min-height: 40px;
  white-space: nowrap;
  justify-content: center;
}

.zalo-debug-output {
  min-height: 260px;
  max-height: 65vh;
  margin: 0;
  overflow: auto;
  padding: 16px 18px;
  border: 0;
  background: var(--bg-panel-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

@media (max-width: 1280px) {
  .zalo-debug-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .zalo-debug-actions .btn { width: 100%; }
}

@media (max-width: 720px) {
  .zalo-debug-card-head { align-items: flex-start; padding: 14px; }
  .zalo-debug-toolbar { grid-template-columns: 1fr; padding: 14px; }
  .zalo-debug-agent-state { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .zalo-debug-output { min-height: 220px; max-height: 58vh; padding: 14px; font-size: 11.5px; }
}
