:root { --bg:#0f1115; --card:#181b22; --line:#2a2f3a; --fg:#e6e9ef; --mut:#9aa4b2; --pri:#ee4d2d; --ok:#39b54a; --err:#e5484d; }
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, Segoe UI, Roboto, sans-serif; background:var(--bg); color:var(--fg); }
header { padding:16px 20px; border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--bg); }
h1 { font-size:18px; margin:0 0 10px; }
h2 { font-size:16px; }
small.pill { font-size:11px; padding:2px 8px; border-radius:10px; background:var(--card); color:var(--mut); }
nav { display:flex; gap:8px; }
.tab { background:var(--card); color:var(--fg); border:1px solid var(--line); padding:8px 14px; border-radius:8px; cursor:pointer; }
.tab.active { border-color:var(--pri); color:var(--pri); }
.tab-panel { padding:20px; max-width:1100px; }
.hidden { display:none; }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; margin-bottom:16px; }
.grid { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.grid button[type=submit] { grid-column:1/-1; }
/* form: 1 hàng, TỰ WRAP theo bề rộng cửa sổ (không cuộn ngang) */
.row-form { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.break { flex-basis:100%; height:0; margin:0; padding:0; }  /* ép xuống dòng mới */
.row-form input[name=name] { flex:0 0 170px; }
.row-form input[name=cookie] { flex:1 1 auto; min-width:220px; }
.row-form input[name=proxy] { flex:0 0 260px; }
.row-form button[type=submit] { flex:0 0 auto; white-space:nowrap; }
/* ô sửa trực tiếp trong bảng */
input.edit { width:100%; padding:6px 8px; }
td .btn-save { background:var(--pri); border-color:var(--pri); color:#fff; margin-right:6px; }
.nowrap { white-space:nowrap; }
/* Bảng tự co theo cửa sổ (table-layout fixed), input dài cuộn TRONG ô, không đẩy trang */
body { overflow-x:hidden; }
table { table-layout:fixed; }
/* bảng cuộn ngang khi cửa sổ hẹp (thay vì cắt mất cột) */
.table-wrap { width:100%; overflow-x:auto; }
#acc-table { min-width:980px; }
#sch-table { min-width:880px; }
#job-table { min-width:820px; }
#evt-table { min-width:560px; }
#acctsch-table { min-width:760px; }
th, td { overflow:hidden; text-overflow:ellipsis; }
#acc-table th:nth-child(1), #acc-table td:nth-child(1) { width:40px; }
#acc-table th:nth-child(2), #acc-table td:nth-child(2) { width:15%; }
#acc-table th:nth-child(3), #acc-table td:nth-child(3) { width:24%; }
#acc-table th:nth-child(4), #acc-table td:nth-child(4) { width:14%; }
#acc-table th:nth-child(5), #acc-table td:nth-child(5) { width:76px; }
#acc-table th:nth-child(6), #acc-table td:nth-child(6) { width:120px; white-space:nowrap; }
#acc-table th:nth-child(7), #acc-table td:nth-child(7) { width:210px; }
/* cột thao tác: giữ 1 hàng (không wrap) + GHIM bên phải (luôn thấy Sửa/Kiểm tra/Xoá dù bảng cuộn ngang) */
#acc-table td.acts, #acc-table th:nth-child(7) { position:sticky; right:0; background:var(--bg); z-index:2; box-shadow:-8px 0 8px -6px rgba(0,0,0,.55); }
#acc-table td.acts { white-space:nowrap; overflow:visible; }
#acc-table td.acts button { margin:0 4px 0 0; padding:4px 7px; }
/* hàng sát nhau hơn + ô sửa thấp hơn */
#acc-table td, #acc-table th { padding-top:4px; padding-bottom:4px; }
#acc-table input.edit { padding:4px 6px; }
td .act, td .btn-save { padding:6px 8px; }
/* Tab 2 form 1 hàng */
.row-form select { flex:0 0 auto; }
.row-form input[name=video_dir] { flex:1 1 220px; min-width:200px; }
.days { display:inline-flex; gap:6px; flex-wrap:wrap; align-items:center; }
.days label { margin:0; }
.slots-wrap { display:inline-flex; gap:4px; align-items:center; flex-wrap:wrap; }
.hint { color:var(--mut); font-size:12px; margin:4px 0 14px; }
input, select, button { font:inherit; padding:9px 10px; border-radius:8px; border:1px solid var(--line); background:#11141a; color:var(--fg); }
button { cursor:pointer; }
button[type=submit], #oracle-test, #add-slot { background:var(--pri); border-color:var(--pri); color:#fff; }
table { width:100%; border-collapse:collapse; font-size:13px; }
th, td { text-align:left; padding:8px; border-bottom:1px solid var(--line); }
th { color:var(--mut); font-weight:600; }
.days label { margin-right:10px; font-size:13px; }
.slot-row { display:inline-flex; gap:4px; margin:4px 8px 4px 0; }
.slot-row input { width:56px; }
.chk { display:flex; align-items:center; gap:6px; }
.days-btn { white-space:nowrap; }
#days-modal-list label { font-size:14px; }
/* Lịch hiện tại bấm được */
.tt-link { cursor:pointer; border-bottom:1px dashed var(--mut); }
.tt-link:hover { color:var(--pri); border-color:var(--pri); }
/* Lưới thời khoá biểu tuần: cột theo thứ, giờ xếp dọc */
.tt-grid { display:flex; gap:10px; flex-wrap:wrap; }
.tt-col { flex:1 1 92px; min-width:84px; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.tt-head { background:var(--card); border-bottom:1px solid var(--line); padding:6px 8px; font-weight:600; text-align:center; position:sticky; top:0; }
.tt-cell { padding:3px 8px; text-align:center; border-bottom:1px solid var(--line); font-size:12px; }
.tt-cell:last-child { border-bottom:none; }
/* Popup sửa tài khoản */
#edit-fields input, #edit-fields textarea, #edit-fields select { width:100%; margin:2px 0 6px; }
#edit-fields label { display:block; margin-top:6px; }
#edit-save { background:var(--pri); border-color:var(--pri); color:#fff; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size:12px; white-space:pre-wrap; color:var(--mut); }
.act { color:var(--err); cursor:pointer; background:none; border:none; }
.act.danger { color:#fff; background:var(--err); border:1px solid var(--err); border-radius:6px; font-weight:600; }
.small { font-size:12px; color:var(--mut); }
textarea { font:inherit; padding:9px 10px; border-radius:8px; border:1px solid var(--line); background:#11141a; color:var(--fg); resize:vertical; }
.st-active, .st-done, .st-info { color:var(--ok); }
.st-error, .st-logged_out, .st-failed { color:var(--err); }
.st-unknown, .st-canceled { color:var(--mut); }
.st-queued, .st-running, .st-warn, .st-review, .st-need_captcha { color:#e8a53d; }
.toast { position:fixed; bottom:20px; right:20px; background:var(--card); border:1px solid var(--pri); padding:12px 16px; border-radius:8px; z-index:50; }
/* Modal tài nguyên */
.modal { position:fixed; inset:0; background:rgba(0,0,0,.6); display:none; align-items:center; justify-content:center; z-index:40; padding:20px; }
.modal:not(.hidden) { display:flex; }   /* chỉ hiện khi KHÔNG có .hidden (tránh .modal đè .hidden do thứ tự CSS) */
.modal-box { background:var(--card); border:1px solid var(--line); border-radius:12px; width:min(820px,96vw); max-height:86vh; display:flex; flex-direction:column; }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--line); }
.modal-head h3 { margin:0; }
.modal-x { background:none; border:none; color:var(--mut); font-size:22px; line-height:1; cursor:pointer; padding:0 6px; }
.modal-x:hover { color:var(--fg); }
#res-summary { padding:10px 16px 0; }
.modal-body { overflow:auto; padding:8px 16px 16px; }
#res-table th:nth-child(1), #res-table td:nth-child(1) { width:56px; }
#res-table th:nth-child(3), #res-table td:nth-child(3) { width:120px; }
#set-fields { display:grid; grid-template-columns:1fr 2fr; gap:8px; align-items:center; margin-bottom:12px; }
#set-fields label { color:var(--mut); font-size:13px; }
/* Tab 3 — card máy ký video */
.signer-row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:10px; }
.signer-row .rg { flex:0 0 56px; font-weight:600; }
.signer-row input { flex:1 1 200px; }
.signer-row input.mono { flex:1 1 260px; }
.signer-row #res-vn, .signer-row #res-sg { flex:1 1 100%; }
details.card > summary { cursor:pointer; color:var(--mut); font-size:13px; }
details.card[open] > summary { margin-bottom:10px; color:var(--fg); }
