:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0eff4;
  --border: #e3e2e8;
  --text: #191919;
  --text-2: #5f5f66;
  --grid: #ececf0;
  --accent: #3b2aa8;
  --accent-soft: #ebe8fb;
  --area-pessoal: #257de0;
  --area-profissional: #f47230;
  --area-relacionamentos: #00b894;
  --area-qualidade_vida: #f2a600;
  --nodata: #e4e4e9;
  --pos: #257de0;
  --neg: #ec4647;
  --neutral: #b8b8bf;
  --good: #0a7d2c;
  --warn: #a15c00;
  --bad: #c62828;
  --bubble-me: #ebe8fb;
  --on-accent: #ffffff;
  --bubble-them: #f0eff4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121214; --surface: #1b1b1f; --surface-2: #24242a; --border: #303036; --text: #efefef; --text-2: #a0a0a8;
    --grid: #2b2b31; --accent: #9887ef; --accent-soft: #2a2546;
    --area-pessoal: #338ced; --area-profissional: #e76624; --area-relacionamentos: #00a888; --area-qualidade_vida: #d28e05;
    --nodata: #33333a; --pos: #338ced; --neg: #eb6263; --neutral: #55555d;
    --good: #4cc36a; --warn: #e3a447; --bad: #ef6b6b; --bubble-me: #2a2546; --bubble-them: #24242a; --on-accent: #141414;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121214; --surface: #1b1b1f; --surface-2: #24242a; --border: #303036; --text: #efefef; --text-2: #a0a0a8;
  --grid: #2b2b31; --accent: #9887ef; --accent-soft: #2a2546;
  --area-pessoal: #338ced; --area-profissional: #e76624; --area-relacionamentos: #00a888; --area-qualidade_vida: #d28e05;
  --nodata: #33333a; --pos: #338ced; --neg: #eb6263; --neutral: #55555d;
  --good: #4cc36a; --warn: #e3a447; --bad: #ef6b6b; --bubble-me: #2a2546; --bubble-them: #24242a; --on-accent: #141414;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 15px; } h3 { font-size: 14px; }
.muted { color: var(--text-2); } .small { font-size: 12px; } .hidden { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.2px; }
.brand b { color: var(--accent); }
.brand em { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.status { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.pill.ok::before { background: var(--good); } .pill.bad::before { background: var(--bad); } .pill.warn::before { background: var(--warn); }
.theme { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 53px); }
.side { border-right: 1px solid var(--border); background: var(--surface); padding: 16px 12px; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 10px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.people li button {
  width: 100%; text-align: left; border: 0; background: transparent; color: inherit; font: inherit;
  padding: 10px; border-radius: 10px; cursor: pointer; display: grid; gap: 2px;
}
.people li button:hover { background: var(--surface-2); }
.people li button[aria-current="true"] { background: var(--accent-soft); }
.people .nm { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.people .sn { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; font-weight: 500; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }

main { padding: 20px; display: grid; gap: 16px; align-content: start; min-width: 0; }
#person { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.welcome p { margin: 8px 0 0; max-width: 680px; }
.who { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.who p { margin: 4px 0 0; }
.chips { display: grid; gap: 8px; align-content: start; }
.chips h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); font-weight: 600; }
.chips ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); }

.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; }
.tile .l { font-size: 12px; color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 240px; }
.chart-box.short { height: 150px; }
.chart-box.square { height: auto; aspect-ratio: 1; max-height: 360px; }
.roda-wrap { display: grid; grid-template-columns: 1fr 150px; gap: 12px; align-items: center; }
.legend { display: grid; gap: 8px; font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }

table.pillars { width: 100%; border-collapse: collapse; font-size: 13px; }
.pillars td { padding: 6px 4px; border-top: 1px solid var(--grid); vertical-align: top; }
.pillars tr:first-child td { border-top: 0; }
.pillars .sw { width: 10px; } .pillars .sw i { display: block; width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; }
.pillars .sc { font-weight: 650; white-space: nowrap; text-align: right; width: 84px; }
.pillars .ev { color: var(--text-2); font-size: 12px; }
.pillars .nd td { color: var(--text-2); }

.exps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.exps li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.exps .h { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.exps p { margin: 4px 0 6px; color: var(--text-2); font-size: 13px; }
.exps .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.sent { font-size: 12px; font-weight: 600; white-space: nowrap; }

.chat-card { display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 620px; padding-right: 4px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.them { align-self: flex-start; background: var(--bubble-them); border-top-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--bubble-me); border-top-right-radius: 4px; }
.msg .meta { display: flex; gap: 8px; justify-content: flex-end; font-size: 11px; color: var(--text-2); margin-top: 4px; }
.msg audio { display: block; width: 240px; max-width: 100%; height: 34px; margin-bottom: 4px; }
.msg .tr { font-style: italic; }
.msg .tr::before { content: "🎙 "; font-style: normal; }
.typing { align-self: flex-end; font-size: 12px; color: var(--text-2); padding: 6px 12px; }
.typing::after { content: "…"; animation: dots 1.2s infinite steps(4); }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.sim form { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; }
.sim input { font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.sim button { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 18px; background: var(--accent); color: var(--on-accent); cursor: pointer; }

.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 280px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 20px rgb(0 0 0 / .15); font-size: 12px;
}
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }

@media (max-width: 1100px) {
  .grid-2, .who { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .roda-wrap { grid-template-columns: 1fr; }
  .legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
  .sim form { grid-template-columns: 1fr; }
  .status { display: none; }
}

/* ---------- tarefas (kanban) ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s; }
.col.over { box-shadow: inset 0 0 0 2px var(--accent); }
.col-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); padding: 2px 4px; }
.col-head .n { font-weight: 600; background: var(--surface); border-radius: 99px; padding: 0 8px; color: var(--text); }
.col-head .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: grab; display: grid; gap: 6px; text-align: left; font: inherit; color: inherit; width: 100%; }
.task:hover { border-color: var(--accent); }
.task:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.task.dragging { opacity: .45; }
.task .t { font-weight: 600; }
.task .nt { font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--text-2); }
.tag.indicada { background: var(--accent-soft); color: var(--accent); }
.tag.assumida { background: color-mix(in srgb, var(--area-relacionamentos) 18%, transparent); color: var(--text); }
.col-empty { font-size: 12px; color: var(--text-2); text-align: center; padding: 14px 4px; border: 1px dashed var(--border); border-radius: 10px; }

.dlg { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
.dlg::backdrop { background: rgb(0 0 0 / .35); }
.dlg form { padding: 18px; display: grid; gap: 8px; }
.dlg p { margin: 0; }
.dlg-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.dlg .x { border: 0; background: transparent; color: var(--text-2); font-size: 22px; line-height: 1; cursor: pointer; }
.sub { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); font-weight: 650; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; display: grid; gap: 0; max-height: 260px; overflow: auto; }
.timeline li { position: relative; font-size: 13px; padding: 0 0 12px 18px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .w { font-size: 11px; color: var(--text-2); }
.td-edit { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; }
.td-edit select, .td-edit input { font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.td-edit button { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 8px 16px; background: var(--accent); color: var(--on-accent); cursor: pointer; }

/* ---------- memória ---------- */
.threads { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.threads button { width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; }
.threads button:hover { border-color: var(--accent); }
.threads button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.threads .h { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.threads .s { font-size: 13px; color: var(--text-2); }
.threads .nx { font-size: 12px; }
.st { font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 6px; white-space: nowrap; }
.st.aberto { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.st.resolvido { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.facts { display: grid; gap: 8px; }
.facts .cat { font-size: 11px; color: var(--text-2); text-transform: capitalize; margin-bottom: 2px; }
.facts ul { margin: 0; padding-left: 18px; font-size: 13px; }
.chat .divider { align-self: center; font-size: 11px; color: var(--text-2); background: var(--surface-2); padding: 2px 10px; border-radius: 99px; margin: 6px 0 2px; }
.exp-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.exp-wrap .exps { margin: 0; }
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exp-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .kanban { grid-template-columns: 1fr; }
  .td-edit { grid-template-columns: 1fr; }
}

/* ---------- entrada, perfis e configurações ---------- */
body[data-role="none"] > :not(#login) { display: none; }
body:not([data-role="admin"]) .admin-only { display: none !important; }
body[data-role="especialista"] .not-spec, body[data-role="cliente"] .side { display: none !important; }
body[data-role="cliente"] .layout { grid-template-columns: 1fr; }
body[data-role="especialista"] .grid-2.tall { grid-template-columns: 1fr; }
body:not([data-role="admin"]) .task { cursor: pointer; }
body:not([data-role="admin"]) .me-user { margin-left: auto; }
.me-user { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost { font: inherit; font-size: 13px; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.ghost:hover { border-color: var(--accent); }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 18px; background: var(--accent); color: var(--on-accent); cursor: pointer; justify-self: start; }
.err { color: var(--bad); margin: 0; } .err:empty { display: none; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); padding: 24px; display: grid; gap: 18px; }
.login-card h1 { margin-bottom: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin-bottom: 12px; }
.seg button { flex: 1; font: inherit; font-size: 13px; color: var(--text-2); background: transparent; border: 0; border-radius: 7px; padding: 7px 10px; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; }
.form label.check { display: flex; gap: 8px; align-items: baseline; }
.form input:not([type="checkbox"]), .form textarea, .row-form input, .row-form select, .act select {
  font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-width: 0; width: 100%;
}
.code { display: block; font: 600 24px/1.2 ui-monospace, monospace; padding: 14px; text-align: center; background: var(--accent-soft); border-radius: 10px; user-select: all; }
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.adm { padding: 18px; display: grid; gap: 10px; }
.adm form { padding: 0; }
.adm .form { gap: 12px; }
.adm .row-form { display: flex; gap: 8px; } .row-form > * { flex: 1; } .row-form .btn { flex: none; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.notice output { display: block; margin-top: 4px; font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.tbl { overflow-x: auto; margin-top: 8px; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 6px 8px 6px 0; white-space: nowrap; }
.tbl td { border-top: 1px solid var(--grid); padding: 8px 8px 8px 0; }
.tbl tr.off td { color: var(--text-2); }
.tbl .act { text-align: right; white-space: nowrap; padding-right: 0; } .tbl .act select { width: 170px; padding: 5px 8px; font-size: 13px; }
@media (max-width: 760px) {
  .adm .row-form { flex-direction: column; } .row-form .btn { align-self: start; }
  .me-user { display: none; } .top { flex-wrap: wrap; gap: 8px; padding: 10px 16px; } .brand { margin-right: auto; }
}
.qr { display: block; width: 100%; border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; }
.wa-alert { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 20px; background: var(--bad); color: #fff; font-weight: 600; }
.wa-alert .ghost { background: #fff; color: var(--bad); border-color: #fff; }
.alert-card { border: 1px solid var(--border); border-left: 5px solid var(--warn); border-radius: 10px; padding: 12px 14px; margin-top: 10px; display: grid; gap: 6px; }
.alert-card.alto { border-left-color: var(--bad); }
.alert-card.encerrado { opacity: .65; }
.alert-card .h { display: flex; justify-content: space-between; gap: 10px; }
.alert-card p { margin: 0; font-size: 13px; }
.alert-card .note { margin: 0; font-family: inherit; font-size: 12px; line-height: 1.5; white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.alert-card .row-form input { flex: 3; }
.alert-card .row-form .ghost { flex: none; }
