/* Page refinements (f1) — loaded after hallmark.css. Login, welcome, portfolio, new project, admin console, MCP card. */

/* ------------------------------------------------------------ shared: "?" tip */
.pj-nowrap { white-space: nowrap; }
.f1-tip { display: inline-block; position: relative; vertical-align: middle; margin-left: var(--space-2xs); }
.f1-tip-q { position: relative; display: inline-grid; padding: 0; font: inherit; place-items: center; width: 20px; height: 20px; border: var(--rule-hair) solid var(--color-rule-2); border-radius: 50%;
  color: var(--color-ink-2); background: var(--color-paper-2); font-size: var(--text-xs); font-weight: 600; line-height: 1; cursor: pointer; }
.f1-tip-q::before { content: ""; position: absolute; inset: -12px; } /* 44px touch target around the 20px mark */
.f1-tip-q:hover { background: var(--color-paper-3); color: var(--color-ink); }
.f1-tip-q:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.f1-tip-q[aria-expanded="true"] { background: var(--color-accent-soft); color: var(--color-accent-text); border-color: var(--color-accent); }
.f1-tip-body[hidden] { display: none; }
.f1-tip-body { position: absolute; z-index: 40; top: calc(100% + 6px); left: -8px; width: max-content; max-width: min(300px, calc(100vw - 32px));
  padding: var(--space-sm); border-radius: var(--radius-card); background: var(--color-paper-2); color: var(--color-ink-2); box-shadow: var(--shadow-pop);
  font-size: var(--text-sm); font-weight: 400; line-height: 1.5; text-align: left; white-space: normal; text-transform: none; letter-spacing: 0; }
.f1-tip-body b { color: var(--color-ink); font-weight: 600; }

/* ------------------------------------------------------------ shared: sortable column heads */
th[data-sort] { padding: 0 !important; }
.f1-sort { display: inline-flex; align-items: center; gap: 6px; width: 100%; min-height: 40px; padding: var(--space-sm) var(--space-md); border: 0; background: none;
  font: inherit; font-weight: 500; color: var(--color-muted); text-align: inherit; cursor: pointer; white-space: nowrap; }
th.num .f1-sort, th.pj-num .f1-sort { justify-content: flex-end; }
.f1-sort i { font-size: 11px; opacity: .55; }
.f1-sort:hover { color: var(--color-ink); }
.f1-sort:hover i { opacity: 1; }
.f1-sort.is-on { color: var(--color-ink); font-weight: 600; }
.f1-sort.is-on i { opacity: 1; color: var(--color-accent-text); }
.f1-sort:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; border-radius: var(--radius-pill); }

/* ------------------------------------------------------------ login */
.hm-login-side h2 { margin-bottom: var(--space-2xs); }
.hm-glimpse-note { margin: 0 0 var(--space-md); color: var(--color-muted); font-size: var(--text-xs); }
.hm-glimpse { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--color-paper-2); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); overflow: hidden; }
.hm-glimpse th { text-align: left; font-weight: 500; color: var(--color-muted); padding: var(--space-xs) var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule); font-size: var(--text-xs); white-space: nowrap; }
.hm-glimpse td { padding: var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule); vertical-align: top; color: var(--color-ink); }
.hm-glimpse tr:last-child td { border-bottom: 0; }
.hm-glimpse td b { font-weight: 600; display: block; }
.hm-glimpse small { display: block; margin-top: 2px; color: var(--color-muted); font-size: var(--text-xs); }
.hm-glimpse .n { text-align: right; }
.hm-glimpse td:nth-child(3) { white-space: nowrap; }
.hm-gbar { display: block; width: 72px; height: 4px; margin-top: 7px; border-radius: 2px; background: var(--color-rule); overflow: hidden; }
.hm-gbar i { display: block; height: 100%; background: var(--color-cool); }
.hm-lz { display: inline-block; padding: 1px var(--space-xs); border-radius: var(--radius-chip); font-size: var(--text-xs); color: var(--color-ink-2); white-space: nowrap; border: var(--rule-hair) solid var(--color-rule-2); }
.hm-lz.is-bad { background: var(--color-bad-soft); }
.hm-lz.is-ok { background: var(--color-ok-soft); }
.hm-gets { list-style: none; margin: var(--space-lg) 0 0; padding: 0; display: grid; gap: var(--space-sm); }
.hm-gets li { color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.55; padding-top: var(--space-sm); border-top: var(--rule-hair) solid var(--color-rule); max-width: 60ch; }
.hm-gets li:first-child { border-top: 0; padding-top: 0; }
.hm-gets b { color: var(--color-ink); font-weight: 600; }
.hm-fhint { margin: 0 0 var(--space-xs); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.5; }
.hm-ferr { margin: 0 0 var(--space-2xs); font-weight: 500; color: var(--color-bad); font-size: var(--text-sm); line-height: 1.5; }
.hm-input[aria-invalid="true"] { border-color: var(--color-bad); }
.hm-btn.is-busy { opacity: .75; cursor: progress; }
@media (max-width: 40rem) {
  .hm-glimpse th:nth-child(3), .hm-glimpse td:nth-child(3) { display: none; }
}
.hm-uat-d > summary small { font-weight: 400; font-size: var(--text-sm); color: var(--color-muted); }
/* Phone: three explicit columns (project, progress, overdue) so the dropped column leaves no empty gap. */
@media (max-width: 30rem) {
  .hm-glimpse { display: block; border-collapse: separate; }
  .hm-glimpse thead, .hm-glimpse tbody { display: block; }
  .hm-glimpse tr { display: grid; grid-template-columns: minmax(0, 1fr) 5rem 5.5rem; align-items: start; }
  .hm-glimpse th, .hm-glimpse td { padding-left: var(--space-xs); padding-right: var(--space-xs); }
  .hm-glimpse th:first-child, .hm-glimpse td:first-child { padding-left: var(--space-sm); }
  .hm-glimpse th:last-child, .hm-glimpse td:last-child { padding-right: var(--space-sm); }
  .hm-glimpse .hm-gbar { width: 100%; }
  .hm-glimpse th, .hm-glimpse td { border-bottom: 0 !important; }
  .hm-glimpse tr { border-bottom: var(--rule-hair) solid var(--color-rule); }
  .hm-glimpse tbody tr:last-child { border-bottom: 0; }
}

/* ------------------------------------------------------------ welcome */
.wl-head > p:first-child { font-size: var(--text-lg); color: var(--color-ink); }
.wl-head:last-child { border-bottom: 0; }
/* The two ways in are two equal cards: same surface, same title size, actions at the foot. */
.wl-choices { align-items: start; margin-bottom: var(--space-lg); }
section.wl-choice { flex-direction: column; gap: var(--space-sm); }
.wl-choice h3 { display: flex; gap: var(--space-sm); align-items: baseline; margin: 0; font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
.wl-choice h3 i { font-size: 1rem; color: var(--color-ink-2); }
.wl-choice p { margin: 0; color: var(--color-ink-2); line-height: 1.55; max-width: 60ch; }
.wl-choice .wl-actions { margin-top: 0; padding-top: var(--space-xs); }
.wl-mail { overflow-wrap: anywhere; color: var(--color-ink); }
.wl-admin { font-size: var(--text-sm); }
.wl-check-res { font-size: var(--text-sm); color: var(--color-muted) !important; }
.wl-gets { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-md); margin: 0 0 var(--space-xl); padding: var(--space-md) 0 0; border-top: var(--rule-hair) solid var(--color-rule); }
.wl-first h2 { margin: 0 0 var(--space-xs); font-size: var(--text-md); font-weight: 600; }
.wl-first { margin-bottom: var(--space-xl); }
.wl-first .wl-gets { margin-bottom: 0; counter-reset: wl; padding-top: var(--space-sm); }
.wl-first .wl-gets li { counter-increment: wl; }
.wl-first .wl-gets b::before { content: counter(wl) ". "; font-variant-numeric: tabular-nums; }
.wl-gets li { color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.55; }
.wl-gets b { display: block; color: var(--color-ink); font-weight: 600; }

/* ------------------------------------------------------------ portfolio */
.pj-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.pj-toolbar .pj-filter { margin: 0; }
.pj-search { position: relative; flex: 1 1 220px; max-width: 320px; margin-left: auto; }
.pj-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted); font-size: 13px; pointer-events: none; }
.pj-search input { width: 100%; min-height: 40px; padding: var(--space-xs) var(--space-sm) var(--space-xs) 34px; border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-pill);
  background: var(--color-paper-2); color: var(--color-ink); font: inherit; font-size: var(--text-sm); }
.pj-search input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -1px; }
.pj-sortsel { display: none; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--color-ink-2); }
.pj-sortsel select { min-height: 40px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink); font: inherit; font-size: var(--text-sm); }
.pj-help { margin: 0 0 var(--space-md); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.55; max-width: 90ch; }
.pj-zero { color: var(--color-muted); }
.pj-help-narrow { display: none; }
.f1-th { display: flex; align-items: center; gap: 0; }
th.pj-num .f1-th, th.num .f1-th { justify-content: flex-end; }
.f1-th .f1-sort { width: auto; padding-right: var(--space-2xs); }
.f1-th .f1-tip { margin: 0 var(--space-xs) 0 0; }
.pj-table thead .f1-tip-body, .ad-tbl thead .f1-tip-body { font-weight: 400; }
th.pj-num .f1-tip-body { left: auto; right: -8px; }
.pj-table td.pj-c-od, .pj-table td.pj-c-rk { vertical-align: top; }
.pj-c-next .chip-hm { margin-left: var(--space-2xs); }
.pj-none { padding: var(--space-xl) var(--space-md); text-align: center; color: var(--color-ink-2); }
.pj-none p { margin: 0 0 var(--space-sm); }
@media (max-width: 40rem) {
  .pj-search { order: 2; max-width: none; flex-basis: 100%; margin-left: 0; }
  .pj-sortsel { display: flex; order: 3; flex: 1; }
  .pj-sortsel select { flex: 1; }
  .pj-new { order: 4; }
  .pj-filter { order: 1; width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .pj-filter button { flex: 1 0 auto; padding-inline: 10px; }
  .pj-help-wide { display: none; }
  .pj-help-narrow { display: inline; }
  /* Rows become cards: name, status, progress, next milestone, then overdue / hot risks / end in one line. */
  .pj-table-wrap:has(.pj-cards) { border: 0; background: none; box-shadow: none; overflow: visible; }
  .pj-table.pj-cards { min-width: 0; display: block; }
  .pj-cards thead { display: none; }
  .pj-cards tbody { display: grid; gap: var(--space-sm); }
  .pj-cards tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs) var(--space-sm); padding: var(--space-md);
    background: var(--color-paper-2); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); }
  .pj-cards tbody tr.is-current { background: var(--color-accent-soft); }
  .pj-cards td { display: block; padding: 0; border: 0 !important; text-align: left; min-width: 0 !important; }
  .pj-cards .pj-c-name { grid-column: 1 / 3; }
  .pj-cards .pj-c-st { grid-column: 3; justify-self: end; }
  .pj-cards.no-st .pj-c-name { grid-column: 1 / -1; }
  .pj-cards .pj-c-prog, .pj-cards .pj-c-next { grid-column: 1 / -1; }
  .pj-cards .pj-c-next { padding-top: var(--space-xs); border-top: var(--rule-hair) solid var(--color-rule) !important; }
  .pj-cards .pj-c-od, .pj-cards .pj-c-rk, .pj-cards .pj-c-end { padding-top: var(--space-xs); }
  .pj-cards td[data-l]::before { content: attr(data-l); display: block; margin-bottom: 2px; color: var(--color-muted); font-size: var(--text-xs); }
  .pj-cards .pj-c-next { display: block; }
}

/* ------------------------------------------------------------ new project */
.np-row > .np-field { align-content: start; }
.np-ferr { color: var(--color-bad); font-size: var(--text-sm); }
.np-ferr::before { content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 6px; font-size: 12px; }
.np-dw { color: var(--color-ink-2); }
.np ::placeholder { color: var(--color-ink-2); opacity: 1; }
.np-why { margin: 0 0 var(--space-xs); color: var(--color-ink-2); font-size: var(--text-sm); }
.np-actions .btn[disabled] { cursor: not-allowed; }
/* The one date box of both steps: dd/mm/yyyy text, the weekday small beside it in a task row. */
.np-main input.np-date { max-width: 14rem; font-family: inherit; font-size: var(--text-md); }
.np-tbl input.np-date { min-width: 0 !important; width: 7.5rem; font-family: inherit; }
.np-c-start, .np-c-due { white-space: nowrap; }
.np-dwc { display: inline-block; margin-left: var(--space-2xs); color: var(--color-ink-2); font-size: var(--text-xs); }
@media (max-width: 40rem) { .np-tbl-tasks input.np-date { width: calc(100% - 1.9rem); padding-inline: 8px !important; font-size: var(--text-sm) !important; } .np-main input.np-date { max-width: none; } }
.np-money { position: relative; display: block; }
.np-money input { padding-right: 36px !important; }
.np-money > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted); pointer-events: none; }
.np-plan-t p { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.np-redo { margin-left: var(--space-xs); }
.np-dash { color: var(--color-muted); display: inline-block; padding: var(--space-xs) var(--space-sm); }
.np-tbl td small.np-dw { display: block; margin-top: 2px; font-size: var(--text-xs); white-space: nowrap; }
.np-sec > .np-err { margin: 0 0 var(--space-sm); }
.np-shift { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); margin: 0 0 var(--space-sm); font-size: var(--text-sm); }
.np-shift label { font-weight: 500; }
.np-shift-in { display: inline-flex; align-items: center; gap: var(--space-xs); color: var(--color-ink-2); }
.np-shift-in input { width: 88px; min-height: 36px; padding: 0 var(--space-xs); border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink); font: inherit; }
.np-shift-in input[aria-invalid="true"] { border-color: var(--color-bad); }
.np-shift .np-hint { flex-basis: 100%; }
.np-shift .np-ferr { flex-basis: 100%; }
.np-shift .np-ferr[hidden] { display: none; }
.np-grp { margin: 0 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); background: var(--color-paper-2); }
.np-grp > summary { display: flex; align-items: baseline; gap: var(--space-sm); min-height: 44px; padding: var(--space-sm) var(--space-md); cursor: pointer; list-style: none; }
.np-grp > summary::-webkit-details-marker { display: none; }
.np-grp > summary::before { content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 11px; color: var(--color-muted); transition: transform var(--dur-micro, 120ms) ease-out; }
.np-grp[open] > summary::before { transform: rotate(90deg); }
.np-grp > summary small { color: var(--color-muted); }
.np-grp > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; border-radius: var(--radius-card); }
.np-grp .np-tbl-wrap { border: 0; border-top: var(--rule-hair) solid var(--color-rule); border-radius: 0; }
.np-grp > .np-add { margin: var(--space-xs) var(--space-md) var(--space-sm); }
.np-grp-empty { margin: 0; padding: var(--space-xs) var(--space-md); border-top: var(--rule-hair) solid var(--color-rule); }
.np-tbl-risks select { min-width: 140px; }
.np-score { display: inline-block; min-width: 2ch; color: var(--color-ink-2); }
.np-r-s { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .np-grp > summary::before { transition: none; } }
.np-tbl [aria-invalid="true"] { border-color: var(--color-bad) !important; outline: 2px solid var(--color-bad); outline-offset: -2px; }
@media (max-width: 40rem) {
  /* Tasks become two-line cards: title (+ delete) on top; group, dates, priority, milestone below. */
  .np-tbl-wrap:has(.np-tbl-tasks) { overflow: visible; background: none; box-shadow: none; border: 0; }
  .np-tbl.np-tbl-tasks { display: block; min-width: 0; }
  .np-tbl-tasks thead { display: none; }
  .np-tbl-tasks tbody { display: grid; gap: var(--space-sm); }
  .np-tbl-tasks tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--space-xs); padding: var(--space-sm);
    background: var(--color-paper-2); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); }
  .np-tbl-tasks td { display: block; padding: 0 !important; border: 0 !important; min-width: 0 !important; text-align: left !important; }
  .np-tbl-tasks .np-c-title { grid-column: 1 / 3; }
  .np-tbl-tasks .np-c-del { grid-column: 3; grid-row: 1; }
  .np-tbl-tasks .np-c-start { grid-column: 1; grid-row: 2; }
  .np-tbl-tasks .np-c-due { grid-column: 2 / -1; grid-row: 2; }
  .np-tbl-tasks .np-c-ws { grid-column: 1; grid-row: 3; }
  .np-tbl-tasks .np-c-pri { grid-column: 2 / -1; grid-row: 3; }
  .np-tbl-tasks .np-c-ms { grid-column: 1 / -1; grid-row: 4; display: flex; align-items: center; gap: var(--space-xs); }
  .np-tbl-tasks td[data-l]::before { content: attr(data-l); display: block; margin-bottom: 2px; color: var(--color-muted); font-size: var(--text-xs); }
  .np-tbl-tasks .np-c-ms::before { display: inline; margin: 0; }
  .np-tbl-tasks select { width: 100%; }
  .np-tbl-tasks tr.is-ms td { background: none !important; }
  .np-tbl-tasks input[type="text"], .np-tbl-tasks input[type="date"], .np-tbl-tasks select { min-height: 40px; border: var(--rule-hair) solid var(--color-rule-2) !important; border-radius: var(--radius-pill); background: var(--color-paper-2); }
  .np-sec-h { flex-wrap: wrap; }
  /* Groups: name (+ delete) on one line, scope under it, so neither is cut off. */
  .np-tbl.np-tbl-ws { display: block; }
  .np-tbl-ws thead { display: none; }
  .np-tbl-ws tbody { display: block; }
  .np-tbl-ws tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: var(--space-2xs) var(--space-xs); border-bottom: var(--rule-hair) solid var(--color-rule); }
  .np-tbl-ws tr:last-child { border-bottom: 0; }
  .np-tbl-ws td { display: block; padding: 0 !important; border: 0 !important; }
  .np-tbl-ws .np-w-name input { font-weight: 600; }
  .np-tbl-ws .np-w-scope { grid-column: 1; grid-row: 2; }
  .np-tbl-ws .np-w-scope input { color: var(--color-ink-2); }
  .np-tbl-ws .np-w-del { grid-column: 2; grid-row: 1; }
  .np-sec-h small { flex-basis: 100%; }
  .np-shift label { flex-basis: 100%; }
  /* Inside a folded group the task cards sit on the group's own surface. */
  .np-grp .np-tbl-wrap:has(.np-tbl-tasks) { padding: var(--space-sm); }
  .np-grp .np-tbl-tasks tr { box-shadow: none; border: var(--rule-hair) solid var(--color-rule); }
  .np-tbl-tasks input[type="date"] { min-width: 0; }
  /* Risks become cards: title (+ delete), likelihood and impact side by side, score, then mitigation. */
  .np-tbl-wrap:has(.np-tbl-risks) { overflow: visible; background: none; box-shadow: none; border: 0; }
  .np-tbl.np-tbl-risks { display: block; min-width: 0; }
  .np-tbl-risks thead { display: none; }
  .np-tbl-risks tbody { display: grid; gap: var(--space-sm); }
  .np-tbl-risks tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--space-xs); padding: var(--space-sm);
    background: var(--color-paper-2); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); }
  .np-tbl-risks td { display: block; padding: 0 !important; border: 0 !important; min-width: 0 !important; }
  .np-tbl-risks .np-r-title { grid-column: 1 / 3; }
  .np-tbl-risks .np-r-del { grid-column: 3; grid-row: 1; }
  .np-tbl-risks .np-r-p { grid-column: 1; }
  .np-tbl-risks .np-r-i { grid-column: 2 / -1; }
  .np-tbl-risks .np-r-s { grid-column: 1 / -1; display: flex; gap: var(--space-xs); align-items: baseline; }
  .np-tbl-risks .np-r-m { grid-column: 1 / -1; }
  .np-tbl-risks td[data-l]::before { content: attr(data-l); display: block; margin-bottom: 2px; color: var(--color-muted); font-size: var(--text-xs); }
  .np-tbl-risks .np-r-s::before { display: inline; margin: 0; }
  .np-tbl-risks td[data-l="Rủi ro"]::before { display: none; }
  .np-tbl-risks select { width: 100%; min-width: 0; }
  .np-tbl-risks input[type="text"], .np-tbl-risks select { min-height: 40px; border: var(--rule-hair) solid var(--color-rule-2) !important; border-radius: var(--radius-pill); background: var(--color-paper-2); }
}

/* ------------------------------------------------------------ admin console */
.ad-help { margin: var(--space-sm) 0 var(--space-md); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.55; max-width: 100ch; }
.ad-kpi .k-label { display: flex; align-items: center; gap: 2px; }
.ad-trend .card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2xs) var(--space-sm); }
.ad-trend .card-head small { color: var(--color-ink-2); }
.ad-spark-few { margin: 0; color: var(--color-muted); font-size: var(--text-sm); line-height: 1.5; max-width: 32ch; }
.ad-spark figcaption small { font-size: var(--text-sm); }
.ad-tabs { gap: var(--space-sm); }
.ad-csv { flex: none; }
.ad-trend .ad-sparks { grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: var(--space-md); }
.ad-trend > .ad-spark-few { margin: 0 0 var(--space-sm); max-width: none; }
.ad-tablist { display: flex; flex-wrap: wrap; gap: 4px; }
.ad-tabs [role=tab] { min-height: 40px; }
.ad-tabs [role=tab][aria-selected=true] small { color: var(--color-accent-text); }
.ad-qwrap { position: relative; margin-left: auto; width: min(100%, 280px); }
.ad-qwrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted); font-size: 13px; pointer-events: none; }
.ad-qwrap .ad-q { width: 100%; margin: 0; padding-left: 34px; }
/* The lists sit straight on the card: no second bordered surface inside it. */
.ad-sortsel { display: none; align-items: center; gap: var(--space-xs); width: 100%; font-size: var(--text-sm); color: var(--color-ink-2); }
.ad-sortsel select { flex: 1; min-height: 40px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink); font: inherit; font-size: var(--text-sm); }
.ad-panel { overflow-x: auto; border-top: var(--rule-hair) solid var(--color-rule); margin: 0 calc(-1 * var(--space-md)); padding: 0 var(--space-md); }
.ad-panel[hidden] { display: none; }
.ad-panel .ad-tbl { width: 100%; border-collapse: collapse; }
.ad-panel .ad-tbl thead th { background: none; }
.ad-none { margin: var(--space-md) 0; }
.ad-tbl .chip-hm { margin-top: 2px; }
@media (max-width: 720px) {
  .ad-kpis .ad-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ad-qwrap { margin-left: 0; width: 100%; }
  .ad-sortsel { display: flex; }
  .ad-panel { overflow: visible; border-top: 0; margin: 0; padding: 0; }
  .ad-tbl.ad-cards { min-width: 0; display: block; }
  .ad-cards thead { display: none; }
  .ad-cards tbody { display: grid; gap: 0; }
  .ad-cards tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs) var(--space-sm); padding: var(--space-sm) 0; border-top: var(--rule-hair) solid var(--color-rule); }
  .ad-cards tbody tr:first-child { border-top: 0; }
  .ad-cards td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; min-width: 0; }
  .ad-cards td:first-child { grid-column: 1 / -1; }
  .ad-cards td:not(:first-child)::before { content: attr(data-l); display: block; color: var(--color-muted); font-size: var(--text-xs); margin-bottom: 1px; }
}

/* ------------------------------------------------------------ MCP card */
.mcp-warn { position: sticky; bottom: 0; }
.mcp-copy pre { font-family: ui-monospace, "IBM Plex Mono", monospace; line-height: 1.5; }
.mcp-copy pre:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.ad-kpi .f1-tip-body { left: auto; right: -8px; }
.ad-kpi .k-label { justify-content: space-between; }
.wl-keys { margin: calc(-1 * var(--space-md)) 0 var(--space-xl); color: var(--color-muted); font-size: var(--text-sm); }
.wl-keys kbd { font: 600 12px/1 var(--font-body); padding: 3px 6px; border-radius: var(--radius-chip); border: var(--rule-hair) solid var(--color-rule-2); background: var(--color-paper-2); color: var(--color-ink-2); }
@media (hover: none), (max-width: 40rem) { .wl-keys { display: none; } }

/* Round 3: projects list. The open project carries a word, not a tint; the last column and its sort icon get room. */
.pj-table tbody tr.is-current { background: transparent; }
.pj-table tbody tr.is-current:hover { background: var(--color-paper-3); }
.pj-open { font-weight: 500; color: var(--color-ink-2); white-space: nowrap; }
.pj-next-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); }
.pj-table th:last-child, .pj-table td:last-child { padding-right: var(--space-lg); }
.pj-table th:last-child .f1-th { padding-right: var(--space-lg); }
@media (min-width: 761px) { .pj-c-next { min-width: 210px; } }

/* Round 3: welcome. Each choice is as tall as its own text; the button sits right under it (no void between). */
.wl-choices { align-items: start; }
.wl-choice .wl-actions { margin-top: 0; }
.wl-admin .wl-copy-admin { margin-left: var(--space-2xs); vertical-align: baseline; }

/* Round 3: step 2 of a new project keeps its actions in view: back, what will be created, create. */
.np-sticky { position: sticky; bottom: 0; z-index: 20; margin: var(--space-lg) calc(-1 * var(--space-xs)) 0; padding: var(--space-sm) var(--space-md);
  background: var(--color-paper-2); border-top: var(--rule-hair) solid var(--color-rule-2); }
.np-sticky-sum { color: var(--color-ink-2); font-size: var(--text-sm); }
@media (max-width: 40rem) { .np-sticky { padding: var(--space-xs) var(--space-sm); gap: var(--space-xs); } .np-sticky .np-spacer { display: none; } .np-sticky-sum { order: -1; flex-basis: 100%; font-size: var(--text-xs); } .np-sticky .btn-primary { margin-left: auto; } }

/* Round 3: admin. Without the trend card the other two share the row; users filters; "Hiện thêm". */
.ad-row:not(:has(.ad-trend)) { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 720px) { .ad-row:not(:has(.ad-trend)) { grid-template-columns: 1fr; } }
.ad-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); }
.ad-filters[hidden] { display: none; }
.ad-filter { display: inline-flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-sm); color: var(--color-ink-2); }
.ad-filter select { min-height: 32px; border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink); font: inherit; padding: 0 var(--space-xs); }
.ad-more { display: flex; justify-content: center; padding: var(--space-md) 0 var(--space-xs); }
.ad-more[hidden] { display: none; }
.wl-head:has(+ .wl-gets) { border-bottom: 0; margin-bottom: 0; padding-bottom: var(--space-md); }
@media (hover: none) { .np-hover-hint { display: none; } }

/* Admin: tighter KPI cards so the list starts higher. */
.ad-kpis { gap: var(--space-sm); }
.ad-kpi { padding-block: var(--space-sm) !important; }

/* Round 5: projects name column holds the name and its meta on two lines, not three. */
@media (min-width: 761px) { .pj-c-name { min-width: 260px; } }
.np-tbl textarea.np-grow { display: block; resize: none; overflow: hidden; line-height: 1.4; field-sizing: content; box-sizing: border-box; }
.np-sec-h .np-fold { margin-left: auto; }
.np-tbl textarea.np-grow { border-radius: var(--radius-card); }

/* Round 5: admin. The list toolbar is two stable rows (tabs + CSV, then search + filters) so it does not move between tabs; the CSV button never wraps. */
.ad-tabs { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: var(--space-xs); }
.ad-tb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); }
.ad-tb:first-child .ad-tablist { flex: 1 1 auto; }
.ad-tb .ad-csv { flex: none; white-space: nowrap; margin-left: auto; }
.ad-tb2 .ad-qwrap { margin-left: 0; flex: 0 1 280px; }
@media (max-width: 720px) { .ad-tb2 .ad-qwrap { flex-basis: 100%; } }
/* Cơ cấu dự án: a couple of short facts, so the lists run inline instead of filling a tall card. */
.ad-mix .card-head { margin-bottom: var(--space-2xs); }
.ad-mix .ad-h3 { margin: var(--space-xs) 0 var(--space-3xs); font-size: var(--text-sm); color: var(--color-ink-2); font-weight: 500; }
.ad-mix .ad-mixl { display: flex; flex-wrap: wrap; gap: 0 var(--space-md); margin: 0; }
.ad-mix .ad-mixl li { justify-content: flex-start; gap: var(--space-xs); padding: 2px 0; }

/* The sticky bottom bar never covers the last rows: room for it under the page, and focus scrolls clear of it. */
.np:has(.np-sticky) { padding-bottom: var(--sticky-bar-h, 0px); }
html:has(.np-sticky) { scroll-padding-bottom: calc(var(--sticky-bar-h, 0px) + var(--space-md)); }

/* Admin: status mix as one stacked bar; the word and count stay in the list under it. */
.ad-stack { display: flex; gap: 2px; height: 10px; margin: 0 0 var(--space-xs); border-radius: var(--radius-pill); overflow: hidden; }
.ad-stack i { display: block; min-width: 4px; }
.ad-stack .is-active, .ad-sw.is-active { background: var(--color-ink); }
.ad-stack .is-planning, .ad-sw.is-planning { background: var(--color-muted); }
.ad-stack .is-on_hold, .ad-sw.is-on_hold { background: var(--color-warn); }
.ad-stack .is-done, .ad-sw.is-done { background: var(--color-ok); }
.ad-stack .is-archived, .ad-sw.is-archived { background: var(--color-rule-2, var(--color-rule)); }
.ad-sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.ad-detail-c { display: none; }
@media (max-width: 720px) {
  .ad-cards .ad-x { display: none; }
  .ad-cards tr.is-open .ad-x { display: block; }
  .ad-cards .ad-detail-c { display: block; grid-column: 1 / -1; }
  .ad-cards .ad-detail-c .ad-detail { min-height: 44px; padding-inline: 0; }
}
.hm-uat-d > summary { white-space: nowrap; }
.wl-first { margin: 0 0 var(--space-xl); color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.55; max-width: 70ch; }
.wl-first b { color: var(--color-ink); font-weight: 600; }
@media (max-width: 640px) {
  #brand-sub .uat-side { margin-left: 8px; }
  #brand-sub .uat-side::before { content: none; }
  #brand-sub:has(.uat-side) { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
}
/* Admin: the sort in words beside the CSV button (wide screens); the Người dùng tab also keeps the sort select in view. */
.ad-sortlbl { display: none; margin-left: auto; color: var(--color-ink-2); font-size: var(--text-sm); white-space: nowrap; }
.ad-sortlbl + .ad-csv { margin-left: 0; }
.ad-lists .ad-sortsel { display: flex; width: auto; margin-left: auto; }
.ad-lists .ad-sortsel select { flex: none; min-width: 14rem; }
.ad-st-q { color: var(--color-ink-2); font-size: var(--text-sm); }
@media (max-width: 720px) {
  .ad-sortlbl { display: none; }
  .ad-lists .ad-sortsel { width: 100%; }
}
.ad-stack i { min-width: 6px; }
/* New project: the notice (with its undo) sits bottom-right, above the sticky bar, clear of the plan table on the left. */
@media (min-width: 901px) {
  body:has(.np-sticky) .toast-root { left: auto; right: 22px; align-items: flex-end; }
}
/* Portfolio toolbar: tabs, search and the new-project button share one 40px height and one centre line. */
.pj-toolbar .pj-filter { min-height: 40px; box-sizing: border-box; align-items: stretch; }
.pj-toolbar .pj-filter button { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.pj-toolbar .pj-new { min-height: 40px; }

/* R9 login: wider hero, balanced headline, no repeated sentence on phones, quiet UAT disclosure. */
.hm-login-wrap { width: min(100%, 1200px); grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); }
@media (max-width: 60rem) { .hm-login-wrap { max-width: 440px; grid-template-columns: minmax(0, 1fr); } }
.hm-login h1 { text-wrap: balance; }
@media (max-width: 40rem) { .hm-proof { display: none; } }
.hm-uat-d > summary { font-size: var(--text-sm); font-weight: 400; color: var(--color-muted); }
.hm-uat-d > summary:hover, .hm-uat-d[open] > summary { color: var(--color-ink-2); }
.hm-uat-d { border-top-style: dashed; }

/* R9 welcome: the copy buttons are one stack, same style, same indent. */
.wl-choice .wl-stack { flex-direction: column; align-items: flex-start; }
.wl-choice .wl-stack .btn { justify-content: flex-start; }

/* R9 projects: planned-to-date tick on the progress bar; the "?" on column heads shows on hover or focus. */
.pj-bar { position: relative; overflow: visible; }
.pj-bar .pj-plan { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--color-ink); border-radius: 1px; }
@media (hover: hover) {
  .pj-table th .f1-tip-q:not([aria-expanded="true"]) { opacity: 0; transition: opacity var(--dur-micro, 120ms); }
  .pj-table th:hover .f1-tip-q, .pj-table th:focus-within .f1-tip-q { opacity: 1; }
}

/* R9 new project: on phones the step keeps its words ("Bước 1/3: Mô tả dự án"); the record card follows the form. */
.np-step-of { display: none; }
@media (max-width: 40rem) {
  .np-steps li[aria-current="step"] .np-step-n { display: none; }
  .np-steps li[aria-current="step"] .np-step-of { display: inline; }
  .np-steps li[aria-current="step"] { display: block; }
  .np-steps li[aria-current="step"] b { display: inline; }
}
@media (max-width: 60rem) { .np-aside { order: 1; } }

/* R9 admin: a user row opens a read-only detail line. */
.ad-uopen { text-align: left; }
.ad-uopen::after { content: "\25BE"; margin-left: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); }
.ad-uopen[aria-expanded="true"]::after { content: "\25B4"; }
.ad-drow td { padding: var(--space-sm) var(--space-md) !important; background: var(--color-paper-3); }
.ad-ud { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-sm) var(--space-lg); margin: 0; }
.ad-ud > div { min-width: 0; }
.ad-ud dt { color: var(--color-muted); font-size: var(--text-xs); margin: 0 0 2px; }
.ad-ud dd { margin: 0; font-size: var(--text-sm); color: var(--color-ink); overflow-wrap: anywhere; }
.ad-ud .ad-ud-w { grid-column: 1 / -1; }
@media (max-width: 40rem) { .ad-cards tbody tr.ad-drow { display: block; padding: 0; } .ad-drow td { display: block; } }
.hm-login h1 .hm-nb { white-space: nowrap; }
.hm-login h1 { margin-bottom: var(--space-md); }
