:root {
  --bg: #0d0f13; --panel: #161a21; --panel2: #1d222b; --line: #262c37;
  --fg: #e7eaf0; --dim: #9aa3b2; --accent: #6ea8fe; --accent2: #a78bfa;
  --ok: #4ade80; --warn: #fbbf24; --err: #f87171;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg); min-height: 100vh;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- topo */
header.top {
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .2px; color: var(--fg); }
.brand span { color: var(--accent2); }
nav.top { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.top a {
  padding: 6px 12px; border-radius: 8px; color: var(--dim); font-weight: 500;
}
nav.top a:hover { background: var(--panel2); color: var(--fg); text-decoration: none; }
nav.top a.on { background: var(--panel2); color: var(--fg); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; background: var(--panel2); border: 1px solid var(--line);
  font-size: 12px; color: var(--dim); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--err); }

/* -------------------------------------------------------------- layout */
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
main.wide { max-width: 1400px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.sub { color: var(--dim); margin: 0 0 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ controles */
label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 5px; }
input, textarea, select, button {
  font: inherit; color: var(--fg); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 110px; }
button, .btn {
  background: var(--accent); color: #0b1220; border: none; font-weight: 600;
  cursor: pointer; width: auto; padding: 9px 16px;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
button.ghost { background: var(--panel2); color: var(--fg); border: 1px solid var(--line); }
button.danger { background: var(--err); color: #2a0b0b; }
button.small { padding: 4px 10px; font-size: 13px; }
.checkline { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.checkline input { width: auto; }
.checkline label { margin: 0; color: var(--fg); font-size: 14px; }

.msg { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.msg.ok { background: #10331f; color: #b6f0cd; border: 1px solid #1d5c37; }
.msg.err { background: #3a1717; color: #ffc9c9; border: 1px solid #6b2727; }
.hint { font-size: 12.5px; color: var(--dim); margin-top: 5px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--dim); font-weight: 600; font-size: 12.5px;
     padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel2);
       border: 1px solid var(--line); color: var(--dim); }
.tag.ok { color: var(--ok); border-color: #1d5c37; }
.tag.warn { color: var(--warn); border-color: #5c4a1d; }
.tag.err { color: var(--err); border-color: #6b2727; }

/* ---------------------------------------------------------------- chat */
.chat-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
@media (max-width: 820px) { .chat-wrap { grid-template-columns: 1fr; } .convs { display: none; } }
.convs { max-height: 70vh; overflow-y: auto; }
.convs a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--dim);
           font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convs a:hover, .convs a.on { background: var(--panel2); color: var(--fg); text-decoration: none; }
#log { min-height: 45vh; max-height: 62vh; overflow-y: auto; padding-right: 6px; }
.turn { margin-bottom: 16px; }
.turn .who { font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.bubble { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
          padding: 11px 14px; white-space: pre-wrap; word-wrap: break-word; }
.turn.me .bubble { background: #1b2740; border-color: #2b3d63; }
.composer { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.composer textarea { min-height: 52px; max-height: 200px; }

/* -------------------------------------------------------------- imagens */
.bar { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden;
       border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0;
           background: linear-gradient(90deg, var(--accent), var(--accent2));
           transition: width .3s ease; }
.gal { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.gal figure { margin: 0; background: var(--panel); border: 1px solid var(--line);
              border-radius: var(--radius); overflow: hidden; }
.gal img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.gal figcaption { padding: 8px 10px; font-size: 12px; color: var(--dim);
                  max-height: 58px; overflow: hidden; }
dialog { border: 1px solid var(--line); background: var(--panel); color: var(--fg);
         border-radius: var(--radius); padding: 0; max-width: 92vw; max-height: 92vh; }
dialog::backdrop { background: rgba(0,0,0,.75); }
dialog img { max-width: 88vw; max-height: 80vh; display: block; }
dialog .cap { padding: 10px 14px; font-size: 13px; color: var(--dim); }

.center-box { max-width: 380px; margin: 8vh auto; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
      padding: 12px; overflow-x: auto; }
details summary { cursor: pointer; color: var(--dim); font-size: 14px; padding: 6px 0; }
