/* Grimório UI — camada dos sites (painel do Monstro, WL, Kanban e Chamados), visual Legado (v0.2).
   Carregue depois de tokens.css e bundle.css. Aqui só fica o que o bundle não tem: a página do site, a tela
   de entrada, tabelas, etiquetas, avisos e o vocabulário dos sites simples (<body class="gr-site">).
   Botões, campos, painéis e o menu lateral são os do bundle (gr-btn, gr-input, gr-panel, gr-sidebar).
   Regras em DESIGN_v0.md §15. */

/* ---------- base ---------- */
:where(html) { -webkit-text-size-adjust: 100%; }
:where(*, *::before, *::after) { box-sizing: border-box; }
:where(body) { min-height: 100vh; -webkit-font-smoothing: antialiased; }
::selection { background: var(--gold); color: var(--on-gold); }
:where(*) { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
:where(:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
a.gr-btn { text-decoration: none; }

/* Ícones do sistema como máscara: pegam a cor do texto, sem SVG inline (a CSP dos sites bloqueia estilo inline). */
.gr-ico { display: inline-block; flex: none; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.gr-ico--s { width: 16px; height: 16px; }
.gr-ico--ajustes { --ico: url("icons/ajustes.svg"); }
.gr-ico--brasao { --ico: url("icons/brasao.svg"); }
.gr-ico--coruja { --ico: url("icons/coruja.svg"); }
.gr-ico--fechar { --ico: url("icons/fechar.svg"); }
.gr-ico--livro { --ico: url("icons/livro.svg"); }
.gr-ico--mapa { --ico: url("icons/mapa.svg"); }
.gr-ico--mochila { --ico: url("icons/mochila.svg"); }
.gr-ico--ok { --ico: url("icons/ok.svg"); }
.gr-ico--personagem { --ico: url("icons/personagem.svg"); }
.gr-ico--sair { --ico: url("icons/sair.svg"); }
.gr-ico--seta { --ico: url("icons/seta.svg"); }
.gr-ico--varinha { --ico: url("icons/varinha.svg"); }

/* Rótulo pequeno acima de um título (de que sistema é a tela) */
.gr-eyebrow { margin: 0; font-family: var(--font-display); font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-muted); }

/* ---------- tela de entrada: <main class="gr-login"> + <section class="gr-panel gr-login__painel"> ---------- */
.gr-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-4) var(--space-6);
}
.gr-login__painel { width: min(440px, 100%); padding: var(--space-8) var(--space-8) var(--space-6); text-align: center; }
.gr-login__logo { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto var(--space-3); }
.gr-login__titulo {
  margin: var(--space-1) 0 0;
  font-family: var(--font-display); font-size: 22px; line-height: 30px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 14px var(--gold-glow);
}
.gr-login .gr-divider { max-width: 220px; margin: var(--space-4) auto; }
.gr-login__texto { margin: 0 0 var(--space-6); font-family: var(--font-body); font-size: 16px; line-height: 24px; color: var(--ink-muted); }
.gr-login__erro {
  display: flex; gap: var(--space-2); align-items: flex-start;
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4);
  text-align: left; font-size: 14px; line-height: 20px; color: var(--ink);
  background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 18%, transparent), transparent 80%), var(--surface-200);
  border-left: 2px solid var(--danger);
}
.gr-login__entrar { width: 100%; min-height: 48px; }
.gr-login__nota { margin: var(--space-4) 0 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.gr-login__rodape { font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-muted); }

/* ---------- página de app: <div class="gr-app"> com <aside class="gr-sidebar gr-app__lateral"> e <main class="gr-app__main"> ---------- */
.gr-app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.gr-app__lateral { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.gr-app__marca { position: relative; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-1) var(--space-4); color: var(--ink); text-decoration: none; }
.gr-app__marca::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--filigrana); opacity: 0.6; }
.gr-app__marca img { width: 44px; height: auto; flex: none; }
.gr-app__marca b { display: block; font-family: var(--font-display); font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 12px var(--gold-glow); }
.gr-app__marca small { display: block; font-family: var(--font-display); font-size: 9px; line-height: 14px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-muted); }
.gr-nav__item .gr-ico { color: var(--ink-muted); }
.gr-nav__item:hover .gr-ico, .gr-nav__item[aria-current="page"] .gr-ico { color: var(--gold); }
.gr-app__rodape { display: flex; align-items: center; gap: var(--space-2); }
.gr-app__rodape .gr-profile { flex: 1; min-width: 0; padding: 0; }
.gr-app__rodape .gr-profile__text { display: grid; min-width: 0; }
.gr-app__rodape .gr-profile__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-profile__seal b { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--gold-bright); }
.gr-app__sair:hover { background: var(--danger); color: var(--danger); }
.gr-app__main { width: 100%; max-width: 1180px; margin: 0 auto; padding: var(--space-8) var(--space-8) 64px; min-width: 0; }

/* Cabeçalho de página: título, descrição e ações à direita, sobre uma filigrana */
.gr-cabeca { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-6); padding-bottom: var(--space-4); }
.gr-cabeca::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--filigrana); opacity: 0.7; }
.gr-cabeca__texto { flex: 1 1 320px; min-width: 0; }
.gr-cabeca h1 { margin: 0; font-family: var(--font-display); font-size: 26px; line-height: 34px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 14px var(--gold-glow); }
.gr-cabeca__desc { margin: var(--space-2) 0 0; max-width: 72ch; font-family: var(--font-body); font-size: 16px; line-height: 24px; color: var(--ink-muted); }
.gr-cabeca__acoes { display: flex; flex-wrap: wrap; gap: var(--space-2); }

@media (max-width: 900px) {
  .gr-app { grid-template-columns: minmax(0, 1fr); }
  .gr-app__lateral {
    position: sticky; z-index: 20; top: 0; width: auto; height: auto; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3);
  }
  .gr-app__lateral::after { top: auto; left: 0; width: auto; height: 1px; background: var(--filigrana); }
  .gr-app__marca { padding: 0; }
  .gr-app__marca::after, .gr-app__marca small, .gr-nav__heading, .gr-app__rodape .gr-profile { display: none; }
  .gr-app__marca img { width: 36px; }
  .gr-app__lateral .gr-sidebar__footer { order: 2; margin: 0 0 0 auto; padding: 0; }
  .gr-app__lateral .gr-sidebar__footer::before { display: none; }
  .gr-app__lateral .gr-nav { order: 3; flex-basis: 100%; display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
  .gr-app__lateral .gr-nav__item { flex: none; }
  .gr-app__main { padding: var(--space-6) var(--space-4) 48px; }
  .gr-cabeca h1 { font-size: 20px; line-height: 28px; }
}

/* ---------- conteúdo dos sites simples (painel do Monstro e WL): <body class="gr-site"> ---------- */
:where(.gr-site) :is(h2, h3, h4) { margin: 0 0 var(--space-3); font-family: var(--font-display); font-weight: 600; text-transform: uppercase; line-height: 1.35; }
:where(.gr-site) h2 { font-size: 18px; letter-spacing: 0.12em; color: var(--ink); }
:where(.gr-site) h3 { font-size: 14px; letter-spacing: 0.14em; color: var(--gold); text-shadow: 0 0 12px var(--gold-glow); }
:where(.gr-site) h4 { font-size: 12px; letter-spacing: 0.14em; color: var(--ink); }
:where(.gr-site) p { margin: 0 0 var(--space-3); }
.gr-site a:not([class]) { color: var(--gold-bright); text-underline-offset: 3px; }
.gr-site code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--ink-muted); background: var(--surface-0); border: 1px solid var(--line); padding: 1px 5px; }
:where(.gr-site) :is(ol, ul) { padding-left: 22px; }
.gr-site .muted { color: var(--ink-muted); font-size: 14px; line-height: 20px; }

/* Cartão = gr-panel. Dentro de outro painel ele vira bloco liso (nunca painel dentro de painel). */
.gr-site .card { margin-bottom: var(--space-4); padding: var(--space-6); }
.gr-site .card > :last-child { margin-bottom: 0; }
.gr-site .card > h3:not(:first-child), .gr-site .card > h4:not(:first-child) { margin-top: var(--space-6); }
.gr-site .card.destaque::after { --c: var(--gold-bright); filter: drop-shadow(0 0 4px var(--gold-glow)); }
.gr-site .gr-panel .gr-panel { background: var(--surface-200); border-color: var(--line); box-shadow: none; }
.gr-site .gr-panel .gr-panel::before, .gr-site .gr-panel .gr-panel::after { display: none; }

/* Números de resumo */
.gr-site .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.gr-site .cards .card { margin: 0; padding: var(--space-4) var(--space-6); }
.gr-site .rotulo { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); }
.gr-site .num { margin-top: var(--space-1); font-family: var(--font-ui); font-size: 32px; line-height: 40px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold-bright); text-shadow: 0 0 14px var(--gold-glow); }
.gr-site .num.ok { color: var(--success); text-shadow: none; }
.gr-site .num.erro { color: var(--danger); text-shadow: none; }

/* Botão de alternância ligado (filtros): o contorno vira o principal */
.gr-btn.ativo { background: var(--gold-bright); color: var(--on-gold); }
.gr-btn.ativo::before { background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, color-mix(in srgb, var(--gold) 85%, black)); }

/* Campos: rótulo em Cinzel acima do gr-input */
.gr-site label { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.gr-site label > .muted { font-family: var(--font-body); font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.gr-site label > .gr-input { text-transform: none; letter-spacing: 0; }
.gr-site .gr-input:disabled { opacity: 0.55; cursor: not-allowed; }
.gr-site textarea.gr-input { min-height: 120px; line-height: 1.5; }
.gr-site select.gr-input:not([multiple]) {
  appearance: none; padding-right: 36px; cursor: pointer;
  background: url("icons/seta.svg") no-repeat right 10px center / 18px, linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.05)), var(--surface-200);
}
.gr-site select[multiple].gr-input { padding: var(--space-1); }
.gr-site option { background: var(--surface-200); color: var(--ink); padding: var(--space-1) var(--space-2); }
.gr-site option:checked { background: var(--gold); color: var(--on-gold); }
.gr-site label.gr-check { flex-direction: row; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; font-family: var(--font-body); font-size: 16px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); }

/* Grades e linhas de formulário */
.gr-site .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.gr-site .linha { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-bottom: var(--space-4); }
.gr-site .linha > label { flex: 1 1 160px; }
.gr-site .acoes { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }
.gr-site .acoes > label { flex-direction: row; }
.gr-site .acoes input:not([type]) { flex: 1 1 200px; width: auto; }

/* Tabelas */
.gr-site .tabela-wrap { overflow-x: auto; margin: 0 calc(var(--space-2) * -1); }
.gr-site table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 15px; }
.gr-site th, .gr-site td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--line-faint); vertical-align: middle; }
.gr-site th { font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); border-bottom-color: var(--line); white-space: nowrap; }
.gr-site td { font-variant-numeric: tabular-nums; }
.gr-site tbody tr:last-child td { border-bottom: 0; }
.gr-site tr.clicavel { cursor: pointer; }
.gr-site tr.clicavel:hover td, .gr-site tr.clicavel:focus-visible td { background: var(--lavagem); color: var(--gold-bright); }
.gr-site .paginacao { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-4); font-size: 14px; color: var(--ink-muted); }

/* Etiquetas de estado: placa chanfrada com um ◆, sempre com texto */
.gr-site .badge {
  --tom: var(--ink-muted);
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px 10px; font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; line-height: 16px; text-transform: uppercase; white-space: nowrap;
  color: var(--tom); background: color-mix(in srgb, var(--tom) 14%, var(--surface-200));
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 6px 100%, 0 50%);
}
.gr-site .badge::before { content: ""; width: 5px; height: 5px; background: currentColor; transform: rotate(45deg); flex: none; }
.gr-site .badge.ok { --tom: var(--success); }
.gr-site .badge.erro { --tom: var(--danger); }
.gr-site .badge.atencao { --tom: var(--gold-bright); }
.gr-site .badge.info { --tom: var(--ink); }

/* Avisos (sucesso, erro, atenção, informação): lavagem na cor do estado */
.gr-site .msg, .gr-site .aviso {
  --tom: var(--line-strong);
  margin-bottom: var(--space-3); padding: var(--space-3) var(--space-4);
  font-size: 15px; line-height: 22px; color: var(--ink);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tom) 16%, transparent), transparent 80%), var(--surface-200);
  border-left: 2px solid var(--tom);
}
.gr-site .msg.ok, .gr-site .aviso.ok { --tom: var(--success); }
.gr-site .msg.erro, .gr-site .aviso.erro { --tom: var(--danger); }
.gr-site .aviso.atencao { --tom: var(--gold); }

/* Blocos de texto, vazio e carregando */
.gr-site .detalhe, .gr-site .resposta { white-space: pre-wrap; word-break: break-word; margin: var(--space-2) 0; padding: var(--space-3); font-family: var(--font-body); font-size: 16px; line-height: 24px; background: var(--surface-0); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.gr-site .vazio { padding: var(--space-8) var(--space-4); text-align: center; font-family: var(--font-body); font-style: italic; color: var(--ink-muted); border: 1px dashed var(--line); }
.gr-site .carregando { color: var(--ink-muted); font-style: italic; }
.gr-site .chips { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0; }

/* O atributo hidden sempre esconde, mesmo em componente com display próprio (gr-btn, gr-check) */
.gr-site [hidden] { display: none !important; }

/* Campo com vários controles (lista de caixas, Sim/Não, cor): o mesmo rótulo do campo, num div com role="group" */
.gr-site .gr-grupo { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.gr-site .gr-grupo__rotulo { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.gr-site .gr-grupo > .muted { font-family: var(--font-body); font-size: 14px; }
/* Lista de caixas de seleção (escolher vários): gr-check em coluna, numa caixa com rolagem */
.gr-site .gr-checklist {
  display: grid; align-content: start; max-height: 220px; overflow-y: auto; padding: var(--space-1) var(--space-3);
  background: var(--surface-200); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  font-family: var(--font-body); font-size: 16px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink);
}
.gr-site .gr-checklist label.gr-check { margin: var(--space-1) 0; }
.gr-site .gr-checklist .vazio { padding: var(--space-3); border: 0; }
/* Escolha única em linha (Sim / Não): rádios gr-check lado a lado */
.gr-site .gr-opcoes { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.gr-site .gr-opcoes label.gr-check { margin: var(--space-1) 0; }

/* Cor: amostra clicável (abre o seletor de cor do navegador) ao lado do código #RRGGBB */
.gr-site .gr-cor { display: flex; gap: var(--space-2); align-items: stretch; }
.gr-site .gr-cor input[type="color"] {
  flex: none; width: 44px; min-height: 40px; padding: 3px; cursor: pointer;
  background: var(--surface-200); border: 1px solid var(--line-strong);
}
.gr-site .gr-cor input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.gr-site .gr-cor input[type="color"]::-webkit-color-swatch { border: 0; }
.gr-site .gr-cor input[type="color"]::-moz-color-swatch { border: 0; }
.gr-site .gr-cor input[type="color"]:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 14px var(--gold-wash); }
.gr-site .gr-cor .gr-input { flex: 1 1 auto; font-family: var(--font-ui); font-variant-numeric: tabular-nums; }

/* Prévia de mensagem do Discord: como o Monstro vai publicar (texto, embed com a cor dele e botão de link).
   A cor do embed vem em --cor-embed, definida pelo JS (a CSP não deixa estilo inline em atributo). */
.gr-site .gr-previa-discord {
  --cor-embed: var(--gold);
  display: grid; grid-template-columns: 40px 1fr; gap: var(--space-1) var(--space-3); margin: var(--space-3) 0; padding: var(--space-3) var(--space-4);
  background: var(--surface-0); border: 1px solid var(--line); font-family: var(--font-body); font-size: 15px; line-height: 22px; color: var(--ink);
}
.gr-site .gr-previa-discord__avatar { grid-row: span 2; width: 40px; height: 40px; border-radius: var(--radius-pill); object-fit: cover; background: var(--surface-200); }
.gr-site .gr-previa-discord__autor { font-family: var(--font-ui); font-weight: 700; color: var(--gold-bright); }
.gr-site .gr-previa-discord__autor small { margin-left: var(--space-2); font-weight: 400; font-size: 12px; color: var(--ink-muted); }
.gr-site .gr-previa-discord__corpo { display: grid; gap: var(--space-2); min-width: 0; }
.gr-site .gr-previa-discord__texto { white-space: pre-wrap; word-break: break-word; }
.gr-site .gr-previa-discord__mencao { padding: 0 2px; color: var(--gold-bright); background: var(--gold-wash); }
.gr-site .gr-previa-discord__embed {
  display: grid; gap: var(--space-2); max-width: 520px; padding: var(--space-3) var(--space-4);
  background: var(--surface-200); border-left: 4px solid var(--cor-embed);
}
.gr-site .gr-previa-discord__titulo { font-family: var(--font-ui); font-weight: 700; color: var(--ink); }
.gr-site .gr-previa-discord__imagem { max-width: 100%; max-height: 260px; object-fit: contain; justify-self: start; }
.gr-site .gr-previa-discord__rodape { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.gr-site .gr-previa-discord__botao {
  justify-self: start; padding: var(--space-1) var(--space-4); font-family: var(--font-ui); font-size: 14px;
  color: var(--ink); background: var(--surface-200); border: 1px solid var(--line-strong);
}
.gr-site .gr-previa-discord__botao::after { content: " ↗"; color: var(--ink-muted); }
.gr-site .gr-previa-discord__nota { grid-column: 1 / -1; font-size: 13px; font-style: italic; color: var(--ink-muted); }

@media (prefers-reduced-motion: reduce) {
  .gr-site tr.clicavel td { transition: none; }
}
