@font-face { font-family: "Plex Sans"; src: url("fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/plex-sans-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --bg: #0a0c10; --canvas: #0d1015; --surface: #12161d; --surface-2: #171c25; --surface-3: #1f2630;
  --border: #212834; --border-strong: #2f3847;
  --text: #e9ecf1; --muted: #9aa4b4; --faint: #7a8596;
  --accent: #3570d0; --accent-strong: #5287e4; --accent-bg: rgba(53,112,208,.16); --accent-line: rgba(53,112,208,.5);
  --ok: #37b981; --ok-bg: rgba(55,185,129,.14); --warn: #e3a73c; --warn-bg: rgba(227,167,60,.14); --bad: #ee6159; --bad-bg: rgba(238,97,89,.14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 1px 1px rgba(0,0,0,.2); --shadow-md: 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 18px 40px rgba(0,0,0,.5);
  --mono: "Plex Mono", Consolas, monospace; --sans: "Plex Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
::selection { background: rgba(53,112,208,.4); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* botões */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); border-color: #3a4556; }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: #2b63c4; border-color: #2b63c4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* topo */
.topbar { display: flex; align-items: center; gap: 22px; height: 56px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; box-shadow: var(--shadow-sm); z-index: 10; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-tag { font-size: 11px; font-weight: 600; color: var(--accent-strong); background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 6px; padding: 1px 7px; letter-spacing: .02em; }
.head-stats { display: flex; gap: 18px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.head-stats b { color: var(--text); font-weight: 600; }
#btnUpdates { margin-left: auto; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.conn.bad .dot { background: var(--bad); }

/* estrutura: lista de máquinas + detalhe */
.shell { flex: 1; min-height: 0; display: flex; }
.sidebar { width: 300px; flex: none; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 15px 18px 10px; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; display: flex; align-items: center; gap: 8px; }
.side-count { background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 11px; letter-spacing: 0; }
.side-list { flex: 1; min-height: 0; overflow: auto; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.side-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: background .1s; }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-bg); border-color: var(--accent-line); }
.side-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.side-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.side-dot.off { background: var(--faint); }
.side-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-meta { color: var(--faint); font-size: 11.5px; margin-top: 1px; font-variant-numeric: tabular-nums; }
.side-mini { margin-left: auto; display: flex; gap: 5px; }
.dotnum { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dotnum i { width: 6px; height: 6px; border-radius: 50%; }
.dotnum.go i { background: var(--ok); } .dotnum.run i { background: var(--accent-strong); } .dotnum.err i { background: var(--bad); }

/* detalhe da máquina */
.detail { flex: 1; min-width: 0; overflow: auto; background: var(--canvas); }
.detail-pad { padding: 22px 26px 40px; max-width: 1100px; }
.detail-empty { display: grid; place-items: center; height: 100%; color: var(--faint); text-align: center; padding: 20px; }
.dh { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; row-gap: 12px; }
.dh-name { flex: 1 1 60%; }
.dh-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dh-name { font-size: 20px; font-weight: 600; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh-sub { color: var(--faint); font-size: 12.5px; margin-bottom: 20px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh-actions { flex: none; display: flex; gap: 8px; }

/* tabela de perfis — rola na horizontal se a janela ficar estreita (não quebra o layout) */
/* lista de perfis: grade (não tabela) — cada coluna tem largura própria e as ações nunca quebram linha.
   Em espaço estreito (container query) a linha vira blocos: nome+estado / script / ações. */
.plist-wrap { container-type: inline-size; }
/* as linhas usam SUBGRID: todas dividem as mesmas 4 colunas (cabeçalho incluso), então ficam alinhadas */
.plist { display: grid; grid-template-columns: minmax(0, 1fr) max-content minmax(150px, 240px) max-content; column-gap: 20px; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); background: var(--surface); overflow: hidden; }
.plist-head, .prow { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; padding: 0 18px; }
.plist-head { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding-top: 11px; padding-bottom: 11px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.plist-head .ph-acts { text-align: right; }
.prow { padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.prow:hover { background: var(--surface-2); }
.pc-name { min-width: 0; }
.pname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plog { font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.pc-state { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.pc-script { min-width: 0; }
.pc-script .scriptsel { width: 100%; max-width: none; text-overflow: ellipsis; }
.prow .pacts { flex-wrap: nowrap; justify-content: flex-end; }
.pacts-end { display: inline-flex; align-items: center; gap: 8px; }   /* "abrir junto" + lixeira andam juntos */
.prow .mini[data-act="start"], .prow .mini[data-act="stop"] { min-width: 84px; }
.prow .mini[data-act="run"], .prow .mini[data-act="stopScript"] { min-width: 64px; }
.mini.icon-only { width: 30px; padding: 0; display: inline-grid; place-items: center; }
.mini.icon-only .ic { width: 15px; height: 15px; }
@container (max-width: 820px) {
  .plist { display: block; }
  .plist-head { display: none; }
  .prow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name state" "script script" "acts acts"; column-gap: 14px; row-gap: 12px; }
  .pacts-end { margin-left: auto; }
  .pc-name { grid-area: name; } .pc-script { grid-area: script; }
  .pc-state { grid-area: state; flex-direction: row; }
  .prow .pacts { grid-area: acts; justify-content: flex-start; flex-wrap: wrap; }
}
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); } .badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); } .badge.accent { color: var(--accent-strong); background: var(--accent-bg); }
.pacts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mini { height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.mini:hover { background: var(--surface-3); } .mini:disabled { opacity: .4; cursor: not-allowed; }
.mini.go { color: var(--ok); border-color: rgba(55,185,129,.4); } .mini.go:hover { background: var(--ok-bg); }
.mini.danger { color: var(--bad); border-color: rgba(238,97,89,.4); } .mini.danger:hover { background: var(--bad-bg); }
.mini-check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.mini-check input { accent-color: var(--accent); width: 15px; height: 15px; }
.scriptsel { height: 30px; max-width: 210px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); padding: 0 8px; font: inherit; font-size: 12.5px; cursor: pointer; }
.scriptsel:focus { border-color: var(--accent-line); outline: 0; box-shadow: 0 0 0 3px var(--accent-bg); }

/* gaveta (biblioteca) */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 40; animation: slide .22s cubic-bezier(.16,1,.3,1); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-title { font-weight: 600; letter-spacing: -.01em; }
.drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.lib-name { font-weight: 500; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-acts { margin-left: auto; display: flex; gap: 6px; }
.lib-empty { color: var(--faint); font-size: 13px; padding: 10px 2px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(4,6,10,.66); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 22px; animation: fade .14s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; width: min(640px, 100%); max-height: calc(100vh - 44px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.16,1,.3,1); }
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea { height: 38px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); padding: 0 12px; outline: 0; font: inherit; }
.field textarea { height: auto; min-height: 260px; padding: 11px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-bg); }
.section-lbl { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; overflow: hidden; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* login */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 100; padding: 22px; }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow-md); text-align: center; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.login-brand .brand-mark { width: 26px; height: 26px; color: var(--accent); }
.login-box p { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }
.login-box input { width: 100%; height: 40px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); padding: 0 12px; outline: 0; margin-bottom: 12px; font-family: var(--mono); }
.login-box input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-bg); }
.btn-primary { width: 100%; height: 40px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font: inherit; font-weight: 500; cursor: pointer; }
.btn-primary:hover { background: #2b63c4; }
.login-err { color: var(--bad); font-size: 13px; margin-top: 12px; }

/* logs no painel central */
.loghub { height: min(56vh, 460px); overflow: auto; background: var(--canvas); font: 12.5px/1.6 var(--mono); font-variant-numeric: tabular-nums; padding: 10px 0; }
.loghub .ln { display: flex; gap: 12px; padding: 1px 16px; white-space: pre-wrap; word-break: break-word; }
.loghub .ln:hover { background: rgba(255,255,255,.025); }
.loghub .ln .t { color: var(--faint); flex: none; }
.loghub .ln.lv-warn .m { color: var(--warn); }
.loghub .ln.lv-error .m { color: var(--bad); }
.loghub .ln.lv-debug { opacity: .5; }
#logState { display: inline-flex; align-items: center; gap: 7px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-md); font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 820px) { .sidebar { width: 220px; } .head-stats { display: none; } }
/* janela estreita: máquinas viram uma faixa no topo; botões da barra só com ícone */
@media (max-width: 700px) {
  .topbar { gap: 10px; padding: 0 14px; }
  .btn-label, .conn-text { display: none; }
  #btnUpdates, #btnLibrary { padding: 0 10px; }
  .shell { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .side-head { padding: 10px 14px 6px; }
  .side-list { flex: none; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 10px 10px; }
  .side-item { flex: 0 0 auto; max-width: 260px; min-width: 0; }
  .detail-pad { padding: 18px 16px 32px; }
  .dh-actions { width: 100%; }   /* botões descem pra linha de baixo: o nome da máquina fica inteiro */
}
