/* ESA CORE, tema escuro */
:root {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --border: #33332f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8a8981;
  --accent: #3987e5;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 10px;
}
.central-keep-row { background: rgba(250, 178, 25, .12); }
.central-keep-label { color: var(--warning); font-weight: 700; font-size: 12px; }
.central-keep-notice { border-left: 4px solid var(--warning); background: rgba(250, 178, 25, .09); margin-bottom: 14px; }
.central-keep-notice strong { color: var(--warning); }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface-1);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 18px 14px; }
.esa-logo { display: inline-flex; align-items: center; gap: 9px; }
.esa-logo svg { display: block; flex-shrink: 0; }
.esa-word { font-size: 19px; font-weight: 600; letter-spacing: .5px; color: var(--text-primary); }
.esa-word b { color: var(--accent); font-weight: 800; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.sidebar nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--text-secondary); font-weight: 500;
  display: flex; align-items: center; gap: 11px;
}
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.sidebar nav a.active { background: var(--surface-2); color: var(--text-primary); }
.sidebar nav a.active .nav-ic { color: var(--accent); }
.nav-ic { display: inline-flex; color: var(--text-muted); flex-shrink: 0; }
.nav-ic svg { width: 18px; height: 18px; display: block; }
.sidebar nav a:hover .nav-ic, .sidebar nav a.active .nav-ic { color: var(--accent); }
.sidebar-bottom { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--border); }
.sb-widgets { display: flex; gap: 8px; margin-bottom: 12px; }
.sb-wbtn { position: relative; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; }
.sb-wbtn:hover { border-color: var(--accent); color: var(--text-primary); }
.sb-wbtn svg { width: 19px; height: 19px; }
.whoami { color: var(--text-secondary); margin-bottom: 8px; }
.whoami small { color: var(--text-muted); }
.logout { color: var(--critical); font-weight: 600; }

.content { flex: 1; padding: 24px 30px; max-width: 1640px; margin: 0 auto; width: 100%; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; color: var(--text-secondary); }
/* prosa: largura de leitura confortável, sem colar na margem */
p.muted, p.lead { max-width: 82ch; }

/* dica ⓘ: explicação complexa aparece ao passar o mouse */
.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--text-muted);
  color: var(--text-muted); font-size: 10px; font-weight: 700; font-style: normal;
  cursor: help; position: relative; margin-left: 6px; vertical-align: middle; user-select: none;
}
.info::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: 145%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; width: max-content; max-width: 300px;
  font-size: 12px; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.info:hover::after, .info:focus::after { opacity: 1; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: block; color: inherit;
}
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 700; margin-top: 2px; }
.tile.good .value { color: var(--good); }
.tile.warning .value { color: var(--warning); }
.tile.serious .value { color: var(--serious); }
.tile.critical .value { color: var(--critical); }

/* tabelas */
.tablewrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* badges de status: cor + texto (nunca só cor) */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); }
.badge.on { color: var(--good); border-color: var(--good); }
.badge.off { color: var(--warning); border-color: var(--warning); }
.badge.off10 { color: var(--serious); border-color: var(--serious); }
.badge.off30 { color: var(--critical); border-color: var(--critical); }
.badge.nunca { color: var(--text-muted); }
.badge.bloqueada { color: var(--critical); border-color: var(--critical); }
.badge.liberada { color: var(--good); border-color: var(--good); }
.badge.inadimplente { color: var(--critical); border-color: var(--critical); }
.badge.adimplente { color: var(--good); border-color: var(--good); }
.badge.suspenso { color: var(--warning); border-color: var(--warning); }
.badge.teste { color: var(--accent); border-color: var(--accent); }

/* forms */
form.stack { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
input, select, textarea {
  background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

button, .btn {
  background: var(--accent); border: none; color: #fff; padding: 9px 16px; font: inherit;
  font-weight: 600; border-radius: 8px; cursor: pointer; display: inline-block; text-align: center;
}
button:hover, .btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn.danger { background: var(--critical); }
.btn.good { background: var(--good); }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--surface-0); }
.auth-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 34px; width: 380px; max-width: calc(100vw - 32px);
}
.auth-card h1 { text-align: center; }
.auth-card .brand { text-align: center; font-size: 26px; padding: 0 0 16px; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.alert.error { color: var(--critical); border-color: var(--critical); background: rgba(208,59,59,.08); }
.alert.ok { color: var(--good); border-color: var(--good); background: rgba(12,163,12,.08); }
.alert.info { color: var(--accent); border-color: var(--accent); background: rgba(57,135,229,.08); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.cards-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .cards-row { grid-template-columns: 1fr; } .grid2, .grid3 { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select { width: auto; }
.muted { color: var(--text-muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
#map { height: 480px; border-radius: var(--radius); border: 1px solid var(--border); }
.map-small { height: 260px; }

/* Monitoramento: lista + mapa, ocupando a altura da tela sem cortar */
.monitor { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: stretch; height: calc(100vh - 200px); min-height: 480px; }
.monitor #map { height: 100%; min-height: 480px; }
.monitor-list { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.monitor-list > input { margin: 10px; width: calc(100% - 20px); }
.devlist { overflow-y: auto; flex: 1; }
.devrow { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.devrow.haspos { cursor: pointer; }
.devrow.haspos:hover { background: var(--surface-2); }
.devrow.sel { background: rgba(57,135,229,.14); border-left: 3px solid var(--accent); }
.devinfo { flex: 1; min-width: 0; }
.devname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.devmeta { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nopos { color: var(--text-muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; background: var(--text-muted); }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.off { background: var(--warning); }
.dot.off10 { background: var(--serious); }
.dot.off30 { background: var(--critical); }
.dot.nunca { background: #555; }
@media (max-width: 820px) { .monitor { grid-template-columns: 1fr; height: auto; } .monitor #map { height: 380px; } .devlist { height: 320px; flex: none; } }
.mono { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 13px; }

/* console de comandos (estilo chat) na ficha do ativo */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto;
  padding: 12px; background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--radius); }
.chat .msg { max-width: 88%; padding: 7px 11px; border-radius: 13px; font-size: 13px; line-height: 1.4; word-break: break-word; }
.chat .out { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.chat .in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat .in.err { border-color: var(--critical); }
.chat .msg .meta { font-size: 10px; opacity: .75; margin-top: 4px; }
.chat .out .mono { color: #fff; }
.chat-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px; }

/* sino de avisos + chat da equipe (no rodapé da barra lateral) */
.tw-badge { position: absolute; top: -5px; right: -5px; background: var(--critical); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 9px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center; }
.tw-panel { position: fixed; left: 14px; bottom: 76px; width: 320px; max-height: 60vh; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55); display: none; flex-direction: column; z-index: 300; }
.tw-panel.open { display: flex; }
.tw-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.tw-alert { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tw-empty { padding: 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.tw-msgs { flex: 1; overflow-y: auto; max-height: 300px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tw-msg { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.tw-msg.mine { background: rgba(57,135,229,.14); border-color: var(--accent); }
.tw-msg-h { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; display: flex; justify-content: space-between; gap: 8px; }
.tw-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0; width: auto; line-height: 1; }
.tw-del:hover { color: var(--critical); }
.tw-send { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.tw-send input { flex: 1; width: auto; }
.tw-send button { padding: 6px 12px; }
.tw-chatpanel { width: 380px; max-height: 74vh; }
.tw-chatpanel .tw-msgs { max-height: 46vh; }
.tw-team { display: flex; flex-wrap: wrap; gap: 5px; padding: 9px 12px; border-bottom: 1px solid var(--border);
  max-height: 92px; overflow-y: auto; }
.tw-team-h { width: 100%; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin-bottom: 2px; }
.tw-chip { font-size: 11.5px; padding: 2px 9px; border-radius: 20px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-primary); white-space: nowrap; }
.tw-chip.adm { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tw-chip.me { background: rgba(57,135,229,.14); }
@media (max-width: 720px) { .tw-panel, .tw-chatpanel { width: calc(100vw - 40px); } }

/* modal (pop-up de ficha rápida) */
.modal-ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 400; padding: 20px; }
.modal-ov.open { display: flex; }
.modal-box { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; width: 470px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-h h3 { margin: 0; font-size: 17px; }
.modal-x { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; line-height: 1; padding: 0; width: auto; }
.modal-x:hover { color: var(--text-primary); }
.modal-b { padding: 14px 18px; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
