/* Second Brain Dashboard — phần bổ sung cho bản thiết kế Openclaw Brain OS (cùng token, cùng hình học) */
[hidden] { display: none !important; }
body { background: var(--bg-void); }
code { font-family: var(--font-mono); font-size: .92em; color: var(--accent-ink); background: rgba(249,115,22,.08); border-radius: 4px; padding: 1px 5px; }
.muted { color: var(--text-low); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; }

/* ---------- đăng nhập ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(60% 60% at 50% 45%, rgba(56,189,248,.07), transparent 70%), radial-gradient(40% 35% at 50% 55%, rgba(167,139,250,.06), transparent 70%), var(--bg-space); }
.login-card { width: min(380px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px 24px; display: grid; gap: 14px; }
.lsub { margin: 0 0 4px; color: var(--text-mid); font-size: 13px; }
.login-card label { display: grid; gap: 6px; font-size: 12px; color: var(--text-mid); }
.login-card input { height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-1); padding: 0 12px; font-size: 14px; color: var(--text-hi); }
.login-card input:focus { border-color: rgba(249,115,22,.55); outline: none; box-shadow: 0 0 0 3px rgba(249,115,22,.12); }
.lerr { min-height: 18px; color: var(--bad-ink); font-size: 12.5px; }
.login-card .pbtn { height: 38px; }

/* ---------- top bar: menu tài khoản, badge rail ---------- */
.usermenu { position: absolute; right: 0; top: 40px; width: 240px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: none; z-index: 40; box-shadow: 0 18px 50px var(--shadow-c); }
.usermenu.on { display: grid; }
.usermenu a, .usermenu button { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--text-hi); text-decoration: none; font-size: 13px; text-align: left; }
.usermenu a:hover, .usermenu button:hover { background: var(--surface-2); }
.usermenu svg { width: 15px; height: 15px; color: var(--text-mid); }
.notifs .nempty { padding: 14px 12px; color: var(--text-mid); font-size: 12.5px; line-height: 1.5; }
#notifCount[hidden] { display: none !important; }

/* ---------- trang (thay canvas) ---------- */
.page { position: absolute; inset: 0; z-index: 12; overflow: auto; background:
  radial-gradient(50% 40% at 70% 0%, rgba(56,189,248,.045), transparent 70%), var(--bg-space); }
.pg { max-width: 1240px; margin: 0 auto; padding: 56px 28px 64px; }
.pg-loading { padding: 80px 28px; color: var(--text-low); font-size: 12px; text-align: center; }
.pg-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pg-head h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.pg-head p { margin: 0; color: var(--text-mid); font-size: 13.5px; line-height: 1.55; max-width: 760px; }
.pg-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.pg-acts .pbtn, .pcard .pbtn, .da .pbtn { padding: 0 12px; text-decoration: none; }
.pbtn:disabled { opacity: .45; cursor: not-allowed; }
.pg-grid { display: grid; gap: 16px; }
.pg-grid.two { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.pg-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.pg-grid > div { display: grid; gap: 16px; align-content: start; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px 16px; display: grid; gap: 4px; }
.kpi b { font-size: 24px; font-weight: 600; color: var(--text-hi); }
.kpi span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mid); }
.kpi em { font-style: normal; font-size: 12px; color: var(--text-low); }
.kpi.warn { border-color: rgba(251,191,36,.4); }
.kpi.warn b { color: var(--warn-ink); }

.pcard { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 16px; min-width: 0; }
.pcard > h2 { margin: 0 0 12px; }
.pempty { color: var(--text-mid); font-size: 13px; line-height: 1.6; padding: 18px 4px; text-align: center; }
.pempty svg { width: 22px; height: 22px; display: block; margin: 0 auto 8px; color: var(--text-low); }
.foot-note { display: flex; gap: 8px; align-items: flex-start; color: var(--text-mid); font-size: 12.5px; line-height: 1.55; margin: 14px 2px 0; }
.foot-note svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--text-low); }

.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--text-mid); white-space: nowrap; vertical-align: middle; }
.pill.ok { color: var(--ok-ink); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.pill.warn { color: var(--warn-ink); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.08); }
.pill.bad { color: var(--bad-ink); border-color: rgba(244,63,94,.4); background: rgba(244,63,94,.08); }
.pill.mute { color: var(--text-low); }

.ptable { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel); }
.ptable.flat { border: 0; background: none; border-radius: 0; margin: -4px -4px 0; }
.ptable table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ptable th { text-align: left; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-low); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.ptable td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); color: var(--text-mid); vertical-align: top; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable td b { color: var(--text-hi); font-weight: 500; }
.ptable .r { text-align: right; }
.ptable tr[data-goid] { cursor: pointer; }
.ptable tr[data-goid]:hover td { background: var(--surface-2); }
.rdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

.fchips, .ptabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.fchips button, .ptabs button { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--text-mid); display: inline-flex; align-items: center; gap: 6px; }
.fchips button[style]::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.fchips button.on, .ptabs button.on { border-color: rgba(249,115,22,.5); background: var(--accent-soft); color: var(--accent-ink); }
.ptabs .cnt { font-family: var(--font-mono); font-size: 10.5px; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 6px; }

/* Hỏi thử */
.probe { display: grid; gap: 10px; margin-bottom: 18px; }
.probe textarea { width: 100%; resize: vertical; min-height: 76px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-1); color: var(--text-hi); padding: 12px 14px; font: inherit; font-size: 14px; line-height: 1.5; }
.probe textarea:focus { outline: none; border-color: rgba(249,115,22,.55); box-shadow: 0 0 0 3px rgba(249,115,22,.1); }
.probe-row { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.probe-row .pbtn { padding: 0 16px; }
.seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font-size: 12.5px; padding: 0 14px; height: 32px; color: var(--text-mid); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }
.probe-meta { font-size: 11.5px; color: var(--text-low); margin: 0 2px 10px; }
.pg-grid.two > div > .pcard + .pcard, .pg-grid.two > div > .probe-meta + .pcard { margin-top: 0; }
.hit { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 10px 6px; border-radius: 8px; cursor: default; }
.hit[data-goid] { cursor: pointer; }
.hit[data-goid]:hover { background: var(--surface-2); }
.hit + .hit { border-top: 1px solid var(--line-soft); }
.hit .hn { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; color: var(--text-mid); }
.hit.src .hn { width: 8px; height: 8px; border-radius: 50%; margin: 6px 7px; }
.hit b { color: var(--text-hi); font-weight: 600; font-size: 13.5px; }
.hit p { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: var(--text-mid); }
.linkbtn svg { width: 14px; height: 14px; }
.raw { white-space: pre-wrap; font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6; color: var(--text-mid); background: var(--bg-void); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; max-height: 520px; overflow: auto; }
.qlist { display: grid; gap: 4px; }
.qlist button { text-align: left; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: var(--text-mid); line-height: 1.45; }
.qlist button:hover { background: var(--surface-2); color: var(--text-hi); }

/* feed + chip note */
.feed { display: grid; }
.fi { display: grid; grid-template-columns: 112px 120px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.fi:last-child { border-bottom: 0; }
.fi.bad .fk { color: var(--bad-ink); }
.fi .ft { color: var(--text-low); font-size: 11px; }
.fi .fk { color: var(--text-hi); display: inline-flex; gap: 6px; align-items: center; }
.fi .fk svg { width: 13px; height: 13px; color: var(--text-low); }
.fi .fq { color: var(--text-mid); min-width: 0; overflow-wrap: anywhere; }
.fi .fn { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.fi .fg { color: var(--text-low); font-size: 11px; white-space: nowrap; }
.nchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nchip { font-family: var(--font-mono); font-size: 11px; height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--link); background: rgba(56,189,248,.06); display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.nchip:hover { border-color: rgba(56,189,248,.45); }

/* Năng lực */
.tool { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 2px; }
.tool + .tool { border-top: 1px solid var(--line-soft); }
.tool .ti { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent-ink); background: var(--accent-soft); }
.tool .ti svg { width: 16px; height: 16px; }
.tool b { font-size: 13.5px; color: var(--text-hi); }
.tool p { margin: 4px 0 0; font-size: 13px; color: var(--text-mid); line-height: 1.55; }
.tool .ts { font-size: 11.5px; color: var(--text-low); white-space: nowrap; padding-top: 2px; }
.rules, .cmds { margin: 0; padding-left: 20px; color: var(--text-mid); font-size: 13px; line-height: 1.7; }
.rules b { color: var(--text-hi); font-weight: 600; }
.cmds { list-style: none; padding: 0; display: grid; gap: 8px; }

/* Việc */
.drafts, .fbl { display: grid; gap: 12px; }
.draft, .fb { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px 16px; }
.dh { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.dh b { color: var(--text-hi); font-size: 14px; font-weight: 600; }
.da { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.errs, .warns { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.errs { color: var(--bad-ink); }
.warns { color: var(--warn-ink); }
.fbn { margin: 6px 0; color: var(--text-hi); font-size: 14px; line-height: 1.55; }
.fb details { margin-top: 6px; font-size: 12.5px; color: var(--text-mid); }
.fb summary { cursor: pointer; color: var(--text-mid); }
.callout { border: 1px solid var(--line); background: var(--surface-1); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--text-mid); line-height: 1.55; margin: 0 0 14px; }
.callout.err { border-color: rgba(244,63,94,.4); background: rgba(244,63,94,.06); color: var(--bad-ink); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }

/* Kết nối */
.conn { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; }
.conn .ci { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--link); background: rgba(56,189,248,.07); }
.conn .ci svg { width: 18px; height: 18px; }
.conn b { color: var(--text-hi); font-size: 14px; font-weight: 600; margin-right: 6px; overflow-wrap: anywhere; }
.conn p { margin: 6px 0 10px; line-height: 1.5; }

/* Hệ thống */
.kv { display: grid; }
.kv > div { display: grid; grid-template-columns: minmax(120px, 42%) minmax(0, 1fr); gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.kv > div:last-child { border-bottom: 0; }
.kv span { color: var(--text-mid); }
.kv b { color: var(--text-hi); font-weight: 500; overflow-wrap: anywhere; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 58px; gap: 10px; align-items: center; font-size: 11.5px; }
.bar .bl { color: var(--text-low); }
.bar .bt { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); }
.bar .bt i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, rgba(167,139,250,.55), #A78BFA); }
.bar.over .bt i { background: linear-gradient(90deg, rgba(244,63,94,.55), #F43F5E); }
.bar .bt u { position: absolute; top: -3px; bottom: -3px; width: 1px; background: rgba(251,191,36,.7); }
.bar .bv { text-align: right; color: var(--text-mid); }

/* ---------- Inspector / Reader bổ sung ---------- */
.ins-type .pill { margin-left: 4px; }
.ins-body .tag.pd { color: #93C5FD; border-color: rgba(96,165,250,.35); }
.ins-body .tag.fa { color: #C4B5FD; border-color: rgba(167,139,250,.35); }
.ins-body .tag.ap { color: #67E8F9; border-color: rgba(34,211,238,.3); }
.ins-meta b { font-size: 15px; overflow-wrap: anywhere; }
.seclist { display: grid; gap: 2px; font-size: 12px; color: var(--text-mid); max-height: 340px; overflow: auto; }
.seclist > div { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.seclist .mono { color: var(--text-low); font-size: 11px; }
.reader .rb h2 { font-size: 18px; margin: 22px 0 8px; }
.reader .rb h3 { margin-top: 20px; }
.reader .rb h4 { font-size: 13px; margin: 16px 0 6px; color: var(--text-hi); }
.reader .rb ul, .reader .rb ol { padding-left: 22px; color: var(--text-mid); line-height: 1.7; }
.reader .rb li.sub { margin-left: 18px; list-style: circle; }
.reader .rb b { color: var(--text-hi); }
.reader .rb em { color: var(--text-hi); }
.mdt { overflow-x: auto; margin: 10px 0 14px; }
.mdt table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.mdt th, .mdt td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; color: var(--text-mid); }
.mdt th { color: var(--text-hi); background: var(--surface-2); font-weight: 600; }
.reader .q { border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.reader .q .qh { font-size: 11px; color: var(--text-low); }
.reader .q li.ok { color: var(--ok-ink); }
.reader .q .qn { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.wl { cursor: pointer; }

@media (max-width: 1023px) {
  .pg { padding: 52px 16px 56px; }
  .pg-grid.two, .pg-grid.three { grid-template-columns: minmax(0, 1fr); }
  .fi { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 639px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 20px; }
  .ptable th:nth-child(n+4), .ptable td:nth-child(n+4) { display: none; }
  .tool { grid-template-columns: 34px minmax(0, 1fr); }
  .tool .ts { grid-column: 2; }
}

/* ---------- sửa sau khi chụp kiểm tra ---------- */
.foot-note { display: block; position: relative; padding-left: 22px; }
.foot-note svg { position: absolute; left: 0; top: 1px; }
@media (max-width: 639px) {
  #keysBtn, .vaultsel .n { display: none; }
  .tb-right { gap: 6px; margin-left: auto; }
  .topbar { gap: 8px; padding: 0 12px; }
  .stage { padding-bottom: 0; }
  .hud { bottom: 74px; }
  .toast { bottom: 140px; }
  .page { bottom: 58px; }
  .sidebar { bottom: 58px; }
  .inspector { bottom: 58px; }
  .pg { padding: 48px 16px 40px; }
}

/* ---------- hộp xác nhận ---------- */
.modal { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(460px, 100%); background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; gap: 12px; box-shadow: 0 24px 70px var(--shadow-c); }
.modal-card h3 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; }
.modal-card p { margin: 0; color: var(--text-mid); font-size: 13.5px; line-height: 1.55; }
.modal-card textarea { width: 100%; resize: vertical; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-space); color: var(--text-hi); padding: 10px 12px; font: inherit; font-size: 13.5px; }
.modal-card textarea:focus { outline: none; border-color: rgba(249,115,22,.55); }
.modal-acts { display: flex; justify-content: flex-end; gap: 8px; }
.modal-acts .pbtn { padding: 0 16px; }
.fbact { margin-top: 10px; }
.ptable td .pbtn { height: 30px; padding: 0 10px; font-size: 12.5px; white-space: nowrap; }
