/* CODE TELE relay — bố cục gọn theo tool desktop: mọi thứ trong một màn hình,
   phần dài (tài khoản, báo cáo, nhật ký) tự cuộn bên trong thẻ. */
:root {
  color-scheme: dark;
  --bg: #0a101d;
  --panel: #101a2e;
  --panel2: #0c1526;
  --line: #1d2b46;
  --line2: #24344f;
  --text: #dbe6f5;
  --muted: #7f93b3;
  --accent: #0d6efd;
  --ok: #4ade80;
  --warn: #f5c36b;
  --bad: #f87171;
  --info: #38bdf8;
}
* { box-sizing: border-box; }
html { font-family: "Segoe UI", "SF Pro Text", "Noto Sans", Arial, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 13px; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--panel2); }
::-webkit-scrollbar-thumb { background: #2a3c5c; border-radius: 5px; }

/* ---------- Khung chính ---------- */
.dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
  max-width: 1560px;
  margin: 0 auto;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  background: #0d1626;
  border: 1px solid #1c2942;
  border-radius: 10px;
}
.app-title { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .04em; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12px; }
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 700; color: var(--info); margin: 0; }

/* Chip trạng thái — giống StatusChip của tool */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 3px 10px;
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  background: #16233a;
  color: #8fa3c4;
  border: 1px solid #2a3c5c;
}
.chip.ok { background: rgba(34, 197, 94, .14); color: var(--ok); border-color: rgba(34, 197, 94, .45); }
.chip.warn { background: rgba(245, 195, 107, .14); color: var(--warn); border-color: rgba(245, 195, 107, .45); }
.chip.err { background: rgba(248, 113, 113, .14); color: var(--bad); border-color: rgba(248, 113, 113, .45); }
.chip.info { background: rgba(0, 180, 244, .14); color: var(--info); border-color: rgba(0, 180, 244, .45); }

/* Nút bấm — giống QPushButton của tool */
button.primary, button.ghost, button.secondary {
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #2a3c5c;
  background: #16233a;
  color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #2b7dff; border-color: #2b7dff; }
button.ghost { background: transparent; border-color: transparent; color: #8fa3c4; }
button.ghost:hover:not(:disabled) { color: #e6eefc; }
button.secondary:hover:not(:disabled) { background: #1c2c49; border-color: #37507a; }

/* ---------- Dải thống kê ---------- */
.stats-strip {
  display: grid;
  grid-template-columns: 1.7fr 1.1fr 1fr 1fr 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.stat > span { font-size: 11px; color: var(--muted); font-weight: 700; }
.stat strong { font-size: 17px; line-height: 1.15; letter-spacing: -.02em; }
.stat.ok strong { color: var(--ok); }
.stat.bad strong { color: var(--bad); }
.stat em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 5px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line2); overflow: hidden; margin-top: 4px; }
.meter span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .4s; }

/* ---------- Lưới nội dung ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  gap: 10px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-title h2 { font-size: 13px; font-weight: 700; color: #fff; margin: 0; }
.panel-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tài khoản ---------- */
.account-scroll { flex: 1; min-height: 0; overflow: auto; padding: 4px 12px 10px; }
.account-site { padding: 8px 0 10px; }
.account-site + .account-site { border-top: 1px solid var(--line); }
.account-site-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.account-site-head h3 { margin: 0; font-size: 13px; font-weight: 700; color: #fff; }
.account-site-head .site-summary { font-size: 11px; color: var(--muted); }
.account-site-head button { margin-left: auto; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
td { color: var(--text); }
th.cell-center, td.cell-center { text-align: center; }
.account-input {
  width: 140px;
  max-width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  color: #e6edf7;
  padding: 4px 8px;
  outline: none;
}
.account-input:focus { border-color: #00b4f4; }
.proxy-input { width: 160px; }
.row-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid #2a3c5c;
  border-radius: 6px;
  color: #8fa3c4;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
}
.row-remove:hover { color: #fca5a5; border-color: #b91c1c; }
.accounts-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}
.feedback { font-size: 12px; color: var(--ok); min-height: 16px; }
.feedback.error { color: var(--bad); }

/* ---------- Cột phải ---------- */
.side-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.report-card { flex: none; }
.report-card .table-scroll { max-height: 190px; }
.activity-card { flex: none; }
.activity-list { max-height: 132px; overflow: auto; padding: 2px 12px 8px; }
.activity-item { display: flex; gap: 9px; padding: 7px 0; border-top: 1px solid var(--line); }
.activity-item:first-child { border-top: 0; }
.activity-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--ok); flex: none; }
.activity-item.failed .activity-dot { background: var(--bad); }
.activity-item.running .activity-dot { background: var(--warn); }
.activity-copy { min-width: 0; }
.activity-copy p { font-size: 12px; margin: 0 0 2px; line-height: 1.4; overflow-wrap: anywhere; }
.activity-copy span { font-size: 11px; color: var(--muted); }
.log-card { flex: 1; }
.logs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px;
  background: #0a1220;
  font-family: Consolas, "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.6;
}
.log-line { border-bottom: 1px solid #16233a; padding: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #c7d6ee; }
.log-line:last-child { border-bottom: 0; }
.empty { color: var(--muted); font-size: 12px; margin: 8px 0; }

/* ---------- Thanh trạng thái ---------- */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 12px;
  background: #0d1626;
  border: 1px solid #1c2942;
  border-radius: 8px;
  font-size: 12px;
  color: #9fb2d0;
}
.statusbar .feedback { text-align: right; }

/* ---------- Đăng nhập ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(100%, 360px);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.login-card h1 { font-size: 22px; letter-spacing: .08em; margin: 4px 0 0; color: #fff; }
.login-note { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 10px 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 9px; }
.login-card label { font-size: 12px; font-weight: 700; }
.login-card input {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  color: #e6edf7;
  padding: 0 10px;
  outline: none;
}
.login-card input:focus { border-color: #00b4f4; }
.login-card form button { margin-top: 6px; padding: 9px 14px; }
.form-error { color: var(--bad); font-size: 12px; min-height: 16px; margin: 10px 0 0; }

/* ---------- Màn hình hẹp: xếp dọc, trang cuộn tự nhiên ---------- */
@media (max-width: 1080px) {
  .stats-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .dashboard { height: auto; min-height: 100vh; padding: 8px; }
  .layout { grid-template-columns: 1fr; }
  .account-scroll { max-height: 60vh; }
  .logs { min-height: 260px; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .top-actions { width: 100%; }
}
