/* Thiệp mời Gala (/thiep-moi) — 2026/10/13 ツー */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #172036;
  --ink-soft: #4b5672;
  --ink-mute: #6b7489;
  --line: #dfe3ee;
  /* xanh ngọc của mẫu 3 (Xanh ngọc): nền nút, số bước; chữ trắng trên --accent 6,5:1 */
  --accent: #0b6b48;
  --accent-hover: #084a33;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ec;
  --info: #1d4ed8;
  --info-soft: #e7eeff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1f7a4d;
  --low: #fff4d6;
  --low-line: #e8c46a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 48, .06), 0 8px 24px rgba(16, 24, 48, .06);
  --f-body: "Be Vietnam Pro", system-ui, "Segoe UI", sans-serif;
  --f-display: "Playfair Display", Georgia, serif;
  --tap: 40px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--f-body); overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ---------- thanh trên ---------- */
.tm-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.tm-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.tm-brand b { display: block; font: 600 17px/1.1 var(--f-display); }
.tm-brand small { display: block; font-size: 12px; color: var(--ink-mute); }
.tm-brand-mark { width: 36px; height: 36px; border-radius: 50%; background: #101c40; display: grid; place-items: center; flex-shrink: 0; }
.tm-brand-mark svg { width: 19px; height: 19px; fill: #e0b56a; }
.tm-bar-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- nút ---------- */
.tm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.tm-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.tm-btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 500; }
.tm-btn.ghost:hover { background: var(--surface-2); border-color: #c9cfdd; }
.tm-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tm-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.tm-btn.big { min-height: 50px; font-size: 16px; width: 100%; }
.tm-btn.danger { color: var(--danger); }
.tm-btn:disabled, .tm-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.tm-icon-btn { width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.tm-icon-btn:disabled { opacity: .35; cursor: default; }
.tm-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- bố cục chính ---------- */
.tm-app { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 22px; padding: 20px; max-width: 1680px; margin: 0 auto; align-items: start; }
.tm-work { position: sticky; top: 76px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.tm-work > * { min-width: 0; }
.tm-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }

/* ---------- thanh sửa ngữ cảnh ---------- */
.tm-ctx { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 54px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.ctx-empty { color: var(--ink-soft); font-size: 13px; padding: 4px 4px; flex: 1; min-width: 0; }
.ctx-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.ctx-label { font-size: 12px; color: var(--ink-mute); padding: 0 6px 0 2px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-ctx select, .ctx-btn, .ctx-tog, .ctx-size button { min-height: 36px; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 0 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tm-ctx select { border-color: var(--line); background: var(--surface); padding-right: 4px; max-width: 210px; }
.ctx-font { min-width: 170px; }
.ctx-btn { border-color: var(--line); }
.ctx-btn:hover, .ctx-tog:hover, .ctx-size button:hover { background: var(--surface-2); }
.ctx-tog { min-width: 36px; justify-content: center; }
.ctx-tog[aria-pressed="true"] { background: var(--info-soft); color: var(--info); border-color: #c7d6fb; }
.ctx-tog svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.ctx-size { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; }
.ctx-size button { min-width: 34px; justify-content: center; font-size: 17px; }
.ctx-size output { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
.ctx-color { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.ctx-color input { width: 24px; height: 24px; border: 0; padding: 0; background: none; cursor: pointer; }
.ctx-range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ctx-range input { width: 120px; }
.ctx-range output { min-width: 44px; font-variant-numeric: tabular-nums; }
.ctx-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 0 6px; min-height: 36px; }
.ctx-sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.ctx-drag { margin-left: auto; }
.ctx-drag[aria-pressed="true"] { background: var(--info-soft); color: var(--info); }

/* ---------- khung thiệp ---------- */
.tm-stage-wrap { position: relative; border-radius: 10px; background: #e7e9f0; padding: 14px; min-width: 0; }
.tm-stage { width: 100%; min-width: 0; max-width: 100%; aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; box-shadow: 0 14px 34px rgba(16, 24, 48, .22); background: #222; touch-action: pan-y; }
.tm-stage canvas { display: block; }
.tm-drop { position: absolute; inset: 14px; border: 2px dashed var(--info); border-radius: 8px; background: rgba(231, 238, 255, .82); display: grid; place-items: center; font-weight: 600; color: var(--info); pointer-events: none; opacity: 0; transition: opacity .12s; }
.tm-stage-wrap.dragging .tm-drop { opacity: 1; }
.tm-inline-edit { position: absolute; z-index: 5; margin: 0; padding: 0; border: 1px dashed #79a8ff; background: rgba(255, 255, 255, .96); color: #172036; resize: none; overflow: hidden; outline: none; line-height: 1.25; border-radius: 4px; }
.tm-guestnav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tm-guestnav-label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.tm-warn { font-size: 13px; color: var(--danger); background: var(--danger-soft); padding: 4px 10px; border-radius: 99px; }

/* ---------- tab ---------- */
.tm-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 61px; z-index: 5; }
.tm-tabs button { border: 0; background: transparent; border-radius: 8px; min-height: 44px; padding: 0 6px; cursor: pointer; font-weight: 600; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.tm-tabs button span { width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: var(--ink-soft); font-size: 11px; display: inline-grid; place-items: center; flex-shrink: 0; }
.tm-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 48, .12); }
.tm-tabs button[aria-selected="true"] span { background: var(--accent); color: #fff; }
.tm-tabpanel { padding: 16px; display: grid; gap: 14px; }

/* ---------- mẫu ---------- */
.tm-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; background: var(--surface); }
.tm-hint { font-size: 12.5px; color: var(--ink-soft); }
.tm-step { font-size: 13.5px; color: var(--ink); background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 0; }
.tm-next { justify-self: end; }
.tm-panel { scroll-margin-top: 70px; }

/* ---------- khung thu gọn (mặc định đóng) ---------- */
.tm-fold { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 0; }
.tm-fold > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px; cursor: pointer; font-weight: 600; font-size: 14px; border-radius: 10px; }
.tm-fold > summary::-webkit-details-marker { display: none; }
.tm-fold > summary small { font-weight: 400; color: var(--ink-mute); }
.tm-fold > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(45deg) translateY(-2px); transition: transform .15s; flex-shrink: 0; }
.tm-fold[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.tm-fold > summary:hover { background: var(--surface-2); }
.tm-fold > summary:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.tm-fold[open] > summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.tm-fold-body { padding: 12px 14px 14px; display: grid; gap: 8px; min-width: 0; }
.tm-fold-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: inline-grid; place-items: center; flex-shrink: 0; }
/* card thu gọn ở cả 4 tab: nền xanh ngọc nhạt của mẫu 3; ô nhập bên trong vẫn nền trắng */
.tm-fold-tint { background: var(--accent-soft); border-color: #bfe0cf; }
.tm-fold-tint > summary { color: var(--accent-hover); }
.tm-fold-tint > summary small { color: var(--ink-soft); }
.tm-fold-tint > summary:hover { background: #d3ecdf; }
.tm-fold-tint[open] > summary { border-bottom-color: #bfe0cf; }
.tm-fold-tint .tm-fold-sm { background: var(--surface); }
.tm-fold-sm { margin-top: 4px; }
.tm-fold-sm > summary { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.tm-fold-sm .tm-chips { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .tm-fold > summary::after { transition: none; } }

/* ---------- hộp hỏi mã AI ---------- */
.tm-pass { width: min(92vw, 380px); padding: 18px; }
.tm-pass form { display: grid; gap: 12px; }
.tm-pass h3 { margin: 0; font-size: 17px; }
.tm-pass .tm-row { justify-content: flex-end; }

/* ---------- form ---------- */
.tm-form { display: grid; gap: 12px; }
.tm-field { display: grid; gap: 4px; min-width: 0; }
.tm-field > span, .tm-field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.tm-field input, .tm-field select, .tm-form textarea, .tm-import textarea, .tm-agenda input, .tm-contacts input, .tm-inline select { min-height: var(--tap); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); width: 100%; min-width: 0; }
.tm-import textarea { padding: 8px 10px; resize: vertical; min-height: 96px; }
.tm-field input:focus, .tm-field select:focus, .tm-import textarea:focus, .tm-agenda input:focus, .tm-contacts input:focus, .tm-table input:focus, .tm-table select:focus { border-color: var(--info); outline: none; box-shadow: 0 0 0 3px var(--info-soft); }
.tm-inline { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.tm-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tm-fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.tm-fieldset legend { font-weight: 600; font-size: 13.5px; padding: 0 4px; }
.tm-fieldset legend small { font-weight: 400; color: var(--ink-mute); }
.tm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tm-chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; min-height: 36px; text-align: left; }
.tm-chip:hover { border-color: var(--accent); }
.tm-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.tm-agenda { display: grid; gap: 6px; }
.tm-agenda-row { display: grid; grid-template-columns: 86px minmax(0, 1fr) var(--tap); gap: 6px; }
.tm-contacts { display: grid; gap: 6px; }
.tm-contact-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--tap); gap: 6px; }
.tm-del { width: var(--tap); height: var(--tap); border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--ink-soft); font-size: 18px; }
.tm-del:hover { color: var(--danger); border-color: #f0b4ad; }
.tm-logo-drop { min-height: 96px; border: 2px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; text-align: center; color: var(--ink-soft); cursor: pointer; background: var(--surface-2); }
.tm-logo-drop.dragging, .tm-logo-drop:hover { border-color: var(--info); color: var(--info); }
.tm-logo-drop img { max-width: 80px; max-height: 80px; object-fit: contain; }
.tm-radio, .tm-check { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.tm-radio small { color: var(--ink-mute); }
.tm-radio input, .tm-check input { width: 18px; height: 18px; }

/* ---------- khách mời ---------- */
.tm-import { display: grid; gap: 10px; }
.tm-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-thumb { position: relative; width: 74px; height: 74px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.tm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.tm-thumb button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(16, 24, 48, .72); color: #fff; cursor: pointer; line-height: 1; }
.tm-guests-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); }
.tm-low { font-size: 12.5px; background: var(--low); border: 1px solid var(--low-line); color: #6b4a00; padding: 2px 9px; border-radius: 99px; }
.tm-sources { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
.tm-table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 60vh; }
.tm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tm-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 8px 6px; border-bottom: 1px solid var(--line); z-index: 1; white-space: nowrap; }
.tm-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tm-table td.num { padding: 10px 6px 0; color: var(--ink-mute); font-variant-numeric: tabular-nums; width: 34px; }
.tm-table input, .tm-table select { width: 100%; min-width: 0; min-height: 36px; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 0 6px; }
.tm-table input:hover, .tm-table select:hover { border-color: var(--line); }
.tm-table select { width: 76px; }
.tm-table .c-table input { width: 54px; }
.tm-table tr.low td { background: var(--low); }
.tm-table tr.current td { box-shadow: inset 3px 0 0 var(--info); }
.tm-table tr.current td ~ td { box-shadow: none; }
.tm-note { display: block; font-size: 11.5px; color: #6b4a00; padding: 0 6px 4px; }
.tm-note button { border: 0; background: none; color: var(--info); text-decoration: underline; cursor: pointer; padding: 0 0 0 6px; font-size: 11.5px; }
.tm-row-actions { display: flex; gap: 2px; }
.tm-row-actions button { width: 34px; height: 34px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink-soft); }
.tm-row-actions button:hover { background: var(--surface-2); color: var(--ink); }
.tm-empty { padding: 18px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* ---------- xuất ---------- */
.tm-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.tm-progress progress { grid-column: 1 / -1; width: 100%; height: 10px; accent-color: var(--accent); }

/* ---------- thông báo, hộp thoại ---------- */
.tm-toasts { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.tm-toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; }
.tm-toast.error { background: var(--danger); }
.tm-toast.ok { background: var(--ok); }
.tm-dialog { border: 0; border-radius: 12px; padding: 12px; max-width: min(92vw, 1000px); max-height: 92vh; }
.tm-dialog img { max-width: 100%; max-height: calc(92vh - 90px); display: block; margin-bottom: 10px; }
.tm-dialog::backdrop { background: rgba(16, 24, 48, .6); }
.show-touch { display: none; }
@media (pointer: coarse) { .show-touch { display: inline-flex; } }

/* ---------- tablet ---------- */
@media (max-width: 1180px) {
  .tm-app { grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; padding: 16px; }
  .tm-tabs button { font-size: 13px; }
}
@media (max-width: 960px) {
  .tm-app { grid-template-columns: minmax(0, 1fr); }
  .tm-work { position: static; }
  .tm-tabs { top: 61px; }
}

/* ---------- điện thoại ---------- */
@media (max-width: 640px) {
  :root { --tap: 44px; }
  .tm-bar { padding: 8px 12px; }
  .hide-sm { display: none; }
  .tm-bar-actions { flex-wrap: nowrap; }
  .tm-bar-actions .tm-btn { padding: 0 10px; font-size: 13px; }
  .tm-brand b { font-size: 15px; white-space: nowrap; }
  .tm-app { padding: 10px 12px 24px; gap: 12px; }
  .tm-stage-wrap { padding: 6px; }
  .tm-drop { inset: 6px; }
  .tm-ctx { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .ctx-group { flex-wrap: nowrap; }
  .ctx-empty { white-space: normal; min-width: 240px; }
  .tm-ctx select, .ctx-btn, .ctx-tog, .ctx-size button, .ctx-color { min-height: 44px; }
  .ctx-color { width: 44px; height: 44px; }
  .tm-tabs button { flex-direction: column; gap: 2px; font-size: 12px; min-height: 52px; }
  .tm-tabpanel { padding: 12px; }
  .tm-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tm-inline { grid-template-columns: minmax(0, 1fr); }
  .tm-chip { min-height: 44px; }
  .tm-guestnav-label { flex: 1; max-width: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.35; }
  .tm-radio, .tm-check { min-height: 44px; }
  /* bảng khách thành thẻ */
  .tm-table-wrap { max-height: none; border: 0; overflow: visible; }
  .tm-table thead { display: none; }
  .tm-table, .tm-table tbody { display: block; }
  .tm-table tr { display: grid; grid-template-columns: 80px minmax(0, 1fr) 76px; gap: 4px; padding: 8px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .tm-table tr.low { background: var(--low); border-color: var(--low-line); }
  .tm-table td { display: block; border: 0; padding: 0; background: transparent !important; }
  .tm-table td.num { display: none; }
  .tm-table td.c-title { grid-column: 1; grid-row: 1; }
  .tm-table td.c-name { grid-column: 2; grid-row: 1; }
  .tm-table td.c-actions { grid-column: 3; grid-row: 1; }
  .tm-table td.c-pos { grid-column: 1 / 3; grid-row: 2; }
  .tm-table td.c-table { grid-column: 3; grid-row: 2; }
  .tm-table td.c-unit { grid-column: 1 / -1; grid-row: 3; }
  .tm-table .c-table input { width: 100%; }
  .tm-table input, .tm-table select { border-color: var(--line); background: var(--surface); min-height: 44px; width: 100%; }
  .tm-row-actions button { width: 38px; height: 44px; }
  .tm-note { grid-column: 1 / -1; }
}
