/* ------------------------------------------------------------------
   Painel de Servidores — tema meia-noite
   ------------------------------------------------------------------ */
:root {
  --bg:            #070b19;
  --bg-deep:       #050813;
  --panel:         rgba(255, 255, 255, .034);
  --panel-hover:   rgba(255, 255, 255, .055);
  --line:          rgba(255, 255, 255, .075);
  --line-strong:   rgba(255, 255, 255, .13);
  --text:          #dde2f0;
  --text-dim:      #9aa3bd;
  --muted:         #6b7490;
  --accent:        #d8c27f;
  --accent-soft:   rgba(216, 194, 127, .13);
  --accent-line:   rgba(216, 194, 127, .32);
  --ok:            #86b39a;
  --warn:          #cfa869;
  --danger:        #c07d7b;
  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 20px 50px -30px rgba(0, 0, 0, .95);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

input[type=checkbox] { accent-color: var(--accent); width: 13px; height: 13px; }

html { height: 100%; background: var(--bg-deep); }
body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 620px at 18% -8%, rgba(58, 76, 140, .30), transparent 62%),
    radial-gradient(900px 520px at 88% 4%, rgba(38, 58, 116, .24), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .01em;
}

/* ---------------- fumaça de fundo ---------------- */
.smoke { position: fixed; inset: -25%; z-index: -2; overflow: hidden; pointer-events: none; }
.smoke i {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(78px);
  background: radial-gradient(circle at 32% 30%, rgba(226, 233, 255, .85), rgba(190, 205, 255, .18) 55%, transparent 72%);
  opacity: .1;
  will-change: transform;
  animation: drift 68s ease-in-out infinite;
}
.smoke i:nth-child(1) { width: 46vw; height: 46vw; top: 6%;  left: 4%;  animation-duration: 74s; }
.smoke i:nth-child(2) { width: 38vw; height: 38vw; top: 46%; left: 58%; animation-duration: 92s; animation-delay: -20s; opacity: .085; }
.smoke i:nth-child(3) { width: 30vw; height: 30vw; top: 68%; left: 16%; animation-duration: 84s; animation-delay: -45s; opacity: .075; }
.smoke i:nth-child(4) { width: 34vw; height: 34vw; top: -6%; left: 66%; animation-duration: 100s; animation-delay: -60s; opacity: .09; }

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  25%  { transform: translate3d(6vw, -4vh, 0) scale(1.14); }
  50%  { transform: translate3d(-3vw, 6vh, 0) scale(.94); }
  75%  { transform: translate3d(-7vw, -3vh, 0) scale(1.08); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .03;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (prefers-reduced-motion: reduce) {
  .smoke i { animation: none; }
}

/* ---------------- tipografia ---------------- */
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
a { color: var(--accent); text-decoration: none; }

.eyebrow {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--muted); font-weight: 500;
}
.accent { color: var(--accent); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------------- login ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 372px; padding: 34px 32px 30px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.login-card .mark { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.login-card h1 { font-size: 17px; }
.login-card .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

label { display: block; font-size: 11.5px; color: var(--text-dim); margin: 0 0 6px; letter-spacing: .03em; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; padding: 10px 12px; color: var(--text);
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 13.5px;
  transition: border-color .18s, background .18s;
}
input:not([type="checkbox"]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-line); background: rgba(255, 255, 255, .055);
}
.field + .field { margin-top: 15px; }

/* ---------------- botões ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); cursor: pointer;
  background: rgba(255, 255, 255, .045); color: var(--text);
  border: 1px solid var(--line); font: inherit; font-size: 13px;
  transition: background .16s, border-color .16s, color .16s, transform .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn-primary:hover { background: rgba(216, 194, 127, .2); }
.btn-danger { color: var(--danger); border-color: rgba(192, 125, 123, .26); }
.btn-danger:hover { background: rgba(192, 125, 123, .12); border-color: rgba(192, 125, 123, .4); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-dim); padding: 7px 9px; }
.btn-ghost:hover { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn-full { width: 100%; padding: 11px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------------- layout ---------------- */
.app { display: none; min-height: 100vh; flex-direction: column; }
.app.show { display: flex; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 13px 26px; border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 25, .62); backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: 8px; }
.brand-name { font-size: 14px; letter-spacing: .05em; text-transform: uppercase; }
.brand-name b { font-weight: 500; color: var(--accent); }
.topbar .spacer { flex: 1; }

.hoststats { display: flex; gap: 20px; align-items: center; }
.hoststat { display: flex; flex-direction: column; gap: 2px; min-width: 74px; }
.hoststat .k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hoststat .v { font-size: 12.5px; font-family: var(--mono); color: var(--text-dim); }

.shell { flex: 1; display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0; }
.sidebar { border-right: 1px solid var(--line); padding: 22px 14px; }
.side-title { padding: 0 10px 10px; }
.srv-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; margin-bottom: 6px; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent; color: var(--text-dim);
  cursor: pointer; font: inherit; text-align: left; transition: background .16s, color .16s;
}
.srv-item:hover { background: var(--panel); color: var(--text); }
.srv-item.active { background: var(--panel); border-color: var(--line); color: var(--text); }
.srv-item .meta { font-size: 11px; color: var(--muted); }
.srv-item .nm { font-size: 13px; }

.main { padding: 26px 30px 60px; min-width: 0; }

/* ---------------- cartões ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(8px);
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2 { flex: 1; }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* cabeçalho do servidor */
.srv-head { display: flex; align-items: flex-start; gap: 22px; flex-wrap: wrap; }
.srv-head .title h1 { display: flex; align-items: center; gap: 12px; }
.srv-head .addr { margin-top: 7px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.srv-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 11.5px;
  border: 1px solid var(--line); color: var(--text-dim); background: rgba(255, 255, 255, .03);
  letter-spacing: .02em;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.pill.on   { color: var(--ok);     border-color: rgba(134, 179, 154, .3); }
.pill.on .dot   { background: var(--ok); box-shadow: 0 0 0 3px rgba(134, 179, 154, .13); animation: pulse 2.6s ease-in-out infinite; }
.pill.off  { color: var(--danger); border-color: rgba(192, 125, 123, .3); }
.pill.off .dot  { background: var(--danger); }
.pill.warn { color: var(--warn);   border-color: rgba(207, 168, 105, .3); }
.pill.warn .dot { background: var(--warn); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(134, 179, 154, .13); } 50% { box-shadow: 0 0 0 6px rgba(134, 179, 154, 0); } }

/* métricas */
.stat { display: flex; flex-direction: column; gap: 5px; }
.stat .k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 25px; font-weight: 300; letter-spacing: -.02em; color: var(--text); }
.stat .v small { font-size: 13px; color: var(--muted); margin-left: 3px; font-weight: 400; }
.stat .s { font-size: 11.5px; color: var(--muted); }

/* ---------------- abas ---------------- */
.tabs { display: flex; gap: 3px; margin: 22px 0 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  padding: 9px 14px; background: none; border: none; border-bottom: 1.5px solid transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: color .16s, border-color .16s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { width: 14px; height: 14px; }
.panel-view { display: none; }
.panel-view.show { display: block; }

/* ---------------- tabelas ---------------- */
/* Tabelas rolam dentro do próprio cartão em vez de esticar a página. */
#onlineTable, #histTable, #banTable, #bkList, #auList { overflow-x: auto; }
table { width: 100%; min-width: 460px; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); font-weight: 500; padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid rgba(255, 255, 255, .04); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }
td.right, th.right { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 30px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------------- gráficos ---------------- */
.chart-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.chart-head .k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.chart-head .now { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.chart { width: 100%; height: 132px; display: block; overflow: visible; }
.range { display: flex; gap: 2px; }
.range button {
  padding: 5px 11px; font: inherit; font-size: 11.5px; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 7px; color: var(--muted);
}
.range button:hover { color: var(--text); }
.range button.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

/* ---------------- console e logs ---------------- */
.console {
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.7;
  max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--text-dim);
}
.console::-webkit-scrollbar, .cfg-list::-webkit-scrollbar { width: 9px; }
.console::-webkit-scrollbar-thumb, .cfg-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 9px; }
.cmdbar { display: flex; gap: 8px; margin-top: 12px; }
.cmdbar input { font-family: var(--mono); }

/* ---------------- config ---------------- */
.cfg-search { max-width: 280px; }
.cfg-list { max-height: 560px; overflow: auto; }
.cfg-row { display: grid; grid-template-columns: minmax(0, 1fr) 230px auto; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.cfg-row .key { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.cfg-row input { padding: 7px 10px; font-size: 12.5px; font-family: var(--mono); }
.cfg-row.changed input { border-color: var(--accent-line); }

/* ---------------- toast e modal ---------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 9px; z-index: 90; }
.toast {
  padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13px; max-width: 370px;
  background: rgba(16, 22, 42, .95); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: rise .24s ease-out; backdrop-filter: blur(10px); display: flex; gap: 9px; align-items: flex-start;
}
.toast.ok  { border-color: rgba(134, 179, 154, .4); }
.toast.err { border-color: rgba(192, 125, 123, .45); }
.toast svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

.modal-bg {
  position: fixed; inset: 0; background: rgba(4, 7, 16, .74); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 80; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px; padding: 24px;
  background: #0c1224; border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow);
}
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

.error-msg { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 12px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); padding: 14px; }
  .main { padding: 20px 16px 50px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .hoststats { display: none; }
  .cfg-row { grid-template-columns: 1fr; }
}
