:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #14202e; --muted: #5d6b7c; --line: #dfe5ec;
  --navy: #0d2b45; --accent: #0f7c90; --accent-soft: #e2f3f6; --warn: #b7791f; --warn-soft: #fdf3e1;
  --bad: #b83232; --bad-soft: #fbe9e9; --good: #2f7d4a; --good-soft: #e6f4ea; --hot: #c2410c;
  --bubble-in: #ffffff; --bubble-bot: #dff3f6; --bubble-team: #e8eefc; --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b; --panel: #151d27; --ink: #e6edf3; --muted: #93a1b1; --line: #263241;
    --navy: #0a1b2b; --accent: #3bb3c6; --accent-soft: #123039; --warn: #e0a84a; --warn-soft: #33270f;
    --bad: #ef7d7d; --bad-soft: #3a1717; --good: #6ccb8d; --good-soft: #13301f; --hot: #f59e5b;
    --bubble-in: #1c2733; --bubble-bot: #12343b; --bubble-team: #1b2742; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
[x-cloak] { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
small, .muted { color: var(--muted); }
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; margin: 10px 0 4px; font-size: 13px; }
label .muted { font-weight: 400; }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: var(--navy); color: #cfe0ee; padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
nav.side .brand { color: #fff; font-weight: 700; font-size: 17px; padding: 0 8px 14px; }
nav.side .brand small { color: #8fb3cc; font-weight: 400; display: block; font-size: 11px; }
nav.side a { display: flex; justify-content: space-between; color: #cfe0ee; text-decoration: none; padding: 8px 10px; border-radius: 8px; }
nav.side a.on, nav.side a:hover { background: rgba(255,255,255,.1); color: #fff; }
.badge { background: var(--hot); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
main { padding: 20px 24px; min-width: 0; }

.topbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.topbar .spacer { flex: 1; }
.pill { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.good { background: var(--good-soft); color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card .n { font-size: 24px; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.click:hover td { background: var(--accent-soft); cursor: pointer; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.chat-layout { display: grid; grid-template-columns: 300px 1fr 330px; gap: 12px; height: calc(100vh - 110px); }
.list { overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list .item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item.on, .list .item:hover { background: var(--accent-soft); }
.list .item .row1 { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; }
.list .item .row2 { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.conv header { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.bubble { max-width: 75%; padding: 7px 10px; border-radius: 10px; word-wrap: break-word; border: 1px solid var(--line); }
.bubble .body { white-space: pre-wrap; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); }
.bubble.bot { align-self: flex-end; background: var(--bubble-bot); }
.bubble.team { align-self: flex-end; background: var(--bubble-team); }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bubble .info { font-size: 12px; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 6px; margin-top: 4px; }
.bubble img { max-width: 240px; border-radius: 6px; display: block; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 42px; height: 42px; }
.side-panel { overflow-y: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 300px; }
.col.drop { outline: 2px dashed var(--accent); }
.col h2 { display: flex; justify-content: space-between; font-size: 13px; }
.kcard { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; cursor: grab; font-size: 13px; }
.kcard .t { font-weight: 600; }
.temp-quente { color: var(--hot); } .temp-morno { color: var(--warn); } .temp-frio { color: var(--accent); }

.draft { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--panel); }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 50; max-width: 360px; }
.toast.err { background: var(--bad); }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: 260px; }
.steps li { margin-bottom: 6px; }
.steps li.done { color: var(--good); }
.login { max-width: 340px; margin: 12vh auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.chip button { border: 0; background: transparent; padding: 0 6px; color: inherit; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 10px; }
.sim .bubble { max-width: 90%; }
pre.json { background: var(--bg); padding: 8px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; }

@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 260px 1fr; height: auto; }
  .chat-layout .side-panel { grid-column: 1 / -1; }
  .msgs { max-height: 60vh; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; }
  nav.side .brand { width: 100%; padding-bottom: 6px; }
  main { padding: 14px 16px; }
  .grid2, .chat-layout { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}
