/* Dragon Game · Game Design — cùng tông màu với Bug Center. */
:root {
  --ink: #243246; --muted: #6b7a8e; --line: #e1e7ef; --line2: #d3dbe6; --bg: #f6f8fb; --panel: #fff; --head: #f2f5f8;
  --brand: #138a62; --brand-deep: #077553; --brand-soft: #e3f4ec; --blue: #2454a6; --sel: #1a73e8; --sel-fill: rgba(26, 115, 232, .1);
  --bad: #c0392b; --bad-bg: #fdecea; --warn: #9a6206; --warn-bg: #fff4dc; --ok: #1f7a4d; --ok-bg: #e3f4ec;
  --shadow: 0 12px 40px rgba(41, 57, 83, .14); --radius: 10px;
  --chart: #138a62; --chart-grid: #e6ebf1; --chart-axis: #79879a; --chart-target: #243246;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e4eaf2; --muted: #9aa8ba; --line: #2c3746; --line2: #364354; --bg: #121820; --panel: #18202b; --head: #1e2833;
    --brand: #2fa87b; --brand-deep: #48c393; --brand-soft: #173a2f; --blue: #7aa7f0; --sel: #6aa3ff; --sel-fill: rgba(106, 163, 255, .16);
    --bad: #ff7b6e; --bad-bg: #3b1f1d; --warn: #f0b35a; --warn-bg: #3a2c14; --ok: #6fd3a3; --ok-bg: #173a2f;
    --shadow: 0 12px 40px rgba(0, 0, 0, .45); --chart: #2fa87b; --chart-grid: #2a3441; --chart-axis: #8d9bad; --chart-target: #e4eaf2;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
a { color: var(--blue); }
.link { color: var(--blue); text-decoration: none; }
.link:hover { text-decoration: underline; }
kbd { font: 12px Consolas, monospace; background: var(--head); border: 1px solid var(--line2); border-radius: 4px; padding: 1px 5px; }

/* Nút */
.btn { font: inherit; border: 1px solid var(--line2); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--head); }
.btn:focus-visible, .chip:focus-visible, .tcard:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-deep); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover, .btn.ghost.on { background: var(--head); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* Đăng nhập */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.login-card input, .field input, .field select, .field textarea, .filters input, .filters select, select, input[type=date] { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; }
.form-err { color: var(--bad); min-height: 1em; font-size: 13px; }
.brand-row { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-row span { color: var(--brand); font-weight: 600; }
.appicon { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }

/* Thanh trên */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.gamepick { display: flex; align-items: center; gap: 6px; }
.gamepick select { padding: 6px 8px; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--ink); padding: 7px 12px; border-radius: 8px; font-weight: 600; }
.nav a:hover { background: var(--head); }
.nav a.on { background: var(--brand-soft); color: var(--brand-deep); }
.nav .count:not(:empty) { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }
.me { display: flex; align-items: center; gap: 8px; }
.me span { display: grid; line-height: 1.15; }
.me small { color: var(--muted); font-size: 11px; }
main { flex: 1; min-height: 0; }

/* Trang */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.page.wide { max-width: 1500px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin: 0 0 2px; font-size: 22px; }
.page-head p { margin: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.search { min-width: 260px; flex: 0 1 340px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line2); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 4px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip b { color: var(--muted); font-weight: 600; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.pad { padding: 14px 16px; overflow: visible; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card.bad { border-color: var(--bad); }
.pad { padding: 10px 14px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.banner { padding: 8px 16px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

/* Bảng danh sách */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--head); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--head); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.act { text-align: right; width: 1%; white-space: nowrap; }
.title { font-weight: 600; }
.tpl { display: inline-block; width: 22px; }
.tpl.big { font-size: 20px; width: auto; }

/* Trạng thái */
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.st-draft { background: var(--head); color: var(--muted); } .dot.st-draft { background: var(--muted); }
.st-writing { background: #e5efff; color: var(--blue); } .dot.st-writing { background: var(--blue); }
.st-review { background: var(--warn-bg); color: var(--warn); } .dot.st-review { background: var(--warn); }
.st-approved { background: var(--ok-bg); color: var(--ok); } .dot.st-approved { background: var(--ok); }
.ts-todo { background: var(--head); color: var(--muted); } .dot.ts-todo { background: var(--muted); }
.ts-doing { background: #e5efff; color: var(--blue); } .dot.ts-doing { background: var(--blue); }
.ts-review { background: var(--warn-bg); color: var(--warn); } .dot.ts-review { background: var(--warn); }
.ts-changes { background: var(--bad-bg); color: var(--bad); } .dot.ts-changes { background: var(--bad); }
.ts-done { background: var(--ok-bg); color: var(--ok); } .dot.ts-done { background: var(--ok); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-writing, :root:not([data-theme="light"]) .ts-doing { background: #1c2c46; } }
.badge-sel { font: inherit; font-size: 13px; font-weight: 600; border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }

/* Ảnh đại diện */
.av { --h: 160; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 50% 25%); font-size: 10px; font-weight: 700; vertical-align: middle; flex: none; }
.av.big { width: 32px; height: 32px; font-size: 12px; }
.av.empty { background: var(--head); color: var(--muted); border: 1px dashed var(--line2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .av:not(.empty) { background: hsl(var(--h) 30% 28%); color: hsl(var(--h) 60% 85%); } }

/* Mẫu */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; text-align: left; margin-top: 12px; }
.tpl-card { font: inherit; color: var(--ink); text-align: left; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 12px; cursor: pointer; display: grid; gap: 4px; }
.tpl-card:hover { border-color: var(--brand); }
.tpl-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); background: var(--brand-soft); }
.tpl-card small { color: var(--muted); font-size: 12px; }
.tpl-ic { font-size: 22px; }

/* Hộp thoại */
.overlay { position: fixed; inset: 0; background: rgba(20, 30, 45, .42); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.field .muted { font-weight: 400; }
.field textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
table.keys td { padding: 4px 10px 4px 0; vertical-align: top; }

/* Thông báo, menu */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #243246; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: min(560px, calc(100% - 32px)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }
.ctx { position: fixed; z-index: 150; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 200px; }
.ctx button { display: flex; width: 100%; justify-content: space-between; gap: 18px; font: inherit; font-size: 13px; text-align: left; background: none; border: 0; color: var(--ink); padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.ctx button:hover:not(:disabled) { background: var(--head); }
.ctx button:disabled { opacity: .45; cursor: default; }
.ctx kbd { font-size: 11px; color: var(--muted); background: none; border: 0; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* ======== Trình soạn ======== */
.editor { display: flex; flex-direction: column; height: calc(100vh - 51px); }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-title { font: 600 17px/1.3 inherit; font-family: inherit; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; min-width: 220px; max-width: 520px; flex: 0 1 420px; }
.ed-title:hover { border-color: var(--line2); }
.ed-title:focus { border-color: var(--sel); outline: 0; background: var(--panel); }
.ed-meta { font-size: 13px; }
.chip-link { text-decoration: none; color: var(--ink); font-size: 13px; border: 1px solid var(--line2); border-radius: 999px; padding: 3px 10px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.pending { color: var(--warn); }
.save-state.err { color: var(--bad); font-weight: 600; }
.save-state.ok { color: var(--ok); }
.sheet-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.sh { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--panel); }
.sh-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line); background: var(--head); flex-wrap: wrap; }
.tb { font: inherit; font-size: 13px; min-width: 30px; height: 30px; border: 1px solid transparent; background: transparent; color: var(--ink); border-radius: 6px; padding: 0 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.tb:hover:not(:disabled) { background: var(--panel); border-color: var(--line2); }
.tb:disabled { opacity: .4; cursor: default; }
.tb-sep { width: 1px; height: 20px; background: var(--line2); margin: 0 6px; }
.tb-caret { font-size: 9px; color: var(--muted); }
.tb-a { font-weight: 700; text-decoration: underline; text-decoration-color: var(--bad); text-decoration-thickness: 3px; }
.tb-pop { position: relative; }
.tb-menu { position: absolute; top: 34px; left: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; display: grid; grid-template-columns: repeat(5, 24px); gap: 6px; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line2); cursor: pointer; font-size: 11px; color: var(--muted); padding: 0; }
.sh-fbar { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.sh-ref { width: 96px; flex: none; padding: 5px 10px; font: 600 13px Consolas, monospace; color: var(--muted); border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.sh-fx { padding: 5px 8px; color: var(--muted); font-style: italic; border-right: 1px solid var(--line); }
.sh-fxin { flex: 1; font: inherit; border: 0; resize: none; padding: 5px 10px; color: var(--ink); background: var(--panel); outline: 0; height: 30px; max-height: 120px; }
.sh-fxin:focus { height: 80px; box-shadow: inset 0 0 0 2px var(--sel); }
.sh-find { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--warn-bg); }
.sh-findin { font: inherit; padding: 4px 8px; border: 1px solid var(--line2); border-radius: 6px; width: 280px; background: var(--panel); color: var(--ink); }
.sh-findn { font-size: 12px; color: var(--muted); min-width: 64px; }
.sh-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; background: var(--panel); }
.sh-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; font-size: 13px; }
.sh-grid th, .sh-grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; height: 26px; }
.sh-grid td { white-space: pre-wrap; word-break: break-word; vertical-align: top; cursor: cell; background: var(--panel); }
.sh-grid thead th { position: sticky; top: 0; z-index: 3; background: var(--head); font-weight: 600; text-align: left; user-select: none; vertical-align: top; }
.sh-grid th.sh-rh { position: sticky; left: 0; z-index: 2; background: var(--head); color: var(--muted); font-weight: 400; font-size: 12px; text-align: center; user-select: none; cursor: pointer; }
.sh-grid th.sh-corner { left: 0; z-index: 4; cursor: pointer; }
.sh-grid th.on { background: #d3e3fd; color: #0b57d0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sh-grid th.on { background: #213a63; color: #a8c7fa; } }
.sh-ch { position: relative; cursor: pointer; }
.sh-letter { display: block; font-size: 11px; color: var(--muted); font-weight: 400; text-align: center; }
.sh-ch.on .sh-letter { color: inherit; }
.sh-cname { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-rz { position: absolute; right: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; }
.sh-rz:hover { background: var(--sel); opacity: .5; }
.sh-chin { width: 100%; font: inherit; border: 1px solid var(--sel); border-radius: 4px; padding: 2px 4px; }
.sh-range { position: absolute; display: none; pointer-events: none; background: var(--sel-fill); border: 1px solid var(--sel); z-index: 1; }
.sh-active { position: absolute; display: none; pointer-events: none; border: 2px solid var(--sel); z-index: 1; }
.sh-input { position: absolute; z-index: 2; opacity: 0; resize: none; border: 0; padding: 4px 6px; margin: 0; font: inherit; font-size: 13px; line-height: 1.45; overflow: hidden; color: var(--ink); background: var(--panel); outline: 0; white-space: pre-wrap; caret-color: transparent; pointer-events: none; }
.sh-input.on { opacity: 1; caret-color: auto; pointer-events: auto; box-shadow: 0 0 0 2px var(--sel), 0 4px 14px rgba(0, 0, 0, .15); overflow: auto; }
.sh-grid td.sh-hit { background: #fff1a8 !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sh-grid td.sh-hit { background: #5a4a10 !important; } }
.sh-more { position: sticky; left: 0; padding: 10px 52px 24px; display: flex; gap: 8px; }
.sh-tabs { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-top: 1px solid var(--line); background: var(--head); overflow-x: auto; }
.sh-tlist { display: flex; gap: 2px; }
.sh-tab { font: inherit; font-size: 13px; border: 1px solid transparent; background: transparent; color: var(--ink); padding: 5px 14px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; }
.sh-tab:hover { background: var(--panel); }
.sh-tab.on { background: var(--panel); border-color: var(--line2); border-bottom-color: var(--panel); color: var(--brand-deep); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
.sh-tabin { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--sel); border-radius: 6px; width: 160px; }
.sh-tadd { font: inherit; font-size: 16px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--ink); border-radius: 6px; cursor: pointer; }
.sh-tadd:hover { background: var(--panel); }
.sh-hint { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; padding-left: 16px; }
.sh-ro .sh-grid td { cursor: default; }

/* ======== Công việc ======== */
.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.col { background: var(--head); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.col-head { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 6px 10px; }
.col-head b { color: var(--muted); font-weight: 600; }
.col-head .hint { margin-left: auto; font-size: 11px; color: var(--warn); font-weight: 600; }
.col-body { display: grid; gap: 8px; }
.col-empty { text-align: center; color: var(--muted); padding: 10px; }
.tcard { font: inherit; text-align: left; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; cursor: pointer; display: grid; gap: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.tcard:hover { border-color: var(--brand); }
.tcard.urgent { border-left: 3px solid var(--bad); }
.tc-top { display: flex; align-items: center; gap: 6px; }
.tc-id { font: 600 11px Consolas, monospace; color: var(--muted); }
.tc-title { font-weight: 600; line-height: 1.3; }
.tc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.prio { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 5px; }
.p-urgent { background: var(--bad-bg); color: var(--bad); }
.p-high { background: var(--warn-bg); color: var(--warn); }
.due { font-size: 12px; white-space: nowrap; color: var(--muted); }
.due.over, .due.late-done { color: var(--bad); font-weight: 600; }
.due.soon { color: var(--warn); font-weight: 600; }
.due.ok { color: var(--ok); }
.pts { color: var(--brand-deep); font-weight: 600; font-size: 12px; }
.rev { color: var(--warn); font-size: 12px; }
.legend { display: inline-flex; gap: 12px; flex-wrap: wrap; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); z-index: 60; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); padding: 14px 18px 30px; overflow: auto; }
.dr-head { display: flex; align-items: center; gap: 8px; }
.dr-title { margin: 10px 0 12px; font-size: 19px; line-height: 1.3; }
.dr-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; margin: 0 0 14px; font-size: 13px; }
.dr-grid dt { color: var(--muted); }
.dr-grid dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dr-desc { white-space: pre-wrap; background: var(--head); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.dr-prog { margin-bottom: 14px; display: grid; gap: 6px; }
.dr-prog input { width: 100%; accent-color: var(--brand); }
.dr-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.dr-comment { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 16px; }
.dr-comment textarea { flex: 1; font: inherit; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; resize: vertical; background: var(--panel); color: var(--ink); }
.drawer h3 { font-size: 14px; margin: 0 0 8px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 13px; }
.timeline li { border-left: 2px solid var(--line); padding-left: 10px; }
.tl-note { white-space: pre-wrap; background: var(--head); border-radius: 6px; padding: 6px 10px; margin-top: 4px; }

/* ======== KPI ======== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.tile.bad { border-color: var(--bad); }
.tile.bad .t-label { color: var(--bad); font-weight: 600; }
.t-label { font-size: 12px; color: var(--muted); }
.t-val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-val small { font-size: 15px; color: var(--muted); font-weight: 500; }
.t-sub { font-size: 12px; color: var(--muted); }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.kpi-grid.three { grid-template-columns: repeat(3, 1fr); }
.kpi-grid + .card { margin-bottom: 14px; }
.chart { position: relative; min-height: 120px; }
.chart svg { display: block; max-width: 100%; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--chart-axis); font-size: 11px; }
.chart .lbl { fill: var(--ink); font-size: 12px; }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .bar { fill: var(--chart); }
.chart .target { stroke: var(--chart-target); stroke-width: 2; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; }
.chart .dotm, .chart .crossdot { fill: var(--chart); stroke: var(--panel); stroke-width: 2; }
.chart .cross { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit:hover .bar { opacity: .85; }
.ch-tip { position: absolute; display: none; pointer-events: none; background: var(--ink); color: var(--panel); font-size: 12px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; z-index: 5; }
table.kpi td { padding: 8px 12px; }
.tgt { width: 72px; font: inherit; text-align: right; border: 1px solid var(--line2); border-radius: 6px; padding: 3px 6px; background: var(--panel); color: var(--ink); }
.pbar { display: inline-block; width: 90px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.pbar span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.tlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tlist li { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.link-btn { font: inherit; text-align: left; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn:hover { color: var(--blue); }
.tl-meta { display: flex; gap: 6px; align-items: center; flex: none; }

@media (max-width: 900px) {
  .kpi-grid, .kpi-grid.three, .row3, .row2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(5, 260px); }
  .brand-txt, .sh-hint { display: none; }
  .search { min-width: 0; flex: 1 1 100%; }
}

/* ======== Thư viện mẫu ======== */
.modal.xwide { width: min(1120px, 100%); }
.tp-top { margin-bottom: 4px; }
.tp { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: min(470px, calc(100vh - 330px)); min-height: 300px; }
.tp-left { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.tp-left .search { min-width: 0; flex: none; width: 100%; }
#tpList { overflow: auto; flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tp-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 8px 4px; }
.tp-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; font: inherit; color: var(--ink); background: none; border: 1px solid transparent; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.tp-item:hover { background: var(--head); }
.tp-item.on { background: var(--brand-soft); border-color: var(--brand); }
.tp-item b { display: block; font-size: 13px; }
.tp-item small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.tp-ic { font-size: 20px; line-height: 1.2; width: 26px; flex: none; text-align: center; }
.tp-right { overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.tp-head { display: flex; gap: 12px; align-items: flex-start; }
.tp-head h3 { margin: 0 0 4px; font-size: 17px; }
.tp-head p { margin: 0 0 4px; }
.tp-big { font-size: 34px; line-height: 1; }
.tp-sheets { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 8px; }
.tp-tab { font: inherit; font-size: 12px; border: 1px solid var(--line2); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.tp-tab.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); font-weight: 600; }
.tp-prev { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 250px; }
.tp-prev table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.tp-prev th { position: sticky; top: 0; background: var(--head); text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tp-prev td { padding: 5px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; max-width: 260px; white-space: pre-wrap; }
.tp-prev td.b { font-weight: 700; }
.hint { font-style: italic; color: #7b8798; }
.tp-ex { margin-right: auto; font-size: 13px; }
@media (max-width: 900px) { .tp { grid-template-columns: 1fr; height: auto; } #tpList { max-height: 220px; } }
.tp-left .search { font: inherit; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); color: var(--ink); }
