:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel2: #f8fafc; --line: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --primary: #2563eb; --primary-weak: #dbeafe; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --side: #0f172a; --side-text: #cbd5e1; --radius: 10px; --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --epico: #7c3aed; --historia: #0891b2; --task: #2563eb; --bug: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --panel: #111827; --panel2: #0f172a; --line: #1f2937; --text: #e5e7eb; --muted: #94a3b8;
    --primary: #3b82f6; --primary-weak: #1e3a5f; --side: #020617; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 800px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 14px; display: flex; gap: 8px; align-items: center; }
.brand i { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); display: inline-block; }
.side a { color: var(--side-text); padding: 7px 10px; border-radius: 7px; display: flex; gap: 8px; align-items: center; }
.side a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side a.on { background: rgba(59, 130, 246, .25); color: #fff; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 10px 4px; }
.side .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.side .eu { margin-top: auto; padding: 10px; font-size: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.main { padding: 20px 24px; min-width: 0; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .side { flex-direction: row; flex-wrap: wrap; } .side .sec, .side .eu { display: none; } .main { padding: 14px 16px; } }

/* componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--primary); }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; margin: 0; }
label.inline input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.tipo { color: #fff; border: 0; text-transform: uppercase; font-size: 10px; letter-spacing: .03em; }
.tipo.epico { background: var(--epico); } .tipo.historia { background: var(--historia); } .tipo.task { background: var(--task); } .tipo.bug { background: var(--bug); }
.pr-critica { color: var(--danger); border-color: var(--danger); } .pr-alta { color: var(--warn); border-color: var(--warn); }
.st-concluido { color: var(--ok); } .st-em_andamento { color: var(--primary); } .st-revisao { color: var(--warn); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.err { color: var(--danger); }

/* projetos */
.projs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.proj { border-top: 4px solid var(--c, var(--primary)); cursor: pointer; }
.proj:hover { border-color: var(--primary); }
.proj .k { font-size: 11px; font-weight: 700; color: var(--muted); }
.proj .n { font-size: 17px; font-weight: 700; margin: 2px 0 8px; }
.stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.stats b { display: block; color: var(--text); font-size: 16px; }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.col { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 300px; }
.col.over { outline: 2px dashed var(--primary); }
.col h3 { margin: 2px 4px 8px; display: flex; justify-content: space-between; font-size: 13px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.kcard[draggable="true"] { cursor: grab; }
.kcard.mine { border-left: 3px solid var(--primary); }
.kcard .t { margin: 4px 0 6px; font-weight: 500; }
.kcard .pai { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* backlog */
.tree .node { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tree .node:hover { background: var(--panel2); }
.tree .node .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .l1 { padding-left: 28px; } .tree .l2 { padding-left: 52px; } .tree .l3 { padding-left: 76px; }

/* chat refino */
.chat { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; }
@media (max-width: 1000px) { .chat { grid-template-columns: 1fr; } }
.msgs { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.msg { padding: 8px 12px; border-radius: 10px; max-width: 90%; white-space: pre-wrap; }
.msg.pessoa { background: var(--primary-weak); align-self: flex-end; }
.msg.ia { background: var(--panel2); border: 1px solid var(--line); }
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.doc { max-height: 70vh; overflow-y: auto; }
.md h1 { font-size: 18px; } .md h2 { font-size: 15px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.md h3 { font-size: 14px; } .md h4 { font-size: 13px; margin: 10px 0 4px; }
.md ul { padding-left: 20px; margin: 4px 0; } .md p { margin: 6px 0; }
.md blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--line); color: var(--muted); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: s 1s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }

/* modal / toast */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: grid; place-items: start center; padding: 40px 16px; overflow-y: auto; z-index: 10; }
.modal[hidden] { display: none; }
.modal .box { background: var(--panel); border-radius: 12px; width: min(860px, 100%); padding: 18px 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal .box.sm { width: min(480px, 100%); }
.modal .head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.err { background: var(--danger); }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login .card { width: min(360px, 100%); padding: 24px; }
.secret { background: var(--panel2); border: 1px dashed var(--warn); padding: 8px; border-radius: 8px; word-break: break-all; font-family: ui-monospace, monospace; }
.code-big { font-size: 26px; font-weight: 700; letter-spacing: .1em; font-family: ui-monospace, monospace; }
.row > select, .row > input:not([type=checkbox]) { width: auto; min-width: 160px; }
.kanban { grid-template-columns: repeat(4, minmax(200px, 1fr)); }
