/* Giao dien Spy Team: dien thoai truoc, may tinh sau; sang/toi theo he thong. */

:root {
  --bg: #f1f3f6;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e3e6eb;
  --ink: #15191f;
  --ink-soft: #5f6b7a;
  --ink-faint: #6b7785;              /* chu phu 11-12px: 4.6:1 tren nen trang */
  --accent: #2563eb;                 /* nen nut, vien, thanh tien do */
  --accent-text: #1d4ed8;            /* chu/link mau nhan: du tuong phan tren nen sang (toi: #7aa7ff) */
  --accent-dark: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .1);
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --violet: #7c3aed;
  --col-bg: #e8ebf0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .28);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --panel: #181c22;
    --panel-2: #1f242b;
    --line: #2a313b;
    --ink: #e7eaef;
    --ink-soft: #9ba5b4;
    --ink-faint: #8b96a6;
    --accent-text: #7aa7ff;
    --accent-soft: rgba(96, 140, 255, .16);
    --col-bg: #141820;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #181c22; --panel-2: #1f242b; --line: #2a313b; --ink: #e7eaef; --ink-soft: #9ba5b4;
  --ink-faint: #8b96a6; --accent-text: #7aa7ff; --accent-soft: rgba(96, 140, 255, .16); --col-bg: #141820; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--accent-text); }
code { background: rgba(127, 140, 158, .16); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.muted { color: var(--ink-soft); font-size: 13px; }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
[hidden] { display: none !important; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }

/* ---------- man hinh cho / dang nhap ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.small { width: 18px; height: 18px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; width: 100%; max-width: 400px; }
.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.logo-row h1 { margin: 0; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; font-size: 16px; flex: none; }

/* ---------- form ---------- */
label { display: block; margin: 12px 0 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
label.check, label.inline { font-weight: 500; color: var(--ink); }
input, textarea, select {
  width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
input[type="color"] { padding: 2px; height: 38px; width: 56px; }
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.form-error { margin: 12px 0 0; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; background: rgba(220, 38, 38, .1); color: var(--danger); border: 1px solid rgba(220, 38, 38, .25); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.form-grid label { margin-top: 10px; }
.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 3px; font-weight: 400; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* ---------- nut ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 13px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; line-height: 1.3;
}
.btn:hover { border-color: var(--accent); color: var(--accent-text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--danger); border-color: rgba(220, 38, 38, .4); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(1.08); color: #fff; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.big { padding: 12px 20px; width: 100%; font-size: 15px; margin-top: 16px; }   /* cach o nhap cuoi ke ca khi dong bao loi dang an */
.btn:disabled { opacity: .55; cursor: progress; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink); cursor: pointer; font: inherit; font-size: 18px; position: relative;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.small { width: 28px; height: 28px; font-size: 16px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.kbd { font: 11px ui-monospace, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--ink-soft); }
.btn .kbd { color: inherit; border-color: currentColor; opacity: .85; }   /* tren nut xanh/do: chu cung mau chu nut, khong xam mo */

/* ---------- chip / badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .dot { background: #fff !important; }
.chip.static { cursor: default; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-row.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row.scroll::-webkit-scrollbar { display: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(127, 140, 158, .18); color: var(--ink-soft); white-space: nowrap; }
.badge.ok { background: rgba(22, 163, 74, .15); color: var(--ok); }
.badge.warn { background: rgba(217, 119, 6, .16); color: var(--warn); }
.badge.danger { background: rgba(220, 38, 38, .14); color: var(--danger); }
.badge.violet { background: rgba(124, 58, 237, .14); color: var(--violet); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.tint { color: #fff; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: rgba(127, 140, 158, .16); font-size: 12px; }

.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 11px; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

/* ---------- thanh tren ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; flex: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 11px; font-weight: 600; white-space: nowrap; border-radius: 9px; color: var(--ink-soft); text-decoration: none; font-size: 13px; }
.nav a:hover { color: var(--ink); background: var(--accent-soft); }
.nav a.on { color: var(--accent-text); background: var(--accent-soft); }
.top-right { display: flex; align-items: center; gap: 6px; flex: none; }
.today-chip { font-weight: 700; }
.today-chip.ok { background: rgba(22, 163, 74, .15); border-color: rgba(22, 163, 74, .4); color: var(--ok); }
.today-chip.warn { background: rgba(217, 119, 6, .14); border-color: rgba(217, 119, 6, .4); color: var(--warn); }
.today-chip.danger { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .4); color: var(--danger); }
.bell-wrap, .avatar-wrap { position: relative; }
.bell-count { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.avatar-btn { border: 0; background: none; padding: 2px; cursor: pointer; border-radius: 50%; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden;
}
.menu-head { padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 12px; font: inherit; background: none; border: 0; color: var(--ink); cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--accent-soft); }
.bell-menu { width: 360px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto; }
.bell-item { display: block; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; }
.bell-item:hover { background: var(--accent-soft); }
.bell-item .t { color: var(--ink-faint); font-size: 11px; }
.bell-empty { padding: 18px 12px; color: var(--ink-soft); text-align: center; }

.banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-weight: 600; font-size: 13px; }
.banner.warn { background: rgba(217, 119, 6, .14); color: var(--warn); border-bottom: 1px solid rgba(217, 119, 6, .3); }
.banner .icon-btn { margin-left: auto; }
.guide { margin: 12px 16px 0; padding: 12px 14px; background: var(--accent-soft); border: 1px solid rgba(37, 99, 235, .25); border-radius: var(--radius); }
.guide-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.guide pre { font-size: 13px; line-height: 1.6; }

main { padding: 16px; }
.page { max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-box.tight { padding: 12px; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.box-head h2 { margin: 0; }
.empty { padding: 26px 10px; text-align: center; color: var(--ink-soft); }
.retry-box { text-align: center; padding: 30px; }

/* ---------- bo loc chung ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar select, .toolbar input { width: auto; margin-top: 0; padding: 7px 9px; font-size: 13px; }
.toolbar input[type="search"] { min-width: 160px; flex: 1; max-width: 320px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); }
.toolbar label.inline { font-size: 13px; }
.range-custom { display: inline-flex; gap: 4px; align-items: center; }
.range-custom input { width: 130px; }

/* ---------- bang Kanban ---------- */
.board-wrap { margin: 0 -16px; padding: 0 16px 16px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.board { display: flex; gap: 12px; align-items: flex-start; min-height: calc(100vh - 200px); }
.col {
  flex: none; width: 280px; background: var(--col-bg); border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - 190px); scroll-snap-align: start;
}
.col.inactive { opacity: .7; }
.col.drop-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col.locked-drop { outline: 2px dashed var(--danger); outline-offset: -2px; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; font-weight: 700; font-size: 13px; }
.col-head .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .count { color: var(--ink-soft); font-weight: 600; }
.col-body { flex: 1; overflow-y: auto; padding: 2px 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.col-foot { padding: 4px 8px 8px; }
.col-foot .btn { width: 100%; }
.placeholder { height: 60px; border: 2px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }

.card {
  position: relative; background: var(--panel); border-radius: 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
  border: 1px solid transparent; cursor: pointer; overflow: hidden; user-select: none;
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .4; }
.card.selected { outline: 2px solid var(--accent); }
.card-cover { aspect-ratio: 16 / 10; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; color: var(--ink-faint); font-size: 12px; font-weight: 600; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cover.ph { aspect-ratio: auto; height: 34px; justify-content: flex-start; padding: 0 10px; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 8px 10px 8px; }
.card-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.card-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.card-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--ink-soft); flex-wrap: wrap; }
.card-foot .m { white-space: nowrap; }
.card-foot .spacer { flex: 1; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--violet); flex: none; }
.unread-dot.comment { background: var(--danger); }
.card-check { position: absolute; top: 6px; left: 6px; z-index: 2; display: none; background: var(--panel); border-radius: 6px; padding: 2px 3px; }
.card-check input { width: 16px; height: 16px; }
.card:hover .card-check, .board.select-mode .card-check, .card.selected .card-check { display: block; }
.bulk-bar {
  position: sticky; bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 8px 12px; z-index: 5;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-weight: 600;
}
.bulk-bar select { width: auto; margin: 0; padding: 6px 8px; }
.truncated { padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(217, 119, 6, .14); color: var(--warn); font-weight: 600; margin-bottom: 10px; }

/* ---------- overlay / sheet (modal) ---------- */
.ovl { position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 20, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.ovl.center { align-items: center; }
.sheet {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: calc(100vh - 48px);
}
.sheet.md { max-width: 720px; }
.sheet.lg { max-width: 1040px; }
.sheet.sm { max-width: 420px; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { margin: 0; flex: 1; min-width: 0; font-size: 16px; }
.sheet-body { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); flex: none; background: var(--panel); border-radius: 0 0 14px 14px; }
.sheet-foot .left { margin-right: auto; }

/* ---------- the chi tiet (card modal) ---------- */
.cm-title-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cm-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; margin: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.cm-title:hover:not([readonly]) { border-color: var(--line); }
.cm-title:focus { background: var(--panel); border-color: var(--accent); }
.cm-title.auto { background: rgba(250, 204, 21, .18); }
.cm-hint { font-size: 12px; color: var(--warn); font-weight: 600; white-space: nowrap; }
.cm-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.cm-tools select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }
.cm-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .cm-grid { grid-template-columns: 3fr 2fr; } }
.cm-banner { padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.cm-banner.info { background: var(--accent-soft); color: var(--accent-text); }
.cm-banner.warn { background: rgba(217, 119, 6, .14); color: var(--warn); }
.cm-banner.danger { background: rgba(220, 38, 38, .12); color: var(--danger); }
.cm-banner.ok { background: rgba(22, 163, 74, .14); color: var(--ok); }
.cm-banner.violet { background: rgba(124, 58, 237, .14); color: var(--violet); }
.cm-section { margin-bottom: 16px; }
.cm-section h3 { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.fields .f { margin: 0; }
.fields .f.wide { grid-column: 1 / -1; }
.fields .f span.lbl { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.fields .f input, .fields .f select, .fields .f textarea { margin-top: 2px; padding: 6px 8px; font-size: 13px; }
.fields .f .ro { padding: 6px 0; font-size: 13px; min-height: 30px; word-break: break-word; }
.fields .f .ro a { word-break: break-all; }
.f .with-btn { display: flex; gap: 4px; align-items: center; }
.f .with-btn input { flex: 1; }
.f .sub { font-size: 11px; color: var(--ink-faint); }
.f input.saved { border-color: var(--ok); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cover-badge { position: absolute; top: 4px; left: 4px; background: var(--accent); color: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }   /* nen dac, doc duoc tren moi anh */
.thumb.is-cover { outline: 2px solid var(--accent); outline-offset: -2px; }
.thumb .acts { position: absolute; bottom: 0; left: 0; right: 0; display: flex; gap: 2px; padding: 3px; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); opacity: 0; transition: opacity .15s; }
.thumb:hover .acts, .thumb:focus-within .acts { opacity: 1; }
.thumb .acts button { flex: 1; font-size: 11px; padding: 3px 4px; border: 0; border-radius: 5px; background: rgba(255, 255, 255, .9); color: #111; cursor: pointer; font-family: inherit; font-weight: 600; }
.thumb.up { cursor: default; display: grid; place-items: center; text-align: center; font-size: 12px; padding: 4px; }
.thumb.up img { opacity: .4; position: absolute; inset: 0; }
.thumb.up .st { position: relative; z-index: 1; background: rgba(0, 0, 0, .55); color: #fff; padding: 3px 7px; border-radius: 6px; font-weight: 600; }
.thumb.up.err .st { background: var(--danger); }
.thumb.up.ok .st { background: var(--ok); }
.img-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.comment { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment .body { flex: 1; min-width: 0; }
.comment .meta { font-size: 11px; color: var(--ink-faint); display: flex; gap: 6px; align-items: center; }
.comment .meta b { color: var(--ink-soft); }
.comment .text { white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.comment-box textarea { min-height: 56px; margin-top: 0; }
.comment-box .row { margin-top: 6px; justify-content: space-between; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-soft); }
.timeline li { padding: 4px 0 4px 14px; position: relative; border-left: 2px solid var(--line); }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline .t { color: var(--ink-faint); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 0; }
.lightbox .sheet { display: contents; }   /* sheet van la hop thoai (tieu diem, Tab) nhung khong ve khung; nut/anh nam thang trong .lightbox */
.lightbox img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lightbox .lb-close { position: absolute; top: 10px; right: 12px; color: #fff; font-size: 30px; background: none; border: 0; cursor: pointer; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 34px; background: rgba(0, 0, 0, .3); border: 0; cursor: pointer; padding: 10px 14px; border-radius: 10px; }
.lightbox .lb-prev { left: 8px; }
.lightbox .lb-next { right: 8px; }

/* ---------- them mau ---------- */
.paste-zone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--ink-soft); font-weight: 600;
  background: var(--panel-2); cursor: pointer; outline: none;
}
.paste-zone:focus, .paste-zone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.queue { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.queue .q { position: relative; width: 84px; }
.queue .q img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.queue .q .sz { font-size: 10px; color: var(--ink-faint); text-align: center; }
.queue .q .rm { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 12px; cursor: pointer; line-height: 1; }
.dup-warn { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(217, 119, 6, .14); color: var(--warn); font-weight: 600; font-size: 13px; }
.dup-warn .row { margin-top: 6px; }
.similar { margin-top: 6px; font-size: 12px; color: var(--ink-faint); }
.details-toggle { margin-top: 12px; font-weight: 600; color: var(--accent-text); background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.niche-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.niche-chips .chip.on { color: #fff; }

/* ---------- bang du lieu ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent-text); }
th.sorted { color: var(--accent-text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--accent-soft); }
tbody tr.total { font-weight: 700; background: var(--panel-2); }
td .mini-img { width: 44px; height: 32px; object-fit: cover; border-radius: 5px; display: block; background: var(--panel-2); }
.cell-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; font-size: 13px; }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; min-width: 80px; }
.progress i { display: block; height: 100%; background: var(--accent); width: var(--p, 0%); transition: width .3s; }
.progress.ok i { background: var(--ok); }
.progress.warn i { background: var(--warn); }
.progress.danger i { background: var(--danger); }
.progress.big { height: 14px; }
.breakdown { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.who-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; padding: 8px 0; }
.mini-card { display: flex; gap: 8px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--panel); }
.mini-card:hover { border-color: var(--accent); }
.mini-card img, .mini-card .ph { width: 48px; height: 36px; object-fit: cover; border-radius: 5px; background: var(--panel-2); flex: none; display: grid; place-items: center; font-size: 10px; color: var(--ink-faint); }
.mini-card .t { font-size: 12px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini-card .s { font-size: 11px; color: var(--ink-faint); }

/* ---------- theo ngay ---------- */
.daynav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.daynav input[type="date"] { width: auto; margin: 0; }
.month-strip { display: flex; gap: 4px; overflow-x: auto; padding: 8px 0; scrollbar-width: thin; }
.month-strip button { flex: none; width: 44px; padding: 4px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; font: inherit; font-size: 11px; color: var(--ink-soft); }
.month-strip button b { display: block; font-size: 13px; color: var(--ink); }
.month-strip button.on { border-color: var(--accent); background: var(--accent-soft); }
.month-strip button.off { opacity: .5; }
.month-strip button .n { color: var(--accent-text); font-weight: 700; }
.progress-card { display: grid; gap: 8px; }
.progress-card .big-n { font-size: 32px; font-weight: 800; line-height: 1; }

/* ---------- cham cong ---------- */
.att-grid-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.att-grid { border-collapse: separate; border-spacing: 0; font-size: 11px; }
.att-grid th, .att-grid td { padding: 3px 4px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; }
.att-grid th:first-child, .att-grid td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 2; text-align: left; min-width: 130px; }
.att-grid th { top: 0; }
.att-grid td.off, .att-grid th.off { background: rgba(127, 140, 158, .12); }
.att-grid td.cell { cursor: pointer; min-width: 46px; height: 40px; vertical-align: middle; }
.att-grid td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.att-grid td.g { background: rgba(22, 163, 74, .18); }
.att-grid td.a { background: rgba(217, 119, 6, .18); }
.att-grid td.r { background: rgba(220, 38, 38, .12); }
.att-grid .in { font-weight: 700; white-space: nowrap; }
.att-grid .in.late { color: var(--danger); }
.att-grid .sm:not(.avatar) { color: var(--ink-soft); }   /* :not(.avatar): avatar cung mang class "sm", chu cai phai giu mau trang */
.att-today { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.att-today .kv { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.att-today .kv b { display: block; font-size: 20px; }
.att-today .kv span { font-size: 12px; color: var(--ink-soft); }

/* ---------- thong ke ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 26px; line-height: 1.15; }
.kpi span { font-size: 12px; color: var(--ink-soft); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-box .legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--ink-soft); margin-top: 6px; }
.chart-box .legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 3px; vertical-align: middle; }
/* viewBox rong 360 (CHART_W trong app-pages.js) ~ be rong o bieu do khi ve -> chu 13px hien gan dung 13px */
.svg-axis { fill: var(--ink-faint); font-size: 13px; }
.svg-val { fill: var(--ink-soft); font-size: 13px; font-weight: 600; }
.svg-grid { stroke: var(--line); stroke-width: 1; }

/* ---------- cai dat ---------- */
.list-editor { display: grid; gap: 6px; }
.list-editor .li { display: flex; gap: 6px; align-items: center; }
.list-editor .li input { margin: 0; }
.col-editor .li { display: grid; grid-template-columns: auto 1fr auto auto auto auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.col-editor .li input[type="text"] { margin: 0; }
.col-editor .li select { margin: 0; width: auto; }
.col-editor .li .inactive-tag { opacity: .6; }
.meter { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); width: var(--p, 0%); }
.meter.warn i { background: var(--warn); }
.cred-block { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.wd-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- duyet mau ---------- */
.review-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 960px) { .review-layout { grid-template-columns: 3fr 2fr; } }
.review-cover { aspect-ratio: 16 / 10; background: var(--panel-2); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: var(--ink-faint); }
.review-cover img { width: 100%; height: 100%; object-fit: contain; }
.review-strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; }
.review-strip img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.review-strip img.on { border-color: var(--accent); }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; position: sticky; bottom: 8px; background: var(--panel); padding: 8px 0; }

/* ---------- toast / fab / upload panel ---------- */
/* Toast khong chan chuot: nam goc duoi phai (SPEC) ngay tren nut Luu cua hop thoai -> bam xuyen qua duoc, chi nut trong toast nhan click. */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 100; display: grid; gap: 8px; width: calc(100% - 32px); max-width: 380px; pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; color: #fff; background: #262c35; box-shadow: 0 8px 24px rgba(0, 0, 0, .28); animation: pop .2s ease-out; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }
.toast button { margin-left: auto; background: rgba(255, 255, 255, .2); border: 0; color: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; font: inherit; font-weight: 700; pointer-events: auto; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.fab { position: fixed; right: 16px; bottom: 20px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 8px 24px rgba(37, 99, 235, .45); cursor: pointer; z-index: 25; }
.upload-panel { position: fixed; left: 16px; bottom: 16px; z-index: 55; width: 260px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; }
.upload-panel .u { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.upload-panel .u img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.upload-panel .u .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- dien thoai ---------- */
/* iOS Safari tu phong to trang khi o nhap < 16px: moi o nhap tren dien thoai >= 16px, ke ca o co quy tac rieng (the chi tiet, thanh loc). */
@media (max-width: 860px) {
  input, textarea, select, .toolbar select, .toolbar input, .fields .f input, .fields .f select, .fields .f textarea, .cm-tools select, .bulk-bar select { font-size: 16px; }
  .fields .f input, .fields .f select, .fields .f textarea { padding: 5px 8px; }
}
@media (max-width: 640px) {
  main { padding: 12px 16px 96px; }   /* chua cho nut + (FAB) khong de len dong cuoi */
  .topbar { padding: 6px 12px; gap: 6px; flex-wrap: wrap; }
  .bell-menu { position: fixed; left: 12px; right: 12px; top: 54px; width: auto; max-width: none; }   /* neo theo man hinh, khong bi cat ben trai */
  .brand { order: 0; }
  .top-right { order: 1; margin-left: auto; }
  .nav { order: 2; width: 100%; flex: none; }
  .today-chip { padding: 3px 8px; font-size: 11px; }
  .card-box { padding: 12px; }
  .tbl-wrap, .att-grid-wrap, .board-wrap { margin: 0 -16px; padding: 0 16px; }
  .col { width: 85vw; max-height: calc(100vh - 230px); }
  .board-wrap { scroll-snap-type: x mandatory; }
  .ovl { padding: 0; align-items: stretch; }
  .sheet, .sheet.md, .sheet.lg, .sheet.sm { max-width: none; max-height: none; min-height: 100vh; border-radius: 0; border: 0; }
  .sheet-foot { position: sticky; bottom: 0; border-radius: 0; }
  .ovl.center .sheet { min-height: 0; margin: auto 12px; border-radius: 14px; border: 1px solid var(--line); }
  .fields { grid-template-columns: 1fr; }
  .cm-hint, .kbd-hint, .btn .kbd { display: none; }   /* goi y phim tat vo nghia tren dien thoai */
  .toasts { right: 12px; bottom: 84px; width: calc(100% - 24px); }
  .upload-panel { left: 12px; bottom: 84px; }
  .col-editor .li { grid-template-columns: 1fr 1fr; }
  .fab { display: block; }
}
@media (min-width: 641px) { .fab { display: none !important; } }
