/* Material 3 (m3.material.io) trên token màu của mdui (m3-theme.css, sinh từ #4F6BDE).
   Các biến cũ (--accent, --line…) giữ tên để các trang hiện có dùng tiếp, giá trị trỏ về token M3 nên tự đổi theo sáng/tối. */
:root {
  --m-primary: rgb(var(--mdui-color-primary)); --m-on-primary: rgb(var(--mdui-color-on-primary));
  --m-primary-c: rgb(var(--mdui-color-primary-container)); --m-on-primary-c: rgb(var(--mdui-color-on-primary-container));
  --m-secondary-c: rgb(var(--mdui-color-secondary-container)); --m-on-secondary-c: rgb(var(--mdui-color-on-secondary-container));
  --m-tertiary-c: rgb(var(--mdui-color-tertiary-container)); --m-on-tertiary-c: rgb(var(--mdui-color-on-tertiary-container));
  --m-error: rgb(var(--mdui-color-error)); --m-error-c: rgb(var(--mdui-color-error-container)); --m-on-error-c: rgb(var(--mdui-color-on-error-container));
  --m-surface: rgb(var(--mdui-color-surface)); --m-on-surface: rgb(var(--mdui-color-on-surface));
  --m-on-surface-v: rgb(var(--mdui-color-on-surface-variant));
  --m-c-lowest: rgb(var(--mdui-color-surface-container-lowest)); --m-c-low: rgb(var(--mdui-color-surface-container-low));
  --m-c: rgb(var(--mdui-color-surface-container)); --m-c-high: rgb(var(--mdui-color-surface-container-high));
  --m-c-highest: rgb(var(--mdui-color-surface-container-highest));
  --m-outline: rgb(var(--mdui-color-outline)); --m-outline-v: rgb(var(--mdui-color-outline-variant));
  --m-inverse: rgb(var(--mdui-color-inverse-surface)); --m-on-inverse: rgb(var(--mdui-color-inverse-on-surface));

  --bg: var(--m-c-low); --surface: var(--m-c-lowest); --surface-2: var(--m-c-low); --line: var(--m-outline-v);
  --line-2: var(--m-outline); --line-soft: var(--m-c-high);
  --text: var(--m-on-surface); --text-2: var(--m-on-surface-v); --muted: var(--m-on-surface-v); --faint: var(--m-outline);
  --accent: var(--m-primary); --accent-dark: var(--m-on-primary-c); --accent-soft: var(--m-primary-c);
  --accent-tint: rgba(var(--mdui-color-primary-container), .45); --accent-line: rgba(var(--mdui-color-primary), .35);
  --err: var(--m-error); --err-bg: var(--m-error-c); --err-line: rgba(var(--mdui-color-error), .4);
  --work: var(--m-on-tertiary-c); --work-bg: var(--m-tertiary-c);
  /* M3 không có màu "thành công/cảnh báo": tự chọn, đủ tương phản cả hai nền. */
  --ok: #1E6C46; --ok-bg: #D3F2E0; --ok-line: #9ED5B7;
  --warn: #7A4D00; --warn-bg: #FFE0B5; --warn-line: #F1C27D;
  --pin: #A3001A; --pin-bg: #FFDAD9; --drib: #8E2457; --drib-bg: #FFD8E7;
  --hover: rgba(var(--mdui-color-on-surface), .08); --press: rgba(var(--mdui-color-on-surface), .12);
  --radius: 12px; --radius-lg: 16px; --radius-xl: 28px;
  --elev-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --elev-2: 0 1px 2px rgb(0 0 0 / .3), 0 2px 6px 2px rgb(0 0 0 / .15);
  --font: 'Roboto Flex', Roboto, system-ui, sans-serif;
  color-scheme: light;
}
/* color-scheme cho popup native (danh sách <option>, lịch, thanh cuộn) theo đúng sáng/tối. */
.mdui-theme-dark {
  color-scheme: dark;
  --bg: var(--m-surface); --surface: var(--m-c); --surface-2: var(--m-c-high);
  --ok: #8BD6A9; --ok-bg: #0F3D27; --ok-line: #2E6A4A; --warn: #FFB95A; --warn-bg: #4A2C00; --warn-line: #7A5310;
  --pin: #FFB3B0; --pin-bg: #5C0010; --drib: #FFB0CD; --drib-bg: #5A1235;
}
@media (prefers-color-scheme: dark) {
  .mdui-theme-auto {
    color-scheme: dark;
    --bg: var(--m-surface); --surface: var(--m-c); --surface-2: var(--m-c-high);
    --ok: #8BD6A9; --ok-bg: #0F3D27; --ok-line: #2E6A4A; --warn: #FFB95A; --warn-bg: #4A2C00; --warn-line: #7A5310;
    --pin: #FFB3B0; --pin-bg: #5C0010; --drib: #FFB0CD; --drib-bg: #5A1235;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.43 var(--font); letter-spacing: .01em; }
a { color: var(--accent); } a:hover { color: var(--accent-dark); }
h1, h2, h3 { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
option, optgroup { background: var(--surface); color: var(--text); }
[x-cloak] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ms { font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr;
  -webkit-font-smoothing: antialiased; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* Khung: navigation rail (80px) + top app bar */
.shell { display: flex; min-height: 100vh; }
.rail { flex: 0 0 80px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0;
  background: var(--m-surface); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.rail-brand { margin-bottom: 20px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--m-primary-c); color: var(--m-on-primary-c);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; }
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 80px; text-decoration: none;
  color: var(--m-on-surface-v); font-size: 12px; font-weight: 500; letter-spacing: .03em; }
.rail-ind { width: 56px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.rail-item:hover { color: var(--m-on-surface); } .rail-item:hover .rail-ind { background: var(--hover); }
.rail-item.is-active { color: var(--m-on-surface); font-weight: 600; }
.rail-item.is-active .rail-ind { background: var(--m-secondary-c); color: var(--m-on-secondary-c); }
.rail-item.is-active .ms { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.frame { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 16px 8px 24px; background: var(--bg); }
.topbar-brand { display: flex; flex-direction: column; margin-right: auto; } .topbar-brand b { font-size: 16px; font-weight: 600; }
.topbar-brand span { font-size: 12px; color: var(--muted); }
.topbar-status { display: flex; gap: 4px; }
.st { width: 36px; height: 36px; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; }
.st .ms { font-size: 20px; }

.main { flex: 1 1 auto; min-width: 0; padding: 8px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
/* Typescale M3: headline-medium / title-large / title-small / body / label */
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: .05em; color: var(--muted); }
.title { font-size: 28px; line-height: 36px; font-weight: 400; }
.h2 { font-size: 22px; line-height: 28px; font-weight: 400; }
.h3 { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .01em; }
.muted { color: var(--muted); } .small { font-size: 12px; line-height: 16px; } .text-2 { color: var(--text-2); }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.num { font-variant-numeric: tabular-nums; }

/* Card: outlined card M3 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-err { border-color: var(--err-line); }
.card-soft { background: var(--surface-2); border-color: transparent; }

/* Button: outlined (mặc định), filled (.btn-primary), tonal lỗi (.btn-danger) */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 24px;
  border-radius: 20px; border: 1px solid var(--m-outline); background: transparent; color: var(--accent); font-size: 14px; font-weight: 500;
  letter-spacing: .01em; text-decoration: none; cursor: pointer; transition: background .15s, box-shadow .15s; }
.btn:hover { background: rgba(var(--mdui-color-primary), .08); color: var(--accent); }
.btn:active { background: rgba(var(--mdui-color-primary), .12); }
.btn-primary { background: var(--m-primary); border-color: transparent; color: var(--m-on-primary); }
.btn-primary:hover { background: var(--m-primary); color: var(--m-on-primary); box-shadow: var(--elev-1); filter: brightness(1.06); }
.btn-sm { min-height: 32px; padding: 0 16px; border-radius: 16px; font-size: 13px; }
.btn-danger { background: var(--m-error-c); border-color: transparent; color: var(--m-on-error-c); }
.btn-danger:hover { background: var(--m-error-c); color: var(--m-on-error-c); box-shadow: var(--elev-1); }
.btn[disabled], .btn[aria-disabled="true"] { background: rgba(var(--mdui-color-on-surface), .12); border-color: transparent;
  color: rgba(var(--mdui-color-on-surface), .38); box-shadow: none; cursor: not-allowed; filter: none; }
.btn:not(.btn-primary):not(.btn-danger)[disabled] { background: transparent; border-color: rgba(var(--mdui-color-on-surface), .12); }

/* Chip: assist/label chip M3 (bo 8px) */
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 8px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip-round { border-radius: 8px; padding: 0 10px; }
.chip-pinterest { background: var(--pin-bg); color: var(--pin); } .chip-dribbble { background: var(--drib-bg); color: var(--drib); }
.chip-ok { background: var(--ok-bg); color: var(--ok); } .chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-err { background: var(--err-bg); color: var(--m-on-error-c); } .chip-work { background: var(--work-bg); color: var(--work); }
.chip-accent { background: var(--accent-soft); color: var(--accent-dark); } .chip-grey { background: var(--m-c-high); color: var(--text-2); }
.kw { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }

/* Filter chip (.pill) + segmented button (.seg) */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--m-outline);
  background: transparent; color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; }
.pill:hover { background: var(--hover); }
.pill[aria-selected="true"], .pill[aria-pressed="true"] { background: var(--m-secondary-c); border-color: transparent; color: var(--m-on-secondary-c); }
.pill[aria-selected="true"]::before, .pill[aria-pressed="true"]::before { content: 'check'; font-family: 'Material Symbols Rounded'; font-size: 18px; margin-left: -6px; }
.seg { display: inline-flex; border: 1px solid var(--m-outline); border-radius: 20px; overflow: hidden; }
.seg button { min-height: 40px; padding: 0 16px; border: 0; border-left: 1px solid var(--m-outline); background: transparent; color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--m-secondary-c); color: var(--m-on-secondary-c); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; padding: 8px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; } .tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl .r { text-align: right; } .tbl tr.is-dim td { color: var(--faint); } .tbl tr.is-hl td { background: var(--accent-tint); }

.progress { height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; transition: width .4s; }
.alert { padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.alert-err { background: var(--err-bg); color: var(--m-on-error-c); } .alert-warn { background: var(--warn-bg); color: var(--warn); } .alert-info { background: var(--accent-tint); color: var(--accent-dark); }

.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }


.top3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.t3 { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.t3.is-manual { border-color: var(--warn-line); }
.t3-img { position: relative; flex: 0 0 96px; }
.t3-img img, .t3-img .ph { display: block; width: 96px; height: 144px; object-fit: cover; border-radius: 10px; background: var(--m-c-high); }
.badge { position: absolute; top: 8px; left: 8px; height: 24px; padding: 0 10px; border-radius: 8px; background: var(--m-inverse); color: var(--m-on-inverse); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; }
.badge-r { left: auto; right: 8px; background: var(--accent); }
.badge-f { top: auto; bottom: 8px; background: rgba(21, 23, 28, .82); color: #fff; }
.stackbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.empty-slot { min-height: 192px; border: 2px dashed var(--line-2); border-radius: 14px; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 13px; color: var(--muted); }

.masonry { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; }
.pin { display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.pin-media { position: relative; display: block; border-radius: 12px; overflow: hidden; }
.pin-media img, .pin-media .ph { display: block; width: 100%; aspect-ratio: 2 / 3; height: auto; object-fit: cover; object-position: top; background: var(--m-c-high); min-height: 0; }
.pin:hover .pin-media img { filter: brightness(.92); }
.pin[aria-pressed="true"] .pin-media { outline: 3px solid var(--accent); outline-offset: -3px; }
.pin-meta { display: flex; flex-direction: column; gap: 3px; padding: 8px 2px 0; }
.ph { display: flex; align-items: center; justify-content: center; background: var(--m-c-high); color: var(--muted); font-size: 12px; min-height: 200px; }
.detail { display: flex; flex-wrap: wrap; gap: 18px; padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.detail img { width: 200px; max-height: 340px; object-fit: cover; border-radius: 10px; }
.stat-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat dt { font-size: 12px; color: var(--muted); } .stat dd { margin: 0; font-size: 22px; font-weight: 500; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { position: sticky; top: auto; bottom: 0; z-index: 30; height: auto; flex-direction: row; justify-content: space-around; width: 100%; padding: 8px 0; order: 2; }
  .rail-brand { display: none; }
  .frame { order: 1; }
  .main { padding: 8px 16px 40px; }
  .topbar { padding: 8px 16px; }
}
@media (prefers-reduced-motion: reduce) { .progress > span { transition: none; } }

.input { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--m-outline); border-radius: 4px; background: transparent; font-size: 14px; color: var(--text); }
.input:hover { border-color: var(--text); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
select.input { padding-right: 32px; }
textarea.input { resize: vertical; }
.layout-3 { display: flex; gap: 16px; align-items: flex-start; }
.assist { flex: 0 0 330px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.draft.is-old { background: var(--surface-2); }
.ai-note { padding: 10px 12px; border-radius: 10px; background: var(--accent-tint); border: 1px solid var(--accent-line); font-size: 13px; color: var(--text-2); }
.media-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.media { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.media img, .media video { display: block; border-radius: 8px; background: var(--line); object-fit: cover; }
.media.pin img, .media.pin video { width: 160px; aspect-ratio: 2 / 3; }
.media.shot img { width: 240px; aspect-ratio: 4 / 3; }
.copy { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); }
.copy dl { margin: 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.copy dl > div { display: contents; }
.copy dt { color: var(--muted); } .copy dd { margin: 0; white-space: pre-wrap; }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.bubble { max-width: 92%; padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.45; }
.bubble.ai { align-self: flex-start; background: var(--m-c-high); }
.bubble.mkt { align-self: flex-end; background: var(--m-primary); color: var(--m-on-primary); }
.progress .indeterminate { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 5px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi b { font-size: 32px; line-height: 40px; font-weight: 400; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding-top: 18px; overflow-x: auto; }
.chart-col { flex: 1 0 36px; max-width: 64px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.chart-bar { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; }
.chart-val { font-size: 11px; color: var(--text-2); } .chart-day { font-size: 11px; color: var(--muted); }
@media (max-width: 1200px) { .layout-3 { flex-wrap: wrap; } .assist { position: static; flex: 1 1 100%; max-height: none; } }
@media (prefers-reduced-motion: reduce) { .progress .indeterminate { animation: none; width: 100%; } }


.pv-wrap { container-type: inline-size; }
.pv-pin { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); max-width: 760px; border-radius: 28px; background: #fff; box-shadow: 0 1px 20px rgba(0, 0, 0, .12); overflow: hidden; font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
.pv-pin-media { background: #000; }
/* Khung hẹp: xếp dọc như Pinterest trên điện thoại, ảnh/video phủ đủ bề ngang thẻ (không để trống bên phải). */
@container (max-width: 620px) {
  .pv-pin { grid-template-columns: minmax(0, 1fr); max-width: 440px; }
}
.pv-pin-media img, .pv-pin-media video { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.pv-pin-body { flex: 1 1 280px; min-width: 0; padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; color: #111; }
.pv-icons { font-size: 20px; color: #111; letter-spacing: 2px; }
.pv-board { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.pv-board b { padding: 10px 16px; border-radius: 22px; background: #E60023; color: #fff; }
.pv-link { font-size: 14px; text-decoration: underline; color: #111; }
.pv-title { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 600; }
.pv-desc { margin: 0; font-size: 14px; line-height: 1.5; color: #333; white-space: pre-wrap; }
.pv-author { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.pv-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 20px; background: #E9E9E9; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #111; }
.pv-shot { max-width: 760px; display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-family: 'Mona Sans', 'Segoe UI', Roboto, sans-serif; color: #0D0C22; }
.pv-shot-head { display: flex; align-items: center; gap: 12px; } .pv-shot-head .stack-sm { flex: 1 1 auto; min-width: 0; }
.pv-like { padding: 8px 14px; border-radius: 20px; border: 1px solid #E7E7E9; font-size: 13px; font-weight: 600; }
.pv-shot-media { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); }

.zoomable { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 16, .88); display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #111; }
.lightbox-close { position: absolute; top: 12px; right: 16px; width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 26px; cursor: pointer; }
.lightbox-close:hover { background: rgba(255, 255, 255, .28); }
.lightbox-open { position: absolute; bottom: 14px; color: #fff; font-size: 13px; opacity: .8; }
.lightbox-open:hover { color: #fff; opacity: 1; }

.pub { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; word-break: break-all; }

/* Cột Kiểm tra (import): mỗi ý một dòng */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12px; line-height: 1.45; }
.checks b { font-weight: 600; }
.chk-skip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-2); }
.chk-skip .chip { height: 20px; font-size: 11px; }
.chk-error { color: var(--err); }
.chk-warning { color: var(--warn); }

/* Chi phí theo bước (bản nháp) */
.usage-log summary { cursor: pointer; }
.usage-log .tbl-sm { font-size: 12px; margin-top: 6px; }
.usage-log .tbl-sm th, .usage-log .tbl-sm td { padding: 4px 8px; }
.usage-log tr.total td { font-weight: 600; border-top: 1px solid var(--line); }

/* ---------- Pipeline ---------- */
.icon-btn { width: 40px; height: 40px; border-radius: 20px; border: 0; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.icon-btn:hover { background: var(--hover); }
.link-btn { padding: 0; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font-weight: 500; }
.link-btn:hover { color: var(--accent); text-decoration: underline; }
.input-sm { min-height: 36px; padding: 6px 8px; width: auto; }
.drop-hint { position: fixed; inset: 16px; z-index: 60; border: 2px dashed var(--accent); border-radius: var(--radius-xl); background: rgba(var(--mdui-color-primary-container), .85);
  color: var(--accent-dark); display: flex; align-items: center; justify-content: center; font-size: 22px; pointer-events: none; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 4px 4px 2px; font-size: 14px; }
.bulk { position: sticky; top: 64px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius-lg);
  background: var(--m-secondary-c); color: var(--m-on-secondary-c); box-shadow: var(--elev-2); }

.pcard { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; cursor: pointer; gap: 14px; align-items: start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.pcard:hover { box-shadow: var(--elev-1); background: color-mix(in srgb, var(--surface), var(--accent) 3%); }
.pcard:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pcard.is-needs { border-left: 4px solid var(--warn); padding-left: 13px; }
.pcard.is-open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pcard.is-dim { opacity: .62; }
.pcard-check { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.pcard-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pcard-title { color: var(--text); font-size: 16px; line-height: 22px; font-weight: 500; }
.pcard:hover .pcard-title { color: var(--accent); }
.pcard-checks { margin-top: 2px; }
.pcard-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 112px; }

.stepper { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; }
.stepper li { position: relative; display: grid; grid-template-columns: auto; justify-items: center; gap: 2px; width: 88px; text-align: center; font-size: 12px; color: var(--muted); }
.stepper li + li::before { content: ''; position: absolute; top: 11px; right: calc(50% + 14px); width: calc(100% - 28px); height: 2px; background: var(--line); }
.stepper li.s-done + li::before, .stepper li.s-done + li.s-done::before { background: var(--ok); }
.stepper .ms { font-size: 22px; width: 24px; height: 24px; }
.stepper .s-label { font-weight: 500; }
.stepper .s-sub { font-size: 11px; line-height: 14px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper .s-idle { color: var(--faint); }
.stepper .s-done { color: var(--ok); } .stepper .s-done .ms { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.stepper .s-run { color: var(--accent); } .stepper .s-run .ms { animation: pulse 1.2s ease-in-out infinite; }
.stepper .s-warn { color: var(--warn); } .stepper .s-warn .s-label { font-weight: 600; }
.stepper .s-err { color: var(--err); } .stepper .s-err .ms { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.stepper .s-sched { color: var(--accent); }
.stepper-sm li { width: 70px; } .stepper-sm .ms { font-size: 18px; width: 20px; height: 20px; } .stepper-sm li + li::before { top: 9px; }
@keyframes pulse { 50% { opacity: .35; } }

/* Side sheet M3 (phải) */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(var(--mdui-color-scrim), .32); }

/* Popup chi tiết bài research */
.modal-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(var(--mdui-color-scrim), .45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { position: relative; width: min(860px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--bg); border-radius: var(--radius-lg); box-shadow: 0 12px 48px rgb(0 0 0 / .3); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.modal-media { background: var(--line); min-height: 280px; }
.modal-media img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 18px; background: rgb(0 0 0 / .06); color: inherit; font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { background: rgb(0 0 0 / .12); }
.modal-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: auto; }
@media (max-width: 720px) { .modal { grid-template-columns: 1fr; } .modal-media img { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 50vh; } }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(1080px, calc(100vw - 96px)); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -4px 0 24px rgb(0 0 0 / .14); border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 8px 24px; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 24px 48px; }
.sheet .layout-3 { flex-wrap: wrap; } .sheet .assist { position: static; flex: 1 1 100%; max-height: none; }
.tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-bottom: 3px solid transparent; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.tabs button:hover { background: var(--hover); color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .ms { font-size: 20px; }
.scope-tabs { padding: 0; }

/* Lịch tháng */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { padding: 4px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day { min-height: 112px; padding: 6px; border-radius: 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; border: 2px solid transparent; }
.cal-day.is-out { opacity: .45; }
.cal-day.is-today { border-color: var(--accent-line); }
.cal-day.is-over { border-color: var(--accent); background: var(--accent-tint); }
.cal-num { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day.is-today .cal-num { color: var(--accent); }
.cal-item { display: block; width: 100%; padding: 4px 6px; border: 0; border-radius: 6px; text-align: left; font-size: 11px; line-height: 15px; cursor: grab;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); background: var(--m-c-high); }
.cal-item:active { cursor: grabbing; }
.ci-needs { background: var(--warn-bg); color: var(--warn); } .ci-run { background: var(--work-bg); color: var(--work); }
.ci-ready { background: var(--accent-soft); color: var(--accent-dark); } .ci-done { background: var(--ok-bg); color: var(--ok); }
.legend-cal { gap: 12px; } .legend-cal span { display: inline-flex; align-items: center; gap: 4px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg-needs { background: var(--warn-bg); border: 1px solid var(--warn); } .lg-run { background: var(--work-bg); border: 1px solid var(--work); }
.lg-ready { background: var(--accent-soft); border: 1px solid var(--accent); } .lg-done { background: var(--ok-bg); border: 1px solid var(--ok); }
.lg-idle { background: var(--m-c-high); border: 1px solid var(--line-2); }

@media (max-width: 900px) {
  .pcard { grid-template-columns: 20px minmax(0, 1fr); }
  .pcard-actions { grid-column: 2 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .stepper li { width: 56px; } .stepper .s-sub { display: none; }
  .sheet { width: 100vw; border-radius: 0; }
  .sheet-body { padding: 12px 16px 96px; }
  .tabs { overflow-x: auto; }
  .cal-day { min-height: 72px; } .cal-item b { display: none; }
}
@media (prefers-reduced-motion: reduce) { .stepper .s-run .ms { animation: none; } }

/* ---------- Tự động ---------- */
.autobar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.autobar > label { margin-right: auto; }
.autobar-cost { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; background: var(--m-c-high); font-size: 13px; }
.autobar-cost .ms { font-size: 18px; }
.autobar-cost.is-over { background: var(--warn-bg); color: var(--warn); }
.rules { display: flex; flex-direction: column; gap: 14px; padding-left: 4px; }
.rules.is-off { opacity: .5; }
.rule { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.rule input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: 0 0 auto; }
.rule span { display: flex; flex-direction: column; gap: 2px; } .rule small { color: var(--muted); font-size: 12px; line-height: 16px; }
.logs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.logs li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.logs li:first-child { border-top: 0; }
.logs .ms { font-size: 20px; color: var(--muted); }
.log-warn .ms, .log-warn > span:nth-child(2) { color: var(--warn); } .log-error .ms, .log-error > span:nth-child(2) { color: var(--err); }

.layout-why { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }

.media-empty > label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line-2); border-radius: 8px; color: var(--muted); cursor: pointer; }
.media.pin.media-empty > label { width: 160px; aspect-ratio: 2 / 3; }
.media.shot.media-empty > label { width: 240px; aspect-ratio: 4 / 3; }
.media-empty > label:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Chi phí + Kết nối ---------- */
.chart-bar.is-over { background: var(--warn); }
.conns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.conns li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.conns li:first-child { border-top: 0; }
.c-ok { color: var(--ok); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; } .c-bad { color: var(--err); } .c-opt { color: var(--faint); }

.results { margin: 0; display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.results > div { display: contents; } .results dt { color: var(--muted); } .results dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- Analytics kiểu Postiz ---------- */
.an-av { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.an-av-pinterest { background: var(--pin-bg); color: var(--pin); } .an-av-dribbble { background: var(--drib-bg); color: var(--drib); }
.an-actions { justify-content: flex-end; }
.an-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; padding: 14px 16px; }
.an-field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.an-field .input { min-width: 150px; }
.an-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1000px) { .an-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .an-kpis { grid-template-columns: 1fr; } }
.an-kpi { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 14px; border-radius: var(--radius-lg); background: var(--m-c-low); border: 1px solid var(--line); overflow: hidden; }
.mdui-theme-dark .an-kpi { background: var(--m-c); }
@media (prefers-color-scheme: dark) { .mdui-theme-auto .an-kpi { background: var(--m-c); } }
.an-label { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.an-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.an-value { font-size: 38px; line-height: 42px; font-weight: 500; }
.an-delta { font-size: 12px; color: var(--muted); } .an-delta.up { color: #1E9E63; } .an-delta.down { color: var(--err); }
.up { color: #1E9E63; } .down { color: var(--err); } .flat { color: var(--muted); }
.an-mini { width: 100%; height: 32px; margin-top: 4px; display: block; overflow: visible; }
.an-mini .an-line { fill: none; stroke: var(--c); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.an-chart { position: relative; width: 100%; height: 280px; }
.an-chart .an-line { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.an-area { fill: var(--c); opacity: .12; } .an-end { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.an-grid-line { stroke: var(--line-soft); stroke-width: 1; } .an-axis { fill: var(--muted); font-size: 11px; }
.an-tbl td, .an-tbl th { white-space: nowrap; } .an-tbl td:first-child { white-space: normal; min-width: 220px; }
.an-post { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.an-post:hover span { color: var(--accent); }
.an-post img, .an-noimg { flex: 0 0 40px; width: 40px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--m-c-high); }
.an-post-tools .input-sm { min-height: 36px; }
.an-post-tools input[type="search"] { min-width: 200px; }
.an-foot { line-height: 1.5; }
.an-period { position: relative; display: inline-flex; align-items: center; }
.an-period .ms { position: absolute; left: 10px; font-size: 20px; color: var(--muted); pointer-events: none; }
.an-period select { padding-left: 38px; min-width: 170px; }
.an-range-note { align-self: center; max-width: 280px; }
.an-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; }
.an-print-head { display: none; }
@media (max-width: 700px) { .an-actions { justify-content: flex-start; } .an-field, .an-field .input { width: 100%; } .an-value { font-size: 32px; } }
/* Bản in / PDF: bỏ khung điều hướng, bộ lọc và nút; giữ KPI, biểu đồ, bảng. */
@media print {
  @page { size: A4; margin: 14mm; }
  .rail, .topbar, .an-actions, .an-filters, .an-more, .an-post-tools, .an-chart-tools, .an-auto, .page-head .small, .alert-info { display: none !important; }
  .shell, .frame, .main { display: block !important; padding: 0 !important; margin: 0 !important; background: #fff !important; }
  .page-head { display: none !important; }
  .an-print-head { display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 2px solid #222; color: #111; }
  .an-print-head b { font-size: 18px; }
  .card, .an-kpi { break-inside: avoid; box-shadow: none !important; background: #fff !important; border: 1px solid #ccc !important; }
  .an-kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .an-tbl tr { break-inside: avoid; } .an-tbl thead { display: table-header-group; }
  .table-wrap { overflow: visible; } .an-post img { display: none; }
  .an-chart { height: 240px; } .an-chart canvas { max-width: 100% !important; }
  body { color: #111 !important; background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.media { position: relative; width: fit-content; max-width: 100%; }
.media figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.media-ctl { display: contents; }
.media-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 14px; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.media-x .ms { font-size: 18px; } .media-x:hover { background: var(--err); }
.link-btn .ms { font-size: 16px; vertical-align: -3px; margin-right: 2px; }

/* Account (trang Cài đặt) */
.accts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.accts li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.accts li:first-child { border-top: 0; }
.accts li.is-off { opacity: 0.6; }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }
@media (max-width: 720px) { .accts li { grid-template-columns: 36px minmax(0, 1fr); } .accts li > :nth-child(n+3) { grid-column: 2; } }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
/* Analytics: đủ các cột của file lịch ngay trên bảng, cuộn ngang; cột Bài dính bên trái */
.an-wide { max-width: 100%; overflow-x: auto; }
.an-wide .an-tbl { width: max-content; min-width: 100%; }
.an-tbl .an-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line-soft); padding-right: 12px; }
.an-tbl td { vertical-align: top; }
/* pre-line chỉ đặt trên chữ bên trong ô: đặt trên td thì khoảng trắng / xuống dòng của HTML thành dòng trống làm ô lệch xuống */
.an-tbl td.an-long { white-space: normal; min-width: 240px; max-width: 360px; }
.an-tbl td.an-long > span, .an-tbl td.an-long > a { white-space: pre-line; overflow-wrap: anywhere; }
.an-tbl .an-post { align-items: flex-start; }
.an-tbl th.an-h-in { box-shadow: inset 0 3px 0 #8ED3EC; } .an-tbl th.an-h-out { box-shadow: inset 0 3px 0 #7FDFA4; }
.an-tbl th.an-h-status { box-shadow: inset 0 3px 0 #FFF1A6; }

/* Bảng lịch sửa trực tiếp: chỉ sửa tại chỗ */
.tbl-edit td { vertical-align: middle; }
.tbl-edit .input:disabled { opacity: .45; }

/* Trang đăng nhập */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); color: var(--text); }
.login-card { width: 100%; max-width: 360px; padding: 32px 24px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card h1 { font-size: 24px; font-weight: 500; margin: 0 0 16px; }
.login-error { margin: 0 0 16px; padding: 10px 12px; border-radius: 12px; background: var(--err-bg); color: var(--err); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }
.login-form input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--m-outline); background: transparent;
  color: var(--text); font: inherit; font-size: 16px; }
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.login-form .btn { margin-top: 8px; }
.topbar-logout { display: contents; }
