/* ═══════════════════════════════════════════════════════════════
   HERMES CONTROL — Mission Control / Industrial dark
   Design tokens
   ═══════════════════════════════════════════════════════════════ */
:root {
  /* superfícies — quase-preto azulado, com profundidade por camadas */
  --bg-0: #0a0c10;
  --bg-1: #0f131a;
  --bg-2: #151b24;
  --bg-3: #1d2530;
  --line: #232c39;
  --line-bright: #313d4e;

  /* texto */
  --tx-0: #e8edf4;
  --tx-1: #9aa7b8;
  --tx-2: #5e6b7d;

  /* acentos — verde-fósforo (status ok), âmbar (alerta), vermelho (erro) */
  --ok: #38e08a;
  --ok-dim: rgba(56, 224, 138, 0.12);
  --warn: #f5b13d;
  --warn-dim: rgba(245, 177, 61, 0.12);
  --err: #ff5466;
  --err-dim: rgba(255, 84, 102, 0.12);
  --accent: #4d9fff;
  --accent-dim: rgba(77, 159, 255, 0.12);

  --radius: 10px;
  --radius-sm: 6px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--tx-0);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* atmosfera: glow sutil no topo + grão */
  background-image:
    radial-gradient(1200px 600px at 70% -200px, rgba(77,159,255,0.08), transparent 60%),
    radial-gradient(900px 500px at 10% -100px, rgba(56,224,138,0.05), transparent 55%);
  background-attachment: fixed;
}

.hidden { display: none !important; }

/* ═══════ LOGIN ═══════ */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  overflow: hidden;
}
.login-grid {
  position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 70%);
  opacity: 0.4;
}
.login-box {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-bright);
  border-radius: 16px;
  padding: 48px 40px;
  width: min(92vw, 380px);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: rise 0.6s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
.brand-mark {
  font-size: 44px; color: var(--ok);
  text-shadow: 0 0 30px rgba(56,224,138,0.5);
  line-height: 1;
}
.brand-mark.sm { font-size: 22px; }
.login-box h1 {
  font-size: 26px; font-weight: 700; letter-spacing: 2px; margin: 14px 0 4px;
}
.login-box h1 span { color: var(--tx-2); font-weight: 400; }
.login-sub { color: var(--tx-1); font-size: 13px; margin-bottom: 28px; }
.login-box input {
  width: 100%; padding: 13px 16px; border-radius: var(--radius);
  background: var(--bg-0); border: 1px solid var(--line-bright);
  color: var(--tx-0); font-family: var(--mono); font-size: 14px;
  outline: none; transition: border-color .2s;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%; margin-top: 14px; padding: 13px;
  background: var(--ok); color: #04130b; border: none;
  border-radius: var(--radius); font-family: var(--sans);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s;
}
.login-box button:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(56,224,138,0.3); }
.login-err { color: var(--err); font-size: 12px; margin-top: 12px; min-height: 16px; }

/* ═══════ TOPBAR ═══════ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10,12,16,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.brand-name { font-weight: 500; letter-spacing: 1.5px; font-size: 15px; }
.brand-name b { color: var(--ok); }
.env-pill {
  font-family: var(--mono); font-size: 12px; color: var(--tx-1);
  background: var(--bg-2); padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--line);
}
.topbar-right { display: flex; gap: 10px; }
.ghost-btn {
  background: var(--bg-2); border: 1px solid var(--line-bright);
  color: var(--tx-1); padding: 8px 14px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.ghost-btn:hover { color: var(--tx-0); border-color: var(--accent); background: var(--accent-dim); }

/* ═══════ KPI STRIP ═══════ */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi {
  background: var(--bg-1); padding: 18px 22px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0;
  transition: opacity .3s;
}
.kpi:hover::after { opacity: 1; }
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--tx-2); margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--mono); font-size: 28px; font-weight: 700;
  color: var(--tx-0); line-height: 1;
}
.kpi-value.ok { color: var(--ok); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.err { color: var(--err); }
.kpi-sub { font-size: 11px; color: var(--tx-2); margin-top: 6px; }

/* ═══════ MAIN ═══════ */
.main { padding: 24px; max-width: 1500px; margin: 0 auto; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.panel-head h2 {
  font-size: 16px; font-weight: 600; letter-spacing: .5px;
  display: flex; align-items: center; gap: 10px;
}
.count {
  font-family: var(--mono); font-size: 12px; color: var(--ok);
  background: var(--ok-dim); padding: 2px 9px; border-radius: 20px;
}
.filter-tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: var(--radius-sm); }
.ft {
  background: transparent; border: none; color: var(--tx-2);
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px;
  cursor: pointer; font-family: var(--sans); transition: all .15s;
}
.ft:hover { color: var(--tx-0); }
.ft.active { background: var(--bg-3); color: var(--tx-0); }

/* ═══════ TENANT GRID ═══════ */
.tenant-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.tcard {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s, box-shadow .25s;
  position: relative; overflow: hidden;
  animation: cardin .4s var(--ease) backwards;
}
@keyframes cardin { from { opacity: 0; transform: translateY(12px); } }
.tcard:hover {
  transform: translateY(-3px); border-color: var(--line-bright);
  box-shadow: 0 14px 36px rgba(0,0,0,0.4);
}
.tcard-status-bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.tcard-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.tcard-name { font-size: 16px; font-weight: 600; }
.tcard-id { font-family: var(--mono); font-size: 11px; color: var(--tx-2); margin-top: 2px; }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 20px; font-weight: 600;
}
.badge.ok { background: var(--ok-dim); color: var(--ok); }
.badge.warn { background: var(--warn-dim); color: var(--warn); }
.badge.err { background: var(--err-dim); color: var(--err); }
.badge.neutral { background: var(--bg-3); color: var(--tx-1); }

.tcard-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.tmetric { text-align: center; padding: 10px 4px; background: var(--bg-0); border-radius: var(--radius-sm); }
.tmetric-val { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.tmetric-lbl { font-size: 10px; color: var(--tx-2); text-transform: uppercase; margin-top: 3px; }

.tcard-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12px;
}
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.err { background: var(--err); }
.dot.neutral { background: var(--tx-2); }
.wa-state { color: var(--tx-1); font-family: var(--mono); font-size: 11px; }
.pay-tag { font-family: var(--mono); font-size: 11px; }
.pay-tag.paid { color: var(--ok); }
.pay-tag.pending { color: var(--warn); }
.pay-tag.overdue { color: var(--err); }

/* ═══════ DRAWER ═══════ */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4,6,10,0.7); backdrop-filter: blur(3px);
  animation: fade .25s;
}
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: min(92vw, 620px);
  background: var(--bg-1); border-left: 1px solid var(--line-bright);
  overflow-y: auto;
  box-shadow: -30px 0 80px rgba(0,0,0,0.6);
  animation: slidein .35s var(--ease);
}
@keyframes slidein { from { transform: translateX(100%); } }
.drawer-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  padding: 22px 24px; display: flex; justify-content: space-between; align-items: flex-start;
}
.drawer-title h2 { font-size: 20px; font-weight: 700; }
.drawer-title .sub { font-family: var(--mono); font-size: 12px; color: var(--tx-2); margin-top: 4px; }
.close-x {
  background: var(--bg-3); border: 1px solid var(--line-bright); color: var(--tx-1);
  width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 18px; line-height: 1; transition: all .15s;
}
.close-x:hover { color: var(--err); border-color: var(--err); }
.drawer-body { padding: 24px; }

.dsection { margin-bottom: 26px; }
.dsection-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--tx-2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.dsection-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.tab-row { display: flex; gap: 4px; margin-bottom: 16px; background: var(--bg-2); padding: 4px; border-radius: var(--radius-sm); }
.dtab { flex: 1; background: transparent; border: none; color: var(--tx-2); padding: 9px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; font-family: var(--sans); transition: all .15s; }
.dtab.active { background: var(--bg-3); color: var(--tx-0); }
.dtab:hover { color: var(--tx-0); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-item { background: var(--bg-2); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.info-item .l { font-size: 10px; text-transform: uppercase; color: var(--tx-2); letter-spacing: .5px; }
.info-item .v { font-family: var(--mono); font-size: 14px; margin-top: 4px; color: var(--tx-0); word-break: break-all; }

/* health bar de containers */
.svc-list { display: flex; flex-wrap: wrap; gap: 8px; }
.svc {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px;
  font-family: var(--mono); font-size: 11px;
}

/* chat history */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 6px; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.bubble.inbound { align-self: flex-start; background: var(--bg-3); border-bottom-left-radius: 3px; }
.bubble.outbound { align-self: flex-end; background: var(--accent-dim); border: 1px solid rgba(77,159,255,0.25); border-bottom-right-radius: 3px; }
.bubble .meta { font-size: 10px; color: var(--tx-2); margin-top: 5px; font-family: var(--mono); }
.tag-int { font-size: 10px; color: var(--accent); }

/* config editor */
.cfg-file { margin-bottom: 16px; }
.cfg-file label { display: block; font-family: var(--mono); font-size: 12px; color: var(--tx-1); margin-bottom: 6px; }
.cfg-file textarea {
  width: 100%; min-height: 120px; resize: vertical;
  background: var(--bg-0); border: 1px solid var(--line-bright); border-radius: var(--radius-sm);
  color: var(--tx-0); font-family: var(--mono); font-size: 12.5px; line-height: 1.6; padding: 12px;
  outline: none; transition: border-color .2s;
}
.cfg-file textarea:focus { border-color: var(--accent); }

/* billing form */
.bform { display: grid; gap: 14px; }
.bform .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { font-size: 11px; color: var(--tx-2); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; background: var(--bg-0);
  border: 1px solid var(--line-bright); border-radius: var(--radius-sm);
  color: var(--tx-0); font-family: var(--mono); font-size: 13px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

/* action buttons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.act-btn {
  flex: 1; min-width: 120px; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-bright); background: var(--bg-2); color: var(--tx-0);
  font-family: var(--sans); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.act-btn:hover { transform: translateY(-2px); }
.act-btn.primary { background: var(--ok); color: #04130b; border-color: var(--ok); }
.act-btn.primary:hover { box-shadow: 0 8px 20px rgba(56,224,138,0.3); }
.act-btn.danger { color: var(--err); border-color: rgba(255,84,102,0.4); }
.act-btn.danger:hover { background: var(--err-dim); }
.act-btn.accent { background: var(--accent); color: #051321; border-color: var(--accent); }

.btn-save {
  width: 100%; margin-top: 8px; padding: 13px; background: var(--ok); color: #04130b;
  border: none; border-radius: var(--radius-sm); font-family: var(--sans);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s;
}
.btn-save:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(56,224,138,0.3); }

/* QR */
.qr-box { text-align: center; padding: 20px; background: var(--bg-0); border-radius: var(--radius); border: 1px solid var(--line); }
.qr-box img { width: 240px; height: 240px; border-radius: 8px; background: #fff; padding: 10px; }
.qr-box p { color: var(--tx-1); font-size: 13px; margin-top: 14px; }
.qr-box .pairing { font-family: var(--mono); font-size: 22px; letter-spacing: 4px; color: var(--ok); margin-top: 10px; }

/* empty / loading */
.empty { text-align: center; padding: 60px 20px; color: var(--tx-2); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-bright); border-top-color: var(--ok); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--bg-3); border: 1px solid var(--line-bright); color: var(--tx-0);
  padding: 13px 22px; border-radius: var(--radius); font-size: 14px; z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); transition: transform .35s var(--ease);
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }

@media (max-width: 640px) {
  .tenant-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
