:root, [data-theme=dark] {
  --bg:#0a0a0d; --panel:#111115; --panel2:#17171d; --line:#24242d; --line2:#30303c;
  --text:#ececf2; --muted:#8e8e9d; --accent:#8b5cf6; --accent2:#a78bfa; --accent-bg:rgba(139,92,246,.14);
  --ok:#22c55e; --ok-bg:rgba(34,197,94,.13); --warn:#f59e0b; --warn-bg:rgba(245,158,11,.13);
  --bad:#ef4444; --bad-bg:rgba(239,68,68,.13); --info:#60a5fa; --info-bg:rgba(96,165,250,.13);
  --shadow:0 10px 30px rgba(0,0,0,.45);
}
[data-theme=light] {
  --bg:#f5f5f9; --panel:#ffffff; --panel2:#f0f0f6; --line:#e5e5ee; --line2:#d3d3e0;
  --text:#16161d; --muted:#6a6a7c; --accent:#7c3aed; --accent2:#6d28d9; --accent-bg:rgba(124,58,237,.1);
  --ok:#16a34a; --ok-bg:rgba(22,163,74,.1); --warn:#d97706; --warn-bg:rgba(217,119,6,.1);
  --bad:#dc2626; --bad-bg:rgba(220,38,38,.09); --info:#2563eb; --info-bg:rgba(37,99,235,.09);
  --shadow:0 10px 30px rgba(20,20,40,.12);
}
* { box-sizing:border-box; }
html { color-scheme:dark; } [data-theme=light] { color-scheme:light; }
body { margin:0; background:var(--bg); color:var(--text); font:14px/1.5 Inter, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing:antialiased; }
.hidden { display:none !important; }
h1 { font-size:24px; margin:0; letter-spacing:-.01em; } h2 { font-size:16px; margin:0 0 10px; } h3 { margin:0; font-size:15px; }
.muted { color:var(--muted); } .small { font-size:12px; } .mono { font-family:ui-monospace,Consolas,monospace; font-size:12px; }
.ic { flex:none; vertical-align:middle; }

/* ---------- layout ---------- */
#app { display:grid; grid-template-columns:240px 1fr; min-height:100vh; }
aside { background:var(--panel); border-right:1px solid var(--line); padding:16px 12px; display:flex; flex-direction:column; gap:6px; position:sticky; top:0; height:100vh; }
.shell { display:flex; flex-direction:column; min-width:0; }
.topbar { height:56px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; padding:0 28px; background:var(--bg); position:sticky; top:0; z-index:5; }
.crumb { color:var(--muted); display:flex; gap:8px; align-items:center; } .crumb b { color:var(--text); font-weight:500; }
.top-right { display:flex; gap:12px; align-items:center; }
main { padding:28px; max-width:1240px; width:100%; margin:0 auto; }

.brand { display:flex; gap:10px; align-items:center; padding:4px 8px 16px; }
.brand b { display:block; font-size:16px; letter-spacing:-.01em; } .brand span { display:block; font-size:9px; letter-spacing:.2em; color:var(--muted); }
.logo { width:34px; height:34px; border-radius:10px; display:grid; place-items:center; font-weight:800; color:#fff; background:linear-gradient(135deg,#8b5cf6,#5b21b6); box-shadow:0 4px 14px rgba(139,92,246,.45); }
.brand.big { padding:0 0 6px; } .brand.big .logo { width:42px; height:42px; }

nav { display:flex; flex-direction:column; gap:2px; flex:1; overflow:auto; }
.nav-group { font-size:10px; letter-spacing:.14em; text-transform:uppercase; color:var(--muted); padding:16px 12px 6px; }
nav button { display:flex; align-items:center; gap:10px; text-align:left; background:none; border:0; color:var(--muted); padding:9px 12px; border-radius:10px; font-weight:500; }
nav button:hover { background:var(--panel2); color:var(--text); border:0; }
nav button.active { background:var(--accent-bg); color:var(--accent2); }
.side-foot { display:flex; align-items:center; gap:10px; padding:12px 8px 2px; border-top:1px solid var(--line); }
.avatar { width:34px; height:34px; border-radius:50%; background:var(--accent-bg); color:var(--accent2); display:grid; place-items:center; font-weight:700; text-transform:uppercase; }
.who { flex:1; min-width:0; } .who b { display:block; font-size:13px; } .who span { font-size:11px; color:var(--muted); }

.engine { display:flex; align-items:center; gap:10px; padding:6px 12px; border:1px solid var(--line); border-radius:10px; background:var(--panel); }
.engine small { display:block; font-size:10px; color:var(--muted); line-height:1.1; } .engine b { font-size:12px; font-weight:600; }
.dot { width:8px; height:8px; border-radius:50%; background:var(--ok); flex:none; } .dot.live { animation:pulse 1.4s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(34,197,94,.6)} 100%{box-shadow:0 0 0 8px rgba(34,197,94,0)} }

/* ---------- page header ---------- */
.bar { display:flex; align-items:flex-end; gap:10px; margin-bottom:20px; flex-wrap:wrap; }
.bar .grow { flex:1; min-width:240px; } .bar .grow .muted { display:block; margin-top:2px; }
.toolbar { display:flex; gap:10px; margin-bottom:18px; flex-wrap:wrap; align-items:center; }
.search { position:relative; flex:1; min-width:220px; max-width:360px; } .search .ic { position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--muted); }
.search input { padding-left:34px; }

/* ---------- controls ---------- */
label { display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted); font-weight:500; }
input, select, textarea { background:var(--panel2); border:1px solid var(--line); color:var(--text); border-radius:10px; padding:9px 12px; font:inherit; width:100%; transition:border-color .15s, box-shadow .15s; }
textarea { min-height:130px; font-family:ui-monospace,Consolas,monospace; font-size:12px; resize:vertical; }
input:focus, select:focus, textarea:focus { outline:0; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-bg); }
button { font:inherit; font-weight:500; cursor:pointer; border-radius:10px; border:1px solid var(--line); background:var(--panel); color:var(--text); padding:8px 14px; display:inline-flex; align-items:center; gap:7px; transition:background .15s, border-color .15s, transform .05s; }
button:hover { background:var(--panel2); border-color:var(--line2); } button:active { transform:translateY(1px); }
button.primary { background:linear-gradient(180deg,#9d78fa,#7c4ff0); border-color:#8b5cf6; color:#fff; box-shadow:0 4px 14px rgba(139,92,246,.35); }
button.primary:hover { filter:brightness(1.08); border-color:#a78bfa; }
button.danger { color:var(--bad); } button.danger:hover { background:var(--bad-bg); border-color:var(--bad); }
button.good { color:var(--ok); } button.good:hover { background:var(--ok-bg); border-color:var(--ok); }
button.ghost { background:none; border-color:transparent; } button.ghost:hover { background:var(--panel2); }
button.sm { padding:5px 10px; font-size:12px; border-radius:8px; }
button.icon { padding:0; width:34px; height:34px; justify-content:center; } button.icon.sm { width:30px; height:30px; border-radius:8px; }
button:disabled { opacity:.5; cursor:not-allowed; }
.row { display:flex; gap:8px; flex-wrap:wrap; } .row.center { align-items:center; } .grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form { display:flex; flex-direction:column; gap:14px; }
.check { flex-direction:row; align-items:flex-start; gap:8px; color:var(--text); font-size:13px; font-weight:400; } .check input { width:auto; margin-top:3px; accent-color:var(--accent); }
.err { color:var(--bad); margin:0; min-height:1em; font-size:13px; }
.note { background:var(--panel2); border:1px solid var(--line); border-radius:12px; padding:12px 14px; font-size:13px; color:var(--muted); }
.note.warn { background:var(--warn-bg); border-color:transparent; color:var(--text); } .note.bad { background:var(--bad-bg); border-color:transparent; color:var(--text); } .note.ok { background:var(--ok-bg); border-color:transparent; color:var(--text); }

/* ---------- cards / tables / pills ---------- */
.card { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:20px; }
.table-wrap { background:var(--panel); border:1px solid var(--line); border-radius:16px; overflow:auto; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:12px 16px; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--muted); font-weight:600; font-size:11px; text-transform:uppercase; letter-spacing:.08em; background:var(--panel); white-space:nowrap; }
tbody tr:hover { background:var(--panel2); } tr:last-child td { border-bottom:0; }
td.empty { text-align:center; color:var(--muted); padding:40px; }
.pill, .badge { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:8px; font-size:12px; font-weight:600; background:var(--panel2); color:var(--muted); border:1px solid var(--line); white-space:nowrap; }
.badge.ok { background:var(--ok-bg); color:var(--ok); border-color:transparent; } .badge.warn { background:var(--warn-bg); color:var(--warn); border-color:transparent; }
.badge.bad { background:var(--bad-bg); color:var(--bad); border-color:transparent; } .badge.info { background:var(--info-bg); color:var(--info); border-color:transparent; }
.badge.acc { background:var(--accent-bg); color:var(--accent2); border-color:transparent; }
.badge i { width:6px; height:6px; border-radius:50%; background:currentColor; }
.phone-pill { display:inline-block; padding:3px 10px; border-radius:8px; font-size:12px; font-weight:600; background:var(--ok-bg); color:var(--ok); }
.inst-name { display:flex; gap:12px; align-items:center; } .inst-name b { display:block; max-width:300px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wa { width:36px; height:36px; border-radius:10px; background:var(--ok-bg); color:var(--ok); display:grid; place-items:center; position:relative; flex:none; }
.wa::after { content:""; position:absolute; right:-2px; bottom:-2px; width:10px; height:10px; border-radius:50%; background:var(--ok); border:2px solid var(--panel); }
.wa.off { background:var(--bad-bg); color:var(--bad); } .wa.off::after { background:var(--bad); }
.qual { display:inline-flex; align-items:flex-end; gap:2px; height:14px; margin-right:6px; vertical-align:middle; } .qual i { width:4px; border-radius:1px; background:var(--line2); } .qual i:nth-child(1){height:6px} .qual i:nth-child(2){height:10px} .qual i:nth-child(3){height:14px}
.qual.q3 i { background:var(--ok); } .qual.q2 i:nth-child(-n+2) { background:var(--warn); } .qual.q1 i:nth-child(1) { background:var(--bad); }
.actions { display:flex; gap:6px; justify-content:flex-end; }

/* ---------- stats (início) ---------- */
.stats { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
.stat { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:18px; }
.stat .top { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px; } .stat .chip { width:34px; height:34px; border-radius:10px; display:grid; place-items:center; background:var(--accent-bg); color:var(--accent2); }
.stat .chip.ok { background:var(--ok-bg); color:var(--ok); } .stat .chip.warn { background:var(--warn-bg); color:var(--warn); } .stat .chip.info { background:var(--info-bg); color:var(--info); }
.stat b { display:block; font-size:30px; margin:10px 0 2px; letter-spacing:-.02em; } .stat small { color:var(--muted); }
.section-title { display:flex; align-items:center; justify-content:space-between; margin:6px 0 14px; } .section-title h2 { margin:0; }
.hero { background:linear-gradient(120deg,rgba(139,92,246,.28),rgba(91,33,182,.08) 60%); border:1px solid var(--line); border-radius:18px; padding:26px 28px; margin-bottom:22px; display:flex; align-items:center; gap:20px; flex-wrap:wrap; }
.hero h1 { font-size:26px; } .hero p { margin:4px 0 0; color:var(--muted); } .hero .grow { flex:1; min-width:240px; }

/* ---------- operações (cards) ---------- */
.ops { display:grid; grid-template-columns:repeat(auto-fill,minmax(340px,1fr)); gap:16px; }
.op { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:18px; display:flex; flex-direction:column; gap:14px; transition:border-color .15s, transform .15s; }
.op:hover { border-color:var(--line2); transform:translateY(-1px); }
.op-head h3 { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-bottom:8px; }
.pills { display:flex; gap:6px; flex-wrap:wrap; }
.op-main { display:flex; align-items:center; gap:18px; }
.ring { width:76px; height:76px; flex:none; } .ring circle { fill:none; stroke-width:7; } .ring .ring-bg { stroke:var(--line); }
.ring .ring-ok { stroke:var(--ok); } .ring .ring-bad { stroke:var(--bad); } .ring text { fill:var(--text); font-size:14px; font-weight:700; }
.kv { flex:1; display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.kv > div { font-size:11px; color:var(--muted); display:flex; flex-direction:column; gap:2px; } .kv b { font-size:18px; color:var(--text); letter-spacing:-.01em; }
.d { display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--line2); margin-right:5px; } .d.ok { background:var(--ok); } .d.bad { background:var(--bad); }
.bar2 { height:6px; border-radius:6px; background:var(--line); display:flex; overflow:hidden; } .bar2 i { display:block; height:100%; } .bar2 .g { background:var(--ok); } .bar2 .r { background:var(--bad); }
.op-mid { display:flex; justify-content:space-between; align-items:center; font-size:12px; color:var(--muted); }
.op-mid a { color:var(--accent2); font-weight:600; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; gap:4px; }
.op-meta { display:flex; flex-wrap:wrap; gap:6px 14px; font-size:12px; color:var(--muted); border-top:1px solid var(--line); padding-top:12px; } .op-meta span { display:inline-flex; gap:5px; align-items:center; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.op-why { font-size:12px; color:var(--warn); background:var(--warn-bg); border-radius:8px; padding:6px 10px; }
.op-actions { display:flex; gap:6px; flex-wrap:wrap; }
.empty-state { grid-column:1/-1; text-align:center; color:var(--muted); padding:60px 20px; background:var(--panel); border:1px dashed var(--line2); border-radius:16px; }
.kpis { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.kpis > div { background:var(--panel2); border-radius:12px; padding:12px 14px; } .kpis small { color:var(--muted); display:block; } .kpis b { font-size:22px; }

/* ---------- dialog / toast / login ---------- */
dialog { background:var(--panel); color:var(--text); border:1px solid var(--line2); border-radius:18px; padding:26px; width:min(680px,94vw); max-height:90vh; box-shadow:var(--shadow); position:relative; }
dialog::backdrop { background:rgba(0,0,0,.65); backdrop-filter:blur(3px); }
.dlg-x { position:absolute; right:14px; top:14px; padding:0; width:30px; height:30px; justify-content:center; border-radius:8px; background:none; border-color:transparent; color:var(--muted); }
dialog h2 { font-size:18px; padding-right:30px; }
.toast { position:fixed; right:22px; bottom:22px; background:var(--panel); border:1px solid var(--line2); padding:12px 18px; border-radius:12px; max-width:440px; box-shadow:var(--shadow); z-index:50; border-left:3px solid var(--ok); }
.toast.bad { border-left-color:var(--bad); }
.login { min-height:100vh; display:grid; place-items:center; background:radial-gradient(900px 500px at 50% -10%, rgba(139,92,246,.22), transparent), var(--bg); }
.login-card { width:360px; display:flex; flex-direction:column; gap:14px; background:var(--panel); border:1px solid var(--line); border-radius:20px; padding:32px; box-shadow:var(--shadow); }
.login-card button { justify-content:center; padding:11px; }

.mb10{margin-bottom:10px}.mt8{margin-top:8px}.mt16{margin-top:16px}.center{align-items:center}.w260{width:260px}.maxw{max-width:680px}
@media (max-width:1000px){ #app{grid-template-columns:72px 1fr} .brand div:last-child,.nav-group,.who,nav button{font-size:0} nav button{justify-content:center;padding:12px} nav button .ic{margin:0} .stats{grid-template-columns:1fr 1fr} }

/* ---------- importação em etapas / foto / extras ---------- */
dialog.wide { width:min(900px,95vw); }
.stepper { display:flex; gap:22px; margin:6px 0 18px; } .stp { display:flex; align-items:center; gap:8px; color:var(--muted); font-weight:500; }
.stp i { width:24px; height:24px; border-radius:50%; display:grid; place-items:center; font-style:normal; font-size:12px; border:1px solid var(--line2); }
.stp.on { color:var(--text); font-weight:600; } .stp.on i { background:var(--accent); border-color:var(--accent); color:#fff; } .stp.done i { background:var(--ok-bg); border-color:var(--ok); color:var(--ok); }
.drop { display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; padding:44px 20px; border:2px dashed var(--line2); border-radius:16px; cursor:pointer; color:var(--muted); transition:.15s; }
.drop:hover, .drop.over { border-color:var(--accent); background:var(--accent-bg); color:var(--text); } .drop b { color:var(--text); }
.between { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:12px; flex-wrap:wrap; }
.map { max-height:46vh; } .map td { vertical-align:middle; } .map select { min-width:200px; }
.chips { display:flex; flex-direction:column; gap:4px; align-items:flex-start; } .chip-s { background:var(--panel2); border:1px solid var(--line); border-radius:8px; padding:2px 8px; font-size:12px; color:var(--muted); }
.foot { display:flex; justify-content:space-between; align-items:center; margin-top:18px; padding-top:16px; border-top:1px solid var(--line); }
button .ic[style] { }
.wa-img { width:100%; height:100%; object-fit:cover; border-radius:10px; }
.photo-row { display:flex; gap:18px; align-items:center; } .photo { width:96px; height:96px; border-radius:50%; background:var(--panel2); border:1px solid var(--line); display:grid; place-items:center; overflow:hidden; color:var(--muted); flex:none; }
.photo img { width:100%; height:100%; object-fit:cover; }
.op-sub { display:flex; gap:14px; flex-wrap:wrap; font-size:12px; color:var(--muted); margin-top:10px; } .op-sub b { color:var(--text); }
.d.info { background:var(--info); }

.phone-box { background:var(--panel2); border:1px solid var(--line); border-radius:14px; padding:14px 16px; }

.selbar { position:fixed; bottom:22px; left:240px; right:0; margin:0 auto; width:max-content; max-width:calc(100vw - 280px); background:var(--panel); border:1px solid var(--line2); border-radius:16px; padding:10px 14px; display:flex; gap:8px; align-items:center; justify-content:center; flex-wrap:wrap; box-shadow:var(--shadow); z-index:20; }
.selbar button { white-space:nowrap; }
.selbar .count { font-weight:700; margin-right:6px; color:var(--accent2); }
tr.sel-row { background:var(--accent-bg); }
