:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --panel-2: #eef1ee;
  --line: #dde3de;
  --text: #17201a;
  --muted: #5f6d63;
  --accent: #2f9e5b;
  --accent-ink: #ffffff;
  --accent-soft: #e2f4e9;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --err: #c53b3b;
  --err-soft: #fbe5e5;
  --info: #2f6fd6;
  --c1: #2f9e5b;
  --c2: #2f6fd6;
  --c3: #b7791f;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1411; --panel: #161d18; --panel-2: #1d261f; --line: #2a352d; --text: #e6ece7; --muted: #93a297;
    --accent: #45c07a; --accent-ink: #08130c; --accent-soft: #183224; --warn: #e0a43f; --warn-soft: #33281a;
    --err: #ef6a6a; --err-soft: #3a1d1d; --info: #6ea2ff; --c1: #45c07a; --c2: #6ea2ff; --c3: #e0a43f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1411; --panel: #161d18; --panel-2: #1d261f; --line: #2a352d; --text: #e6ece7; --muted: #93a297;
  --accent: #45c07a; --accent-ink: #08130c; --accent-soft: #183224; --warn: #e0a43f; --warn-soft: #33281a;
  --err: #ef6a6a; --err-soft: #3a1d1d; --info: #6ea2ff; --c1: #45c07a; --c2: #6ea2ff; --c3: #e0a43f; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 650; font-size: 15px; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
nav button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; width: 100%; box-sizing: border-box;
}
nav button svg { width: 18px; height: 18px; flex: none; }
nav button:hover { background: var(--panel-2); color: var(--text); }
nav button.active { background: var(--accent-soft); color: var(--text); }
nav button.active svg { color: var(--accent); }
nav button:focus-visible { outline: 2px solid var(--accent); }
.aside-foot { margin-top: auto; padding: 8px; font-size: 12px; color: var(--muted); }

main { min-width: 0; }
header.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; flex-wrap: wrap;
}
header.top h1 { font-size: 18px; margin-right: auto; }
.content { padding: 20px 24px 48px; max-width: 1240px; }
section.page { display: none; flex-direction: column; gap: 16px; }
section.page.active { display: flex; }

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin-right: auto; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.bar.warn > i { background: var(--warn); }
.bar.err > i { background: var(--err); }

.btn {
  font: inherit; font-weight: 550; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.danger.solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

input[type=text], input[type=number], input[type=password], input[type=time], select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
textarea { font-family: var(--mono); font-size: 13px; width: 100%; resize: vertical; }
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.field > :is(input, select) { color: var(--text); font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
label.check span small { display: block; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.online { background: var(--accent-soft); color: var(--accent); }
.pill.iniciando, .pill.parando { background: var(--warn-soft); color: var(--warn); }
.pill.iniciando::before, .pill.parando::before { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.banner { border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); }
.banner.err { background: var(--err-soft); }
.banner.info { background: var(--accent-soft); }
.banner p { flex: 1; min-width: 200px; }

.jobbar { display: none; align-items: center; gap: 12px; padding: 8px 24px; background: var(--accent-soft); font-size: 13px; }
.jobbar.on { display: flex; }
.jobbar .bar { flex: 1; max-width: 360px; margin: 0; background: var(--panel); }

/* setup */
.steps { display: grid; gap: 10px; counter-reset: s; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; padding: 12px; border-radius: 10px; background: var(--panel-2); }
.step .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--panel); border: 1px solid var(--line); }
.step.done .n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step h3 { font-size: 14px; margin-bottom: 4px; }
.step .row { margin-top: 8px; }

/* graficos */
.chart-wrap { position: relative; height: 150px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; white-space: nowrap; display: none; box-shadow: 0 4px 14px rgb(0 0 0 / .12); font-variant-numeric: tabular-nums; }

/* console */
.console {
  background: #0c100d; color: #d3dcd5; font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  border-radius: 10px; padding: 12px; height: calc(100vh - 290px); min-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.console .w { color: #f0c26a; }
.console .e { color: #ff8a8a; }
.console .c { color: #8ab4ff; }
.console .p { color: #6fdc9b; }
.console .j { color: #c9a6ff; }
.cmdline { display: flex; gap: 8px; margin-top: 10px; }
.cmdline input { flex: 1; font-family: var(--mono); }

/* listas / tabelas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; background: var(--panel-2); font-weight: 500; }
.chip img { width: 22px; height: 22px; border-radius: 5px; image-rendering: pixelated; }
.chip button { all: unset; cursor: pointer; color: var(--muted); padding: 0 4px; }
.chip button:hover { color: var(--err); }
.player { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.player img { width: 32px; height: 32px; border-radius: 6px; image-rendering: pixelated; }
.player .name { font-weight: 600; margin-right: auto; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.crumbs button { all: unset; cursor: pointer; color: var(--info); padding: 2px 4px; border-radius: 4px; }
.crumbs button:hover { background: var(--panel-2); }
.editor-area { height: calc(100vh - 300px); min-height: 300px; }

.address { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.address code { font-size: 17px; font-weight: 600; background: var(--panel-2); padding: 6px 12px; border-radius: 8px; user-select: all; }
ol.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.badge.gray { background: var(--panel-2); color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
nav button .count { margin-left: auto; background: var(--warn); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

/* desempenho (spark) */
.verdict { display: flex; gap: 16px; align-items: center; }
.verdict .dot { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 22px; font-weight: 700; color: #fff; }
.verdict h2 { font-size: 20px; margin: 0 0 4px; }
.verdict.bom .dot { background: var(--accent); } .verdict.medio .dot { background: var(--warn); } .verdict.ruim .dot { background: var(--err); } .verdict.nada .dot { background: var(--muted); }
.barras { display: flex; flex-direction: column; gap: 10px; }
.barra-l { display: grid; grid-template-columns: minmax(150px, 260px) 1fr 56px; gap: 10px; align-items: center; font-size: 13.5px; }
.barra-l .trilho { height: 12px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.barra-l .trilho i { display: block; height: 100%; background: var(--c1); border-radius: 6px; }
.barra-l .trilho i.plug { background: var(--c2); } .barra-l .trilho i.alto { background: var(--err); } .barra-l .trilho i.medio { background: var(--warn); }
.barra-l .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.barra-l small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.progresso { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; } .progresso i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
@media (max-width: 640px) { .barra-l { grid-template-columns: 1fr 48px; } .barra-l .trilho { grid-column: 1 / -1; grid-row: 2; } }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 560px; min-height: 120px; overflow: auto; padding: 4px 2px 8px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.voce { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.msg.claude { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg.erro { background: var(--err-soft); }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; } .msg ul { margin: 4px 0 6px; padding-left: 20px; }
.msg code { background: rgb(127 127 127 / .15); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.acao-c { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.acao-c b { font-size: 13.5px; }
.diff { font: 12px/1.45 ui-monospace, Consolas, monospace; background: var(--bg); border-radius: 8px; padding: 8px; max-height: 280px; overflow: auto; white-space: pre; margin: 0; }
.diff .add { color: var(--accent); } .diff .del { color: var(--err); }
.chat-prog { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; padding: 4px 2px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: gira 0.8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.chat-in { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; } .chat-in textarea { flex: 1; resize: vertical; min-height: 44px; }
#chSug { margin-top: 8px; } #chSug .chip { padding: 5px 12px; cursor: pointer; border: 1px solid var(--line); font-size: 13px; } #chSug .chip:hover { border-color: var(--accent); }

/* assistente */
.sug { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.sug h3 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sug .acao { font-size: 12.5px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.aghist { display: flex; flex-direction: column; max-height: 420px; overflow: auto; }
.aghist div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.aghist time { color: var(--muted); font-variant-numeric: tabular-nums; }
.aghist .ia b { color: var(--info); }
.aghist .erro b, .aghist .aviso b { color: var(--warn); }
ul.changes { margin: 0; padding-left: 18px; font-family: var(--mono); font-size: 12.5px; }

/* toast e modal */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .18); max-width: 420px; animation: in .2s; }
.toast.err { border-left-color: var(--err); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 20px; max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .row { justify-content: flex-end; margin-top: 16px; }

/* responsivo */
@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  aside { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand, .aside-foot { display: none; }
  nav { display: flex; gap: 4px; }
  nav button { width: auto; white-space: nowrap; }
  header.top { position: static; padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .jobbar { padding: 8px 16px; }
  .console { height: 60vh; }
}
