/* ROLL v0.1 — phong cách sáng, sang như dashboard ESUM v1.0 */
:root {
  --bg: #f7f7f4; --card: #fff; --ink: #1c1c1e; --muted: #6b7280;
  --line: #e7e5e0; --accent: #4f46e5; --accent2: #2563eb;
  --grad: linear-gradient(90deg, #2563eb, #4f46e5);
  --ok: #16a34a; --bad: #dc2626; --warn: #d97706; --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 22px; letter-spacing: 2px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin-left: 10px; color: var(--muted); font-size: 13px; }
.topstats span { margin-left: 12px; font-size: 13px; color: var(--muted); }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.pill.off { background: #fee2e2; color: var(--bad); }
.pill.on { background: #dcfce7; color: var(--ok); }
.tabs { display: flex; gap: 6px; padding: 12px 22px 0; }
.tabs button { border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--grad); color: #fff; border-color: transparent; }
main { padding: 16px 22px 40px; }
.tab { display: none; }
.tab.active { display: block; }
/* v0.3: 2 cột kéo được. NGUYÊN NHÂN GỐC lỗi bóp giao diện ở v0.2:
 * grid 1fr/1fr + min-width:auto mặc định của grid-item/flex-item +
 * .prompt1 { white-space:nowrap } khiến mỗi dòng job có min-content
 * bằng đúng độ dài prompt đầy đủ -> cột Hàng đợi phình theo prompt
 * dài nhất, cột prompt bị ép về min-content của nó (một vệt hẹp).
 * Sửa: min-width:0 xuyên suốt chuỗi grid -> card -> flex -> prompt,
 * minmax(320px, ...) làm sàn cứng cho cả hai cột, thumbnail/meta
 * không được đẩy cột. */
.grid2 { display: grid; grid-template-columns: minmax(320px, 1fr) 10px minmax(320px, 1fr); gap: 0; }
.grid2 > * { min-width: 0; }
#promptCard { margin-right: 8px; }
#queueCard { margin-left: 8px; }
.col-resize { cursor: col-resize; touch-action: none; position: relative; outline: none; }
.col-resize::after { content: ""; position: absolute; top: 24px; bottom: 24px; left: 50%; width: 3px; transform: translateX(-50%); background: var(--line); border-radius: 3px; }
.col-resize:hover::after, .col-resize.dragging::after, .col-resize:focus-visible::after { background: var(--accent); }
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .col-resize { display: none; }
  #promptCard { margin-right: 0; }
  #queueCard { margin-left: 0; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05); margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.badge { background: #eef2ff; color: var(--accent); padding: 2px 10px; border-radius: 999px; font-size: 12px; }
label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 8px 0; }
.row > * { flex: 1; }
.row.actions > * { flex: none; }
.btn { border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; }
.btn.accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: #eef2ff; color: var(--accent); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.chip.bad { background: #fee2e2; color: var(--bad); }
.warnings { color: var(--bad); font-size: 13px; margin: 4px 0; }
.mention-wrap { position: relative; }
.mention-drop { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 10; max-height: 260px; overflow: auto; }
.mention-drop.hidden { display: none; }
.mention-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.mention-item:hover, .mention-item.sel { background: #eef2ff; }
.mention-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.live-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.live-item { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; background: #f8fafc; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.joblist { display: flex; flex-direction: column; gap: 10px; }
.job-row { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; background: #fff; }
.job-row .line1 { display: flex; gap: 10px; align-items: center; }
.job-row .line1 > * { min-width: 0; }
.job-row .thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: #eee; flex: none; }
.job-row .prompt1 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.job-row .meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.job-row .edit-box { margin-top: 10px; }
.job-row .edit-box textarea { width: 100%; }
.job-row .full { display: none; margin-top: 10px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.job-row.open .full { display: block; }
.job-row video, .job-row img.result { max-width: 100%; border-radius: 10px; margin-top: 8px; }
.st { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.st.queued { background: #fef3c7; color: var(--warn); }
.st.running { background: #dbeafe; color: var(--accent2); }
.st.succeeded { background: #dcfce7; color: var(--ok); }
.st.failed, .st.timeout { background: #fee2e2; color: var(--bad); }
.st.stopped { background: #e5e7eb; color: #4b5563; }
.job-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.job-tabs button { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.job-tabs button.active { background: var(--grad); color: #fff; border-color: transparent; }
.job-tabs span { opacity: .75; }
.pager { justify-content: center; align-items: center; }
.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 12px; }
.vault-item { border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; }
.vault-item img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; }
.vault-item .tag { font-weight: 600; font-size: 13px; }
.vault-item .sz { font-size: 12px; color: var(--muted); }
.vault-item .badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.vault-item .badge-g { background: #eef2ff; color: var(--accent); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.vault-item .badge-r { background: #fef3c7; color: var(--warn); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.vault-item .badge-r.lead { background: #dcfce7; color: var(--ok); }
.vault-item .unclass-hint { font-size: 11px; color: var(--muted); margin: 2px 0 6px; }
.vault-item .row.actions { justify-content: center; }
.vault-item .row.actions > * { flex: none; }
.chip-btn { border: 1px solid var(--line); background: #fff; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.chip-btn.active { background: var(--grad); color: #fff; border-color: transparent; }
#genResult img { max-width: 260px; border-radius: 12px; display: block; margin: 10px 0; }
.hidden { display: none !important; }
.vault-item .sz.over { color: var(--bad); font-weight: 600; }
.pending-row { display: flex; gap: 8px; align-items: center; border: 1px dashed var(--line); border-radius: 12px; padding: 8px; margin: 8px 0; }
.pending-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.pending-row input { flex: 1; }
.pending-row .err { color: var(--bad); font-size: 12px; }
.shot { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.shot img.kf { max-width: 220px; border-radius: 10px; display: block; margin: 8px 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1c1c1e; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50; }
.toast.hidden { display: none; }
.toast button { margin-left: 12px; background: #fff; color: #1c1c1e; border: 0; border-radius: 8px; padding: 5px 12px; cursor: pointer; }
.switch-row { display: flex; align-items: center; gap: 8px; }
.switch-row input { width: auto; }

/* ---------- v0.2: màn hình đăng nhập licence (cổng vào duy nhất) ---------- */
#loginScreen { display: none; }
body.locked #loginScreen { display: flex; justify-content: center; padding: 60px 16px; }
body.locked .topbar, body.locked .tabs, body.locked main { display: none; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 1px 3px rgba(0,0,0,.05); max-width: 480px; width: 100%; }
.login-card .logo.big { font-size: 34px; }
.login-card h2 { font-size: 18px; margin: 14px 0 6px; }
.login-card .lbl, .lbl { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
