/* 1M Performance — terminal de fósforo verde.
   O mundo empresta tipo, paleta, densidade e um gesto: a chuva de dígitos
   que acelera enquanto a IA escreve, e o texto que se "decifra" ao chegar. */

:root {
  --void: #02060d;        /* fundo */
  --deck: #06101c;        /* painéis */
  --deck-2: #0a1828;      /* painel elevado / hover */
  --line: #13304d;        /* bordas */
  --line-2: #1d4670;      /* bordas em foco */
  --phosphor: #38b6ff;    /* acento, cabeças da chuva */
  --phosphor-dim: #1f8ce0;/* marcas de dados, ativo */
  --moss: #1a5a8f;        /* rastro da chuva */
  --read: #d6e8f7;        /* texto longo */
  --ink-2: #9bbcd8;       /* texto secundário */
  --ink-3: #6f90ad;       /* texto terciário */
  --amber: #ffbf5e;
  --red: #ff6a5c;
  --red-deep: #3a0f0c;

  --font-ui: 'Chivo Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --font-crt: 'VT323', 'Chivo Mono', ui-monospace, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;

  --r-sm: 4px;
  --r-md: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 288px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--read);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: var(--phosphor); color: var(--void); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid var(--void); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
textarea, input { caret-color: var(--phosphor); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

#rain {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
  opacity: var(--rain-opacity, 0.22);
  transition: opacity 1.2s var(--ease-out);
}
.view { position: relative; z-index: 1; }

/* ------------------------------------------------ marca */
.brand {
  font-family: var(--font-crt);
  color: var(--phosphor);
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 0 12px rgba(56, 182, 255, 0.35);
}
.brand-xl { font-size: clamp(2.25rem, 10.5vw, 3.6rem); margin: 0; max-width: 100%; white-space: nowrap; }

/* glitch: canais vermelho/ciano escorregam por um instante a cada ~5s */
.glitch { position: relative; display: inline-block; animation: jitter 5s infinite steps(1); }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0;
  opacity: 0; pointer-events: none; text-shadow: none;
}
.glitch::before { color: #ff2f68; animation: glitch-a 5s infinite steps(1); }
.glitch::after { color: #b58cff; animation: glitch-b 5s infinite steps(1); }
@keyframes jitter {
  0%, 88%, 100% { transform: none; }
  89% { transform: translate(2px, -1px) skewX(-6deg); }
  91% { transform: translate(-3px, 1px); }
  93% { transform: translate(1px, 0) skewX(4deg); }
  94% { transform: none; }
}
@keyframes glitch-a {
  0%, 88%, 95%, 100% { opacity: 0; transform: none; }
  89% { opacity: 0.85; transform: translate(-5px, 1px); clip-path: inset(8% 0 58% 0); }
  91% { opacity: 0.85; transform: translate(4px, -1px); clip-path: inset(62% 0 6% 0); }
  93% { opacity: 0.85; transform: translate(-3px, 0); clip-path: inset(36% 0 38% 0); }
}
@keyframes glitch-b {
  0%, 88%, 95%, 100% { opacity: 0; transform: none; }
  89% { opacity: 0.75; transform: translate(5px, -1px); clip-path: inset(55% 0 12% 0); }
  91% { opacity: 0.75; transform: translate(-4px, 1px); clip-path: inset(14% 0 60% 0); }
  93% { opacity: 0.75; transform: translate(3px, 0); clip-path: inset(70% 0 4% 0); }
}

/* monitor de fósforo: linhas de varredura, feixe descendo e cantos escuros */
.crt { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.crt::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, var(--scan, 0.07)) 2px 3px);
}
.crt::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 22vh;
  background: linear-gradient(to bottom, transparent, rgba(56, 182, 255, var(--beam, 0.025)), transparent);
  animation: beam 7s linear infinite;
}
@keyframes beam { from { transform: translateY(-25vh); } to { transform: translateY(105vh); } }
body[data-view="login"] { --scan: 0.22; --beam: 0.06; }
body[data-view="login"] .crt { background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.6) 100%); }

/* botão de efeitos */
.fx-toggle {
  background: none; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 10px; color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap;
}
.fx-toggle:hover { color: var(--phosphor); border-color: var(--phosphor-dim); }
.fx-corner { position: fixed; right: 16px; bottom: 16px; background: rgba(2, 6, 13, 0.8); }

/* relógio */
.clock { font-family: var(--font-crt); font-size: 1.375rem; line-height: 1; color: var(--phosphor-dim); letter-spacing: 0.06em; }

/* tela de acesso liberado */
.access {
  position: fixed; inset: 0; z-index: 65;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(2, 6, 13, 0.9);
  animation: access-in 0.15s steps(2);
}
.access-text { font-family: var(--font-crt); font-size: clamp(3rem, 11vw, 7rem); line-height: 1; color: var(--phosphor); text-shadow: 0 0 24px rgba(56, 182, 255, 0.55); white-space: nowrap; }
.access-sub { font-size: var(--fs-sm); color: var(--ink-2); }
.access.out { animation: access-out 0.35s var(--ease-out) forwards; }
@keyframes access-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes access-out { to { opacity: 0; transform: scale(1.04); filter: blur(4px); } }
.brand-md { font-size: 1.875rem; }

/* ------------------------------------------------ botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--deck); color: var(--read);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--deck-2); border-color: var(--phosphor-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--phosphor); border-color: var(--phosphor); color: var(--void); font-weight: 600; }
.btn-primary:hover { background: #85cdff; border-color: #85cdff; color: var(--void); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--deck-2); border-color: var(--line); color: var(--read); }
.btn-danger { background: transparent; border-color: #5c1f1a; color: var(--red); }
.btn-danger:hover { background: var(--red-deep); border-color: var(--red); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--deck-2); color: var(--read); border-color: var(--line); }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0;
  color: var(--ink-2); font-size: var(--fs-sm);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-2);
}
.link-btn:hover { color: var(--phosphor); text-decoration-color: currentColor; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500; }
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-help { font-size: var(--fs-xs); color: var(--ink-3); margin: 0; }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: var(--void); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--read); font-size: var(--fs-md);
}
.input:hover { border-color: var(--moss); }
.input:focus { outline: none; border-color: var(--phosphor); box-shadow: 0 0 0 3px rgba(56, 182, 255, 0.14); }
.input::placeholder, textarea::placeholder { color: var(--ink-3); }
select.input {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239bbcd8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
select.input option { background: var(--deck); }
.form-error { min-height: 1.2em; margin: 0; color: var(--red); font-size: var(--fs-sm); }
.form-error:empty { min-height: 0; }

/* ------------------------------------------------ login */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
}
.login-box {
  position: relative;
  width: min(100%, 460px);
  padding: 0 32px 28px;
  background: rgba(2, 6, 13, 0.88);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  text-align: center;
  overflow: hidden;
  animation: power-on 0.6s var(--ease-out) both;
}
@keyframes power-on {
  0% { opacity: 0; transform: scaleY(0.02) scaleX(0.6); filter: brightness(3); }
  45% { opacity: 1; transform: scaleY(0.02) scaleX(1); }
  100% { transform: none; filter: none; }
}
.login-bar {
  display: flex; align-items: center; gap: 6px;
  margin: 0 -32px 30px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--deck);
}
.login-bar .dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line-2); }
.login-bar .dot:first-child { background: var(--phosphor-dim); border-color: var(--phosphor-dim); }
.login-bar-title { margin-left: 8px; font-size: var(--fs-xs); color: var(--ink-3); }
.bootlog {
  margin: 20px 0 0; min-height: 5.6em; text-align: left;
  font-family: var(--font-ui); font-size: var(--fs-xs); line-height: 1.4;
  color: var(--phosphor-dim); white-space: pre-wrap;
}
.bootlog .ok { color: var(--phosphor); }
.bootlog .caret { display: inline-block; width: 0.6em; height: 1em; vertical-align: -0.15em; background: var(--phosphor); animation: blink 0.9s steps(2) infinite; }
.login-sub { margin: 10px 0 22px; color: var(--ink-2); font-size: var(--fs-sm); text-align: left; }

.login-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.pin-input {
  width: 100%; height: 64px; padding: 0 12px;
  background: var(--void); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--phosphor); text-align: center;
  font-family: var(--font-crt); font-size: 2.75rem; letter-spacing: 0.5em;
  text-indent: 0.5em;
  -webkit-text-security: disc;
}
.pin-input:focus { outline: none; border-color: var(--phosphor); box-shadow: 0 0 0 3px rgba(56, 182, 255, 0.14); }
.login-form .btn { margin-top: 6px; min-height: 46px; font-size: var(--fs-md); }
.login .form-error { margin-top: 14px; }
.login #toggle-admin { margin-top: 18px; }
.login-box.shake { animation: shake 0.36s var(--ease-out); }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}

/* ------------------------------------------------ app do colaborador */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }

.sidebar {
  display: flex; flex-direction: column; gap: 14px; min-height: 0;
  padding: 18px 14px 14px;
  background: var(--deck);
  border-right: 1px solid var(--line);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.chat-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; display: flex; flex-direction: column; gap: 2px; }
.chat-group { margin: 14px 8px 4px; font-size: var(--fs-xs); color: var(--ink-3); }
.chat-group:first-child { margin-top: 2px; }
.chat-item {
  position: relative; display: flex; align-items: center; gap: 6px;
  border-radius: var(--r-sm);
}
.chat-item:hover { background: var(--deck-2); }
.chat-item.active { background: #0e2238; }
.chat-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px;
  background: var(--phosphor); border-radius: 2px;
}
.chat-link {
  flex: 1; min-width: 0; display: block; padding: 8px 4px 8px 12px;
  background: none; border: 0; text-align: left;
  color: var(--ink-2); font-size: var(--fs-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item.active .chat-link, .chat-link:hover { color: var(--read); }
.chat-del {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  height: 28px; min-width: 28px; margin-right: 4px; padding: 0 6px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3);
  font-size: var(--fs-xs); opacity: 0;
}
.chat-del .ic { width: 15px; height: 15px; }
.chat-item:hover .chat-del, .chat-item:focus-within .chat-del, .chat-del.confirm { opacity: 1; }
.chat-del:hover { color: var(--red); background: var(--red-deep); }
.chat-del.confirm { color: var(--void); background: var(--red); }
.chat-empty { padding: 8px 12px; color: var(--ink-3); font-size: var(--fs-sm); }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { padding: 4px 6px 6px; }
.me-name { display: block; font-weight: 600; color: var(--read); font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 0; }
.me-counts div { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--void); }
.me-counts dt { font-size: var(--fs-xs); color: var(--ink-3); }
.me-counts dd { margin: 0; font-family: var(--font-crt); font-size: 1.75rem; line-height: 1; color: var(--phosphor); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 13, 0.82);
  backdrop-filter: blur(6px);
}
.topbar-title {
  flex: 0 1 auto; min-width: 0; margin: 0;
  font-size: var(--fs-md); font-weight: 500; color: var(--read);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }
.status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3);
}
.status:empty::before { display: none; }
.status.live { color: var(--phosphor); }
.status.live::before { background: var(--phosphor); animation: blink 1s steps(2) infinite; }
.status.err { color: var(--red); }
.status.err::before { background: var(--red); }
@keyframes blink { 50% { opacity: 0.2; } }

/* véu atrás da coluna de leitura: a chuva corre nas laterais, nunca sob o texto */
.thread {
  flex: 1; overflow-y: auto; outline: none;
  background: linear-gradient(90deg,
    rgba(2, 6, 13, 0) calc(50% - 470px),
    rgba(2, 6, 13, 0.94) calc(50% - 405px),
    rgba(2, 6, 13, 0.94) calc(50% + 405px),
    rgba(2, 6, 13, 0) calc(50% + 470px));
}
.thread:has(.empty) { background: none; }
.thread-inner { width: min(100% - 48px, 760px); margin: 0 auto; padding: 32px 0 24px; display: flex; flex-direction: column; gap: 28px; }

/* estado vazio */
.empty {
  margin: auto 0; padding: 12vh 0 0; text-align: left;
}
.empty-title {
  margin: 0; font-family: var(--font-crt); font-weight: 400;
  font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.02; color: var(--phosphor);
  max-width: 20ch;
  text-wrap: balance;
}
.empty-text { margin: 16px 0 0; color: var(--ink-2); font-size: var(--fs-md); max-width: 52ch; }
.empty-warn { margin: 18px 0 0; padding: 12px 14px; border: 1px solid #5a4318; background: #1a1407; border-radius: var(--r-sm); color: var(--amber); font-size: var(--fs-sm); max-width: 60ch; }
.cursor { display: inline-block; width: 0.55em; height: 0.9em; margin-left: 4px; vertical-align: -0.05em; background: var(--phosphor); animation: blink 1.1s steps(2) infinite; }

/* mensagens */
.msg-user {
  align-self: flex-end; max-width: min(85%, 600px);
  padding: 12px 16px;
  background: var(--deck-2); border: 1px solid var(--line);
  border-radius: var(--r-md) var(--r-md) 2px var(--r-md);
  color: var(--read); white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: var(--fs-sm);
}
.msg-user.long { max-height: 260px; overflow-y: auto; }

.msg-ai { position: relative; }
.msg-ai .body { font-size: 0.96875rem; line-height: 1.78; color: var(--read); overflow-wrap: anywhere; max-width: 72ch; }
.msg-ai .body > :first-child { margin-top: 0; }
.msg-ai .body > :last-child { margin-bottom: 0; }
.msg-ai .body p { margin: 0 0 1em; }
.msg-ai .body h1, .msg-ai .body h2, .msg-ai .body h3, .msg-ai .body h4 {
  margin: 1.6em 0 0.5em; line-height: 1.2; color: var(--phosphor); font-weight: 400;
  font-family: var(--font-crt); letter-spacing: 0.02em;
}
.msg-ai .body h1 { font-size: 2.5rem; }
.msg-ai .body h2 { font-size: 2.125rem; }
.msg-ai .body h3 { font-size: 1.625rem; }
.msg-ai .body h4 { font-size: 1.375rem; }
.msg-ai .body strong { color: #f1f8ff; font-weight: 650; }
.msg-ai .body em { color: var(--ink-2); }
.msg-ai .body ul, .msg-ai .body ol { margin: 0 0 1em; padding-left: 1.4em; }
.msg-ai .body li { margin: 0.25em 0; }
.msg-ai .body li::marker { color: var(--phosphor-dim); }
.msg-ai .body blockquote { margin: 0 0 1em; padding: 2px 0 2px 14px; border-left: 1px solid var(--line-2); color: var(--ink-2); }
.msg-ai .body hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.msg-ai .body code { padding: 1px 5px; background: var(--deck-2); border: 1px solid var(--line); border-radius: 3px; font-size: 0.9em; }
.msg-ai .body pre { margin: 0 0 1em; padding: 12px 14px; background: var(--deck); border: 1px solid var(--line); border-radius: var(--r-sm); overflow-x: auto; }
.msg-ai .body pre code { padding: 0; border: 0; background: none; }

.decode { color: var(--phosphor); }
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: var(--fs-sm); }
.thinking .glyphs { font-family: var(--font-crt); font-size: 1.4rem; color: var(--phosphor); letter-spacing: 0.1em; }

.msg-actions { display: flex; align-items: center; gap: 4px; margin-top: 10px; min-height: 32px; }
.act {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-3); font-size: var(--fs-xs);
}
.act .ic { width: 15px; height: 15px; }
.act:hover { color: var(--read); background: var(--deck-2); border-color: var(--line); }
.act.ok { color: var(--phosphor); }
.msg-meta { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); }
.msg-flag { font-size: var(--fs-xs); color: var(--amber); }

.msg-error {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid #5c1f1a; background: rgba(58, 15, 12, 0.7);
  border-radius: var(--r-sm); color: #ffb3aa; font-size: var(--fs-sm);
}
.msg-error p { margin: 0; flex: 1 1 260px; }

/* composer */
.composer { padding: 12px 24px 16px; background: linear-gradient(to top, var(--void) 60%, rgba(2, 6, 13, 0)); }
.composer-box {
  width: min(100%, 760px); margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--deck); border: 1px solid var(--line-2); border-radius: var(--r-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-row { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px; }

/* cliente da pergunta: nome + nascimento, acima da mensagem */
.client-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 148px auto; align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.client-field { display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 7px 14px 7px 16px; min-width: 0; }
.client-field + .client-field { border-left: 1px solid var(--line); }
.client-field label { font-size: 0.6875rem; color: var(--ink-3); line-height: 1.3; }
.client-field input {
  width: 100%; padding: 0; margin: 0; border: 0; outline: none; background: transparent;
  color: var(--read); font-size: var(--fs-md); font-weight: 600; line-height: 1.5;
}
.client-birth input { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.client-field:focus-within label { color: var(--phosphor); }
.client-field.invalid label { color: var(--red); }
.client-field.invalid { background: rgba(255, 106, 92, 0.07); }
.client-clear {
  align-self: center; margin: 0 8px; padding: 6px 10px; white-space: nowrap;
  background: none; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-2); font-size: var(--fs-xs);
}
.client-clear:hover { color: var(--phosphor); border-color: var(--phosphor-dim); }
.composer-hint.err { color: var(--red); }

/* etiqueta do cliente nas mensagens */
.client-tag {
  display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 3px 9px;
  background: rgba(56, 182, 255, 0.08); border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--phosphor); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
}
.client-tag .birth { color: var(--ink-2); font-weight: 400; }
button.client-tag { cursor: pointer; }
button.client-tag:hover { border-color: var(--phosphor); background: rgba(56, 182, 255, 0.16); }
.msg-user-wrap { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; max-width: min(85%, 600px); }
.msg-user-wrap .msg-user { max-width: 100%; }
.chat-clients { display: block; font-size: 0.6875rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.composer-box:focus-within { border-color: var(--phosphor-dim); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(56, 182, 255, 0.1); }
.composer textarea {
  flex: 1; min-height: 28px; max-height: 40vh; padding: 6px 0; margin: 0;
  background: transparent; border: 0; resize: none; outline: none;
  color: var(--read); font-size: var(--fs-md); line-height: 1.55;
}
.send-btn {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border: 0; border-radius: var(--r-sm);
  background: var(--phosphor); color: var(--void);
  transition: background 0.15s, transform 0.1s;
}
.send-btn:hover { background: #85cdff; }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { background: var(--line); color: var(--ink-3); cursor: not-allowed; }
.send-btn.stop { background: var(--read); }
.send-btn .ic { stroke-width: 2.2; }
.composer-hint { width: min(100%, 760px); margin: 8px auto 0; font-size: var(--fs-xs); color: var(--ink-3); }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 20; }
.only-mobile { display: none; }

/* ------------------------------------------------ administrador */
.admin { display: flex; flex-direction: column; height: 100dvh; }
.admin-top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 32px; min-height: 64px;
  background: var(--deck); border-bottom: 1px solid var(--line);
}
.admin-role { color: var(--ink-2); font-size: var(--fs-sm); padding-left: 16px; border-left: 1px solid var(--line-2); }
.balance { margin-left: auto; font-size: var(--fs-sm); color: var(--ink-2); }
.balance strong { color: var(--phosphor); font-weight: 600; }
.balance.low strong { color: var(--amber); }
.admin-main { flex: 1; overflow-y: auto; padding: 32px 32px 64px; }
.admin-main > section { width: min(100%, 1180px); margin: 0 auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.admin-h1 { margin: 0; font-family: var(--font-crt); font-weight: 400; font-size: 2.75rem; line-height: 1; color: var(--phosphor); }

.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 28px 0 0; border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(7, 18, 12, 0.9); }
.totals div { padding: 16px 20px; border-left: 1px solid var(--line); }
.totals div:first-child { border-left: 0; }
.totals dt { font-size: var(--fs-sm); color: var(--ink-2); }
.totals dd { margin: 4px 0 0; font-family: var(--font-crt); font-size: 3rem; line-height: 1; color: var(--read); }
.totals div:first-child dd { color: var(--phosphor); }

.daily { margin: 20px 0 0; padding: 16px 20px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(7, 18, 12, 0.9); }
.daily figcaption { font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 12px; }
.daily-bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; align-items: end; height: 140px; position: relative; }
.daily-bars::after { content: ''; position: absolute; left: 0; right: 0; bottom: 22px; border-top: 1px solid var(--line); }
.bar-col { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; outline: none; }
.bar-col .bar { width: min(24px, 70%); min-height: 0; background: var(--phosphor-dim); border-radius: 4px 4px 0 0; transition: background 0.15s; }
.bar-col .bar.zero { height: 1px !important; background: var(--line-2); border-radius: 0; }
.bar-col .bar-day { font-size: 0.6875rem; color: var(--ink-3); height: 16px; line-height: 16px; }
.bar-col .bar-val { font-size: var(--fs-xs); color: var(--read); visibility: hidden; }
.bar-col:hover .bar, .bar-col:focus-visible .bar { background: var(--phosphor); }
.bar-col:hover .bar-val, .bar-col:focus-visible .bar-val, .bar-col.today .bar-val { visibility: visible; }
.bar-col.today .bar-day { color: var(--read); }

.table-wrap { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; background: rgba(7, 18, 12, 0.92); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--deck-2); }
.table .num { text-align: right; }
.table td.num { font-family: var(--font-crt); font-size: 1.5rem; line-height: 1; color: var(--read); }
.table td.num.hot { color: var(--phosphor); }
.cell-name { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--read); }
.cell-name .ic { color: var(--ink-3); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); border: 1px solid var(--line-2); color: var(--ink-2); }
.tag.off { border-color: #5a4318; color: var(--amber); }
.muted { color: var(--ink-3); }
.empty-row td { padding: 40px 16px; text-align: center; color: var(--ink-2); white-space: normal; cursor: default; }

.back { margin-bottom: 16px; text-decoration: none; }
.tabs { display: flex; gap: 4px; margin: 24px 0 0; border-bottom: 1px solid var(--line); }
.tab {
  padding: 10px 16px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500;
}
.tab:hover { color: var(--read); }
.tab[aria-selected="true"] { color: var(--phosphor); border-bottom-color: var(--phosphor); }

.detail-form { display: flex; flex-direction: column; gap: 22px; padding-top: 24px; }
.form-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 16px; align-items: start; }
.field-switch { min-width: 120px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--line); border: 1px solid var(--line-2); transition: background 0.2s; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-2); transition: transform 0.2s var(--ease-out), background 0.2s; }
.switch input:checked + .switch-track { background: #0f3a63; border-color: var(--phosphor-dim); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--phosphor); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--phosphor); outline-offset: 2px; }
.switch-text { font-size: var(--fs-sm); color: var(--read); }
.prompt-area { min-height: 46vh; resize: vertical; font-size: var(--fs-sm); line-height: 1.65; padding: 14px 16px; }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-actions .btn-danger { margin-left: auto; }
.saved-note { font-size: var(--fs-sm); color: var(--phosphor); }

.chats-panel { display: grid; grid-template-columns: 300px 1fr; gap: 0; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--r-md); min-height: 60vh; background: rgba(7, 18, 12, 0.92); overflow: hidden; }
.admin-chat-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 75vh; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.admin-chat-list button { display: block; width: 100%; padding: 10px 12px; text-align: left; background: none; border: 0; border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--fs-sm); }
.admin-chat-list button:hover { background: var(--deck-2); color: var(--read); }
.admin-chat-list button.active { background: #0e2238; color: var(--read); }
.admin-chat-list small { display: block; color: var(--ink-3); font-size: var(--fs-xs); margin-top: 2px; }
.admin-chat-view { overflow-y: auto; max-height: 75vh; padding: 24px 28px; display: flex; flex-direction: column; gap: 24px; background: var(--void); }
.empty-note { color: var(--ink-3); font-size: var(--fs-sm); margin: 0; }
.empty-note.pad { padding: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  padding: 10px 16px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--deck); color: var(--read); font-size: var(--fs-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------ responsivo */
@media (max-width: 960px) {
  .form-row { grid-template-columns: 1fr 1fr; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .totals div:nth-child(3) { border-left: 0; }
  .totals div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .chats-panel { grid-template-columns: 1fr; }
  .admin-chat-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 240px; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .scrim.only-mobile { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform 0.28s var(--ease-out);
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6); }
  .topbar { padding: 8px 12px; }
  .thread-inner { width: calc(100% - 32px); padding-top: 20px; }
  .composer { padding: 8px 12px 12px; }
  .composer-hint { display: none; }
  .clock { display: none; }
  .composer-hint.err { display: block; }
  .client-row { grid-template-columns: minmax(0, 1fr) 118px; }
  .client-clear { display: none; }
  .client-field { padding: 6px 10px 6px 12px; }
  .input-row { padding-left: 12px; }
  .msg-user { max-width: 92%; }
  .chat-del { opacity: 1; }
}
@media (max-width: 640px) {
  .admin-top { padding: 10px 16px; gap: 10px; }
  .admin-role { display: none; }
  .admin-top .btn-ghost { margin-left: auto; padding: 8px 10px; }
  .balance { order: 3; flex-basis: 100%; margin-left: 0; font-size: var(--fs-xs); }
  .admin-main { padding: 20px 16px 48px; }
  .admin-h1 { font-size: 2.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .totals dd { font-size: 2.25rem; }
  .daily-bars .bar-day { font-size: 0.625rem; }
  .login-box { padding: 0 20px 22px; }
  .login-bar { margin: 0 -20px 24px; }
}

/* Botão "Efeitos: desligados" — o dono quer movimento por padrão; quem achar pesado desliga aqui. */
html[data-fx="off"] *, html[data-fx="off"] *::before, html[data-fx="off"] *::after {
  animation: none !important; transition-duration: 0.01ms !important;
}
html[data-fx="off"] .crt { display: none; }
@media (forced-colors: active) {
  .bar-col .bar { background: CanvasText; }
}

/* acesso negado */
.login .form-error .denied { display: block; font-family: var(--font-crt); font-size: 1.75rem; line-height: 1.1; letter-spacing: 0.06em; }
.login .form-error .denied-msg { display: block; margin-top: 4px; }
.login-box.shake { border-color: var(--red); }

/* ------------------------------------------------ prompts */
.new-chat-wrap { position: relative; }
.prompt-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 25;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--deck-2); border: 1px solid var(--line-2); border-radius: var(--r-md);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}
.prompt-menu-title { padding: 6px 10px 4px; font-size: var(--fs-xs); color: var(--ink-3); }
.prompt-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--r-sm); background: none;
  color: var(--read); font-size: var(--fs-sm); text-align: left;
}
.prompt-menu button:hover, .prompt-menu button:focus-visible { background: #0e2238; color: var(--phosphor); outline: none; }
.prompt-menu button::before { content: ''; width: 6px; height: 6px; border-radius: 1px; background: var(--phosphor-dim); flex: none; }

.prompt-badge {
  flex: none; display: inline-block; padding: 2px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: rgba(56, 182, 255, 0.08);
  color: var(--phosphor); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
}
.chat-link .chat-main { display: block; overflow: hidden; text-overflow: ellipsis; }
.chat-link .chat-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 0.6875rem; color: var(--ink-3); }
.chat-link .chat-sub .prompt-badge { padding: 0 6px; font-size: 0.6875rem; font-weight: 500; }

.prompt-pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; }
.prompt-pick-label { width: 100%; font-size: var(--fs-xs); color: var(--ink-3); }
.prompt-pick button {
  padding: 7px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--deck); color: var(--ink-2); font-size: var(--fs-sm);
}
.prompt-pick button:hover { border-color: var(--phosphor-dim); color: var(--read); }
.prompt-pick button[aria-pressed="true"] { border-color: var(--phosphor); background: rgba(56, 182, 255, 0.12); color: var(--phosphor); font-weight: 600; }

/* editor de prompts do administrador */
.prompts-field { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.prompts-legend { display: flex; flex-direction: column; gap: 2px; padding: 0; margin-bottom: 4px; }
.prompt-list { display: flex; flex-direction: column; gap: 14px; }
.prompt-card { border: 1px solid var(--line-2); border-radius: var(--r-md); background: rgba(6, 16, 28, 0.9); }
.prompt-card-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.prompt-card-head .input { flex: 1; min-height: 36px; padding: 6px 10px; font-weight: 600; }
.prompt-card-head .count { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.prompt-card textarea.input { border: 0; border-radius: 0 0 var(--r-md) var(--r-md); min-height: 28vh; resize: vertical; font-size: var(--fs-sm); line-height: 1.65; padding: 14px 16px; background: transparent; box-shadow: none; }
.prompt-card textarea.input:focus { box-shadow: inset 0 0 0 1px var(--phosphor-dim); }
.prompt-remove { flex: none; }
.add-prompt { align-self: flex-start; }
.prompts-empty { padding: 18px; border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--ink-2); font-size: var(--fs-sm); margin: 0; }

/* ------------------------------------------------ logo */
.login-logo { margin: 0 auto 4px; width: min(200px, 58%); line-height: 0; }
.login-logo img {
  display: block; width: 100%; height: auto;
  filter: drop-shadow(0 12px 28px rgba(56, 182, 255, 0.22));
  animation: logo-glitch 5s infinite steps(1);
}
@keyframes logo-glitch {
  0%, 88%, 95%, 100% { transform: none; filter: drop-shadow(0 12px 28px rgba(56, 182, 255, 0.22)); }
  89% { transform: translate(-4px, 0) skewX(-4deg); filter: drop-shadow(-5px 0 0 rgba(255, 47, 104, 0.85)) drop-shadow(5px 0 0 rgba(111, 247, 255, 0.85)); }
  91% { transform: translate(4px, 1px); filter: drop-shadow(5px 0 0 rgba(255, 47, 104, 0.85)) drop-shadow(-5px 0 0 rgba(111, 247, 255, 0.85)); }
  93% { transform: translate(-2px, 0) skewX(3deg); filter: drop-shadow(-3px 0 0 rgba(255, 47, 104, 0.7)) drop-shadow(3px 0 0 rgba(111, 247, 255, 0.7)); }
}
.brand-row { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; object-position: 50% 15%;
  background: var(--deck-2); border: 1px solid var(--line-2);
}
.access-logo { width: min(170px, 40vw); height: auto; filter: drop-shadow(0 14px 40px rgba(56, 182, 255, 0.35)); }
/* logo inteira na lateral do chat */
.brand-logo { flex: none; width: 58px; height: auto; filter: drop-shadow(0 4px 12px rgba(56, 182, 255, 0.2)); }
.sidebar-head .brand-md { font-size: 1.625rem; }
