/* Hermes Panel — hệ thiết kế port từ openclaw-control-panel (v2 design).
   Thuần CSS, không build, không tải font/CDN ngoài (VPS LAN có thể không ra net). */

:root {
  /* Brand — ICTSAIGON blue */
  --brand-50: #ebf4ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-400: #60a5fa;
  --brand-500: #1e88e5;
  --brand-600: #0a6bff;
  --brand-700: #0052cc;
  --brand-800: #003a99;
  --brand-900: #0a2540;

  --bg: #f6f9fd;
  --card: #ffffff;
  --ink: #0e1a2b;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;

  --emerald-50: #ecfdf5;
  --emerald-500: #10b981;
  --emerald-700: #047857;
  --amber-50: #fffbeb;
  --amber-500: #f59e0b;
  --amber-700: #b45309;
  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --sand: #f5b82e;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lift: 0 4px 12px rgba(15, 42, 84, .06), 0 2px 4px rgba(15, 42, 84, .04);
  --shadow-brand: 0 8px 24px rgba(10, 107, 255, .22);
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--brand-700); }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--slate-500); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.grow { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Đăng nhập: hero trái + form phải ──────────────────────────── */
.login {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}
.login-hero {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 48px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-800) 55%, var(--brand-900));
}
.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, .08) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, black 30%, transparent 95%);
}
.login-hero > * { position: relative; z-index: 1; }
.hero-brand { display: flex; align-items: center; gap: 14px; font-size: 18px; font-weight: 800; }
.hero-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .85;
}
.hero-title { font-size: 38px; font-weight: 800; line-height: 1.1; margin: 12px 0 14px; }
.hero-title span { color: var(--sand); }
.hero-desc { max-width: 34rem; font-size: 15px; opacity: .9; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 28px; }
.hero-stats b { display: block; font-family: var(--font-mono); font-size: 22px; font-weight: 800; }
.hero-stats span { font-size: 12px; opacity: .85; }

.login-form-wrap {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-form { width: 100%; max-width: 26rem; }
.login-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand-700);
}
.login-form h2 { font-size: 24px; font-weight: 800; margin: 6px 0 4px; }

/* ─── Khung ứng dụng ────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 260px;
  height: 100vh;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--slate-200);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--slate-200);
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  box-shadow: var(--shadow-brand);
  color: #fff;
}
.sidebar-brand .title { font-size: 14px; font-weight: 800; line-height: 1.2; }
.sidebar-brand .ver { font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); }

.nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-section {
  padding: 12px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate-400);
}
/* justify-content + height phải khai báo TƯỜNG MINH: quy tắc `button, .btn` ở
   dưới cũng khớp phần tử này (nav-item là <button>) và sẽ áp center + 38px,
   làm icon/nhãn của mục không có badge bị dồn vào giữa. */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--slate-600);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--slate-50); color: var(--ink); }
.nav-item .ic {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--slate-100);
  color: var(--slate-500);
}
.nav-item.active {
  background: linear-gradient(180deg, var(--brand-50), rgba(235, 244, 255, .4));
  color: var(--brand-700);
  font-weight: 700;
}
.nav-item.active .ic { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-brand); }
.nav-item .badge { margin-left: auto; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
}
.crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--slate-400); min-width: 0; }
.crumb .current { color: var(--ink); font-weight: 700; }
.icon-btn {
  display: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--slate-600);
  cursor: pointer;
}
.icon-btn:hover { background: var(--slate-100); }

.pills { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  background: var(--slate-50);
  font-size: 12px;
  color: var(--slate-600);
  white-space: nowrap;
}
.pill .label { color: var(--slate-400); }
.pill .value { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }
.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--slate-300); box-shadow: 0 0 0 2px var(--slate-200); }
.dot.ok { background: var(--emerald-500); box-shadow: 0 0 0 2px #a7f3d0; }
.dot.warn { background: var(--amber-500); box-shadow: 0 0 0 2px #fde68a; }
.dot.err { background: var(--red-500); box-shadow: 0 0 0 2px #fecaca; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.user-chip:hover { background: var(--slate-100); }
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-500), #22d3ee);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.page { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head p { margin: 4px 0 0; font-size: 14px; color: var(--slate-500); }

/* ─── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
}
.card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--slate-500); }
.card-body { padding: 20px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Meter */
.meter { padding: 20px; background: var(--card); border: 1px solid var(--slate-200); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); }
/* Tiêu đề giữ nguyên một dòng, phần chú thích bên phải co lại + cắt bớt —
   nếu không, ở cột hẹp nhãn bị xuống dòng và đè lên số liệu. */
.meter .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter .top > * { min-width: 0; white-space: nowrap; }
.meter .side { overflow: hidden; text-overflow: ellipsis; text-align: right; }
/* line-height thoáng: chữ hoa tiếng Việt (Ổ, Ứ…) có dấu cao, sát quá sẽ bị cắt. */
.meter .name { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; line-height: 1.7; color: var(--slate-500); }
.meter .side { font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); }
.meter .value { margin-top: 8px; font-family: var(--font-mono); font-size: 19px; font-weight: 800; }
.meter .bar { margin-top: 12px; height: 8px; border-radius: 999px; background: var(--slate-100); overflow: hidden; }
.meter .bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand-600); transition: width .5s ease; }
.meter .bar > i.warn { background: var(--amber-500); }
.meter .bar > i.err { background: var(--red-500); }
.meter .bar > i.ok { background: var(--emerald-500); }

/* ─── Badge / nút / form ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.ok { background: var(--emerald-50); color: var(--emerald-700); }
.badge.warn { background: var(--amber-50); color: var(--amber-700); }
.badge.err { background: var(--red-50); color: var(--red-600); }
.badge.info { background: var(--brand-50); color: var(--brand-700); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--slate-50); }
button:focus-visible, .btn:focus-visible, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 4px var(--brand-100);
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: var(--shadow-brand); }
.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.danger { color: var(--red-600); }
.danger:hover { background: var(--red-50); border-color: #fecaca; }
.tiny { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.wide { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.mt { margin-top: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--slate-600); }
.field .hint { font-size: 12px; color: var(--slate-400); }
input, select, textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}
textarea { height: auto; padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; }
input::placeholder, textarea::placeholder { color: var(--slate-400); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-600); }
.check input { width: auto; height: auto; }

.notice { padding: 10px 12px; border-radius: 10px; background: var(--red-50); color: var(--red-600); font-size: 13px; }
.step-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--slate-300);
  border-radius: var(--radius-lg);
  background: var(--slate-50);
}
.step-box p { margin: 0 0 8px; font-size: 13.5px; }
.step-box p:last-child { margin-bottom: 0; }
.code {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--slate-200);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
}
.qr { display: block; margin: 0 auto; background: #fff; padding: 8px; border: 1px solid var(--slate-200); border-radius: var(--radius); }

/* Hàng dịch vụ */
.svc { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--slate-100); }
.svc:last-child { border-bottom: 0; padding-bottom: 0; }
.svc:first-child { padding-top: 0; }
.svc .name { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.svc .desc { font-size: 12px; color: var(--slate-400); font-family: var(--font-sans); font-weight: 500; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--slate-100); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--slate-500); }
.kv .v { font-family: var(--font-mono); font-weight: 700; text-align: right; word-break: break-all; }

.log {
  margin: 0;
  padding: 14px;
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: var(--brand-900);
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

details summary { cursor: pointer; font-size: 13px; color: var(--slate-500); }
details[open] summary { margin-bottom: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 30rem);
  padding: 12px 18px;
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--brand-600);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-lift);
  font-size: 13.5px;
  font-weight: 600;
}
.toast.ok { border-left-color: var(--emerald-500); }
.toast.err { border-left-color: var(--red-500); }

.backdrop { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(2, 6, 23, .45); }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pills { display: none; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .shell.drawer-open .sidebar { transform: translateX(0); }
  .shell.drawer-open .backdrop { display: block; }
  .icon-btn { display: grid; }
  .page { padding: 16px; }
  .login-hero { display: none; }
  .login-form-wrap { max-width: none; }
}
@media (max-width: 620px) {
  .grid.cols-4, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .hero-title { font-size: 30px; }
}
