:root {
  --bg: #0d1117;
  --surface: #161b22;
  --line: #262c36;
  --ink: #e6edf3;
  --muted: #8b949e;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #da3633;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); font-size: 14px; }
button:not(:disabled), [role=tab], .chip, .switch, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
code { background: #21262d; padding: 1px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.5; margin: 6px 0 0; }
.err { color: var(--bad); min-height: 18px; margin: 4px 0 8px; font-size: 13px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand-lg { font-size: 20px; margin-bottom: 8px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px; border: 2px solid #fff; border-radius: 3px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }

/* layout */
.app { height: 100vh; display: grid; grid-template-rows: 56px 1fr; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-right { display: flex; align-items: center; gap: 12px; }
.grid { display: grid; grid-template-columns: 270px minmax(0, 1fr) 330px; min-height: 0; }
.col { background: var(--surface); padding: 20px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.col-left { border-right: 1px solid var(--line); }
.col-right { border-left: 1px solid var(--line); }

.h { font-size: 12.5px; font-weight: 650; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.h-sm { font-size: 11px; margin-bottom: 4px; }

/* lista de aparelhos */
.devlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.devlist li { border-bottom: 1px solid var(--line); }
.dev { width: 100%; text-align: left; background: none; border: 0; padding: 12px 8px; font: inherit; color: var(--ink); display: block; border-radius: 0; }
.dev:hover { background: #1c2128; }
.dev.is-on { background: #1c2533; }
.dev b { display: block; font-weight: 600; }
.dev span { font-size: 12px; color: var(--muted); }
.devlist .none { padding: 14px 8px; color: var(--muted); font-size: 13px; }
.locate-box { padding-top: 4px; }
.locate-box p { margin-top: 8px; }
.locate-box p.is-bad { color: var(--bad); }
.locate-box p a { color: #58a6ff; font-weight: 600; }
.adb-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.adb-box:first-of-type { margin-top: 20px; }
.col-right .adb-box:last-child { margin-top: auto; }

/* estados com ponto */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6e7681; margin-right: 6px; }
.pill, .state { display: inline-flex; align-items: center; font-size: 12.5px; color: var(--muted); }
.is-ok .dot { background: var(--ok); }
.is-warn .dot { background: var(--warn); }
.is-bad .dot { background: var(--bad); }
.state.is-ok { color: var(--ok); }
.state.is-warn { color: var(--warn); }

/* palco */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 16px 20px; gap: 12px; }
.stage-bar { display: flex; align-items: center; gap: 14px; }
.stage-bar .switch { margin-left: auto; }
.seg { display: inline-flex; background: #21262d; border-radius: 9px; padding: 3px; }
.seg-b { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; font: inherit; color: var(--muted); }
.seg-b.is-on { background: #30363d; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); font-weight: 600; }
.screen-wrap { flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
#screen { height: 100%; width: auto; max-width: 100%; max-height: 640px; object-fit: contain; background: #0b1220; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); touch-action: none; }
#screen.remote { cursor: crosshair; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; padding: 24px; background: var(--bg); color: var(--muted); }
.empty strong { color: var(--ink); font-size: 15px; }
.empty span { max-width: 360px; line-height: 1.5; }
.stage-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.textform { display: flex; gap: 8px; margin-left: auto; flex: 1; max-width: 420px; }

/* controles */
.btn { font: inherit; border: 1px solid var(--line); background: #21262d; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 550; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:hover:not(:disabled) { background: #2a313c; border-color: #3d444d; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: #388bfd; border-color: #388bfd; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #e5534b; border-color: #e5534b; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-block { width: 100%; margin-top: 8px; padding: 10px 14px; }
.input { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #0d1117; color: var(--ink); }
.input:focus { outline: 2px solid rgba(31, 111, 235, .45); border-color: var(--brand); }
.input::placeholder { color: #6e7681; }
textarea.input { resize: none; line-height: 1.45; }
.lbl { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 12.5px; }
.ov-head { display: flex; align-items: center; justify-content: space-between; }
.ov-head .h { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 16px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12.5px; color: var(--muted); }
.chip:hover { color: var(--ink); border-color: #3d444d; }

.switch { display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-t { width: 34px; height: 20px; border-radius: 999px; background: #30363d; position: relative; transition: background .15s; }
.switch-t::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #e6edf3; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .45); }
.switch input:checked + .switch-t { background: var(--brand); }
.switch input:checked + .switch-t::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-t { outline: 2px solid rgba(31, 111, 235, .45); outline-offset: 2px; }

.switch-row { margin-top: 16px; }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; }
.toast { background: #2d333b; color: #e6edf3; border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; max-width: 360px; font-size: 13px; line-height: 1.4; }
.toast.bad { background: var(--bad); border-color: var(--bad); color: #fff; }

@media (max-width: 1280px) {
  .grid { grid-template-columns: 250px minmax(0, 1fr) 300px; }
  .col { padding: 16px; }
}

@media (max-width: 1000px) {
  .app { height: auto; min-height: 100vh; }
  .grid { grid-template-columns: 1fr; }
  .col { overflow: visible; padding: 20px; }
  .col-left, .col-right { border: 0; border-top: 1px solid var(--line); }
  .stage { min-height: 70vh; }
  .tabs-head { margin: -20px -20px 16px; padding: 10px 12px; }
  .tabs-head .seg-b { padding: 6px 10px; font-size: 12.5px; }
}

.ripple { position: fixed; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%; border: 2px solid #3ddc84; background: rgba(61, 220, 132, .25); pointer-events: none; animation: ripple .5s ease-out forwards; z-index: 50; }
@keyframes ripple { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* abas do painel direito */
.tabs-head { margin: -20px -20px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tabs-head .seg { width: 100%; }
.tabs-head .seg-b { flex: 1; padding: 7px 12px; font-size: 13px; }
.tab-content { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; }

/* monitoramento */
.monitor-filters { display: flex; gap: 12px; margin: 12px 0 16px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.filter-check input { width: 16px; height: 16px; }
.monitor-list { flex: 1; min-height: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.empty-monitor { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 20px; color: var(--muted); }
.monitor-item { border-bottom: 1px solid var(--line); padding: 12px; }
.monitor-item:last-child { border-bottom: 0; }
.monitor-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.monitor-item-app { font-weight: 600; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.monitor-item-time { font-size: 11px; color: var(--muted); }
.monitor-item-text { font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.monitor-item-title { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.monitor-badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.monitor-badge-text { background: rgba(31, 111, 235, .15); color: #58a6ff; }
.monitor-badge-notif { background: rgba(218, 54, 51, .18); color: #f85149; }

/* modal de confirmacao */
.modal-backdrop { position: fixed; inset: 0; background: rgba(1, 4, 9, .7); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; opacity: 0; transition: opacity .15s ease; }
.modal-backdrop.show { opacity: 1; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 420px; width: 100%; padding: 24px; box-shadow: 0 24px 64px rgba(1, 4, 9, .6); transform: translateY(10px) scale(.98); transition: transform .15s ease; }
.modal-backdrop.show .modal-card { transform: translateY(0) scale(1); }
.modal-icon { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.modal-icon.danger { background: rgba(218, 54, 51, .16); color: #f85149; }
.modal-icon.brand { background: rgba(31, 111, 235, .16); color: #58a6ff; }
.modal-title { font-size: 17px; font-weight: 650; margin: 0 0 8px; color: var(--ink); }
.modal-text { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin: 0 0 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { padding: 9px 18px; }
