/* ============================================================
   miravo · admin — mesma linguagem visual do app público
   ============================================================ */
@font-face { font-family: "Sora"; font-style: normal; font-weight: 300; font-display: swap; src: url("/assets/fonts/sora-300.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/sora-400.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/sora-600.woff2") format("woff2"); }

:root {
  --void: #000000;
  --elev: #0c0c11;
  --elev-2: #131319;
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --ink: #f4f4f8;
  --ink-dim: #9b9ba7;
  --ink-faint: #56565f;
  --violet: #6d5ef7;
  --violet-lift: #8577ff;
  --violet-glow: rgba(109, 94, 247, 0.45);
  --cyan: #22e6f0;
  --ok: #30c07a;
  --warn: #e0a53c;
  --danger: #f0575c;
  --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
  --pad: clamp(14px, 4vw, 24px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font: "Sora", var(--sys);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { max-width: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--void); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
::selection { background: var(--violet); color: #fff; }

.brand { font-size: 1rem; letter-spacing: 0.22em; text-transform: lowercase; font-weight: 300; }
.brand span { color: var(--violet-lift); }

/* ---------- botões / inputs (iguais ao público) ---------- */
.btn {
  position: relative; appearance: none; border: 1px solid transparent; border-radius: var(--r-md);
  padding: 13px 20px; font-size: 0.98rem; font-weight: 600; color: #fff; cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--violet-lift); outline-offset: 2px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--violet); box-shadow: 0 8px 26px -8px var(--violet-glow); }
.btn--primary:hover { background: var(--violet-lift); }
.btn--ghost { background: transparent; border-color: var(--hairline-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink-dim); background: rgba(255, 255, 255, 0.03); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy .btn__label { opacity: 0; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.input {
  width: 100%; background: var(--elev); color: var(--ink); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 13px 15px; font-size: 1.02rem; outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-glow); }
.input--code { text-align: center; font-size: 1.7rem; letter-spacing: 0.5em; text-indent: 0.5em; font-weight: 600; }
.input--sm { padding: 10px 13px; font-size: 0.95rem; }

.linkbtn { background: none; border: 0; color: var(--ink-dim); font-size: 0.85rem; cursor: pointer; padding: 6px 2px; transition: color 0.2s var(--ease); }
.linkbtn:hover:not(:disabled) { color: var(--violet-lift); }
.linkbtn:disabled { color: var(--ink-faint); cursor: default; }
.hint { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-faint); min-height: 1.2em; }
.hint.is-error { color: var(--danger); }
.field__label { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }

/* ---------- gate ---------- */
.gate { min-height: 100svh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 10vh var(--pad); }
.panel { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.gatecard { gap: 14px; }
.brand--gate { margin-bottom: 4px; }
.gate__lead { margin: 2px 0 4px; font-size: 0.9rem; line-height: 1.55; color: var(--ink-dim); }
.gate__lead b { color: var(--ink); font-weight: 500; }
.gate__step { display: flex; flex-direction: column; gap: 13px; }
.gate__links { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: max(12px, env(safe-area-inset-top)) var(--pad) 12px;
  background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.who { display: flex; align-items: center; gap: 10px; }
.who__email { font-size: 0.8rem; color: var(--ink-dim); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { background: transparent; border: 1px solid var(--hairline); color: var(--ink-dim); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem; transition: color 0.2s, border-color 0.2s, transform 0.3s; }
.iconbtn:hover { color: var(--ink); border-color: var(--ink-faint); }
.iconbtn.is-spin { transform: rotate(360deg); }

.tabs {
  position: sticky; top: 58px; z-index: 20; display: flex; gap: 4px; padding: 8px var(--pad);
  background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow-x: auto; border-bottom: 1px solid var(--hairline); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; background: transparent; border: 0; color: var(--ink-dim); padding: 8px 14px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap; transition: color 0.2s, background 0.2s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: #fff; background: var(--violet); }

.views { padding: var(--pad) var(--pad) calc(env(safe-area-inset-bottom) + 48px); max-width: 900px; margin: 0 auto; }
.vh { margin: 24px 0 12px; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.vh:first-child { margin-top: 4px; }
.vh__meta { color: var(--ink-faint); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; }

/* ---------- cards de saúde ---------- */
.cardgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { background: var(--elev); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 14px; min-width: 0; overflow: hidden; }
.card__label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__value { margin-top: 6px; font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card__value > :not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__sub { margin-top: 3px; font-size: 0.8rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.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--bad { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* ---------- stat tiles ---------- */
.statgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--elev); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 14px 12px; text-align: center; min-width: 0; overflow: hidden; }
.stat__num { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.stat__lbl { margin-top: 4px; font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.04em; }

/* ---------- listas (jobs / users / events / fila) ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--elev); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 13px 14px;
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease); color: inherit;
}
.row:hover { border-color: var(--hairline-strong); background: var(--elev-2); }
.row--static { cursor: default; }
.row--static:hover { border-color: var(--hairline); background: var(--elev); }
.row__main { flex: 1 1 auto; min-width: 0; }
.row__title { font-size: 0.95rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { margin-top: 3px; font-size: 0.78rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.row__time { font-size: 0.74rem; color: var(--ink-faint); white-space: nowrap; }

.badge { font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge--completed { color: var(--ok); border-color: rgba(48, 192, 122, 0.35); background: rgba(48, 192, 122, 0.08); }
.badge--failed { color: var(--danger); border-color: rgba(240, 87, 92, 0.35); background: rgba(240, 87, 92, 0.08); }
.badge--processing { color: var(--violet-lift); border-color: rgba(133, 119, 255, 0.4); background: rgba(109, 94, 247, 0.1); }
.badge--queued { color: var(--warn); border-color: rgba(224, 165, 60, 0.35); background: rgba(224, 165, 60, 0.08); }

.empty { color: var(--ink-faint); font-size: 0.9rem; text-align: center; padding: 28px 8px; }
.searchbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.searchbar .input { flex: 1; }

/* ---------- overlay / detalhe do job ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 720px) { .overlay { align-items: center; padding: 24px; } }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--elev);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px var(--pad) calc(env(safe-area-inset-bottom) + 24px);
  animation: sheetup 0.28s var(--ease);
}
@media (min-width: 720px) { .sheet { border-radius: var(--r-lg); } }
@keyframes sheetup { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; }
.sheet__close { background: transparent; border: 1px solid var(--hairline); color: var(--ink-dim); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; }
.sheet__close:hover { color: var(--ink); border-color: var(--ink-faint); }
.imgpair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.imgpair figure { margin: 0; }
.imgpair figcaption { font-size: 0.72rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.imgpair img { width: 100%; border-radius: var(--r-sm); border: 1px solid var(--hairline); background: #000; display: block; }
.kv { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--hairline); }
.kv__k { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); }
.kv__v { font-size: 0.92rem; color: var(--ink); word-break: break-word; }
.promptbox { background: var(--void); border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 11px 12px; font-size: 0.86rem; line-height: 1.5; color: var(--ink-dim); white-space: pre-wrap; word-break: break-word; margin-top: 6px; }
.promptbox--tech { color: var(--ink); border-color: rgba(109, 94, 247, 0.28); }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-dim); }
.danger-txt { color: var(--danger); }
.tiny { font-size: 0.78rem; }
.evdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; vertical-align: middle; flex: 0 0 auto; }
.ev--ok { background: var(--ok); box-shadow: 0 0 6px rgba(48, 192, 122, 0.5); }
.ev--bad { background: var(--danger); box-shadow: 0 0 6px rgba(240, 87, 92, 0.5); }
.ev--violet { background: var(--violet-lift); }
.ev--cyan { background: var(--cyan); }
.ev--dim { background: var(--ink-faint); }
.link { color: var(--violet-lift); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* auditoria de códigos */
.codes__note { font-size: 0.82rem; color: var(--ink-dim); line-height: 1.5; margin: 0 0 14px; }
.scopetag { font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--violet-lift); border: 1px solid rgba(133, 119, 255, 0.4); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
.codebtn { display: inline-flex; align-items: center; gap: 7px; background: var(--void); border: 1px solid var(--hairline-strong); color: var(--ink); font-family: inherit; font-variant-numeric: tabular-nums; font-size: 1.02rem; font-weight: 600; letter-spacing: 0.14em; padding: 6px 11px; border-radius: 9px; cursor: pointer; transition: border-color 0.15s var(--ease), color 0.15s var(--ease); -webkit-tap-highlight-color: transparent; }
.codebtn:hover { border-color: var(--violet); }
.codebtn:active { transform: scale(0.97); }
.codebtn.is-copied { border-color: var(--ok); color: var(--ok); }
.codebtn__ic { font-size: 0.85rem; opacity: 0.55; letter-spacing: 0; }

/* detalhe do usuário + detalhe do código */
.sheet__back { background: transparent; border: 0; color: var(--violet-lift); font-size: 0.92rem; cursor: pointer; padding: 4px 0; }
.sheet__back:hover { color: var(--violet); }
.sheet__utitle { font-size: 1.02rem; font-weight: 600; margin: 2px 0 4px; word-break: break-word; }
.sheet__sec { margin: 20px 0 8px; font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.minilist { display: flex; flex-direction: column; gap: 6px; }
.minirow { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: var(--void); border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; color: var(--ink); cursor: pointer; font-size: 0.85rem; transition: border-color 0.15s var(--ease); -webkit-tap-highlight-color: transparent; }
.minirow:hover { border-color: var(--hairline-strong); }
.minirow:active { transform: scale(0.995); }
.minirow__l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.minirow__r { flex: 0 0 auto; color: var(--ink-faint); white-space: nowrap; font-size: 0.78rem; }
.codechip { font-weight: 600; letter-spacing: 0.1em; color: var(--ink); }
.ok-txt { color: var(--ok); }
.codebig { display: flex; justify-content: center; margin: 8px 0 14px; }
.codebtn--lg { font-size: 1.7rem; letter-spacing: 0.26em; padding: 12px 22px; }

@media (min-width: 560px) { .cardgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .statgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }
