/* ===== Corus · Conexões WhatsApp — tokens ===== */
:root {
  --brand-1: #0A5BFF;
  --brand-2: #00C6F0;
  --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);

  --bg: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #EEF3FA;
  --rail: #0C1A2F;
  --rail-ink: #DCE6F5;
  --rail-muted: #7F93B0;

  --ink: #0E1A2B;
  --ink-2: #3E4F66;
  --muted: #6B7A90;
  --border: #DFE6F1;
  --border-2: #CBD6E6;
  --ring: rgba(10, 91, 255, .28);
  --shadow: 0 1px 2px rgba(14, 26, 43, .06), 0 8px 24px -12px rgba(14, 26, 43, .18);

  --ok: #16A34A;   --ok-bg: #E7F7EC;
  --warn: #D97706; --warn-bg: #FFF4E0;
  --bad: #DC2626;  --bad-bg: #FDECEC;

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1220; --surface: #121D30; --surface-2: #182640;
    --rail: #070E1A; --rail-ink: #DCE6F5; --rail-muted: #7F93B0;
    --ink: #EAF0F8; --ink-2: #B7C4D8; --muted: #8EA0B8;
    --border: #1E2C42; --border-2: #2A3B55; --ring: rgba(0, 198, 240, .32);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -12px rgba(0,0,0,.6);
    --ok-bg: rgba(22,163,74,.16); --warn-bg: rgba(217,119,6,.16); --bad-bg: rgba(220,38,38,.16);
    --ok: #4ADE80; --warn: #FBBF24; --bad: #F87171;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1220; --surface: #121D30; --surface-2: #182640;
  --rail: #070E1A; --rail-ink: #DCE6F5; --rail-muted: #7F93B0;
  --ink: #EAF0F8; --ink-2: #B7C4D8; --muted: #8EA0B8;
  --border: #1E2C42; --border-2: #2A3B55; --ring: rgba(0, 198, 240, .32);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -12px rgba(0,0,0,.6);
  --ok-bg: rgba(22,163,74,.16); --warn-bg: rgba(217,119,6,.16); --bad-bg: rgba(220,38,38,.16);
  --ok: #4ADE80; --warn: #FBBF24; --bad: #F87171;
}

/* ===== base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font-body); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; text-wrap: balance; margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
:focus-visible { outline: 2px solid var(--brand-1); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ===== botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: transform .06s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px -8px var(--brand-1); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--ghost { background: var(--surface); border-color: var(--border-2); color: var(--ink-2); }
.btn--ghost:hover { border-color: var(--brand-1); color: var(--ink); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { height: 34px; padding: 0 12px; font-size: 14px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: inherit;
}
.icon-btn:hover { background: var(--surface-2); }

/* ===== formulário ===== */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--brand-1); box-shadow: 0 0 0 4px var(--ring); }
.field__pw { position: relative; }
.field__pw input { padding-right: 44px; }
.field__eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.field__eye:hover { color: var(--ink); background: var(--surface-2); }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-bg); color: var(--bad); font-size: 14px; font-weight: 600; }
.form-error--bar { margin: 0 0 16px; }

/* ===== login ===== */
.login {
  min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg);
}
.login__art {
  position: relative; overflow: hidden; background: var(--rail);
  background-image: radial-gradient(1200px 600px at -10% 110%, rgba(0,198,240,.28), transparent 60%),
                    radial-gradient(900px 500px at 110% -10%, rgba(10,91,255,.35), transparent 60%);
}
.login__waves { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-45deg); width: 520px; height: 520px; }
.login__waves span {
  position: absolute; inset: 0; border-radius: 40px; border: 22px solid transparent;
  border-top-color: rgba(255,255,255,.12); border-right-color: rgba(255,255,255,.12);
  animation: pulse 4s ease-in-out infinite;
}
.login__waves span:nth-child(2) { inset: 90px; animation-delay: .5s; }
.login__waves span:nth-child(3) { inset: 180px; animation-delay: 1s; }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
.login__card {
  align-self: center; justify-self: center; width: min(420px, 100%); margin: 24px 16px;
  padding: 36px 32px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.login__logo { width: 132px; height: auto; margin: 0 auto 10px; }
.login__title { font-size: 24px; text-align: center; }
.login__lead { margin: 6px 0 24px; text-align: center; color: var(--muted); }
.login__foot { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
}

/* ===== app shell ===== */
.app { min-height: 100%; display: grid; grid-template-columns: 264px 1fr; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--rail); color: var(--rail-ink); padding: 22px 16px 16px;
}
.rail__brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.rail__brand img { width: 44px; height: 44px; border-radius: 10px; background: #fff; padding: 3px; }
.rail__name { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.rail__sub { font-size: 12px; color: var(--rail-muted); }
.rail__nav { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 18px 0; flex: 1; }
.rail__nav-label { margin: 14px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--rail-muted); opacity: .7; }
.rail__link {
  position: relative; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px;
  color: var(--rail-muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.rail__link:hover { background: rgba(255,255,255,.05); color: var(--rail-ink); }
.rail__link.is-active { background: rgba(255,255,255,.08); color: #fff; }
.rail__link.is-active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--brand-grad); }
.rail__link.is-active svg { color: var(--brand-2); }
.rail__link.is-soon { cursor: default; color: var(--rail-muted); opacity: .6; }
.rail__link.is-soon:hover { background: transparent; }
.rail__link em {
  margin-left: auto; padding: 3px 7px; border-radius: 999px;
  font: 700 9.5px/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase; font-style: normal;
  color: var(--brand-2); background: rgba(0,198,240,.12); border: 1px solid rgba(0,198,240,.22);
}
.rail__user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-grad); color: #fff; font-weight: 700; font-family: var(--font-display); flex: none; }
.rail__user-text { min-width: 0; flex: 1; }
.rail__user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail__user-company { font-size: 12px; color: var(--rail-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .icon-btn:hover { background: rgba(255,255,255,.1); }

.main { padding: 28px clamp(16px, 4vw, 40px) 48px; min-width: 0; }
.main__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.main__title { font-size: clamp(22px, 2.4vw, 28px); }
.main__actions { display: flex; align-items: center; gap: 12px; }
.last-check { font-size: 13px; color: var(--muted); }

/* ===== resumo ===== */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.summary__item {
  display: flex; align-items: baseline; gap: 10px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  border-left-width: 4px;
}
.summary__item--ok { border-left-color: var(--ok); }
.summary__item--warn { border-left-color: var(--warn); }
.summary__item--bad { border-left-color: var(--bad); }
.summary__n { font: 600 26px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.summary__l { font-size: 13px; color: var(--muted); }

/* ===== grade de instâncias ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
  position: relative;
}
.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card__title { font-size: 17px; }
.card__company { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; flex: none;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--connected { background: var(--ok-bg); color: var(--ok); }
.pill--connecting { background: var(--warn-bg); color: var(--warn); }
.pill--connecting::before { animation: blink 1s ease-in-out infinite; }
.pill--disconnected { background: var(--bad-bg); color: var(--bad); }
.pill--unknown { background: var(--surface-2); color: var(--muted); }
@keyframes blink { 50% { opacity: .2; } }

.card__who { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.card__pic { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--border); flex: none; }
.card__pic--empty { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.card__who-text { min-width: 0; }
.card__who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__who-phone { font-size: 13px; color: var(--muted); }
.card__hint { font-size: 13px; color: var(--muted); margin: 0; }
.card__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.card.is-loading::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--surface); opacity: .5; pointer-events: none;
}

/* ===== modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(6, 12, 24, .55); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative; width: min(680px, 100%); max-height: calc(100% - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 22px 24px;
}
.modal__panel--sm { width: min(440px, 100%); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal__title { font-size: 20px; }
.modal__text { color: var(--ink-2); margin: 10px 0 20px; }
.modal__btns { display: flex; justify-content: flex-end; gap: 10px; }
.modal__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

.qr { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.qr__frame {
  width: 296px; height: 296px; display: grid; place-items: center; padding: 16px;
  background: #fff; border-radius: var(--r-md); border: 1px solid var(--border-2);
}
.qr__frame img { width: 264px; height: 264px; image-rendering: pixelated; }
.qr__loading { display: flex; align-items: center; gap: 10px; color: #6B7A90; font-weight: 600; }
.qr__done { display: grid; place-items: center; gap: 8px; text-align: center; color: #0E1A2B; }
.qr__done img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.qr__done-check { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-bg); color: var(--ok); font-size: 28px; font-weight: 700; }
.qr__steps { margin: 0; padding-left: 20px; color: var(--ink-2); display: grid; gap: 10px; }
.qr__timer { font-size: 13px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #CBD6E6; border-top-color: var(--brand-1); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .qr { grid-template-columns: 1fr; justify-items: center; }
  .qr__frame { width: min(296px, 100%); height: auto; aspect-ratio: 1; }
}

/* ===== toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60; padding: 12px 16px; border-radius: var(--r-md); background: var(--rail); color: #fff;
  font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast--bad { background: var(--bad); }

/* ===== responsivo ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; }
  .rail__brand { padding: 0; border: 0; }
  .rail__nav { display: none; }
  .rail__user { margin-left: auto; border: 0; padding: 0; }
  .summary { grid-template-columns: 1fr; }
  .summary__item { padding: 10px 14px; }
}
