:root {
  --bg: #0f1419;
  --panel: #171d26;
  --panel-2: #1f2733;
  --line: #2a3340;
  --text: #e7edf3;
  --muted: #93a1b1;
  --accent: #25a36f;       /* verde mensageria */
  --accent-2: #1d8a5d;
  --amber: #e0a82e;
  --red: #e0533d;
  --blue: #3b82f6;
  --radius: 12px;
}
* { box-sizing: border-box; }
/* o atributo HTML `hidden` deve sempre esconder, mesmo quando a classe define
   display:grid/flex (senao login-view/app-view/modal aparecem todos juntos) */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #18222e 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* brand */
.brand { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.brand.sm { font-size: 20px; }
.brand-z {
  display: inline-block; background: linear-gradient(135deg, var(--accent), #34c98a);
  color: #06231a; width: 1.25em; height: 1.25em; line-height: 1.25em; text-align: center;
  border-radius: 9px; margin-right: 4px; font-weight: 800;
}

/* card */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 32px 28px; }
.login-card .muted { margin: 4px 0 22px; }

/* fields */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5c6b7a; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,163,111,.22);
}
.pass { position: relative; display: block; }
.pass input { padding-right: 44px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; font-size: 16px; padding: 6px; opacity: .7;
}
.eye:hover { opacity: 1; }

/* buttons */
.btn {
  width: 100%; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer;
  color: #06231a; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0; border-radius: 10px; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--panel-2); filter: none; }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(224,83,61,.12); }
.btn.sm { width: auto; padding: 8px 14px; font-size: 14px; }
.btn.xs { width: auto; padding: 6px 11px; font-size: 13px; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 22px;
  border-bottom: 1px solid var(--line); background: rgba(15,20,25,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.container { max-width: 980px; margin: 0 auto; padding: 26px 22px 60px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 19px; }

/* grid de instancias */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.inst {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.inst-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inst-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.inst-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { text-align: center; padding: 50px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* badge de estado */
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.open   { background: rgba(37,163,111,.15); color: #45d196; }
.badge.qr     { background: rgba(224,168,46,.15); color: var(--amber); }
.badge.connecting { background: rgba(59,130,246,.15); color: #6ea8fe; }
.badge.close, .badge.not_found { background: rgba(147,161,177,.15); color: var(--muted); }
.badge.logged_out, .badge.error { background: rgba(224,83,61,.15); color: var(--red); }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(4,8,12,.62); display: grid; place-items: center;
  padding: 20px; z-index: 20;
}
.modal { width: 100%; max-width: 420px; padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.x { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.x:hover { color: var(--text); }
.qr-box { text-align: center; }
.qr-box img { width: 250px; height: 250px; background: #fff; border-radius: 10px; padding: 8px; }
.qr-hint { font-size: 13px; margin-top: 12px; }

.error {
  background: rgba(224,83,61,.12); border: 1px solid rgba(224,83,61,.4); color: #f0a596;
  padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px;
}
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 40;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .container { padding: 18px 14px 50px; }
}
