/* TickOff — giao diện danh sách gọn, tập trung vào tick việc */
:root {
  --bg: #F4F3EE;
  --surface: #FFFFFF;
  --ink: #1B1A17;
  --ink-2: #3A3833;
  --muted: #5F5C55;
  --faint: #8C887E;
  --line: #E6E3DB;
  --line-2: #EFEDE7;
  --accent: #1F7A4D;
  --accent-ink: #155C39;
  --accent-soft: #E4F1E9;
  --red: #B42318;
  --red-soft: #FBEAE8;
  --amber: #9A4A0C;
  --blue: #1D4F86;
  --blue-soft: #E3EEF9;
  --radius: 10px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 64px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
p { margin: 0 0 10px; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.red { color: var(--red); font-weight: 600; }
.ok-text { color: var(--accent); font-weight: 600; }
.pad { padding: 0 16px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 20px; padding-bottom: 110px; }
.narrow { max-width: 640px; }
.narrow-left { max-width: 640px; }

/* Thanh trên */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 54px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4L18 8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/70% no-repeat; flex-shrink: 0; }
.brand-mark.big { width: 36px; height: 36px; border-radius: 9px; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--ink); background: var(--line-2); }
.nav a.on { color: var(--ink); background: var(--line-2); font-weight: 600; }
.me { display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
.me-name { color: var(--muted); }
.me a { color: var(--muted); }
@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; gap: 0 12px; padding-top: 6px; }
  .brand { order: 1; }
  .me { order: 2; margin-left: auto; }
  .me-name { display: none; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -8px; padding-bottom: 4px; }
}

.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--line-2); color: var(--muted); vertical-align: middle; }
.tag-off { background: var(--red-soft); color: var(--red); }

/* Đầu trang */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head-main { min-width: 0; flex: 1 1 260px; }
.sub { color: var(--muted); margin: 0; font-size: 14px; }
.crumb { margin: 0 0 8px; font-size: 14px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }

.progress { min-width: 180px; flex: 0 1 240px; }
.progress-num { font-size: 13px; color: var(--muted); margin-bottom: 5px; text-align: right; }
.progress-num strong { font-size: 18px; color: var(--ink); }
.bar { height: 5px; background: #E4E1D8; border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.mini-bar { display: inline-block; width: 64px; height: 4px; background: #E4E1D8; border-radius: 2px; overflow: hidden; vertical-align: middle; }
.mini-bar span { display: block; height: 100%; background: var(--accent); }

/* Tab sự kiện */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

/* Thanh lọc */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills a, .pill-toggle { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid #D9D6CD; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; }
.pills a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }

/* Nhóm và danh sách việc */
.group { margin-top: 18px; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 16px 6px; margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.group-count { font-weight: 600; color: var(--muted); letter-spacing: 0; }
.group-tools { display: inline-flex; align-items: center; gap: 4px; }
.tone-red .group-head > span:first-child { color: var(--red); }
.tone-green .group-head > span:first-child { color: var(--accent); }
.group-foot { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; padding: 8px 16px 0; }

.tasks, .rows, .subtasks, .log, .chips, .checks, .steps { list-style: none; margin: 0; padding: 0; }
.tasks, .rows { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (min-width: 721px) { .tasks, .rows { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; } }

.task { display: flex; align-items: stretch; border-bottom: 1px solid var(--line-2); transition: opacity .25s ease, transform .25s ease; }
.task:last-child { border-bottom: 0; }
.task.leaving { opacity: 0; transform: translateX(12px); }
.tick { width: 52px; min-height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: none; border: 0; padding: 0; cursor: pointer; }
.box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--faint); background: var(--surface); display: inline-block; flex-shrink: 0; transition: background-color .15s ease, border-color .15s ease; }
.st-overdue .box { border-color: var(--red); }
.is-done .box, [aria-pressed="true"] > .box { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/70% no-repeat; border-color: var(--accent); }
.tick:hover .box { border-color: var(--accent); }
.tick[disabled] { opacity: .5; cursor: progress; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 9px 14px 9px 0; color: inherit; text-decoration: none; }
.task-main:hover .tt { text-decoration: underline; text-decoration-color: var(--faint); }
.task-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tt { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-done .tt { text-decoration: line-through; color: var(--faint); }
.task-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--muted); }
.st-overdue .time { color: var(--red); font-weight: 600; }
.st-soon .time { color: var(--amber); font-weight: 600; }
.subs { display: inline-flex; align-items: center; gap: 3px; }
.ic { flex-shrink: 0; }
.badge-new { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); }

.tpl-tasks .task { align-items: center; }
.tpl-when { width: 128px; flex-shrink: 0; padding: 0 12px 0 16px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tpl-tasks .task-main { padding-left: 0; min-height: 52px; }
@media (max-width: 560px) { .tpl-when { width: 92px; padding-left: 12px; } }

/* Dòng chung (sự kiện, thành viên, Template) */
.rows > li { border-bottom: 1px solid var(--line-2); }
.rows > li:last-child { border-bottom: 0; }
.row-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: inherit; text-decoration: none; min-height: 56px; }
.row-link:hover .row-title { text-decoration: underline; text-decoration-color: var(--faint); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; }
.row-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--muted); }
.row-desc { font-size: 13px; color: var(--ink-2); }
.row-side { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.row-tools { display: flex; align-items: center; gap: 6px; padding-right: 12px; flex-wrap: wrap; }
.tpl-row { display: flex; align-items: center; flex-wrap: wrap; }
.tpl-row .row-link { flex: 1 1 300px; }
.tpl-row .row-tools { padding: 0 16px 12px; }
@media (min-width: 721px) { .tpl-row .row-tools { padding: 0 16px 0 0; } }
.member { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 12px; padding: 12px 16px; }
.member .row-main { flex: 1 1 240px; }
.member.is-off { opacity: .65; }
.member .row-tools { padding: 0; }
.row-actions { flex: 0 0 auto; font-size: 13px; }
.row-actions[open] { flex-basis: 100%; }
.row-actions > summary, .more > summary, details.panel > summary, details > summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.row-actions > summary { padding: 4px 0; }
.row-actions[open] > summary { margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 9px; border: 1px solid #D9D6CD; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--faint); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #8F1C13; color: #fff; }
.btn-danger-text { color: var(--red); }
.btn-danger-text:hover { color: #8F1C13; border-color: var(--red); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; }
.icon-btn:hover:not([disabled]) { background: var(--line-2); color: var(--ink); }
.icon-btn[disabled] { opacity: .3; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.actions form { margin: 0; }

.fab { position: fixed; right: max(16px, calc((100vw - 920px) / 2 + 16px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 15; display: inline-flex; align-items: center; gap: 6px; min-height: 50px; padding: 0 20px; border-radius: 25px; background: var(--ink); color: #fff; font-weight: 600; text-decoration: none; box-shadow: 0 6px 18px rgba(27, 26, 23, .22); }
.fab:hover { color: #fff; background: #000; }

/* Khối và form */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.panel > h2:first-child { margin-top: 0; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; }
fieldset.field { gap: 8px; }
fieldset.plain { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid #D4D0C6; border-radius: 8px; padding: 9px 11px; min-height: 42px; width: 100%; }
textarea { min-height: 0; resize: vertical; line-height: 1.45; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); flex-shrink: 0; }
input[type="file"] { padding: 7px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 12px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; }
.choice span { display: flex; flex-direction: column; gap: 1px; }
.choice small { color: var(--muted); font-size: 13px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: minmax(0, 1fr); } }
.row2 .field input { margin-top: 4px; }
.inline-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-row.panel { flex-direction: row; }
.inline-row .grow { flex: 1 1 200px; }
.inline-row input:not([type]), .inline-row input[type="password"], .inline-row select { flex: 1 1 180px; width: auto; }
.inline-row.compact { gap: 6px; align-items: center; margin-top: 8px; }
.inline-row.compact input, .inline-row.compact select { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 720px) { .split { grid-template-columns: minmax(0, 1fr); } }
.seg { display: inline-flex; border: 1px solid #D4D0C6; border-radius: 9px; overflow: hidden; align-self: flex-start; }
.seg label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 14px; cursor: pointer; }
.seg label + label { border-left: 1px solid #D4D0C6; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.lbl-slot { display: none; }
.is-slot .lbl-slot { display: inline; }
.is-slot .lbl-deadline { display: none; }
.only-slot { display: none; }
.is-slot .only-slot { display: flex; }
.danger-zone { border-color: #EBC7C3; }

/* Thông báo */
.flash { padding: 11px 14px; border-radius: 9px; margin: 0 0 12px; font-size: 14px; background: var(--accent-soft); color: #173F2A; border: 1px solid #C7E1D1; }
.flash-err { background: var(--red-soft); color: #7A1810; border-color: #EBC7C3; }
.flash a { color: inherit; font-weight: 600; }
.mono-box { display: block; background: var(--bg); border: 1px dashed #CFCBC1; padding: 8px 10px; border-radius: 7px; font-size: 13px; word-break: break-all; }
.mono-box.inline { display: inline; padding: 2px 6px; }
.pin { font-size: 18px; letter-spacing: 0.2em; }
.notifs { background: var(--blue-soft); border: 1px solid #C9DCF1; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.notifs ul { list-style: none; margin: 0; padding: 0; font-size: 14px; flex: 1 1 280px; }
.notifs li { padding: 3px 0; color: #1A3657; }
.notifs a { color: #123B66; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: min(420px, calc(100vw - 32px)); background: var(--ink); color: #fff; border-radius: 10px; padding: 0 6px 0 16px; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }
.toast-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-undo { min-height: 44px; padding: 0 12px; background: none; border: 0; color: #9EDDB9; font: inherit; font-weight: 700; cursor: pointer; flex-shrink: 0; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); }

/* Chi tiết việc */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-head h1 { flex: 1 1 280px; }
.status { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 6px; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.status-done { background: var(--accent-soft); color: var(--accent-ink); }
.status-overdue { background: var(--red-soft); color: var(--red); }
.status-soon { background: #FBEFD9; color: var(--amber); }
.facts { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.desc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; line-height: 1.6; }
.subs-box, .proof, .history { margin: 16px 0; }
.subtasks { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.subtasks li { border-bottom: 1px solid var(--line-2); }
.subtasks li:last-child { border-bottom: 0; }
.subtick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.subtasks .is-done .lbl { text-decoration: line-through; color: var(--faint); }
.proof img { border-radius: 8px; border: 1px solid var(--line); max-height: 360px; width: auto; }
.done-form { margin-top: 16px; }
.log { font-size: 14px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.log li:last-child { border-bottom: 0; }
.log.panel { padding: 6px 16px; }
.log-day { font-size: 12px; font-weight: 700; color: var(--muted); padding-top: 12px !important; }

/* Nhóm */
.team-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.team-tools { display: flex; }
.team-tools form { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--line-2); border-radius: 16px; padding: 3px 4px 3px 12px; font-size: 14px; position: relative; }
.chip-menu > summary { list-style: none; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 13px; color: var(--muted); }
.chip-menu > summary::-webkit-details-marker { display: none; }
.chip-menu[open] > summary { background: var(--line); }
.chip-pop { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.more { margin-top: 8px; }

/* Thống kê */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stats strong { font-size: 22px; line-height: 1.2; }
.stats span { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Đăng nhập, cài đặt */
.login { max-width: 400px; margin: 6vh auto 0; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 24px; font-weight: 700; margin-bottom: 18px; }
.pin-input { font-size: 26px; letter-spacing: 0.5em; text-align: center; }
.checks li { padding: 4px 0; font-size: 14px; }
.checks .ok { color: var(--accent-ink); }
.checks .bad { color: var(--red); font-weight: 600; }
.steps { counter-reset: s; }
.steps li { counter-increment: s; padding: 4px 0 4px 28px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 5px; width: 20px; height: 20px; border-radius: 10px; background: var(--line-2); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.qr-dialog { border: 0; border-radius: 14px; padding: 20px; max-width: 320px; text-align: center; }
.qr-dialog::backdrop { background: rgba(27, 26, 23, .45); }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img, .qr-box canvas { width: 240px; height: 240px; }

.foot { color: var(--faint); font-size: 12px; padding-bottom: 90px; letter-spacing: 0.04em; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print { .topbar, .fab, .toolbar, .tabs, .actions, .foot, .toast, .ntf-stack { display: none !important; } body { background: #fff; } }

/* Bình luận (1.1) */
.comments { margin: 20px 0; }
.comment-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.comment.is-mine { border-color: #CFE3D6; background: #F7FBF8; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 14px; margin-bottom: 2px; }
.comment-body { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.comment-tools { display: flex; align-items: flex-start; gap: 14px; margin-top: 6px; font-size: 13px; }
.comment-tools details { flex: 1; }
.comment-tools details[open] { flex-basis: 100%; }
.comment-tools form.form { margin-top: 8px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--red); }
.comment-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { border: 0; padding: 4px 6px; min-height: 48px; }
.comment-form textarea:focus { outline: none; }
.comment-form:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.comment-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ===== 1.2: công ty, khách hàng, yêu cầu, danh mục ===== */
.co-switch { display: inline-flex; align-items: center; gap: 6px; }
.co-switch select { min-height: 34px; padding: 4px 8px; font-size: 13px; font-weight: 600; width: auto; max-width: 180px; }
.co-name { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.co-dot { width: 10px; height: 10px; border-radius: 5px; display: inline-block; flex-shrink: 0; }
.co-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink-2); }
.co-tag::before { content: ""; width: 8px; height: 8px; border-radius: 4px; background: var(--co, var(--muted)); }
@media (max-width: 720px) { .co-switch, .co-name { order: 2; } .co-switch select { max-width: 140px; } }

.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; background: var(--line-2); padding: 1px 6px; border-radius: 4px; letter-spacing: 0.02em; white-space: nowrap; }
.code.big { font-size: 20px; padding: 2px 8px; }
.badge-svc { flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #F1E9DD; color: #6B4A12; }
.tag-loyal { background: #FBEFD9; color: var(--amber); }

.rstatus { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 5px; white-space: nowrap; vertical-align: middle; }
.rs-new { background: var(--blue-soft); color: var(--blue); }
.rs-consulting { background: #FBEFD9; color: var(--amber); }
.rs-won { background: var(--accent-soft); color: var(--accent-ink); }
.rs-lost { background: var(--line-2); color: var(--muted); }

.search-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.search-row input[type="search"] { flex: 1 1 240px; width: auto; }
.search-row select { flex: 0 1 180px; width: auto; }

.cust-panel { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 14px; }
.cust-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 14px; }
.cust-head .btn { margin-left: auto; }
.cust-facts { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 4px 12px; margin: 10px 0 0; font-size: 13.5px; }
.cust-facts dt { color: var(--muted); }
.cust-facts dd { margin: 0; }

.chips-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { position: relative; display: inline-flex; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid #D4D0C6; border-radius: 18px; font-size: 13.5px; background: var(--surface); cursor: pointer; user-select: none; }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-check input:checked + span::before { content: "✓ "; white-space: pre; }
.chip-check input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.svc-group { margin-bottom: 10px; }
.svc-group-name { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.dur-row { display: flex; gap: 12px; flex-wrap: wrap; }
.dur-row .field { flex: 1 1 140px; }
.dur-other { display: none; }
.is-dur-other .dur-other { display: flex; }
.only-pick { display: none; }
.is-pick .only-pick { display: flex; }
.is-pick .only-new { display: none; }
.dup-box { background: #FFF7E8; border: 1px solid #F0D9A8; border-radius: 9px; padding: 12px 14px; }
.dup-box ul { margin: 6px 0; padding-left: 18px; }

.event-link { border-left: 3px solid var(--accent); }
.comment.is-system { background: var(--bg); border-style: dashed; }
.comment.is-system .comment-body { color: var(--ink-2); font-size: 13.5px; }

.svc-list { list-style: none; margin: 0 0 8px; padding: 0; }
.svc-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.svc-list li:last-child { border-bottom: 0; }
.svc-list li.is-off { opacity: .6; }
.svc-list a { font-weight: 600; }
.panel.is-off { opacity: .7; }
.company h2 { display: flex; align-items: center; gap: 8px; margin: 0; }

.preview-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 9px; }
.preview-list li { padding: 6px 12px; border-bottom: 1px solid var(--line-2); }
.preview-list li:last-child { border-bottom: 0; }
.preview-list .check { flex-wrap: wrap; align-items: baseline; }

.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--bg); }
.nowrap { white-space: nowrap; }
.err-list { margin: 6px 0 0; padding-left: 18px; }

.share-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn-zalo { background: #0068FF; border-color: #0068FF; color: #fff; }
.btn-zalo:hover { background: #0052CC; border-color: #0052CC; color: #fff; }
.invite-preview { white-space: pre-wrap; font-family: inherit; font-size: 13px; background: rgba(255,255,255,.6); border: 1px dashed #B9D6C4; border-radius: 7px; padding: 8px 10px; margin: 6px 0 0; }
.svc-suggest { align-items: center; }

/* ===== 1.3: menu tài khoản, thư mục dự án ===== */
.me-menu { position: relative; }
.me-menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 20px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.me-menu > summary::-webkit-details-marker { display: none; }
.me-menu > summary:hover, .me-menu[open] > summary, .me-menu > summary.on { background: var(--line-2); }
.me-avatar { width: 28px; height: 28px; border-radius: 14px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.me-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 50; display: flex; flex-direction: column; }
.me-pop a { padding: 9px 12px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: 14px; }
.me-pop a:hover, .me-pop a.on { background: var(--line-2); }
.me-pop a.on { font-weight: 600; }
.me-pop-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.me-pop .me-logout { color: var(--muted); border-top: 1px solid var(--line-2); border-radius: 0 0 7px 7px; margin-top: 4px; }
.nav { overflow-x: auto; }
.btn-folder { gap: 6px; }
.folder-name { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.folder-name input { flex: 1 1 260px; width: auto; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.panel.folder-panel h2 { margin-top: 0; }
.me-menu { display: block; }
.flash-warn { background: #FFF7E8; border: 1px solid #F0D9A8; color: #6B4A12; }
.flash-warn a { color: #6B4A12; font-weight: 600; }

/* ===== 1.4: báo đỏ, hạng mục, tuỳ chỉnh ===== */
.badge-new { background: #FDECEC; color: #B42318; }
.nav a { position: relative; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #D92D20; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; vertical-align: 1px; }
.nav-badge[hidden], .me-dot[hidden] { display: none; }
.me-avatar { position: relative; }
.me-dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 5px; background: #D92D20; border: 2px solid var(--surface); }

.cat-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; margin: 0 0 12px; }
.cat-chip { display: inline-flex; flex-direction: column; gap: 3px; min-width: 110px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px; }
.cat-chip:hover { border-color: #C9C5BA; }
.cat-chip.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cat-chip:first-child { justify-content: center; font-weight: 600; min-width: 0; }
.cat-name { font-weight: 600; white-space: nowrap; }
.cat-count { font-size: 12px; color: var(--muted); }
.cat-track { display: block; height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.cat-track span { display: block; height: 100%; background: var(--accent); }
.cat-chip.is-full .cat-count { color: var(--accent-ink); font-weight: 600; }
.cat-sort { align-self: center; font-size: 13px; color: var(--muted); margin-left: 4px; }
.cat-tag { color: var(--muted); }

.order-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 9px; }
.order-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line-2); }
.order-list li:last-child { border-bottom: 0; }
.order-no { width: 20px; color: var(--muted); font-size: 12px; font-weight: 700; }
.order-name { flex: 1; font-weight: 500; }
.facts.compact { margin: 8px 0; }

.folder-panel > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
.folder-panel > summary::-webkit-details-marker { display: none; }
.folder-tools { display: inline-flex; gap: 6px; align-items: center; }
.folder-toggle svg { transition: transform .15s; }
.folder-panel[open] .folder-toggle svg { transform: rotate(180deg); }
.folder-body { margin-top: 12px; }

/* ===== 1.5: menu gọn trên điện thoại, thanh lọc sự kiện ===== */
.lbl-short { display: none; }
@media (max-width: 480px) {
  .nav { gap: 0; }
  .nav a { padding: 7px 7px; font-size: 13.5px; }
  .nav a .lbl-full { display: none; }
  .nav a .lbl-short { display: inline; }
  .nav-badge { min-width: 16px; height: 16px; font-size: 10px; margin-left: 2px; padding: 0 4px; }
}
.toolbar-event { flex-direction: column; align-items: stretch; gap: 8px; }
.toolbar-event .toolbar-side { gap: 8px 12px; }
.toolbar-event select { width: auto; max-width: 190px; }
.cat-tag { font-size: 12px; color: var(--muted); opacity: .85; }

/* ===== 1.6: lịch họp, popup, giai đoạn ===== */
.tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #D92D20; color: #fff; font-size: 11px; font-weight: 700; }
.meeting-row.is-past { opacity: .75; }
.meeting-row.is-cancelled .row-title { text-decoration: line-through; color: var(--muted); }
.att { display: inline-flex; align-items: baseline; gap: 2px; margin: 0 10px 4px 0; padding: 2px 8px; border-radius: 6px; background: var(--line-2); font-size: 13.5px; }
.att small { color: var(--muted); }
.att-yes { background: var(--accent-soft); }
.att-no { background: var(--red-soft); }
.respond-row { align-items: center; }
.group-edit { margin-left: 6px; color: var(--muted); text-decoration: none; font-weight: 400; }
.group-edit:hover { color: var(--ink); }

/* Popup thông báo (1.9.6: tên lớp riêng, không dùng chung .toast của thanh "Hoàn tác") */
.ntf-stack { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.ntf { position: relative; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid #D92D20; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 12px 14px; animation: ntf-in .2s ease-out; }
.ntf.is-sticky { border-left-color: var(--amber, #B7791F); }
.ntf p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; color: var(--ink); }
.ntf-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ntf.is-out { opacity: 0; transform: translateY(6px); transition: all .2s; }
@keyframes ntf-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ntf { animation: none; } }
@media (max-width: 560px) {
  .ntf-stack { left: 12px; right: 12px; bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 10px); width: auto; }
}

/* ===== 1.7 — Báo giá ===== */
.code-link { color: inherit; text-decoration: none; }
.code-link:hover { background: var(--line); }
.qstatus { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 5px; white-space: nowrap; vertical-align: middle; }
.qs-draft { background: var(--line-2); color: var(--muted); }
.qs-sent { background: var(--blue-soft); color: var(--blue); }
.qs-won { background: var(--accent-soft); color: var(--accent-ink); }
.qs-cancelled { background: var(--red-soft); color: var(--red); }
[data-pi-show][hidden] { display: none !important; }
.pi-rows > li > details > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 4px; cursor: pointer; }
.pi-rows > li > details > summary::-webkit-details-marker { display: none; }
.pi-body { padding: 4px 4px 14px; }
.pi-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.pi-add > summary { list-style: none; display: inline-flex; margin-top: 10px; }
.pi-add > summary::-webkit-details-marker { display: none; }
.quote-form .panel h2 { margin-top: 0; }
.quote-form .row2, .quote-form .row3 { margin-top: 10px; }
.seg { display: flex; gap: 18px; flex-wrap: wrap; }
.q-kind { font-size: 14px; margin: 16px 0 6px; }
.q-items { list-style: none; margin: 0; padding: 0; }
.q-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.q-item .check { align-items: flex-start; }
.q-item .check input { margin-top: 3px; }
.q-noprice { display: none; }
.q-item.q-off { opacity: .55; }
.q-item.q-off .q-noprice { display: inline-block; }
.q-qty { display: flex; align-items: center; gap: 6px; }
.q-qty input { width: 76px; }
.q-custom { margin-top: 6px !important; }
.q-submit { display: flex; gap: 8px; margin: 16px 0; }
.q-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.q-inline { margin: 0; }
.q-status select { min-height: 42px; width: auto; }
.q-hint { margin: 0 0 10px; }
.q-filter { display: flex; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.q-filter select { width: auto; }
.q-filter input { flex: 1 1 200px; width: auto; }
.qpaper { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14mm 14mm 10mm; margin: 8px auto 16px; max-width: 210mm; box-shadow: 0 2px 10px rgba(0,0,0,.05); overflow-x: auto; }
@media (max-width: 640px) { .qpaper { padding: 16px 12px; } .qpaper .qdoc { font-size: 8.5pt; } }
@media print {
  /* Lề trang = 0 để trình duyệt không in ngày giờ, đường dẫn, số trang; lề thật nằm trong .qpaper */
  @page { size: A4; margin: 0; }
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  .no-print, .flash, .crumb { display: none !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .qpaper { border: 0; box-shadow: none; padding: 11mm 12mm; margin: 0; max-width: none; border-radius: 0; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  main.page, .wrap { margin: 0 !important; width: auto !important; max-width: none !important; }
  .qdoc h2 { break-after: avoid; }
  .qdoc tr, .qdoc .q-sign { break-inside: avoid; }
}
/* 1.7.1 */
.tier-grid { display: grid; grid-template-columns: minmax(0, 140px) minmax(0, 140px) 1fr; gap: 6px 10px; align-items: center; }
.q-new > summary { list-style: none; display: inline-flex; }
.q-new > summary::-webkit-details-marker { display: none; }
.q-new[open] > summary { margin-bottom: 10px; }
.q-new-body .q-filter input { flex: 1 1 220px; }
.q-calc > summary { cursor: pointer; }
.q-calc-row { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; padding: 8px 0; align-items: baseline; }
@media (max-width: 640px) { .q-calc-row { grid-template-columns: 1fr auto; } .q-calc-row .muted { grid-column: 1 / -1; } }
/* 1.7.2 */
.disc-row { display: flex; gap: 8px; }
.disc-row input { flex: 1 1 90px; min-width: 0; }
.disc-row select { flex: 0 1 230px; width: auto; }
/* 1.7.3 */
.q-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.q-unit { display: flex; align-items: center; gap: 6px; }
.q-unit input { width: 120px; }
@media (max-width: 640px) { .q-item { flex-wrap: wrap; } .q-side { width: 100%; justify-content: flex-end; } .q-unit input { width: 110px; } }
/* 1.8 — Package Quotation */
.pk-ghead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pk-ghead h2 { margin: 0 0 6px; }
.pk-gsum strong { font-variant-numeric: tabular-nums; }
.pk-row { flex-wrap: wrap; }
.pk-row .pk-fields { display: none; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pk-row.on .pk-fields { display: flex; }
.pk-fields label { display: flex; align-items: center; gap: 4px; }
.pk-fields input { width: 72px; }
.pk-fields input[data-pk-price] { width: 110px; }
.pk-amt { min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.pk-prog .pk-amt { margin-left: auto; }
.pk-custom { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pk-crow { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.2fr) 64px 64px minmax(0, 1.1fr) 110px 110px 24px; gap: 6px; align-items: center; }
.pk-gfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.pk-disc { display: flex; align-items: center; gap: 6px; }
.pk-disc input { width: 70px; }
.pk-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; background: var(--card, #fff); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 14px 0; box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
.pk-bar strong { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .pk-crow { grid-template-columns: 1fr 1fr; }
  .pk-crow input:first-child { grid-column: 1 / -1; }
  .pk-row .pk-fields { width: 100%; justify-content: flex-start; }
}
.q-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; flex-wrap: wrap; }
.q-pick-btns { display: flex; gap: 6px; }
.sv-io { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sv-import { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.sv-table-wrap { overflow-x: auto; margin-bottom: 10px; }
.sv-table { border-collapse: collapse; width: 100%; min-width: 900px; }
.sv-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px; }
.sv-table td { padding: 3px 4px; vertical-align: middle; }
.sv-table input:not([type=checkbox]), .sv-table select { width: 100%; min-height: 36px; padding: 6px 8px; font-size: 14px; }
.sv-table .sv-num { width: 110px; }
.sv-table .sv-sort { width: 64px; }
.sv-table tr.muted input { opacity: .6; }
details.panel > summary { cursor: pointer; }
/* 1.9 */
.pk-crow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line-2); grid-template-columns: none; }
.pk-crow > input:first-child { flex: 1 1 220px; }
.pk-crow > select { width: auto; flex: 0 0 auto; }
.pk-crow .pk-fields { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; justify-content: flex-end; }
.pk-rule { display: inline-flex; align-items: center; gap: 4px; }
.pk-rule select { width: auto; min-height: 36px; padding: 4px 6px; font-size: 13px; }
.pk-rule input { width: 56px !important; min-height: 36px; padding: 4px 6px; }
.pk-eq { font-weight: 600; font-size: 13px; color: var(--muted); min-width: 34px; }
.pk-x { color: var(--muted); }
.pk-pr { display: inline-flex; align-items: center; gap: 4px; }
.pk-pr input { width: 110px !important; }
.pk-fields input[data-pk-qn][hidden] { display: none; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tpl-card { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.tpl-card h2 { margin: 0; font-size: 16px; }
.tpl-card .btn { margin-top: auto; align-self: flex-start; }
.sv-table { min-width: 1180px; }
.sv-table th.c-name { min-width: 230px; }
.sv-table .sv-rule { white-space: nowrap; }
.sv-table .sv-rule select { width: auto; display: inline-block; }
.sv-table .sv-n { width: 56px !important; display: inline-block; margin-left: 4px; }
.sv-table select { min-width: 84px; }
.sv-table .sv-sort { width: 56px !important; }
.sv-log li { padding: 8px 4px; font-size: 14px; }
/* 1.9.1 */
.q-new > summary.btn-primary, .q-new > summary.btn-primary * { color: #fff !important; }
.q-new > summary.btn-primary svg { stroke: #fff; }
/* 1.9.2 — bảng Thư viện dịch vụ: cố định độ rộng cột */
.sv-table.sv-fixed { table-layout: fixed; width: 100%; min-width: 1280px; }
.sv-fixed col.w-name { width: auto; }
.sv-fixed col.w-name2 { width: 15%; }
.sv-fixed col.w-sel { width: 92px; }
.sv-fixed col.w-rule { width: 166px; }
.sv-fixed col.w-usd { width: 84px; }
.sv-fixed col.w-vnd { width: 118px; }
.sv-fixed col.w-tt { width: 52px; }
.sv-fixed col.w-chk { width: 46px; }
.sv-fixed th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-fixed td { overflow: hidden; }
.sv-table.sv-fixed td input:not([type=checkbox]), .sv-table.sv-fixed td select { width: 100% !important; min-width: 0 !important; box-sizing: border-box; padding: 6px 8px; }
.sv-rw { display: flex; gap: 4px; align-items: center; }
.sv-table.sv-fixed .sv-rw select { flex: 1 1 auto; width: auto !important; min-width: 0 !important; }
.sv-table.sv-fixed .sv-rw input.sv-n { flex: 0 0 48px; width: 48px !important; margin: 0; text-align: center; }
.sv-table.sv-fixed td input.sv-num { text-align: right; font-variant-numeric: tabular-nums; }
.sv-table.sv-fixed td:nth-last-child(-n+2) input[type=checkbox] { display: block; margin: 0 auto; }
/* 1.9.3 — icon biểu cảm */
.rx { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 2px; }
.rx-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 2px 10px; border-radius: 15px; border: 1px solid var(--line); background: var(--card, #fff); font: inherit; font-size: 14px; cursor: pointer; }
.rx-chip span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rx-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.rx-chip.on span { color: var(--accent-ink); font-weight: 600; }
.rx-add { position: relative; }
.rx-add > summary { list-style: none; display: inline-flex; align-items: center; min-height: 30px; padding: 2px 8px; border-radius: 15px; border: 1px dashed var(--line); font-size: 13px; color: var(--muted); cursor: pointer; }
.rx-add > summary::-webkit-details-marker { display: none; }
.rx-pick { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 20; display: flex; gap: 2px; padding: 4px; background: var(--card, #fff); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.rx-pick button { width: 38px; height: 38px; border: 0; background: none; border-radius: 19px; font-size: 20px; cursor: pointer; }
.rx-pick button:hover, .rx-pick button:focus-visible { background: var(--line-2); }
/* 1.9.3 — chiết khấu nhóm thu gọn */
.pk-disc-d > summary { list-style: none; font-size: 13px; color: var(--muted); cursor: pointer; }
.pk-disc-d > summary::-webkit-details-marker { display: none; }
.pk-disc-d[open] > summary { display: none; }
/* 1.9.5 — báo giá trên điện thoại: chữ nhỏ hơn, số không xuống dòng (bản in giữ A4) */
@media screen and (max-width: 640px) {
  .qpaper .qdoc .q-det th, .qpaper .qdoc .q-det td { padding: 4px 3px; font-size: 7.4pt; }
  .qpaper .qdoc .q-sum th, .qpaper .qdoc .q-sum td { padding: 4px 4px; font-size: 7.8pt; }
  .qpaper .qdoc .q-lines .r { white-space: nowrap; }
}

/* 1.9.6: cảnh báo hồ sơ người lập */
.prep-warn { margin: 0 0 10px; }
.prep-sync { margin: 0 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ===== 1.10: Trao đổi với khách ===== */
.cv-entry { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); text-decoration: none; }
.cv-entry:hover { border-color: #C9C5BA; }
.cv-tools { display: grid; gap: 12px; margin-bottom: 16px; }
.cv-panel > summary { cursor: pointer; }
.cv-panel[open] > summary { margin-bottom: 12px; }
.cv-status { color: var(--muted); margin: 8px 0 0; min-height: 1.2em; }
.cv-result { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.cv-result textarea { font-family: inherit; }
.cv-preview { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.cv-copy { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.cv-sent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.cv-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cv-msg { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; max-width: 92%; min-width: 0; }
.cv-in { justify-self: start; border-left: 3px solid var(--blue); }
.cv-out { justify-self: end; background: var(--accent-soft); border-color: transparent; }
.cv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 6px; }
.cv-subject { font-weight: 600; margin-bottom: 4px; }
.cv-body { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.cv-body-wrap > summary { list-style: none; cursor: pointer; }
.cv-body-wrap > summary::-webkit-details-marker { display: none; }
.cv-body-wrap[open] > summary { display: none; }
.cv-clip { display: block; }
.cv-ai { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); font-size: 13.5px; }
.cv-ai p { margin: 0; }
.cv-ai.is-loading { color: var(--muted); }
.cv-ai.is-error { color: var(--red); }
.cv-ai-label { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); margin-right: 4px; }
.cv-suggest { margin-top: 8px; }
.cv-suggest ul { margin: 4px 0 8px; padding-left: 18px; }
.cv-suggest-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 8px; font-size: 13px; }
.cv-actions details[open] { flex-basis: 100%; }
.sel { user-select: all; }
@media (max-width: 560px) { .cv-msg { max-width: 100%; } }
.cv-quote-ref { font-size: 13.5px; background: var(--blue-soft); color: var(--ink); border-radius: 8px; padding: 6px 10px; margin: 0; }
