:root {
  --purple: #7c3aed; --purple-2: #8b5cf6; --orange: #f97316; --green: #16a34a; --red: #dc2626;
  --bg: #f5f3fb; --surface: #ffffff; --surface-2: #f0edf8; --text: #1b1530; --muted: #6b6580; --border: #e4dff0;
  --primary: var(--purple); --primary-soft: #ede9fe; --on-primary: #fff;
  --orange-soft: #ffedd5; --green-soft: #dcfce7; --red-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(40, 20, 90, .06), 0 4px 16px rgba(40, 20, 90, .06);
  --side: #0a0714; --side-text: #cfc8e6; --side-hover: #1a1230; --radius: 12px;
}
:root[data-theme='dark'] {
  --purple: #8b5cf6; --orange: #fb923c; --green: #4ade80; --red: #f87171;
  --bg: #0a0714; --surface: #130e22; --surface-2: #1b1530; --text: #f1eefb; --muted: #9a93b3; --border: #2a2142;
  --primary: #8b5cf6; --primary-soft: #2a1d52; --orange-soft: #3a2210; --green-soft: #12301f; --red-soft: #3b1618;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --side: #07040f; --side-hover: #170f2b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; border-right: 1px solid #1d1535; overflow-y: auto; }
.side .logo { display: block; width: 100%; padding: 4px 6px 14px; }
.side .logo img { width: 100%; display: block; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: linear-gradient(90deg, rgba(124, 58, 237, .38), rgba(124, 58, 237, .12)); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
.nav .badge { margin-left: auto; background: var(--orange); color: #1b1000; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side .grow { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid #1d1535; margin-top: 6px; }
.userbox b { display: block; color: #fff; font-size: 13px; }
.userbox small { color: #8f86ad; }
.userbox .icon-btn { margin-left: auto; color: var(--side-text); }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { font-size: 18px; }
.topbar .sp { flex: 1; }
.topbar .menu-btn { display: none; }
.content { flex: 1; overflow: auto; padding: 22px 24px 40px; }
.wpp-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding: 5px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); text-decoration: none; }
.wpp-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.wpp-dot.ok i { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }

/* ---------- componentes ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 9px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #1b1000; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; display: inline-flex; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
textarea.input { resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 .sp { flex: 1; }
.chip { --c: var(--primary); display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); white-space: nowrap; }
:root[data-theme='light'] .chip { color: color-mix(in srgb, var(--c) 78%, #000); }
.chip.green { --c: var(--green); } .chip.red { --c: var(--red); } .chip.orange { --c: var(--orange); } .chip.gray { --c: var(--muted); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }
.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--orange)); border-radius: 99px; transition: width .4s; }
.bar.green i { background: var(--green); }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .sp { flex: 1; }
.toolbar .input { width: auto; min-width: 150px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--k, var(--purple)); }
.kpi small { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.kpi b { display: block; font-size: 24px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.orange { --k: var(--orange); } .kpi.green { --k: var(--green); } .kpi.red { --k: var(--red); }
.cols { display: grid; gap: 16px; margin-bottom: 16px; }
.cols.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols.c21 { grid-template-columns: 2fr 1fr; }
.chart { position: relative; width: 100%; }
.list { display: flex; flex-direction: column; }
.list .li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list .li:last-child { border-bottom: 0; }
.list .li .grow { flex: 1; min-width: 0; }
.list .li .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.li, .clickable { cursor: pointer; }
.clickable:hover { background: var(--surface-2); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; border-top: 3px solid var(--c, var(--purple)); }
.col.over { outline: 2px dashed var(--primary); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col-h b { font-size: 13px; }
.col-h .n { background: var(--surface); border-radius: 99px; padding: 0 8px; font-size: 12px; font-weight: 700; }
.col-h small { margin-left: auto; font-weight: 600; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--primary); }
.kcard.dragging { opacity: .4; }
.kcard .t { font-weight: 700; }
.kcard .s { font-size: 12.5px; color: var(--muted); }
.kcard .f { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.kcard .val { font-weight: 700; color: var(--text); margin-left: auto; font-variant-numeric: tabular-nums; }
.dot-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

/* ---------- operação ---------- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.pcard:hover { border-color: var(--primary); }
.pcard h3 { font-size: 15px; }
.pcard .meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.warn { color: var(--red); font-weight: 600; }
.okc { color: var(--green); font-weight: 600; }
.stepper { display: flex; gap: 0; overflow-x: auto; padding: 4px 0 8px; }
.step { flex: 1; min-width: 150px; padding: 10px 12px; border: 1px solid var(--border); background: var(--surface); position: relative; cursor: pointer; }
.step:first-child { border-radius: 10px 0 0 10px; } .step:last-child { border-radius: 0 10px 10px 0; }
.step + .step { margin-left: -1px; }
.step .n { font-size: 11px; font-weight: 700; color: var(--muted); }
.step b { display: block; font-size: 13px; margin: 1px 0 4px; }
.step small { font-size: 11.5px; }
.step.andamento { background: var(--primary-soft); border-color: var(--primary); z-index: 1; }
.step.concluida { background: var(--green-soft); }
.step.concluida .n { color: var(--green); }
.step.atrasada { border-color: var(--red); background: var(--red-soft); }
.tasks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; }
.task:hover { border-color: var(--primary); }
.task .t { font-weight: 600; }
.task .f { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.feed .item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.feed .item:last-child { border-bottom: 0; }
.feed p { margin: 2px 0 0; white-space: pre-wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); font-weight: 600; }
.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); } 100% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); } }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - 140px); min-height: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list .top { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.chat-list .items { overflow-y: auto; flex: 1; }
.citem { display: flex; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border); align-items: center; }
.citem:hover { background: var(--surface-2); }
.citem.on { background: var(--primary-soft); }
.citem .grow { flex: 1; min-width: 0; }
.citem .t { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.citem .t small { font-weight: 500; white-space: nowrap; }
.citem .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.citem .un { background: var(--orange); color: #1b1000; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-h { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.chat-h .grow { flex: 1; min-width: 0; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--primary) 8%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.bubble { max-width: min(70%, 520px); padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); align-self: flex-start; white-space: pre-wrap; word-break: break-word; }
.bubble.out { align-self: flex-end; background: var(--primary); border-color: var(--primary); color: #fff; }
.bubble .meta { display: block; font-size: 10.5px; opacity: .7; text-align: right; margin-top: 2px; }
.bubble .media { font-style: italic; opacity: .8; }
.dayhd { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 2px 12px; margin: 8px 0; }
.composer { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.composer .r { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 140px; resize: none; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--orange-soft); color: var(--text); border: 1px solid var(--orange); margin-bottom: 14px; }
.back-btn { display: none; }

/* ---------- reuniões ---------- */
.day-group h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.day-group h4.hoje { color: var(--orange); }
.meet { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; margin-bottom: 8px; }
.meet .hr { font-weight: 700; min-width: 54px; font-variant-numeric: tabular-nums; }
.meet .grow { flex: 1; min-width: 0; }

/* ---------- config / qr ---------- */
.qr { width: 260px; height: 260px; background: #fff; border-radius: 14px; padding: 10px; display: grid; place-items: center; border: 1px solid var(--border); }
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.status-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.status-pill.ok i { background: var(--green); } .status-pill.wait i { background: var(--orange); }
.swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--border); }
input[type=color] { padding: 2px; height: 38px; width: 60px; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 4, 20, .6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.modal.wide { width: min(860px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-b { padding: 18px; overflow-y: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 340px; cursor: pointer; }
.toast.err { border-left-color: var(--red); } .toast.info { border-left-color: var(--purple); } .toast.msg { border-left-color: var(--orange); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(900px 500px at 20% 10%, rgba(124, 58, 237, .45), transparent 60%), radial-gradient(700px 500px at 90% 100%, rgba(249, 115, 22, .28), transparent 60%), #05030c; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; gap: 26px; color: #fff; text-align: center; }
.login-art img { width: min(460px, 86%); mix-blend-mode: screen; }
.login-art p { max-width: 380px; color: #b9b0d6; margin: 0; font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 30px; background: var(--bg); position: relative; }
.login-form form { width: min(380px, 100%); }
.login-form h2 { font-size: 24px; margin-bottom: 4px; }
.login-form .theme { position: absolute; top: 16px; right: 16px; }
.err-msg { color: var(--red); background: var(--red-soft); padding: 9px 12px; border-radius: 9px; margin-bottom: 12px; font-size: 13px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) { .cols.c3 { grid-template-columns: 1fr 1fr; } .cols.c21 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-105%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 14px; } .content { padding: 16px 14px 40px; }
  .cols.c2, .cols.c3 { grid-template-columns: 1fr; }
  .tasks { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; } .login-art { padding: 26px 20px; gap: 12px; } .login-art p { display: none; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 120px); }
  .chat.open .chat-list { display: none; } .chat:not(.open) .chat-main { display: none; }
  .back-btn { display: inline-flex; }
  .grid2 { grid-template-columns: 1fr; }
  .wpp-dot span { display: none; }
}
