/* ============================================================================
   Painel Rubinho AUTOMOB — design system
   Direção: precisão automotiva / industrial refinado.
   Petrol-navy da marca + papel quente + faísca âmbar. Tipografia geométrica.
   ============================================================================ */

:root {
  /* marca (petrol-navy do logo AUTOMOB) */
  --brand:        #13323f;
  --brand-deep:   #0d242d;
  --brand-soft:   #1c4756;
  --brand-tint:   #eaf0f1;

  /* faísca */
  --amber:        #e2902f;
  --amber-deep:   #c2741a;

  /* superfícies */
  --paper:        #f1eee7;   /* fundo da página, papel quente */
  --paper-2:      #e9e5db;
  --surface:      #ffffff;
  --line:         #e0dccf;
  --line-strong:  #cdc7b6;

  /* texto */
  --ink:          #16303a;
  --ink-soft:     #5b6a70;
  --ink-faint:    #6a7470;   /* >= 4.5:1 sobre o paper (AA) */

  /* sinais */
  --ok:           #2f8f5b;
  --ok-bg:        #e3f3ea;
  --off:          #b23b3b;
  --off-bg:       #f7e6e4;

  --radius:       10px;
  --radius-sm:    7px;
  --shadow:       0 1px 2px rgba(13,36,45,.05), 0 8px 24px -12px rgba(13,36,45,.18);
  --shadow-lift:  0 2px 6px rgba(13,36,45,.08), 0 18px 40px -18px rgba(13,36,45,.30);

  --font-display: "Archivo", system-ui, sans-serif;
  --font-body:    "IBM Plex Sans", system-ui, sans-serif;
  --sidebar-w:    248px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* atmosfera de fundo: textura sutil de grid + leve vinheta de cor */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1200px 600px at 78% -10%, rgba(19,50,63,.06), transparent 60%),
    linear-gradient(rgba(19,50,63,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19,50,63,.025) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  pointer-events: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--brand);
  letter-spacing: -.015em;
  line-height: 1.1;
  margin: 0 0 .35em;
}
h1 { font-size: clamp(1.6rem, 2.4vw, 2.15rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p  { margin: 0 0 1rem; }
a  { color: var(--brand-soft); text-decoration: none; }
a:hover { color: var(--amber-deep); }
code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .85em;
  background: var(--brand-tint);
  color: var(--brand);
  padding: .1em .4em;
  border-radius: 4px;
}
small { color: var(--ink-soft); }

/* ===================== shell: sidebar + conteúdo ====================== */

/* BASE = MOBILE: conteúdo ocupa tudo; a sidebar é um drawer fora da tela */
.app-shell { min-height: 100dvh; }

.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #cdd9dd;
  padding: 1.4rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  width: min(82vw, 300px);
  height: 100dvh;
  z-index: 60;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .25s ease;
}
.app-shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lift); }

/* botão hambúrguer (topbar mobile) + backdrop do drawer */
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; flex: none;
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); color: var(--brand); cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; }
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(13,36,45,.45);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.app-shell.nav-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .sidebar, .drawer-backdrop { transition: none; }
}
/* marca-d'água do mark no rodapé da sidebar */
.sidebar::after {
  content: "";
  position: absolute;
  bottom: -60px;
  right: -50px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(226,144,47,.10), transparent 70%);
  pointer-events: none;
}

.brand-logo {
  display: block;
  padding: .2rem .4rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo img {
  width: 100%;
  max-width: 168px;
  /* logo é navy sobre transparente -> deixa branco na sidebar escura */
  filter: brightness(0) invert(1);
  opacity: .96;
}
.brand-sub {
  font-family: var(--font-display);
  font-size: .66rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--amber);
  margin-top: .55rem;
  padding-left: .45rem;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .7rem;
  border-radius: var(--radius-sm);
  color: #b7c5ca;
  font-weight: 500;
  font-size: .92rem;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
  background: rgba(226,144,47,.12);
  color: #fff;
  border-left-color: var(--amber);
}
.nav a.active svg { opacity: 1; color: var(--amber); }

.sidebar-foot { margin-top: auto; font-size: .78rem; color: #7c8e94; }
.sidebar-foot .who { color: #d4dee1; font-weight: 600; }
.sidebar-foot .role {
  display: inline-block;
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  background: rgba(255,255,255,.08);
  padding: .12rem .45rem;
  border-radius: 20px;
  margin-left: .3rem;
}
.sidebar-foot form { margin: .7rem 0 0; }

/* topbar + conteúdo */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(241,238,231,.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .eyebrow {
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
main.page { padding: 1.25rem 1rem 2.5rem; max-width: 100%; width: 100%; }

/* tablet */
@media (min-width: 640px) {
  .topbar { padding: .9rem 1.5rem; }
  main.page { padding: 1.5rem 1.5rem 3rem; }
}
/* DESKTOP: a sidebar fixa volta, drawer/hambúrguer somem */
@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    position: sticky; top: 0; height: 100vh; width: auto;
    transform: none; z-index: auto; overflow: hidden; box-shadow: none;
  }
  .nav-toggle, .drawer-backdrop { display: none; }
  .topbar { padding: 1.1rem 2.2rem; }
  main.page { padding: 2rem 2.2rem 3rem; max-width: 1180px; }
}

/* ===================== componentes ====================== */

article, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin: 0 0 1.2rem;
  box-shadow: var(--shadow);
}
article header { margin-bottom: .8rem; }
hgroup { margin-bottom: 1.6rem; }
hgroup p { color: var(--ink-soft); margin: 0; }

/* mobile-first: 1 coluna; multi-coluna a partir de 640px */
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
}
.grid.cols-2 { grid-template-columns: 1fr; }
@media (min-width: 480px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

/* botões */
button, a[role="button"], .btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .86rem;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .58rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
  text-decoration: none;
  line-height: 1.2;
}
button:hover, a[role="button"]:hover, .btn:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: #fff;
  box-shadow: var(--shadow);
}
button:active, a[role="button"]:active { transform: translateY(1px); }

/* secundário / outline (Pico-compat) */
.secondary, button.secondary, a[role="button"].secondary {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line-strong);
}
.secondary:hover, button.secondary:hover, a[role="button"].secondary:hover {
  background: var(--brand-tint);
  color: var(--brand);
  border-color: var(--brand-soft);
}
.outline, button.outline, a[role="button"].outline {
  background: transparent;
  color: var(--brand);
  border-color: var(--line-strong);
}
.outline:hover, button.outline:hover, a[role="button"].outline:hover {
  background: var(--brand-tint);
  border-color: var(--brand-soft);
  color: var(--brand);
}
.contrast, button.contrast, a[role="button"].contrast {
  background: var(--amber);
  border-color: var(--amber);
  color: #1c1206;
}
.contrast:hover, button.contrast:hover { background: var(--amber-deep); border-color: var(--amber-deep); color:#fff; }

/* CTA âmbar reservado pra ação principal pontual */
.btn-amber { background: var(--amber); border-color: var(--amber); color: #1c1206; }
.btn-amber:hover { background: var(--amber-deep); border-color: var(--amber-deep); color: #fff; }

/* formulários */
label { display: block; font-weight: 600; color: var(--ink); margin-bottom: .9rem; font-size: .9rem; }
input, select, textarea {
  font-family: var(--font-body);
  font-size: .95rem;
  width: 100%;
  margin-top: .35rem;
  padding: .58rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(28,71,86,.15);
}
input[type="search"] { min-width: 200px; }
textarea { resize: vertical; line-height: 1.5; }

/* tabelas */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  text-align: left;
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--line-strong);
}
tbody td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--brand-tint); }

/* ações compactas dentro de tabela */
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
td button, td a[role="button"], td .btn { padding: .38rem .7rem; font-size: .78rem; }
td input, td select { margin-top: 0; padding: .4rem .55rem; font-size: .85rem; }

/* status: ins=ativo, del=inativo viram chips */
ins, del { text-decoration: none; font-weight: 600; font-size: .78rem;
  padding: .18rem .55rem; border-radius: 20px; display: inline-block; }
ins  { color: var(--ok);  background: var(--ok-bg); }
del  { color: var(--off); background: var(--off-bg); }

/* utilidades de layout (compat com os módulos) */
.nav-bar { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.nav-bar .spacer, .spacer { flex: 1; }

/* flash / avisos */
.flash {
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
  border-left: 3px solid var(--brand-soft);
  color: var(--brand);
  margin-bottom: 1rem;
  font-size: .92rem;
}
.flash.error { background: var(--off-bg); border-left-color: var(--off); color: #7d2222; }

details summary { cursor: pointer; color: var(--ink-soft); }

/* ===================== usuários: convite, avatar, chips, ações ============ */
/* bloco do link de convite gerado: input mono + botão copiar colado */
.copy-group { display: flex; margin-top: .4rem; }
.copy-group input {
  flex: 1; margin-top: 0; border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--paper); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .82rem;
}
.copy-group .btn-copy { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; min-width: 104px; }
.btn-copy.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.invite-meta { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .76rem;
  color: var(--ink-faint); margin-top: .4rem; }

/* avatar com iniciais */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--brand-soft); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: .72rem;
}
.user-cell { display: flex; align-items: center; gap: .65rem; }
.user-cell .nome { font-weight: 600; color: var(--ink); }
.user-cell .email { font-size: .8rem; color: var(--ink-soft); }

/* chip de papel */
.chip-role {
  display: inline-block; font-family: var(--font-display); font-weight: 600;
  font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
  padding: .14rem .5rem; border-radius: 20px; border: 1px solid var(--line-strong); color: var(--ink-soft);
}
.chip-role.admin { border-color: var(--brand-soft); color: var(--brand); background: var(--brand-tint); }
.chip-you {
  display: inline-block; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); border: 1px solid var(--line); border-radius: 20px; padding: .08rem .4rem;
  margin-left: .4rem;
}
tr.is-you { box-shadow: inset 3px 0 0 var(--amber); }

/* disclosure de ações por linha ("Gerenciar") */
.row-menu { position: relative; }
.row-menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--font-display); font-weight: 600; font-size: .78rem;
  padding: .38rem .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--brand); background: var(--surface);
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--brand-tint); border-color: var(--brand-soft); }
.row-menu .menu-pop {
  position: absolute; right: 0; z-index: 20; margin-top: .35rem; width: 300px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: .9rem; text-align: left;
}
.menu-pop .menu-sec { padding: .5rem 0; border-top: 1px solid var(--line); }
.menu-pop .menu-sec:first-child { border-top: 0; padding-top: 0; }
.menu-pop .menu-lbl { font-family: var(--font-display); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: .4rem; display: block; }

/* seção de criar-direto (disclosure secundário) */
details.bloco > summary {
  cursor: pointer; color: var(--brand-soft); font-weight: 600; font-size: .9rem;
  list-style: none; padding: .2rem 0;
}
details.bloco > summary::-webkit-details-marker { display: none; }
details.bloco > summary::before { content: "+ "; color: var(--amber); font-weight: 700; }
details.bloco[open] > summary::before { content: "− "; }

/* ===================== senha: olhinho + checklist ====================== */
.pwd-wrap { position: relative; display: block; margin-top: .35rem; }
.pwd-wrap input { padding-right: 2.4rem; margin-top: 0; }
.pwd-eye {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; min-width: 0; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; box-shadow: none; cursor: pointer;
  color: var(--ink-faint); line-height: 0;
}
.pwd-eye:hover { background: none; box-shadow: none; color: var(--brand); }
.pwd-eye svg { width: 17px; height: 17px; }
.pwd-eye .i-eyeoff { display: none; }
.pwd-eye.show .i-eye { display: none; }
.pwd-eye.show .i-eyeoff { display: inline; }

.pwd-rules { list-style: none; padding: 0; margin: .6rem 0 1rem; display: grid; gap: .25rem; }
.pwd-rules li {
  font-size: .82rem; color: var(--ink-faint); display: flex; align-items: center; gap: .45rem;
}
.pwd-rules li::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line-strong); background: transparent;
  transition: background .15s, border-color .15s;
}
.pwd-rules li.ok { color: var(--ok); }
.pwd-rules li.ok::before {
  background: var(--ok); border-color: var(--ok);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-size: 11px; background-repeat: no-repeat; background-position: center;
}

/* ===================== login (split hero) ====================== */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth-hero {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #dbe6e9;
  padding: 3.5rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero::after {
  content: "";
  position: absolute;
  width: 460px; height: 460px;
  right: -160px; bottom: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(226,144,47,.18), transparent 65%);
}
.auth-hero img.logo { width: 220px; filter: brightness(0) invert(1); }
.auth-hero .tagline { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800;
  line-height: 1.12; color: #fff; max-width: 18ch; letter-spacing: -.02em; }
.auth-hero .tagline span { color: var(--amber); }
.auth-hero .foot { font-size: .8rem; color: #87999f; letter-spacing: .04em; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--paper); }
.auth-form .box { width: 100%; max-width: 360px; }
.auth-form h1 { margin-bottom: .2rem; }
.auth-form .lead { color: var(--ink-soft); margin-bottom: 1.6rem; }
.auth-form button[type="submit"] { width: 100%; padding: .7rem; margin-top: .4rem; }

@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* ===================== animação de entrada ====================== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
main.page > * { animation: fadeUp .4s ease both; }
main.page > *:nth-child(2) { animation-delay: .05s; }
main.page > *:nth-child(3) { animation-delay: .1s; }
main.page > *:nth-child(4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { main.page > * { animation: none; } }

/* ===================== editor markdown (EasyMDE) ====================== */
.EasyMDEContainer .CodeMirror {
  border-color: var(--line-strong);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .9rem; color: var(--ink); background: var(--surface);
}
.editor-toolbar {
  border-color: var(--line-strong);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--paper-2);
}
.editor-toolbar button { color: var(--ink-soft) !important; }
.editor-toolbar button.active, .editor-toolbar button:hover {
  background: var(--brand-tint); border-color: var(--line-strong);
}
.editor-toolbar i.separator { border-color: var(--line-strong); }
.editor-preview, .editor-preview-side { background: var(--paper); font-family: var(--font-body); }
.editor-preview h1, .editor-preview h2, .editor-preview-side h1, .editor-preview-side h2 { color: var(--brand); }
.EasyMDEContainer .editor-statusbar { color: var(--ink-faint); }

/* ===================== conversas (chat) ====================== */
.chat { display: flex; flex-direction: column; gap: .8rem; max-width: 820px; }
.msg { display: flex; gap: .6rem; align-items: flex-end; }
.msg .av {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .7rem;
}
.msg .bubble {
  padding: .65rem .9rem; border-radius: 16px; max-width: 76%;
  box-shadow: var(--shadow); font-size: .95rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.msg .bubble .who {
  display: block; font-family: var(--font-display); font-size: .64rem;
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: .25rem; opacity: .7;
}
/* lead à esquerda */
.msg.lead .av { background: var(--brand); color: #fff; }
.msg.lead .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
/* Rubinho à direita */
.msg.bot { flex-direction: row-reverse; }
.msg.bot .av { background: var(--amber); color: #1c1206; }
.msg.bot .bubble { background: var(--brand); color: #e9f1f3; border-bottom-right-radius: 5px; }
.msg.bot .bubble .who { color: var(--amber); }
/* ferramenta / sistema: faixa central discreta */
.msg.tool { justify-content: center; }
.msg.tool .bubble {
  background: var(--brand-tint); color: var(--brand);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .8rem;
  max-width: 92%; box-shadow: none; border: 1px dashed var(--line-strong);
}
.msg.tool summary {
  cursor: pointer; color: var(--ink-soft); list-style: none;
  font-size: .76rem; letter-spacing: .02em;
}
.msg.tool summary::before { content: "🔧 "; }
.msg.tool .tool-body { margin-top: .5rem; white-space: pre-wrap; }

/* stat cards (home) */
.stat { position: relative; overflow: hidden; }
.stat .num { font-family: var(--font-display); font-size: clamp(2.1rem, 7vw, 2.6rem);
  font-weight: 800; color: var(--brand); line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-size: .9rem; }
.stat .ic { position: absolute; top: 1rem; right: 1rem; color: var(--amber); opacity: .9; }
.stat.tile .num { font-size: 1.25rem; }

/* ============================================================================
   ACESSIBILIDADE GLOBAL
   ============================================================================ */
:where(a, button, summary, [role="button"], input, select, textarea):focus-visible {
  outline: 2px solid var(--amber-deep);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================================
   MOBILE (<= 639px) — ajustes finos por componente
   ============================================================================ */
@media (max-width: 639.98px) {
  /* inputs 16px: evita o zoom automático do Safari iOS ao focar */
  input, select, textarea { font-size: 16px; }

  /* cards um pouco mais justos pra ganhar largura útil */
  article, .card { padding: 1.1rem 1rem; }

  /* alvos de toque confortáveis (>= 44px) */
  button, a[role="button"], .btn { min-height: 44px; }
  .nav a { padding: .8rem .7rem; }
  .row-menu > summary, details.bloco > summary { min-height: 44px; display: inline-flex; align-items: center; }

  /* ---- TABELAS viram cards empilhados (.table-stack) ---- */
  .table-stack thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .35rem .9rem .6rem; margin: 0 0 .8rem;
  }
  .table-stack tr:hover { background: var(--surface); }
  .table-stack td {
    border: 0; border-bottom: 1px solid var(--line);
    padding: .55rem 0; display: grid; grid-template-columns: 8.5rem 1fr;
    gap: .5rem; align-items: center; justify-items: start; text-align: left;
  }
  .table-stack td:last-child { border-bottom: 0; }
  .table-stack td::before {
    content: attr(data-label);
    font-family: var(--font-display); font-size: .64rem; letter-spacing: .1em;
    text-transform: uppercase; color: var(--ink-faint);
  }
  .table-stack td.cell-head { grid-template-columns: 1fr; border-bottom: 1px solid var(--line-strong); padding-top: .2rem; }
  .table-stack td.cell-head::before { display: none; }
  .table-stack td.cell-action { grid-template-columns: 1fr; padding-top: .7rem; }
  .table-stack td.cell-action::before { display: none; }
  .table-stack td.cell-action > *, .table-stack td.cell-action .row-actions { width: 100%; }
  .table-stack td.cell-action .row-actions { display: flex; gap: .5rem; }
  .table-stack td.cell-action .row-actions > * { flex: 1; }

  /* ---- menu "Gerenciar" vira bottom-sheet ---- */
  .row-menu .menu-pop {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; margin: 0;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0;
    max-height: 85vh; overflow-y: auto; z-index: 1000;
    padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lift); animation: sheetUp .22s ease both;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
  .row-menu[open] > summary::after {
    content: ""; position: fixed; inset: 0; background: rgba(13,36,45,.45); z-index: 999;
  }
  .row-menu .menu-pop::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 2px;
    background: var(--line-strong); margin: -.3rem auto .8rem;
  }

  /* ---- filtros/paginação e copy-group empilhados ---- */
  .nav-bar .spacer { display: none; }
  input[type="search"] { min-width: 0; }
  .copy-group { flex-direction: column; }
  .copy-group input { border-right: 1px solid var(--line-strong); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .copy-group .btn-copy { width: 100%; min-width: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

  /* ações de card (conhecimento) full-width */
  article .nav-bar { flex-direction: column; align-items: stretch; gap: .55rem; }
  article .nav-bar > a[role="button"], article .nav-bar > form, article .nav-bar > form button { width: 100%; }

  /* ---- senha: olhinho com alvo cheio ---- */
  .pwd-wrap input { padding-right: 2.9rem; }
  .pwd-eye { top: 0; right: 0; bottom: 0; height: auto; width: 44px; }
  .pwd-eye svg { width: 19px; height: 19px; }
  .pwd-rules li { font-size: .9rem; }

  /* ---- EasyMDE: toolbar quebra linha, esconde side-by-side ---- */
  .editor-toolbar { flex-wrap: wrap; padding: 4px 2px; }
  .editor-toolbar button { width: 40px; height: 38px; margin: 0; }
  .editor-toolbar button.side-by-side { display: none; }
  .EasyMDEContainer .CodeMirror { font-size: .92rem; min-height: 300px; }
  .editor-preview, .editor-preview-side { padding: .8rem 1rem; font-size: .95rem; }

  /* ---- chat: bolhas mais largas + tool à prova de overflow ---- */
  .chat { gap: .6rem; }
  .msg { gap: .4rem; }
  .msg .av { width: 26px; height: 26px; font-size: .6rem; }
  .msg .bubble { max-width: 86%; padding: .55rem .75rem; font-size: .92rem; }
  .msg.tool .bubble { max-width: 100%; }
  .msg.tool .tool-body { overflow-wrap: anywhere; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---- auth (login/cadastro): respiro + box mais largo ---- */
  .auth-form { padding: 1.5rem 1.25rem; align-items: flex-start; }
  .auth-form .box { max-width: 460px; }

  /* botões de formulário (Salvar/Cancelar) full-width */
  main.page form .nav-bar > button[type="submit"],
  main.page form .nav-bar > a[role="button"] { flex: 1; }
}

/* logo da marca no topo do form de auth (some o hero no mobile) */
.auth-logo-mobile { display: none; }
@media (max-width: 759.98px) {
  .auth-logo-mobile { display: block; width: 150px; margin: 0 auto 1.4rem; }
}
