/* ToolInsight UI — dark, pink/black. Rules from skill ui-ux-pro-max (D08): colour only via tokens, text contrast
   >= 4.5:1 (white on --primary 4.9:1; accent --pink is for lines, glow and text on dark only), text >= 12px,
   visible focus, hover / loading states, motion off under prefers-reduced-motion. */
:root {
  --bg: #09080b;
  --surface: #121015;
  --surface-2: #19161d;
  --surface-3: #221e27;
  --border: #2a2530;
  --border-strong: #3a3242;
  --text: #f4eef4;
  --text-2: #c9bfcc;
  --muted: #9a8f9e;       /* >= 5.3:1 on every surface */
  --pink: #ff3d8b;
  --pink-2: #ff7ab0;
  --pink-soft: rgba(255, 61, 139, 0.12);
  --pink-line: rgba(255, 61, 139, 0.35);
  --primary: #d81b66;     /* filled buttons / chips carrying white text */
  --primary-hover: #e0246f;
  --on-primary: #ffffff;
  --placeholder: #8d8291;
  --ok: #3ddc97;
  --warn: #ffb547;
  --err: #ff5d6c;
  --info: #8fa8ff;
  --radius: 12px;
  --radius-sm: 8px;
  --dur: .18s;            /* one timing for hover / focus transitions */
  --ctl: 38px;            /* control height */
  --ctl-sm: 32px;
  --sidebar: 248px;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
  color-scheme: dark; /* native dropdowns, scrollbars, date pickers render dark */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(255, 61, 139, .07), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(179, 0, 90, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--primary); color: var(--on-primary); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin-bottom: 12px; border-radius: 10px; transition: background .15s; }
.brand:hover { background: var(--surface-2); }
.brand:hover .brand-mark { box-shadow: 0 0 30px rgba(255, 61, 139, .55); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pink), #b3005a);
  box-shadow: 0 0 24px rgba(255, 61, 139, 0.35);
  font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { flex: 1; overflow-y: auto; }
.nav-group { margin-top: 14px; }
.nav-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 6px;
}
.nav-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--pink-soft); color: var(--pink-2); box-shadow: inset 2px 0 0 var(--pink); }
.nav-item.active svg { opacity: 1; }
.nav-item .count {
  margin-left: auto; font-size: 12px; padding: 1px 7px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2);
}
.nav-item.active .count { background: var(--primary); color: var(--on-primary); }

.sidebar-foot {
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px;
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 28px;
  background: rgba(9, 8, 11, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs b { color: var(--text); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.jobs-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 0 var(--pink-line); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.content { padding: 28px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 760px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Primitives ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 120px), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 8px 24px -18px rgba(0,0,0,.8);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -.1px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.step-no {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--pink-soft); color: var(--pink-2); border: 1px solid var(--pink-line);
}

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: var(--ctl); padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  cursor: pointer; font-weight: 500; font-size: 13.5px; white-space: nowrap;
  transition: background var(--dur), border-color var(--dur), color var(--dur), transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 6px 20px -8px rgba(255, 61, 139, .7); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.btn.sm { height: var(--ctl-sm); padding: 0 11px; font-size: 12.5px; }
.btn.sm.icon { width: var(--ctl-sm); padding: 0; justify-content: center; }
.btn.xs { height: 28px; padding: 0 8px; font-size: 12px; }
.btn.xs svg { width: 14px; height: 14px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field label .opt { color: var(--muted); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl); padding: 0 12px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.select option { background: var(--surface-2); color: var(--text); }
.select option:checked { background: var(--primary); color: var(--on-primary); }

/* Dropdowns (2026-11-20): Chrome's customizable select, so the open list matches the tool instead of the plain OS list.
   Browsers without it keep the look above. */
@supports (appearance: base-select) {
  .select, .select::picker(select) { appearance: base-select; }
  .select { display: flex; align-items: center; gap: 8px; background-image: none; padding-right: 12px; cursor: pointer; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .select::picker(select) { white-space: normal; }
  .select > button { all: unset; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: inherit; }
  .select > button::after { content: ""; width: 7px; height: 7px; margin-left: auto; flex: none; border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform var(--dur); }
  .select:open > button::after { transform: translateY(2px) rotate(225deg); }
  .select:has(> button)::picker-icon { display: none; }
  .select selectedcontent { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .select:hover:not(:disabled) { border-color: var(--muted); }
  .select:disabled { opacity: .6; cursor: not-allowed; }
  .select::picker-icon { content: ""; width: 7px; height: 7px; margin-left: auto; flex: none; border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform var(--dur); }
  .select:open::picker-icon { transform: translateY(2px) rotate(225deg); }
  .select:open { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
  .select::picker(select) {
    margin-top: 6px; padding: 6px; max-height: min(420px, 60vh); overflow-y: auto;
    background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .55); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
    opacity: 0; translate: 0 -4px; transition: opacity var(--dur), translate var(--dur), overlay var(--dur) allow-discrete, display var(--dur) allow-discrete;
  }
  .select:open::picker(select) { opacity: 1; translate: 0 0; }
  @starting-style { .select:open::picker(select) { opacity: 0; translate: 0 -4px; } }
  .select option {
    display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 10px; border-radius: 7px;
    background: transparent; color: var(--text-2); font-size: 13.5px; cursor: pointer; transition: background var(--dur), color var(--dur);
  }
  .select option:hover, .select option:focus-visible { background: var(--surface-3); color: var(--text); outline: none; }
  .select option:checked { background: var(--pink-soft); color: var(--pink-2); font-weight: 600; }
  .select option::checkmark { order: 1; margin-left: auto; color: var(--pink); }
  .select option:disabled { color: var(--muted); background: transparent; cursor: default; }
  .select optgroup { padding-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .select optgroup + optgroup { margin-top: 6px; border-top: 1px solid var(--border); }
  .select optgroup option { text-transform: none; letter-spacing: 0; }
}

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border-strong); }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 7px;
  color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500;
}
.seg button.on { background: var(--primary); color: var(--on-primary); }
.seg button:not(.on):hover { background: var(--surface-2); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 14px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--pink); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.pink { color: var(--pink-2); background: var(--pink-soft); border-color: var(--pink-line); }
.badge.ok { color: var(--ok); background: rgba(61, 220, 151, .1); border-color: rgba(61, 220, 151, .3); }
.badge.warn { color: var(--warn); background: rgba(255, 181, 71, .1); border-color: rgba(255, 181, 71, .3); }
.badge.err { color: var(--err); background: rgba(255, 93, 108, .1); border-color: rgba(255, 93, 108, .3); }
.badge.info { color: var(--info); background: rgba(143, 168, 255, .1); border-color: rgba(143, 168, 255, .3); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 20px; cursor: pointer; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
}
.chip:hover { border-color: var(--pink-line); }
[role="button"], [data-src], [data-idea], [data-market], [data-tpl], .media.clickable, .list-btn, .tab, .seg button { cursor: pointer; }
.chip.on { background: var(--pink-soft); border-color: var(--pink); color: var(--pink-2); }

.dropzone {
  display: block;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 30px 18px; text-align: center; cursor: pointer;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,.012) 10px 20px);
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--pink); background-color: var(--pink-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--pink-2); }
.dropzone .t { font-weight: 600; margin-top: 8px; }
.dropzone .s { color: var(--muted); font-size: 12.5px; }
.dropzone.has-file { border-style: solid; border-color: var(--pink-line); }

.notice {
  display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 13px;
}
.notice svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--pink-2); }
.notice.warn svg { color: var(--warn); }

/* ---------- Stats ---------- */
.stat { position: relative; padding: 16px 18px; overflow: hidden; transition: border-color .15s; }
.stat:hover { border-color: var(--pink-line); }
.stat-ic {
  position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; color: var(--pink-2);
  background: var(--pink-soft); border: 1px solid var(--pink-line);
}
.stat-ic svg { width: 16px; height: 16px; }
.stat .k { color: var(--muted); font-size: 12.5px; padding-right: 40px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .v .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; }

/* ---------- Entry cards ---------- */
.entry {
  position: relative; overflow: hidden; cursor: pointer;
  padding: 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .2s, transform .2s;
}
.entry:hover { border-color: var(--pink-line); transform: translateY(-2px); }
.entry::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 61, 139, .22), transparent 70%);
}
.entry .ic {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--pink-soft); color: var(--pink-2); border: 1px solid var(--pink-line);
}
.entry .ic svg { width: 20px; height: 20px; }
.entry h3 { margin: 14px 0 4px; font-size: 16px; }
.entry p { margin: 0; color: var(--muted); font-size: 13px; }
.entry .flow { margin-top: 14px; font-size: 12px; color: var(--text-2); }

/* ---------- Pipeline stepper ---------- */
.stepper {
  display: flex; gap: 0; margin-bottom: 20px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.stepper .st {
  flex: 1; min-width: 120px; display: flex; align-items: center; gap: 9px;
  padding: 12px 14px; font-size: 12.5px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.stepper .st + .st { border-left: 1px solid var(--border); }
.stepper .st .n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border-strong);
}
.stepper .st.done { color: var(--text-2); border-bottom-color: var(--pink-line); }
.stepper .st.done .n { background: var(--pink-soft); color: var(--pink-2); border-color: var(--pink-line); }
.stepper .st.cur { color: var(--text); border-bottom-color: var(--pink); font-weight: 600; background: var(--pink-soft); }
.stepper .st .n svg { width: 12px; height: 12px; }
.stepper .st.cur .n { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap .table { min-width: 640px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  letter-spacing: .6px; text-transform: uppercase;
  padding: 9px 12px; border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 61, 139, .035); }

.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #b3005a, var(--pink)); border-radius: 6px; }

/* ---------- Media tiles ---------- */
.media {
  position: relative; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #2a1622, #120e14 60%);
  border: 1px solid var(--border);
}
.media .lbl {
  position: absolute; left: 8px; bottom: 8px; right: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  background: rgba(0,0,0,.55); padding: 3px 6px; border-radius: 5px; backdrop-filter: blur(4px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media .tag { position: absolute; left: 8px; top: 8px; }
.media .x {
  position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; background: rgba(0,0,0,.6); border: 1px solid var(--border-strong);
  cursor: pointer; opacity: .8; transition: opacity .15s;
}
.media:hover .x { opacity: 1; }
.media.removed .x { opacity: 1; color: var(--err); border-color: var(--err); }
.media .x:hover { color: var(--err); border-color: var(--err); }
.media .x svg { width: 14px; height: 14px; }
.media .play { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.7); }
.media .play svg { width: 34px; height: 34px; }
.media.removed { opacity: .25; filter: grayscale(1); }

.set-row { display: grid; grid-template-columns: 110px repeat(auto-fill, minmax(96px, 120px)); gap: 10px; align-items: start; }
.set-row + .set-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.set-meta .t { font-weight: 600; }

/* ---------- Ideas ---------- */
.idea {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); transition: border-color .15s;
}
.idea + .idea { margin-top: 8px; }
.idea.sel { border-color: var(--pink); background: linear-gradient(90deg, var(--pink-soft), var(--surface-2) 60%); }
.idea .no { font-family: var(--mono); color: var(--muted); font-size: 12px; padding-top: 2px; }
.idea .txt { color: var(--text); }
.idea .txt[contenteditable="true"] { outline: 1px dashed var(--pink-line); outline-offset: 4px; border-radius: 4px; }
.check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; cursor: pointer; flex: none; margin-top: 1px;
}
.idea.sel .check { background: var(--primary); border-color: var(--primary); }
.check svg { width: 13px; height: 13px; opacity: 0; color: var(--on-primary); }
.idea.sel .check svg { opacity: 1; }

/* ---------- Timeline (template) ---------- */
.tl { position: relative; margin-top: 6px; }
.tl-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; height: 30px; }
.tl-row .nm { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.tl-track { position: relative; height: 20px; background: var(--bg); border-radius: 5px; border: 1px solid var(--border); }
.tl-bar {
  position: absolute; top: 2px; bottom: 2px; border-radius: 4px;
  font-size: 12px; padding: 0 6px; display: flex; align-items: center; white-space: nowrap; overflow: hidden;
}
.tl-bar.tail { background: rgba(255, 61, 139, .28); border: 1px solid var(--pink); color: #ffd0e3; }
.tl-bar.tut { background: rgba(143, 168, 255, .2); border: 1px solid var(--info); color: #dfe6ff; }
.tl-bar.fx { background: rgba(255, 181, 71, .2); border: 1px solid var(--warn); color: #ffe7c2; }
.tl-bar.glob { background: rgba(255,255,255,.07); border: 1px solid var(--border-strong); color: var(--text-2); }

.media.clickable { cursor: pointer; transition: border-color .15s; }
.media.clickable:hover { border-color: var(--pink); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px);
}
.modal {
  width: min(880px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; padding: 20px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.modal-grid { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; }
.ver { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ver .media { cursor: pointer; }
.ver .media.ver-on { border-color: var(--pink); }
@media (max-width: 820px) { .modal-grid { grid-template-columns: 1fr; } }

.opt-group { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.opt-group .seg { flex-wrap: wrap; background: var(--surface); }
.dur-ref { font-size: 12.5px; color: var(--text-2); padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px dashed var(--pink-line); }

/* ---------- Template picker / preview ---------- */
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.tpl-opt {
  padding: 6px; border-radius: 10px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border-strong); transition: border-color .15s, box-shadow .15s;
}
.tpl-opt:hover { border-color: var(--pink-line); }
.tpl-opt.on { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.tpl-opt video { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: #000; }
.tpl-opt .nm { margin-top: 6px; text-align: center; font-size: 12.5px; font-weight: 600; }
.tpl-video { display: block; width: 100%; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; border: 1px solid var(--border); }
.tpl-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 240px)); gap: 16px; }
.tpl-card { padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: border-color .15s; }
.tpl-card:hover { border-color: var(--pink-line); }

/* ---------- Overview to-do ---------- */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--info); font-size: 13px; color: var(--text-2); transition: border-color .15s, background .15s;
}
.todo:hover { background: var(--surface-3); }
.todo svg { width: 16px; height: 16px; flex: none; color: var(--info); }
.todo.warn { border-left-color: var(--warn); } .todo.warn svg { color: var(--warn); }
.todo.err { border-left-color: var(--err); } .todo.err svg { color: var(--err); }
.todo b { color: var(--text); }
.todo .cta { margin-left: auto; color: var(--pink-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; }

/* ---------- Market ---------- */
.layer { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.layer .h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.layer .h .n { font-family: var(--mono); color: var(--pink-2); font-size: 12px; }
.layer p { margin: 6px 0 0; color: var(--text-2); font-size: 12.5px; }
.layer .meta { margin-top: 8px; font-size: 12px; color: var(--muted); }

.list-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: none; cursor: pointer; text-align: left; color: var(--text-2);
}
.list-btn:hover { background: var(--surface-2); }
.list-btn.on { background: var(--pink-soft); border-color: var(--pink-line); color: var(--text); }
.list-btn .flag { font-family: var(--mono); font-size: 12px; width: 26px; color: var(--pink-2); }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.empty { text-align: center; padding: 34px 14px; color: var(--muted); }
.empty svg { width: 30px; height: 30px; opacity: .6; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px; }
}

/* ---------- Live data ---------- */
.media img, .media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media .tag, .media .x, .media .lbl, .media .play { z-index: 1; }
.media .state { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; font-size: 12px; color: var(--text-2); text-align: center; padding: 10px; }
.media.failed { border-color: var(--err); }
.media.out video { object-fit: contain; background: #000; }
.toast {
  position: fixed; right: 20px; bottom: 88px; z-index: 50; max-width: 420px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--pink);
  border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 13px;
}
.toast.err { border-left-color: var(--err); }
.fav { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; width: 36px; flex: none; cursor: pointer; }
.fav.on { color: var(--warn); border-color: var(--warn); }
.err-text { color: var(--err); font-size: 12px; }

/* ---------- Chat insight (D32) ---------- */
.chat-items { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 6px;
  padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid transparent; color: var(--text-2);
  transition: background var(--dur), border-color var(--dur);
}
.chat-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chat-item .small { grid-row: 2; }
.chat-item .btn { grid-row: 1 / span 2; grid-column: 2; align-self: center; opacity: 0; transition: opacity var(--dur); }
.chat-item:hover, .chat-item:focus-visible { background: var(--surface-2); }
.chat-item:hover .btn, .chat-item:focus-within .btn, .chat-item.on .btn { opacity: 1; }
.chat-item.on { background: var(--pink-soft); border-color: var(--pink-line); color: var(--text); }

.chat-thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 12px; }
.msg { display: flex; flex-direction: column; max-width: min(760px, 88%); }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble code { font-family: var(--mono); font-size: 12.5px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.sources a {
  display: inline-flex; align-items: center; gap: 5px; max-width: 260px; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--border-strong);
  transition: border-color var(--dur), color var(--dur);
}
.sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources a svg { width: 13px; height: 13px; flex: none; }
.sources a:hover { border-color: var(--pink-line); color: var(--text); }
.saved-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--ok); }
.saved-line svg { width: 15px; height: 15px; flex: none; }
.saved-line b { color: var(--text); font-weight: 600; }
.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--pink-2); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 12px; border-top: 1px solid var(--border); }
.composer .input { height: auto; min-height: 46px; max-height: 180px; padding: 11px 12px; resize: vertical; line-height: 1.5; }
.composer .btn { height: 46px; width: 46px; padding: 0; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Layout reorganisation ---------- */
.page-head { align-items: center; padding-bottom: 16px; }
/* Overview board: insights by pipeline stage */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.board-col { display: flex; flex-direction: column; gap: 8px; min-height: 140px; padding: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.board-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); padding: 2px 4px 6px; }
.board-head .count { margin-left: auto; font-size: 12px; padding: 1px 8px; border-radius: 20px; background: var(--surface-3); }
.board-card { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); transition: border-color var(--dur), background var(--dur); }
.board-card .badge { margin-left: auto; }
.board-card:hover { border-color: var(--pink-line); background: var(--surface-3); }
/* From ref: step bar stays on top while scrolling */
.stepper.sticky { position: sticky; top: 72px; z-index: 4; }
.stepper button.st { background: none; border: 0; border-bottom: 2px solid transparent; font: inherit; text-align: left; cursor: pointer; }
.stepper button.st[disabled] { cursor: not-allowed; opacity: .55; }
.stepper button.st:not([disabled]):not(.cur):hover { background: var(--surface-2); color: var(--text); }
/* Source editor as a right drawer: the sets behind stay visible */
.drawer-back { place-items: stretch end; padding: 0; background: rgba(0, 0, 0, .35); backdrop-filter: none; }
.drawer { width: min(560px, 100vw); height: 100vh; max-height: 100vh; border-radius: 0; border-width: 0 0 0 1px; animation: drawer-in .22s ease-out; }
.drawer .modal-grid { grid-template-columns: 180px minmax(0, 1fr); gap: 18px; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .board { grid-template-columns: 1fr; } .drawer .modal-grid { grid-template-columns: 1fr; } }

/* ---------- Floating chat dock ---------- */
.content { padding-bottom: 96px; }
.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; width: 56px; height: 56px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center; color: var(--on-primary); background: var(--primary);
  box-shadow: 0 8px 24px rgba(216, 27, 102, .35); transition: transform var(--dur), background var(--dur), box-shadow var(--dur);
}
.chat-fab svg { width: 24px; height: 24px; }
.chat-fab:hover { background: var(--primary-hover); transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(216, 27, 102, .45); }
.chat-fab:focus-visible { outline: 2px solid var(--pink-2); outline-offset: 3px; }
.chat-fab.on { transform: rotate(90deg); }
.fab-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--err); border: 2px solid var(--bg); }
.chat-panel {
  position: fixed; right: 20px; bottom: 88px; z-index: 40; width: 400px; height: min(600px, calc(100vh - 112px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); overflow: hidden;
  transform-origin: bottom right; animation: dock-in .18s ease-out;
}
.chat-panel.big { width: min(1100px, calc(100vw - 40px)); height: calc(100vh - 108px); }
@keyframes dock-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--border); }
.chat-head .btn.on { background: var(--pink-soft); color: var(--pink-2); }
.chat-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.chat-head .mono { margin-right: 4px; }
.chat-body { flex: 1; min-height: 0; display: flex; }
.chat-body .chat-items { flex: 1; padding: 8px; }
.chat-panel.big .chat-body .chat-items { flex: 0 0 260px; border-right: 1px solid var(--border); }
.chat-body .chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px 12px 12px; }
.chat-panel:not(.big) .msg { max-width: 92%; }
@media (max-width: 600px) {
  .chat-panel, .chat-panel.big { right: 8px; left: 8px; width: auto; bottom: 84px; height: calc(100vh - 100px); }
  .chat-panel.big .chat-body .chat-items { display: none; }
}
@media (prefers-reduced-motion: reduce) { .chat-panel { animation: none; } .chat-fab, .chat-fab.on, .chat-fab:hover { transform: none; } }

/* ---------- Part 2: cases, concepts, sources ---------- */
.case { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.case.sel { border-color: var(--pink); }
.case p { margin: 8px 0; color: var(--text-2); }
.case .kv { margin-top: 6px; }
.idea.dropped { opacity: .55; }
.idea .textarea { margin-top: 6px; width: 100%; }
.srcs { margin-top: 8px; font-size: 12px; }
.srcs summary { cursor: pointer; color: var(--muted); }
.srcs a { display: flex; align-items: center; gap: 6px; color: var(--text-2); margin-top: 4px; overflow: hidden; }
.srcs a svg { width: 13px; height: 13px; flex: none; }
.srcs a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idea .small svg { width: 13px; height: 13px; vertical-align: -2px; flex: none; }

/* ---------- Bún chả ---------- */
.case.dropped { opacity: .55; }
.case .no { color: var(--muted); font-size: 12px; }
.bc-assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bc-asset .media { aspect-ratio: 9 / 16; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; }
.bc-asset .media img, .bc-asset .media video { width: 100%; height: 100%; object-fit: cover; }
.bc-asset .media audio { width: 92%; }
.bc-asset .state { font-size: 12px; color: var(--muted); }
.bc-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.bc-stage { position: sticky; top: 72px; }
.bc-player { aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--border); display: grid; place-items: center; }
.bc-player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.bc-player .state { color: var(--muted); font-size: 13px; }
.bc-strip { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 4px; }
.bc-shot { flex: none; width: 64px; background: none; border: 0; padding: 0; color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; text-align: center; }
.bc-shot .thumb { position: relative; width: 64px; height: 96px; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; margin-bottom: 4px; transition: border-color var(--dur); }
.bc-shot .thumb img, .bc-shot .thumb video { width: 100%; height: 100%; object-fit: cover; }
.bc-shot .ico svg { width: 20px; height: 20px; color: var(--muted); }
.bc-shot .dot { position: absolute; top: 6px; right: 6px; }
.bc-shot:hover .thumb, .bc-shot:focus-visible .thumb { border-color: var(--pink-line); }
.bc-shot.on .thumb { border-color: var(--pink); box-shadow: 0 0 0 2px var(--pink-soft); }
.bc-shot.warn .thumb { border-color: var(--warn); }
.bc-edit { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.bc-edit svg, .bc-opts svg { width: 13px; height: 13px; vertical-align: -2px; }
.bc-opts { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.bc-opts summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
@media (max-width: 900px) { .bc-layout { grid-template-columns: 1fr; } .bc-stage { position: static; } }

/* ---------- Overview report charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .base { stroke: var(--border-strong); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: rgba(255, 255, 255, 0.04); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hrow { display: grid; grid-template-columns: 130px minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: 12.5px; }
.hrow:hover .htrack { background: var(--surface-2); }
.hl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htrack { display: flex; gap: 2px; height: 14px; border-radius: 4px; }
.htrack i { display: block; height: 100%; min-width: 3px; }
.htrack i:last-child { border-radius: 0 4px 4px 0; }
.hv { text-align: right; color: var(--text); font-size: 12px; }
.legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
#tip { position: fixed; z-index: 60; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); font-size: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); max-width: 320px; }

/* ---------- Video library ---------- */
.vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.vid-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; text-align: left; color: inherit; font: inherit; cursor: pointer; transition: border-color var(--dur); }
.vid-card:hover, .vid-card:focus-visible, .vid-card.on { border-color: var(--pink-line); }
.vid-card .thumb { position: relative; aspect-ratio: 9 / 16; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.vid-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.vid-card .play { position: absolute; inset: 0; display: grid; place-items: center; color: white; opacity: .8; }
.vid-card .play svg { width: 28px; height: 28px; }
.vid-open { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 20px; margin-bottom: 16px; }
.vid-open video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius-sm); }
@media (max-width: 700px) { .vid-open { grid-template-columns: 1fr; } }

/* ---------- Đang làm + journey bar ---------- */
.table.work td { vertical-align: middle; }
.table.work td:nth-child(3) { max-width: 360px; }
.journey { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.journey .sep-j { color: var(--muted); opacity: .6; }
.journey .j-steps { margin-left: auto; display: flex; gap: 4px; }
.journey .j-steps a { padding: 3px 10px; border-radius: 999px; color: var(--muted); text-decoration: none; border: 1px solid transparent; }
.journey .j-steps a:hover { color: var(--text); border-color: var(--border); }
.journey .j-steps a.on { background: var(--pink-soft); color: var(--pink-2); border-color: var(--pink-line); }
.vid-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Wallet tiles (overview) ---------- */
.wallet { display: flex; flex-direction: column; gap: 4px; }
.wallet .w-big { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.wallet.low { border-color: var(--warn); }
.input.sm { padding: 6px 8px; font-size: 13px; min-width: 0; flex: 1; }

/* ---------- Ads Meta ---------- */
.table.ads { min-width: 1500px; }
.table.ads th.num, .table.ads td.num { text-align: right; white-space: nowrap; }
.table.ads th:first-child, .table.ads td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 260px; max-width: 320px; }
.table.ads tr.grp { cursor: pointer; }
.table.ads tr.grp:hover td { background: var(--surface-2); }
.table.ads tr.tot td { font-weight: 700; border-bottom: 1px solid var(--border); }
.table.ads tr.ad td:first-child { padding-left: 28px; }
.table.ads .ad-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.table.ads .caret { display: inline-block; width: 12px; color: var(--muted); }
.warn-card { display: flex; gap: 8px; align-items: center; border-color: var(--warn); margin-bottom: 12px; }
.warn-card svg { width: 16px; height: 16px; color: var(--warn); flex: none; }
.ads-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: -6px 0 14px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }

/* ---------- Ads Meta v2 (Ads Manager layout) ---------- */
.ads-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.ads-search { position: relative; flex: 1 1 280px; }
.ads-search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.ads-search .input { padding-left: 34px; width: 100%; }
.ads-bar .select { width: auto; min-width: 180px; }
.ads-dates { display: flex; gap: 6px; align-items: center; }
.ads-dates .input { width: 140px; padding: 6px 8px; }
.ads-dates.on .input { border-color: var(--pink-line); }
.ads-bar2 { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--pink-soft); color: var(--pink-2); font-size: 12px; border: 1px solid var(--pink-line); }
.chip button { display: grid; place-items: center; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; }
.chip svg { width: 12px; height: 12px; }
.ads-card { padding: 0; overflow: hidden; }
.table.ads { min-width: 1180px; border-collapse: separate; border-spacing: 0; }
.table.ads th { position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; font-size: 11px; letter-spacing: .02em; }
.table.ads th.on { color: var(--text); }
.table.ads th.num, .table.ads td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table.ads td { padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.table.ads tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.table.ads th:first-child, .table.ads td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 300px; max-width: 340px; box-shadow: 1px 0 0 var(--border); }
.table.ads tbody tr:nth-child(even) td:first-child { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.table.ads tr.drill { cursor: pointer; }
.table.ads tr.drill:hover td { background: var(--surface-2); }
.table.ads .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; font-weight: 600; }
.table.ads tr.drill .nm { color: var(--pink-2); }
.table.ads .sub { display: flex; gap: 6px; align-items: center; margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 320px; }
.table.ads tfoot td { border-top: 1px solid var(--border); border-bottom: 0; background: var(--surface-2); }
.table.ads tfoot td:first-child { background: var(--surface-2); }

/* Key vault lock screen (D27) */
.lock { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 61, 139, .10), transparent 60%), var(--bg); }
.lock-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.lock-card h2 { margin: 0; font-size: 18px; }
.lock-card p { margin: 0; font-size: 13px; }
.lock-ic { width: 44px; height: 44px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%;
  background: var(--pink-soft); color: var(--pink); }
.lock-ic svg { width: 22px; height: 22px; }
.lock-err { min-height: 18px; color: var(--err); }

/* Ma trận action UA: diagnosis chip, detail card, mini grids, benchmark editor */
.dx { display: inline-flex; gap: 6px; align-items: center; max-width: 230px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dx-v { cursor: pointer; font-family: inherit; }
.dx-diag { max-width: 160px; font-size: 12px; line-height: 1.35; color: var(--text-2); }
.dx-diag.good { color: var(--ok); } .dx-diag.bad { color: var(--err); }
.dx-head { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.dx-big { font-size: 15px; padding: 5px 14px; }
.dx-h { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.dx-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text); font-size: 13px; }
.dx-why { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.dx-why summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.dx-why summary:hover { color: var(--text); }
.dx-v:hover { filter: brightness(1.25); }
.dx-note { margin-top: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dx:hover { border-color: var(--pink-line); color: var(--text); }
.dx .mono { color: var(--pink-2); font-size: 11px; }
.dx.good { border-color: rgba(61, 220, 151, .35); }
.dx.bad { border-color: rgba(255, 93, 108, .4); }
.ads-dx { margin-bottom: 12px; }
.ads-dx .nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.mx-m { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.mx-m.good { border-color: rgba(61, 220, 151, .45); }
.mx-m.bad { border-color: rgba(255, 93, 108, .5); }
.mx-path { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.mx-step { padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.mx-grid { display: grid; grid-template-columns: 52px repeat(3, 1fr); gap: 4px; margin-top: 8px; font-size: 11.5px; }
.mx-h { color: var(--muted); align-self: center; text-align: center; font-size: 11px; }
.mx-c { padding: 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid transparent; color: var(--text-2); line-height: 1.3; }
.mx-c .mono { display: block; color: var(--pink-2); font-size: 10.5px; margin-top: 2px; }
.mx-c.good { background: rgba(61, 220, 151, .08); }
.mx-c.bad { background: rgba(255, 93, 108, .08); }
.mx-c.hit { border-color: var(--pink); color: var(--text); box-shadow: 0 0 0 2px var(--pink-soft); }
.mx-act { margin-top: 8px; font-size: 13px; }
.mx-act ul, .mx-notes { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.mx-notes { margin-top: 8px; }
.mx-notes li { margin-bottom: 4px; }
.mx-notes li.good::marker { color: var(--ok); }
.mx-notes li.bad::marker { color: var(--err); }
.chip.on { border-color: var(--pink-line); color: var(--text); }
.bench-app { padding: 12px 0; border-top: 1px solid var(--border); }
.bench-app .table { margin-top: 8px; }
.bench-app .input.sm { width: 100%; min-width: 90px; }
.select.sm { height: var(--ctl-sm); font-size: 12.5px; }

.dx.thin { opacity: .6; border-style: dashed; }

/* Ads table fits the screen width: no horizontal scroll on a normal desktop (owner, 2026-11-13). */
.table.ads { min-width: 0; width: 100%; font-size: 12px; }
.table.ads th, .table.ads td { padding-left: 6px; padding-right: 6px; }
.table.ads th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.table.ads th.num { text-align: right; white-space: normal; word-break: keep-all; }  /* long headers wrap, never overlap */
.table.ads th:first-child, .table.ads td:first-child { min-width: 0; width: 22%; max-width: none; position: static; }
.table.ads .nm, .table.ads .sub { max-width: none; }
.table.ads .nm { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.table.ads td .dx { max-width: 140px; white-space: normal; line-height: 1.25; }
.table.ads { table-layout: fixed; }
/* Every column fits the window at any size (owner: no metric may be hidden, no sideways scroll).
   Name + "Chẩn đoán · Action" get fixed shares; the 12 number columns split the rest. */
.table.ads th:first-child, .table.ads td:first-child { width: 17%; }
.table.ads th:nth-child(2), .table.ads td:nth-child(2) { width: 12%; overflow: hidden; }
.dx-link { background: none; border: 0; padding: 0; font: inherit; text-align: left; cursor: pointer; }
.dx-link:hover { text-decoration: underline; }
.dx-do { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.table.ads .dx-v { max-width: 100%; white-space: normal; text-align: left; line-height: 1.3; }
.table.ads .dx-note { white-space: normal; line-height: 1.3; }
.table.ads th.num, .table.ads td.num { padding-left: 3px; padding-right: 3px; }
@media (max-width: 1440px) { .table.ads { font-size: 11px; } .table.ads th { font-size: 10px; } }
.table.ads td .dx { max-width: 100%; }

/* Provider teams on the job page (D25) */
.lanes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lane { display: flex; gap: 8px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }
.lane .mono { color: var(--pink-2); }
.lane.idle { opacity: .55; }
.lane.idle .mono { color: var(--text-2); }

/* Production lots (P02 step 4) */
.lot-list { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lot-row { display: grid; grid-template-columns: 20px 48px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.lot-row:last-child { border-bottom: 0; }
.lot-row:hover { background: var(--surface-2); }
.lot-gen { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.jes-note { color: var(--muted); margin-top: 4px; max-width: 280px; }

/* Từ pain point: tick cases → Lô sản xuất */
.case-tick { width: 16px; height: 16px; accent-color: var(--pink, #e0457b); cursor: pointer; flex: none; }
.lot-bar { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); align-items: center; flex-wrap: wrap; }
.warn-text { color: var(--warn, #e0a030); font-size: 12px; }
.lot-bar.stick { position: sticky; bottom: 12px; padding-right: 72px; z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.45); border-color: var(--pink, #e0457b); }

/* Hàng đợi: Jessica's note under a failed job */
.jes-note { display: flex; gap: 6px; align-items: flex-start; max-width: 280px; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-2, var(--muted)); line-height: 1.45; }
.jes-note svg { width: 13px; height: 13px; flex: none; margin-top: 2px; color: var(--pink, #e0457b); }

/* Hàng đợi: status cell stays inside its column whatever the error */
.table td.job-st { width: 300px; max-width: 300px; }
.job-st .err-text { margin-top: 6px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.err-more { margin-top: 4px; font-size: 12px; }
.err-more summary { cursor: pointer; color: var(--muted); width: fit-content; padding: 2px 0; }
.err-more summary:hover { color: var(--text); }
.err-more summary:focus-visible { outline: 2px solid var(--pink, #e0457b); outline-offset: 2px; border-radius: 4px; }
.err-more pre { margin: 6px 0 0; max-height: 180px; overflow: auto; padding: 8px; border-radius: 8px; background: var(--surface-2); font: 11px/1.5 var(--mono, ui-monospace, monospace); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.job-st .jes-note { max-width: none; }
/* Hàng đợi: fixed columns that always fit the card (HD → Full HD); long targets / errors wrap inside their cell */
.table.jobs { table-layout: fixed; width: 100%; }
.table.jobs th:nth-child(1) { width: 34px; }
.table.jobs th:nth-child(2) { width: 58px; }
.table.jobs td:nth-child(2) { overflow-wrap: normal; white-space: nowrap; }
.table.jobs th:nth-child(3) { width: 10%; }
.table.jobs th:nth-child(4) { width: 15%; }
.table.jobs th:nth-child(5) { width: 11%; }
.table.jobs th:nth-child(6) { width: 11%; }
.table.jobs th:nth-child(7) { width: 25%; }
.table.jobs th:nth-child(8) { width: 8%; }
.table.jobs th:nth-child(9) { width: 8%; }
.table.jobs th:nth-child(10) { width: 108px; }
.table.jobs td { overflow-wrap: anywhere; vertical-align: top; }
.table.jobs td.job-st { width: auto; max-width: none; }
.table.jobs .progress { min-width: 0; flex: 1; }
.table.jobs td:nth-child(10) .btn { white-space: nowrap; }

/* Icons from ic(): text-sized by default, aligned with the text around them */
svg.i { flex: none; vertical-align: -0.15em; }
/* Bún chả: scene edit card in the right column */
.bc-scene { display: flex; flex-direction: column; gap: 12px; }
.bc-scene .field { margin: 0; }
.bc-scene .hint { margin-top: 4px; }
.bc-scene .notice { display: flex; gap: 8px; align-items: flex-start; }
.bc-scene code { font-size: 11px; }

/* Trang "Từ idea" (2026-11-19) */
.own-group { display: flex; flex-direction: column; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.own-group:last-child { border-bottom: 0; padding-bottom: 0; }
.own-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.own-idea-text { font-weight: 600; overflow-wrap: anywhere; }
.case-actions { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }

/* Slider for long number options, e.g. clip length 4s…30s (2026-11-20) */
.range-label { display: flex; align-items: baseline; gap: 8px; }
.range-label b { color: var(--pink-2); font-variant-numeric: tabular-nums; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 2px 0 0; background: transparent; cursor: pointer; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--pink) 0 var(--p, 0%), var(--surface-3) var(--p, 0%) 100%); }
.slider::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
.slider::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--pink); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--pink); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); transition: transform var(--dur); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--pink); }
.slider:hover::-webkit-slider-thumb, .slider:active::-webkit-slider-thumb { transform: scale(1.12); }
.slider:focus-visible { outline: none; }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--pink-soft); }
.range-ends { display: flex; justify-content: space-between; margin-top: 2px; }
.tv-sum td .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.tv-sum .num { text-align: right; }
/* Ads on / off (2026-11-23) */
.st-pill { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; padding: 1px 8px 1px 7px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap; vertical-align: 1px; border: 1px solid var(--border-strong); color: var(--muted); }
.st-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pill.on { color: var(--ok); border-color: rgba(61, 220, 151, .35); background: rgba(61, 220, 151, .08); }
.st-pill.warn { color: var(--warn); border-color: rgba(255, 181, 71, .35); }
.st-pill.err { color: var(--err); border-color: rgba(255, 93, 108, .35); }
/* Ads date picker (2026-11-23) */
.dp { position: relative; }
.dp-btn { display: inline-flex; align-items: center; gap: 8px; height: var(--ctl); padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text); cursor: pointer; transition: border-color var(--dur); }
.dp-btn:hover { border-color: var(--muted); }
.dp-btn.open { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.dp-btn svg { width: 16px; height: 16px; color: var(--muted); }
.dp-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; display: flex; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 18px 48px rgba(0, 0, 0, .55); }
.dp-side { display: flex; flex-direction: column; gap: 2px; padding: 8px; min-width: 150px; border-right: 1px solid var(--border); }
.dp-side button { text-align: left; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; }
.dp-side button:hover { background: var(--surface-3); color: var(--text); }
.dp-side button.on { background: var(--pink-soft); color: var(--pink-2); font-weight: 600; }
.dp-main { padding: 10px 14px 12px; position: relative; }
.dp-nav { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.dp-nav .btn { pointer-events: auto; font-size: 16px; width: 30px; padding: 0; }
.dp-months { display: flex; gap: 22px; }
.dp-month { width: 252px; }
.dp-mt { text-align: center; font-weight: 600; height: 32px; line-height: 32px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 36px); gap: 2px 0; }
.dp-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.dp-grid button { height: 34px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp-grid button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.dp-grid button:disabled { color: var(--border-strong); cursor: default; }
.dp-grid button.today { box-shadow: inset 0 0 0 1px var(--border-strong); }
.dp-grid button.in { background: var(--pink-soft); color: var(--text); border-radius: 0; }
.dp-grid button.end { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.dp-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.check-note { display: flex; gap: 8px; align-items: flex-start; margin: -6px 0 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .35); color: var(--warn); line-height: 1.5; overflow-wrap: anywhere; }
.check-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.check-note b { color: var(--warn); }

/* P08: the Tail beat by beat under the owner's description */
.tail-script { display: grid; gap: 10px; }
.ts-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; font-size: 13.5px; line-height: 1.5; }
.ts-row > div { overflow-wrap: anywhere; }

/* 2026-11-27: Jessica's logo in the top bar and her panel */
.jess-btn { position: relative; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface-2); cursor: pointer; display: grid; place-items: center; transition: transform .15s ease, border-color .15s ease; }
.jess-btn:hover { transform: scale(1.06); border-color: var(--pink, #ff4fa3); }
.jess-btn:focus-visible { outline: 2px solid var(--pink, #ff4fa3); outline-offset: 2px; }
.jess-btn img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.jess-dot { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--err, #ff5a5a);
  border: 2px solid var(--bg, #09080b); }
.jess-modal { width: min(560px, calc(100vw - 32px)); }
.jess-face { border-radius: 50%; flex: none; }
.jess-report { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .jess-btn { transition: none; } .jess-btn:hover { transform: none; } }

/* D28: Google sign-in screen */
.login-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(380px, 100%); display: grid; justify-items: center; gap: 14px; text-align: center; padding: 32px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.login-card h2 { margin: 0; }
.sidebar-foot img.avatar { object-fit: cover; padding: 0; }
.jess-btn[hidden], #chatdock[hidden] { display: none; }

/* D18: lessons from the ads */
.lesson { padding: 12px 0; border-top: 1px solid var(--border); }
.lesson:first-of-type { border-top: 0; }
.lesson b { font-weight: 600; line-height: 1.45; }
