/* Trang web Boss — biến màu dùng lại từ src/panel/panel.css, bố cục rộng hơn cho màn máy tính, xếp 1 cột ở điện thoại. */
:root {
  --bg: #ffffff; --fg: #111827; --muted: #6b7280; --line: #e5e7eb; --card: #f9fafb;
  --pri: #1d4ed8; --ok: #047857; --warn: #b45309; --err: #b91c1c; --hi: #eef2ff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f172a; --fg: #e5e7eb; --muted: #94a3b8; --line: #1f2937; --card: #111827; --pri: #60a5fa; --ok: #34d399; --warn: #fbbf24; --err: #f87171; --hi: #1e293b; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
body { min-width: 0; overflow-x: hidden; }
a { color: var(--pri); }

/* ---- thanh trên ---- */
header { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 5; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; max-width: 1400px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; text-decoration: none; color: var(--fg); }
#nav { display: flex; gap: 2px; overflow-x: auto; }
#nav a { padding: 6px 10px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
#nav a.active { color: var(--pri); border-bottom-color: var(--pri); font-weight: 600; }
.spacer { flex: 1; }
.rt { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.rt i { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.rt.off i { background: var(--err); animation: blink 1s infinite; }
.rt.off { color: var(--err); }
@keyframes blink { 50% { opacity: .3; } }

main { padding: 14px 16px 80px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 6px 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; min-width: 0; }
.card.hi { background: var(--hi); border-color: var(--pri); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); } .running { color: var(--pri); }
.wrap { overflow-wrap: anywhere; word-break: break-word; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--line); color: var(--fg); white-space: nowrap; vertical-align: middle; }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); } .tag.err { background: color-mix(in srgb, var(--err) 18%, transparent); } .tag.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); } .tag.running { background: color-mix(in srgb, var(--pri) 18%, transparent); }
.tag.gold { background: #fde68a; color: #78350f; }
button, .btn { font: inherit; padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; text-decoration: none; display: inline-block; }
button.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger, .btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.mini { padding: 1px 7px; font-size: 11px; }
button.link { border: 0; background: none; color: var(--pri); padding: 0; text-decoration: underline; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); width: 100%; max-width: 100%; }
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { min-height: 100px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
label.f { display: block; margin-bottom: 8px; min-width: 0; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
pre { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow: auto; font-size: 11.5px; max-height: 260px; white-space: pre-wrap; word-break: break-word; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
/* Bảng dữ liệu rộng hơn khung → cuộn ngang trong .tbl, không bẻ chữ từng ký tự. */
.tbl table { min-width: 560px; }
.tbl.params table { min-width: 0; }
td.wrap { min-width: 140px; }
/* Tên bot/bundle trong bảng: tối đa 2 dòng, đủ chữ ở title. */
td.name { min-width: 140px; max-width: 260px; }
td.name > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--card); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td .tag { white-space: nowrap; }
td.reason { min-width: 160px; max-width: 360px; overflow-wrap: anywhere; }
td.nowrap, th.nowrap { white-space: nowrap; }
tr.hl td { background: var(--hi); }
.log { max-height: 420px; overflow: auto; }
.status { font-weight: 600; }
.approval { border: 2px solid var(--warn); }
.approval img { max-width: 100%; border-radius: 6px; border: 1px solid var(--line); margin-top: 6px; }
.err-box { border: 1px solid var(--err); color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); padding: 8px 10px; border-radius: 6px; }
.warn-box { border: 1px solid var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); padding: 8px 10px; border-radius: 6px; }
.info-box { border: 1px solid var(--pri); background: var(--hi); padding: 8px 10px; border-radius: 6px; }
#toast { position: fixed; left: 12px; right: 12px; bottom: 14px; background: #111827; color: #fff; padding: 10px 12px; border-radius: 8px; z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 640px; margin: 0 auto; overflow-wrap: anywhere; }
#toast.err { background: var(--err); }
#toast.warn { background: var(--warn); }
kbd { font: 11px ui-monospace, monospace; background: var(--line); padding: 1px 5px; border-radius: 4px; }
details summary { cursor: pointer; color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); vertical-align: middle; margin-right: 4px; }
.dot.on { background: var(--ok); } .dot.off { background: var(--err); }

/* ---- đăng nhập ---- */
.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { text-align: center; }

/* ---- bảng bot ---- */
.toolbar { position: sticky; top: 48px; background: var(--bg); padding: 6px 0 8px; z-index: 4; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; align-items: start; }
.bot { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.bot .name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; word-break: break-word; }
.bot.pending { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.bot.offline { opacity: .75; }
.bot .what { min-height: 1.4em; }

/* ---- xem trực tiếp (gói I) ---- */
.live-pick { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.live-pick-item { max-width: 100%; min-width: 0; }
.live-pick-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 10px; align-items: start; }
.live-cell { margin: 0; min-width: 0; }
.live-cell .name { font-weight: 600; }
/* Ảnh không phóng quá kích thước thật (width auto + max-width 100 %), giữ tỉ lệ; khung có nền để thấy chỗ trống khi chưa có hình. */
.live-shot { position: relative; margin-top: 6px; background: var(--line); border-radius: 6px; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.live-shot img { display: block; width: auto; max-width: 100%; height: auto; }
.live-shot img:not([src]) { display: none; }
.live-cell.no-shot img { opacity: .35; }
.live-err { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: var(--err); font-weight: 600; background: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ---- form job ---- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.params td input { padding: 4px 6px; }
.bot-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
.bot-pick label { display: flex; gap: 6px; align-items: center; min-width: 0; }
.bot-pick label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-pick label.locked { opacity: .55; cursor: not-allowed; }

/* ---- hộp thoại ---- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.modal { background: var(--bg); color: var(--fg); border-radius: 10px; padding: 16px 18px; max-width: 480px; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 8px; text-transform: none; letter-spacing: 0; color: var(--fg); font-size: 16px; }
.code { font: 700 28px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; padding: 10px; background: var(--card); border-radius: 8px; }
.code.sm { font-size: 16px; letter-spacing: .08em; overflow-wrap: anywhere; word-break: break-all; }
.banner { background: color-mix(in srgb, var(--warn) 22%, transparent); border-bottom: 1px solid var(--warn); padding: 8px 16px; font-size: 13px; }
.banner a { font-weight: 600; }

/* ---- thống kê ---- */
.chart { width: 100%; height: auto; max-height: 260px; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- điện thoại ---- */
@media (max-width: 640px) {
  .bar { padding: 8px 12px; gap: 6px; }
  #nav a { padding: 6px 7px; font-size: 13px; }
  #who { display: none; }
  main { padding: 10px 12px 80px; }
  .bots { grid-template-columns: 1fr; }
  .live-grid { grid-template-columns: 1fr; }
  .live-pick-name { max-width: 160px; }
  .two, .stat-grid { grid-template-columns: 1fr; }
  .toolbar { top: 0; position: static; }
  .modal { padding: 12px; }
  td.reason { min-width: 120px; max-width: 220px; }
}
