:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #222220;
  --muted: #6b6a66;
  --line: #e4e3df;
  --accent: #1f2fe0;
  --accent-soft: #e7e9ff;
  --accent-ink: #0000b8;
  --brand-blue: #0000ff;
  --brand-yellow: #f6c22d;
  --brand-red: #e33e33;
  --ok: #1e8e5a;
  --ok-soft: #e3f5ec;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --info: #2b5fd9;
  --info-soft: #e6eeff;
  --bad: #c62828;
  --bad-soft: #fdeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 16, 40, 0.06), 0 4px 16px rgba(20, 16, 40, 0.05);
  /* 9.6.8: màu trước viết cứng => biến (để có màn hình tối) */
  --field: #ffffff;
  --soft: var(--soft);
  --soft2: var(--soft2);
  --bg-soft: #f4f4f5;
  --chip: var(--chip);
  --col: var(--col);
  --track: var(--track);
  --track2: var(--track2);
  --line2: var(--line2);
  --ink2: var(--ink2);
  --muted2: var(--muted2);
  --ok-line: #b9e3cd; --ok-ink: #155c3b;
  --warn-line: #f2d7a6; --warn-ink: #7a4a00;
  --info-line: #c5d5fb; --info-ink: #1e3f8f;
  --bad-ink: #8e1c1c;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'Be Vietnam Pro', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: #222220; color: #fff; flex-wrap: wrap; border-bottom: 3px solid var(--brand-yellow);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; cursor: pointer; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #e91e63, #7b1fa2); display: grid; place-items: center; font-size: 15px; }
.topbar .project-name { font-weight: 600; opacity: 0.95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.save-state { font-size: 12px; opacity: 0.8; white-space: nowrap; }
.api-badges { display: flex; gap: 6px; }
.api-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.1); white-space: nowrap; }
.api-badge.on { background: rgba(46, 204, 113, 0.25); }
.api-badge .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: #999; }
.api-badge.on .dot { background: #2ecc71; }
.topbar .btn { background: rgba(255,255,255,0.12); color: #fff; border-color: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,0.2); }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--line2); background: var(--soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,0.05); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.big { padding: 10px 18px; font-size: 15px; font-weight: 600; border-radius: 8px; }
.btn.icon { padding: 4px 7px; min-width: 28px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- bố cục ---------- */
.container { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- form ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input:not([type]), input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 60px; }
textarea.script { min-height: 520px; font-family: 'JetBrains Mono', Consolas, monospace; font-size: 13.5px; line-height: 1.65; }
textarea.prompt { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; min-height: 170px; background: var(--soft); }
textarea[readonly], input[readonly] { background: var(--soft2); color: var(--ink2); }

/* ---------- stepper ---------- */
.stepper { display: flex; gap: 0; margin-bottom: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.step {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; position: relative;
  border-right: 1px solid var(--line); background: var(--panel); min-width: 0;
}
.step:last-child { border-right: 0; }
.step:hover { background: var(--soft); }
.step .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--chip); color: var(--muted); flex: none; }
.step .label { font-weight: 600; white-space: nowrap; }
.step .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.done .num { background: var(--ok); color: #fff; }
.step.active { background: var(--accent-soft); }
.step.active .num { background: var(--accent); color: #fff; }
.step.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); }
.step.locked { cursor: not-allowed; opacity: 0.55; }
.step .arrow { margin-left: auto; color: var(--line2); }

/* ---------- banner ---------- */
.banner { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.banner.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.banner.info { background: var(--info-soft); border-color: var(--info-line); color: var(--info-ink); }
.banner .grow { flex: 1; }
.banner.block { display: block; }

/* ---------- trạng thái ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-chua_tao { background: var(--chip); color: var(--muted2); }
.st-dang_xu_ly { background: var(--info-soft); color: var(--info); }
.st-hoan_thanh { background: var(--ok-soft); color: var(--ok); }
.st-can_lam_lai { background: var(--warn-soft); color: var(--warn); }
.st-dang_xu_ly::before { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12.5px; user-select: none; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--chip); color: var(--muted); }

/* ---------- trang chủ ---------- */
.home { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card { cursor: pointer; overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s; }
.project-card:hover { transform: translateY(-2px); }
.project-card .cover { height: 140px; background: linear-gradient(135deg, #3d2c5c, #c2185b); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.project-card .cover img { height: 100%; }
.project-card .body { padding: 12px 14px; }
.progress { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); }

/* ---------- nhân vật ---------- */
.char-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.char-list .item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.char-list .item:last-child { border-bottom: 0; }
.char-list .item.active { background: var(--accent-soft); }
.char-list .item img, .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--chip); flex: none; }
.gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 110px; height: 146px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--chip); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: #fff; border: 0; border-radius: 5px; cursor: pointer; font-size: 12px; padding: 1px 6px; }
.thumb .star { position: absolute; left: 4px; bottom: 4px; font-size: 10.5px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 4px; }
.upload-tile { width: 110px; height: 146px; border: 2px dashed var(--line2); border-radius: 8px; display: grid; place-items: center; text-align: center; color: var(--muted); cursor: pointer; font-size: 12px; padding: 8px; background: var(--soft); }
.upload-tile:hover { border-color: var(--accent); color: var(--accent); }
.outfit { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.outfit.default { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.identity-block { font-family: Consolas, monospace; font-size: 12px; background: #1f1d2b; color: #e8e6f0; padding: 12px; border-radius: 8px; white-space: pre-wrap; }

/* ---------- storyboard ---------- */
.scene { margin-bottom: 18px; }
.scene-head { display: grid; grid-template-columns: 36px 1.2fr 1.6fr 0.8fr auto; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--soft); border-radius: var(--radius) var(--radius) 0 0; }
.scene-num { font-weight: 700; color: var(--accent); }
.shots { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.shot { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px; }
.shot.dragging { opacity: 0.4; }
.shot.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.shots.drop-end { box-shadow: inset 0 -3px 0 var(--accent); }
.shot-side { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.shot-code { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.drag-handle { cursor: grab; color: #aaa; user-select: none; }
.shot-ref { width: 100%; aspect-ratio: 9/16; border-radius: 6px; border: 1px dashed var(--line2); background: var(--soft); display: grid; place-items: center; overflow: hidden; cursor: pointer; color: var(--muted); font-size: 11px; text-align: center; position: relative; }
.shot-ref img, .shot-ref video { width: 100%; height: 100%; object-fit: cover; }
.shot-fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px 10px; }
.shot-fields .c2 { grid-column: span 2; }
.shot-fields .c3 { grid-column: span 3; }
.shot-fields .c4 { grid-column: span 4; }
.shot-fields .c6 { grid-column: span 6; }
.shot-fields textarea { min-height: 54px; }
.char-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.char-picker select { width: auto; padding: 2px 6px; font-size: 12px; }
.readonly-mask input, .readonly-mask select, .readonly-mask textarea { pointer-events: none; background: var(--soft2); }
.readonly-mask .chip { pointer-events: none; }
.summary-bar { display: flex; gap: 18px; align-items: center; padding: 10px 14px; flex-wrap: wrap; }
.summary-bar .stat b { font-size: 17px; }

/* ---------- video ---------- */
.video-row { display: grid; grid-template-columns: 150px 1fr 230px; gap: 14px; padding: 14px; border-bottom: 1px solid var(--line); }
.video-row:last-child { border-bottom: 0; }
.video-row .media { width: 150px; aspect-ratio: 9/16; background: #111; border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: #888; font-size: 11px; text-align: center; }
.video-row .media video, .video-row .media img { width: 100%; height: 100%; object-fit: cover; }
.video-actions { display: flex; flex-direction: column; gap: 6px; }
.video-actions .btn { width: 100%; }
.mini-refs { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-refs img { width: 34px; height: 45px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.job-error { color: var(--bad); font-size: 12px; }

/* ---------- dựng phim ---------- */
.edit-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.timeline-item { display: grid; grid-template-columns: 24px 64px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.timeline-item.excluded { opacity: 0.45; }
.timeline-item.playing { background: var(--accent-soft); }
.timeline-item .tl-thumb { width: 64px; height: 86px; border-radius: 6px; overflow: hidden; background: #111; display: grid; place-items: center; color: #777; font-size: 10px; text-align: center; }
.timeline-item .tl-thumb video { width: 100%; height: 100%; object-fit: cover; }
.player { position: sticky; top: 70px; }
.player-frame { background: #000; border-radius: 12px; overflow: hidden; position: relative; margin: 0 auto; }
.player-frame video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.player-frame .sub { position: absolute; left: 8%; right: 8%; bottom: 12%; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px #000, 0 0 2px #000; font-size: 15px; }
.player-frame .code { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.55); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 5px; }
.player-frame .empty { color: #aaa; display: grid; place-items: center; height: 100%; text-align: center; padding: 20px; }
.timebar { height: 8px; display: flex; gap: 2px; margin-top: 10px; }
.timebar > div { background: var(--track2); border-radius: 2px; cursor: pointer; }
.timebar > div.on { background: var(--accent); }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 40, 0.5); display: grid; place-items: center; z-index: 50; }
.modal { width: min(640px, 92vw); max-height: 90vh; overflow: auto; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1f1d2b; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; animation: slide 0.2s; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
kbd { background: var(--chip); border-radius: 4px; padding: 0 5px; font-size: 12px; }

/* ===================== v2 ===================== */
input[type=email], input[type=password] { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); outline: none; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; }
.end { justify-content: flex-end; }
.block { width: 100%; }
.narrow { max-width: 760px; margin: 0 auto; }
.grid-2.top, .grid-3.top { align-items: start; }
.lbl, .field .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
label.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; cursor: pointer; }
.pre { white-space: pre-wrap; word-break: break-word; }
.mono { font-family: Consolas, monospace; word-break: break-all; }
.warn-text { color: var(--warn); } .ok-text { color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
input.missing { border-color: #f2b45a; background: var(--warn-soft); }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.brand.dark { color: var(--ink); margin-bottom: 6px; }
a.brand { color: #fff; text-decoration: none; }
.api-badge.mid .dot { background: #f1c40f; } .api-badge.bad .dot { background: #e74c3c; } .api-badge.on { background: rgba(46, 204, 113, 0.25); } .api-badge.on .dot { background: #2ecc71; }
.topbar a.btn { text-decoration: none; }

/* đăng nhập */
.auth-wrap { min-height: 70vh; display: grid; place-items: center; }
.auth-box { width: min(420px, 94vw); }
.auth-box form { margin-top: 12px; }

/* bảng, danh sách */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table td.btn-row { display: table-cell; }
.table td.btn-row .btn { margin: 2px; }
.table.beats textarea, .table.beats input { min-height: 0; font-size: 12.5px; }
.table.beats tr.dialogue td:first-child { color: var(--accent); font-weight: 700; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-item:hover { background: var(--soft); }
.item-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.avatar.lg { width: 56px; height: 72px; border-radius: 8px; }
a.project-card { text-decoration: none; color: inherit; }

/* tab */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 14px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

/* bước */
.stepper .step { text-decoration: none; color: inherit; }
.outline-scene { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 6px; margin-bottom: 8px; align-items: start; }
.outline-scene textarea { grid-column: 2 / 4; min-height: 44px; }
.scene-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; }
.diff { font-family: Consolas, monospace; font-size: 12.5px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 50vh; overflow: auto; white-space: pre-wrap; }
.d-add { background: var(--ok-soft); color: var(--ok-ink); } .d-del { background: var(--bad-soft); color: var(--bad-ink); text-decoration: line-through; }
.modal.wide { width: min(980px, 95vw); }
textarea.script.short { min-height: 220px; }

/* nhân vật */
.ref { margin: 0; width: 170px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.ref.approved { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); }
.ref img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: var(--chip); }
.ref figcaption { padding: 6px 8px; font-size: 12px; }
.char-list .item .avatar { display: inline-block; }

/* storyboard */
.scene-label { font-weight: 700; color: var(--accent); margin: 14px 0 6px; }
.shot-card { display: grid; grid-template-columns: 130px 1fr; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--panel); }
.shot-card.approved { border-left: 4px solid var(--ok); }
.shot-card.dragging { opacity: 0.4; } .shot-card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.shot-grid { display: grid; grid-template-columns: 1.2fr 2fr 1fr 0.7fr; gap: 8px; margin: 6px 0; }
.dialogue-line { background: var(--accent-soft); border-radius: 6px; padding: 6px 10px; }
.flags { background: var(--warn-soft); color: var(--warn-ink); border-radius: 6px; padding: 6px 10px; font-size: 12px; margin: 6px 0; }
.summary-bar .stat b { font-size: 16px; }

/* render */
.st-chua_render { background: var(--chip); color: var(--muted2); }
.st-da_co_clip { background: var(--info-soft); color: var(--info); }
.st-da_duyet { background: var(--ok-soft); color: var(--ok); }
.st-loi_tu_choi { background: var(--bad-soft); color: var(--bad); }
.qc { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.qc textarea { width: 100%; min-height: 40px; }
.mini-video { width: 54px; height: 96px; object-fit: cover; background: #111; border-radius: 4px; }
.video-row .media { height: auto; }
.player-frame { max-height: 70vh; max-width: 100%; }
.player-frame video { width: 100%; height: 100%; }
@media (max-width: 1000px) { .home, .edit-layout, .char-layout, .grid-2, .grid-3 { grid-template-columns: 1fr; } .shot-grid { grid-template-columns: 1fr 1fr; } .video-row { grid-template-columns: 110px 1fr; } .video-row .video-actions { grid-column: span 2; flex-direction: row; flex-wrap: wrap; } }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: #fff; }
textarea.prompt { font-family: inherit; font-size: 13px; line-height: 1.55; }
.row select, .item-row select, .btn-row select { width: auto; max-width: 360px; }

/* ---------- v3: thương hiệu Kailas ---------- */
.logo-mark { height: 22px; width: auto; display: block; }
.brand-name { letter-spacing: 0.2px; }
.top-nav { display: flex; gap: 4px; }
.nav-link { color: #fff; opacity: 0.8; text-decoration: none; padding: 5px 10px; border-radius: 6px; font-weight: 600; font-size: 13px; }
.nav-link:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.nav-link.on { opacity: 1; background: rgba(255,255,255,0.16); box-shadow: inset 0 -2px 0 var(--brand-yellow); }
.bell { position: relative; }
.bell-count { position: absolute; top: -6px; right: -6px; background: var(--brand-red); color: #fff; border-radius: 999px; font-size: 10px; min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 4px; font-weight: 700; }
.notif-list { max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.notif { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.notif:hover { background: var(--bg); }
.notif.unread { background: var(--accent-soft); }
.notif-icon { font-size: 16px; }
.grow { flex: 1; min-width: 0; }
.auth-logo { display: block; width: 180px; max-width: 70%; margin: 0 auto 8px; }
.auth-title { text-align: center; font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.row.nowrap { flex-wrap: nowrap; }
.pad-s { padding: 6px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.late { color: var(--bad); font-weight: 600; }
.ok-text { color: var(--ok); }
.table-wrap { overflow-x: auto; }

/* trang chủ: việc được giao */
.tasks-box { border-left: 4px solid var(--brand-yellow); }
.task-card { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.late-card { border-color: var(--bad); background: var(--bad-soft); }

/* bảng giao việc */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; align-items: start; }
.kan-col { background: var(--col); border-radius: 10px; padding: 8px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.kan-head { font-weight: 700; font-size: 13px; padding: 2px 4px; }
.kan-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.kan-card:hover { border-color: var(--accent); }
.kan-card.rejected { opacity: 0.6; }

/* thống kê */
.stats-filters input[type=date] { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.kpi { padding: 12px 14px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 24px; font-weight: 700; }
.delta { font-weight: 700; font-size: 12px; color: var(--muted); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 10px; overflow-x: auto; }
.bar { flex: 1; min-width: 14px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar-fill { width: 100%; background: var(--brand-blue); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar:hover .bar-fill { background: var(--brand-red); }
.bar-lbl { font-size: 9px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.status-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-cell { display: flex; flex-direction: column; align-items: center; padding: 8px; background: var(--bg); border-radius: 8px; }
.status-cell b { font-size: 20px; }

/* bước 3: cú máy, ảnh storyboard */
.move-row { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: end; margin-top: 6px; }
.move-reason { padding-bottom: 8px; }
.sb-box { margin-top: 8px; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; }
.sb-gallery { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.sb-img { margin: 0; width: 120px; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--bg); }
.sb-img.approved { border-color: var(--ok); }
.sb-img img { width: 100%; display: block; }
.sb-img figcaption { padding: 4px; }
.sb-thumb { width: 64px; margin-top: 6px; border-radius: 6px; border: 2px solid transparent; display: block; }
.sb-thumb.approved { border-color: var(--ok); }

/* bước 4: render */
.model-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.model-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.model-item.on { border-color: var(--accent); background: var(--accent-soft); }
.render-ctl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.render-ctl select, .render-ctl input { width: auto; max-width: 100%; }

/* bước 6: đăng bài */
.title-row { display: flex; gap: 8px; align-items: center; }
.crops { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.crop { margin: 0; text-align: center; }
.crop canvas { display: block; height: 220px; width: auto; border-radius: 6px; border: 1px solid var(--line); background: #000; }

/* quản trị: team, cú máy */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.move-edit { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
@media (max-width: 760px) {
  .kanban { grid-template-columns: repeat(5, 240px); }
  .move-row, .move-edit { grid-template-columns: 1fr; }
  .top-nav { order: 5; width: 100%; overflow-x: auto; }
  .api-badges { display: none; }
}
.move-row .move-reason { grid-column: 1 / -1; }

/* ---------- v4 ---------- */
.ref img { object-fit: contain; }
.bad-text { color: var(--bad); font-weight: 600; }
.budget-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 13px; }
.budget-line.warn { border-color: var(--warn); background: var(--warn-soft); }
.budget-line.over { border-color: var(--bad); background: var(--bad-soft); }
.budget-track { flex: 0 1 180px; min-width: 100px; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.budget-track span { display: block; height: 100%; background: var(--ok); }
.budget-line.warn .budget-track span { background: var(--warn); }
.budget-line.over .budget-track span { background: var(--bad); }
.lib-suggest { margin-bottom: 12px; border-left: 4px solid var(--ok); }
.lib-suggest .item-row { gap: 10px; align-items: center; }
.lib-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.lib-img { width: 96px; max-height: 96px; object-fit: contain; border-radius: 6px; background: var(--chip); }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 8px; }
.loc-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--panel); min-width: 0; }
.loc-card.approved { border-color: var(--ok); }
.loc-card .ref { width: 120px; }
.scene-block { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin: 0 0 8px; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; }
.scene-block .field { flex: 1 1 260px; margin: 0; }
.loc-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
.axis72 { flex: 1 1 100%; } .axis72 select { margin: 0 6px; }
.staging72 { margin: 6px 0; } .staging72 .row { gap: 12px; align-items: center; }
.angle-slots { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; } .angle-slot { display: flex; align-items: center; gap: 6px; } .angle-slot .loc-thumb { width: 48px; height: 48px; }
.unclear { flex: 1 1 100%; color: var(--warn); }
.claude-tag { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; margin: 4px 0; }
.cont-issues { background: var(--warn-soft); }
.animatic { position: relative; width: min(360px, 100%); margin: 8px auto 0; background: #111; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.animatic img { width: 100%; height: 100%; object-fit: cover; }
.an-empty { color: #ccc; padding: 16px; text-align: center; font-size: 13px; }
.an-sub { position: absolute; left: 8px; right: 8px; bottom: 14px; text-align: center; color: #fff; font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.an-tag { position: absolute; left: 8px; top: 8px; color: #fff; font-size: 11px; background: rgba(0, 0, 0, 0.55); padding: 2px 6px; border-radius: 4px; }
.an-progress { width: min(360px, 100%); margin: 6px auto 0; height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.an-progress span { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.sb-frame { position: relative; width: 100%; height: 100%; }
.sb-frame img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.sb-frame span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); color: #fff; padding: 3px; font-size: 11px; }
.move-row .field.continuity + .field.continuity { grid-column: 1 / -1; }

/* v4.1: trang Hướng dẫn */
.guide { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.guide-toc { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.guide-toc ol { padding-left: 18px; margin: 8px 0 0; }
.guide-toc li { margin: 4px 0; }
.guide-toc-part { display: block; margin: 12px 0 2px -18px !important; font-weight: 600; color: var(--muted); }
.guide-sec h2 { margin-top: 0; font-size: 18px; }
.guide-sec p, .guide-sec li { line-height: 1.55; }
.guide-sec li { margin: 4px 0; }
.guide-fig { margin: 12px 0; }
.guide-fig img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.guide-fig figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.step-help { display: flex; gap: 6px; align-items: center; margin: -4px 0 10px; }
.help-link { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 700; text-decoration: none; }
@media (max-width: 760px) { .guide { grid-template-columns: 1fr; } .guide-toc { position: static; max-height: none; } }
/* 4.1: thêm mục Hướng dẫn => trên màn hình rộng giữ thanh trên 1 dòng, tên phim / trạng thái lưu tự rút gọn */
@media (min-width: 761px) {
  .topbar { flex-wrap: nowrap; }
  .topbar .project-name, .topbar .save-state { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
  .topbar .brand, .top-nav, .topbar .btn { flex-shrink: 0; }
  .api-badges { min-width: 0; flex-shrink: 1; overflow: hidden; }
  .api-badge { white-space: nowrap; }
}

/* 4.5 nhóm thoại */
.group-lines { border: 1px solid var(--line, #e3e3e3); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--soft); }
.group-line { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.group-line .tc { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 72px; font-size: 12px; }
.group-line .grow { flex: 1; }
.btn.xs { padding: 2px 8px; font-size: 12px; }

/* 4.6: trình dựng bước 5 */
.ed-layout { display: grid; grid-template-columns: minmax(220px, 330px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ed-layout > *, .ed-panel > * { min-width: 0; }
.ed-player .player-frame { max-height: 72vh; }
.ed-tl { display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px 10px; margin-top: 8px; border-top: 1px solid var(--line); }
.ed-item { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--panel); cursor: pointer; font-size: 12px; line-height: 1.3; min-height: 64px; display: flex; flex-direction: column; justify-content: space-between; user-select: none; }
.ed-item:hover { border-color: var(--accent); }
.ed-item.sel { outline: 2px solid var(--accent); border-color: var(--accent); }
.ed-item.playing { background: var(--accent-soft); }
.ed-item.bad { border-color: #d33; box-shadow: inset 0 0 0 1px #d33; }
.ed-item.dragging { opacity: 0.4; }
.ed-item.drop-before { box-shadow: -4px 0 0 var(--accent); }
.ed-item .ed-code { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-item .ed-label { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ed-item .ed-sec { white-space: nowrap; }
.ed-item .ed-cut { color: var(--accent); font-weight: 600; }
.ed-panel { display: grid; grid-template-columns: 150px 1fr; gap: 14px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.ed-src video { width: 100%; max-height: 270px; background: #000; border-radius: 8px; display: block; }
.ed-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 6px; font-size: 13px; }
.ed-num { width: 72px; }
.ed-cutbox { margin-top: 10px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.ed-last { margin-top: 6px; }
@media (max-width: 1000px) { .ed-layout { grid-template-columns: minmax(0, 1fr); } .ed-player { position: static; } .ed-player .player-frame { max-height: 60vh; } }
@media (max-width: 560px) { .ed-panel { grid-template-columns: 1fr; } .ed-src video { max-height: 220px; } }
.ed-row label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ed-row input.ed-num { width: 76px; padding: 4px 6px; }
.ed-row select, #ed-add-src, #ed-q { width: auto; max-width: 260px; padding: 4px 8px; }
.ed-player .player-frame .ed-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 13px; text-align: center; padding: 20px; pointer-events: none; }

/* 4.7: kết nối tự cấu hình */
.pre-box { max-height: 360px; overflow: auto; background: var(--bg-soft); padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; }
#cn-form textarea.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* 5.4: bước Thẩm định kịch bản (AI Script Reviewer) */
.rv-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.rv-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin-top: 8px; }
.rv-group { display: grid; grid-template-columns: 1fr 90px 60px; gap: 8px; align-items: center; font-size: 12.5px; }
.rv-total { font-size: 26px; }
.rv-finding { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.rv-finding.lv-blocker { border-left-color: var(--bad); }
.rv-finding.lv-warning { border-left-color: var(--warn); }
.rv-opt { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-top: 6px; cursor: pointer; }
.rv-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rv-opt pre { white-space: pre-wrap; margin: 4px 0 0; }
.rv-opt textarea { width: 100%; margin-top: 4px; }
.rv-finding.closed { opacity: 0.7; }
.rv-quotes { background: var(--soft); border-radius: 6px; padding: 4px 8px; margin: 4px 0; font-style: italic; }
.rv-script { position: sticky; top: 8px; }
.rv-lines { max-height: 75vh; overflow: auto; font-size: 13px; }
.rv-line { display: grid; grid-template-columns: 46px 1fr auto; gap: 6px; padding: 2px 4px; border-radius: 4px; }
/* 10.1.3: sửa tay ngay trên kịch bản đánh số */
.rv-click { cursor: text; }
.rv-click:hover { background: var(--info-soft, rgba(127,127,255,.12)); border-radius: 3px; }
.rv-tools { display: flex; gap: 4px; align-items: start; white-space: nowrap; }
.rv-etools { display: inline-flex; gap: 4px; opacity: 0; }
.rv-line:hover .rv-etools { opacity: 0.7; }
.rv-etools a { text-decoration: none; color: var(--muted); }
.rv-edit textarea { width: 100%; font-size: 13px; }
@media (hover: none) { .rv-etools { opacity: 0.6; } }
.rv-line .rv-id { color: var(--muted); font-family: Consolas, monospace; font-size: 11.5px; }
.rv-line.k-scene { font-weight: 700; margin-top: 8px; }
.rv-line.k-action, .rv-line.k-paren { font-style: italic; color: var(--ink2); }
.rv-line.mk-blocker { background: var(--bad-soft); }
.rv-line.mk-warning { background: var(--warn-soft); }
.rv-line.hl { outline: 2px solid var(--info); }
.rv-line.locked .rv-txt { color: var(--muted2); }
.rv-lock { text-decoration: none; opacity: 0.35; }
.rv-line:hover .rv-lock, .rv-line.locked .rv-lock { opacity: 1; }
.mb-s { margin-bottom: 8px; }
@media (max-width: 1000px) { .rv-layout, .rv-groups { grid-template-columns: 1fr; } .rv-script { position: static; } }

/* 5.6: thẻ trong bước và thanh chuyển bước ở đáy màn hình */
.step-tabs { margin: -10px 0 12px; }
.step-nav { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.step-nav-mid { flex: 1; text-align: center; }
.go-director { border: 2px solid var(--accent); margin-bottom: 12px; gap: 12px; align-items: center; }
.step-nav .nav-short { display: none; }
/* 9.0: màn hình hẹp: thanh nút gọn 1 dòng (nhãn ngắn, việc còn thiếu thu thành 1 dòng cắt "…") */
@media (max-width: 640px) {
  .step-nav { gap: 6px; padding: 8px 10px; }
  .step-nav .nav-long { display: none; }
  .step-nav .nav-short { display: inline; }
  .step-nav .btn.big { padding: 9px 12px; font-size: 14px; white-space: nowrap; }
  .step-nav .btn-row { flex-wrap: nowrap; gap: 6px; }
  .step-nav-mid { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.seg-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; vertical-align: middle; }
.seg-switch .btn { border: 0; border-radius: 0; margin: 0; }
.seg-switch .btn.on { background: var(--accent); color: #fff; }
.prompt-choice { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.tag.ai-tag { background: var(--warn-soft); color: var(--warn-ink); }
/* 6.4: Hỏi Claude trong Hướng dẫn */
.guide-qa { border-left: 3px solid var(--accent, #6b4ce6); }
.guide-qa textarea { width: 100%; }
.qa-answer { border-top: 1px solid var(--line, #e6e3ee); padding-top: 10px; }

/* 6.8: sửa từng lỗi ở bước Tối ưu prompt */
.issue-panel { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; background: var(--soft); }
.issue-card { border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 8px 10px; margin-top: 8px; background: var(--panel); }
.issue-card.lv-blocker { border-left-color: var(--bad); }
.issue-card .fix-box { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--accent-soft); }
.issue-card .fix-ba { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.issue-card .fix-ba > div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.issue-card .fix-edit { margin-top: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; }
.btn.rec { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.btn.rec::after { content: ' · đề xuất, chưa chọn'; font-size: 11px; opacity: .8; }
@media (max-width: 640px) { .issue-card .fix-ba { grid-template-columns: 1fr; } }

/* 6.9: hộp "Duyệt các shot đạt" + AI sửa tất cả shot */
.bulk-list { display: grid; gap: 6px; margin-top: 6px; }
.bulk-row { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 6px 10px; background: var(--panel); }
.bulk-row.warn { border-left-color: var(--warn); }
.bulk-row.bad { border-left-color: var(--bad); }
.bulk-row .issue-panel { margin-top: 4px; }
.bulk-sb { margin: 0; display: grid; gap: 4px; justify-items: center; }
.bulk-sb img { width: 96px; height: 170px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.bulk-foot { position: sticky; bottom: -16px; background: var(--panel); padding: 8px 0; border-top: 1px solid var(--line); }
.ai-fixed { display: inline-block; }
.ai-fixed summary { cursor: pointer; list-style: none; display: inline; }
.ai-fixed[open] { display: block; margin-top: 4px; }
/* 7.1: ô điểm lật dàn ý trải hết chiều ngang (trước bị dồn vào cột 70px, cắt chữ), danh sách nhân vật, hộp app soát dàn ý */
.outline-scene .ol-turn { grid-column: 2 / 4; }
.outline-scene textarea.ol-turn { min-height: 32px; }
.ol-char { gap: 6px; margin-bottom: 4px; }
.ol-char input { flex: 1; min-width: 0; }
.ol-check { padding: 8px 10px; border: 1px dashed var(--border, #ccc); border-radius: 6px; }
.gap-list { margin: 8px 0 10px; padding-left: 4px; list-style: none; display: grid; gap: 6px; line-height: 1.45; } /* 8.6: hộp soát bước */

/* 8.7: trang Dự án thống kê theo ngày + bảng tin 3 tab */
.dash-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.dash-filters input[type=date], .dash-filters select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.dash-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.dash-seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; border-right: 1px solid var(--line); font-size: 13px; }
.dash-seg button:last-child { border-right: 0; }
.dash-seg button.on { background: var(--accent); color: #fff; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-top: 12px; }
.dash-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.dash-kpi .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dash-kpi .l { font-size: 12px; color: var(--muted); }
.dash-kpi .d { font-size: 11.5px; color: var(--ok); }
.dash-kpi .d2 { font-size: 11px; color: var(--muted); }
.dash-kpi.money { border-color: var(--ok); background: var(--ok-soft); }
.dash-kpi.money .n { color: var(--ok); }
.dash-pipe { margin-top: 12px; }
.dash-stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.dash-stg { display: grid; text-align: left; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); cursor: pointer; }
.dash-stg b { font-size: 18px; }
.dash-stg span { font-size: 11.5px; color: var(--muted); }
.dash-stg.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dash-day { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; letter-spacing: .02em; cursor: default; }
details > summary.dash-day { cursor: pointer; }
.dash-table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.dash-table td { vertical-align: middle; }
.dash-table .progress { width: 90px; }
.dash-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.dash-title:hover { text-decoration: underline; }
.tag.dash-f-new { background: var(--accent); color: #fff; font-weight: 600; }
.tag.dash-f-done { background: var(--ok); color: #fff; font-weight: 600; }
.dash-news .dash-tabs { display: flex; border-bottom: 1px solid var(--line); margin: -4px -4px 10px; }
.dash-tab { flex: 1; border: 0; background: none; padding: 7px 2px 9px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.dash-tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.dash-dot { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10.5px; padding: 0 4px; margin-left: 4px; text-align: center; }
.dash-new { font-size: 10.5px; font-weight: 700; color: #fff; background: var(--bad); border-radius: 5px; padding: 0 6px; }
.dash-rel { border-top: 1px solid var(--line); padding: 8px 0; }
.dash-rel:first-child { border-top: 0; padding-top: 0; }
.dash-rel-h { display: flex; gap: 8px; align-items: center; }
.dash-rel ul { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.dash-stp { margin-top: 10px; }
.dash-stp:first-child { margin-top: 0; }
.dash-stp-h { font-weight: 700; font-size: 13px; color: var(--accent); margin-bottom: 5px; }
.dash-imp { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dash-imp li { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 12.5px; line-height: 1.45; display: grid; gap: 2px; }
.dash-imp li span { color: var(--muted); }
.dash-imp li .dash-fix { color: var(--ink); }
.dash-imp li.crit { border: 2px solid var(--bad); background: var(--bad-soft); }
.dash-imp li.crit b, .dash-imp li.crit span { color: var(--bad); }
.dash-more { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12.5px; }
@media (max-width: 760px) { .dash-hide-m { display: none; } .dash-stages { grid-template-columns: repeat(3, 1fr); } }

/* 8.7: KPI tháng (khung trên trang Dự án + menu KPI & Thống kê) */
.kpi-box { border: 2px solid var(--accent); margin-top: 12px; }
.kpi-box h3 { margin: 0; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kpi-grid > div { display: grid; gap: 6px; }
.kpi-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.kpi-bar > div { height: 100%; background: var(--accent); }
.kpi-bar.ok > div { background: var(--ok); } .kpi-bar.warn > div { background: var(--warn); } .kpi-bar.bad > div { background: var(--bad); }
.kpi-tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 8px; background: var(--line); color: var(--muted); white-space: nowrap; }
.kpi-tag.ok { background: var(--ok-soft); color: var(--ok); } .kpi-tag.warn { background: var(--warn-soft); color: var(--warn); } .kpi-tag.bad { background: var(--bad-soft); color: var(--bad); }
.kpi-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; max-width: 420px; }
.kpi-tabs .dash-tab { font-size: 14px; }
.kpi-table td.num, .kpi-table th.num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kpi-in { width: 76px; text-align: right; }
.kpi-prog { min-width: 110px; }
.dash-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) { .kpi-grid { grid-template-columns: 1fr; } }
.section-head input[type=month] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }

/* 8.8: cảnh báo vàng có nút xử lý */
.yellow-box { display: grid; gap: 6px; margin-top: 6px; }
.yw-item { background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.yw-actions { margin-top: 4px; gap: 6px; }
.logic-check ul { list-style: none; padding-left: 0; margin: 4px 0 0; }
.logic-check li { margin: 2px 0; }

/* ---------- 9.6.8 (Nam 18/10): màn hình tối ---------- */
:root[data-theme="dark"] {
  --bg: #15161a;
  --panel: #1e2026;
  --ink: #e6e6e3;
  --muted: #a3a29d;
  --line: #33353d;
  --accent: #6d7cff;
  --accent-soft: #252a52;
  --accent-ink: #c3c9ff;
  --ok: #3fbf7f;
  --ok-soft: #173329;
  --warn: #e0a23a;
  --warn-soft: #382c14;
  --info: #7aa0ff;
  --info-soft: #1c2747;
  --bad: #ef6b6b;
  --bad-soft: #3d1f22;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --field: #17181d;
  --soft: #23252c;
  --soft2: #26282f;
  --bg-soft: #23252c;
  --chip: #2c2e36;
  --col: #1a1c21;
  --track: #2e3038;
  --track2: #4a4c57;
  --line2: #4a4c57;
  --ink2: #c9c7d6;
  --muted2: #a9a7b8;
  --ok-line: #2c5a44; --ok-ink: #a6e6c4;
  --warn-line: #6b5222; --warn-ink: #f2cd8a;
  --info-line: #34467a; --info-ink: #bccdff;
  --bad-ink: #ffb8b8;
  color-scheme: dark;
}
:root[data-theme="dark"] a { color: #9fb0ff; }
:root[data-theme="dark"] a.btn, :root[data-theme="dark"] .topbar a { color: inherit; }
:root[data-theme="dark"] a.btn.primary { color: #fff; }
:root[data-theme="dark"] .topbar { background: #0e0f12; }
:root[data-theme="dark"] .btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
:root[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, 0.6); }
:root[data-theme="dark"] .toast { background: #2c2e36; }
:root[data-theme="dark"] img.logo-mark, :root[data-theme="dark"] .auth-logo { filter: none; }
.theme-btn { min-width: 34px; }
:where(:root[data-theme="dark"]) .btn, :where(:root[data-theme="dark"]) input, :where(:root[data-theme="dark"]) textarea, :where(:root[data-theme="dark"]) select { color: var(--ink); }
:where(:root[data-theme="dark"]) input, :where(:root[data-theme="dark"]) textarea, :where(:root[data-theme="dark"]) select { background-color: var(--field); border-color: var(--line); }

/* 9.8.5: chèn shot ở bước Render */
.insert-bar { display: flex; align-items: center; gap: 10px; padding: 4px 14px; }
.insert-bar::before, .insert-bar::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.insert-bar .btn { border-style: dashed; }
.insert-row { background: var(--accent-soft); }
.insert-opt { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.insert-note { font-style: italic; margin-top: 4px; }

/* 9.8.6: phim drama USA: nhãn + bản dịch tiếng Việt kèm kịch bản tiếng Anh */
.us-tag { background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; vertical-align: middle; }
.us-pairs { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
.us-line { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.us-vi-line { color: var(--muted); font-style: italic; }
.us-gap { height: 8px; }
