/* ===========================================================
   painel — gestão de Instagram (OCTR/otaviom)
   Moldura herdada do portfólio: fundo quase-preto neutro,
   Space Grotesk no UI, IBM Plex Mono nos dados. Uma cor de
   instrumento (--accent) para ação/seleção; verde/vermelho
   são reservados ao veredito e nunca aparecem sem texto.
   Paleta validada (dataviz): #6f88e8 · #2ca584 · #d96a55
   sobre #101014, todas dentro da banda dark L .48–.67.
   =========================================================== */

:root {
  --page: #0a0a0c;
  --panel: #101014;
  --panel-2: #16161b;
  --ink: #efeeea;
  --muted: #a5a29a;
  --faint: #7d7a72;   /* mínimo AA sobre --page para texto pequeno */
  --border: rgba(255, 255, 255, .1);
  --border-soft: rgba(255, 255, 255, .06);
  --accent: #6f88e8;
  --accent-dim: rgba(111, 136, 232, .14);
  --ok: #2ca584;
  --ok-dim: rgba(44, 165, 132, .14);
  --bad: #d96a55;
  --bad-dim: rgba(217, 106, 85, .14);
  --r: 10px;
  --gut: 18px;
  --tabbar-h: 60px;
  /* escala z semântica */
  --z-nav: 40;
  --z-tabbar: 50;
  --z-toast: 60;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: #33322e var(--page);
}

a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 500; margin: 0; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
::selection { background: rgba(255, 255, 255, .18); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

/* números tabulares em qualquer dado */
.num {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: .9375rem;
}

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

/* ===== Login ===== */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gut);
}

.login form {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
}

.login .logo { margin-bottom: 10px; }

.login-erro {
  color: var(--bad);
  font-size: .875rem;
  min-height: 1.2em;
}

/* ===== Shell ===== */
.logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .9375rem;
  letter-spacing: .06em;
}
.logo em { font-style: normal; color: var(--faint); }

header.topo {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--gut);
  background: rgba(10, 10, 12, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px var(--gut) calc(var(--tabbar-h) + 28px);
  display: grid;
  gap: 26px;
}

section[data-view] { display: grid; gap: 22px; align-content: start; }

.view-titulo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.view-titulo .quando { color: var(--faint); font-size: .8125rem; }

/* ===== Tabs =====
   Mobile: barra fixa embaixo (polegar). Desktop: viram nav no topo. */
nav.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-tabbar);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10, 10, 12, .88);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-soft);
}

nav.tabs a {
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
  text-decoration: none;
  font-size: .75rem;
  letter-spacing: .02em;
  color: var(--muted);
  min-height: 44px;
}
nav.tabs a .glifo { font-family: 'IBM Plex Mono', monospace; font-size: 1.05rem; line-height: 1; }
nav.tabs a[aria-current="page"] { color: var(--ink); }
nav.tabs a[aria-current="page"] .glifo { color: var(--accent); }

/* ===== Botões ===== */
.btn {
  font: inherit;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: background-color .18s ease-out, border-color .18s ease-out;
}
.btn:hover { border-color: rgba(255, 255, 255, .22); }
.btn:active { background: var(--panel); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primario {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0c;
}
.btn-primario:hover { background: #7f96ec; border-color: #7f96ec; }
.btn-primario:active { background: #6079e0; }

.btn-fantasma {
  background: none;
  border-color: transparent;
  color: var(--muted);
}
.btn-fantasma:hover { color: var(--ink); border-color: var(--border); }

/* botões de ação rápida do Hoje: alvo de polegar generoso */
.acoes-rapidas { display: grid; gap: 12px; }
.acao {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-height: 64px;
  cursor: pointer;
  transition: border-color .18s ease-out, background-color .18s ease-out;
}
.acao:hover { border-color: var(--accent); }
.acao:active { background: var(--panel-2); }
.acao .glifo {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  font-size: 1.25rem;
}
.acao small { display: block; font-weight: 400; font-size: .8125rem; color: var(--muted); }

/* ===== Painéis e listas ===== */
.bloco {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.bloco > h2, .bloco > h3 { font-size: .9375rem; color: var(--muted); font-weight: 500; }

.lista { display: grid; margin: 0; padding: 0; list-style: none; }
.lista li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 44px;
}
.lista li:last-child { border-bottom: none; }
.lista .principal { min-width: 0; }
.lista .principal .titulo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lista .meta { font-size: .8125rem; color: var(--faint); }
.lista a { text-decoration: none; }

/* linha clicável inteira */
.lista li.link { cursor: pointer; transition: background-color .15s ease-out; }
.lista li.link:hover { background: var(--panel-2); border-radius: 8px; }

/* ===== Fatos (resumo numérico em linha, não grade de KPI) ===== */
.fatos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  padding: 4px 2px;
}
.fatos .fato { display: grid; gap: 2px; }
.fatos .fato .valor { font-size: 1.25rem; }
.fatos .fato .rotulo { font-size: .8125rem; color: var(--muted); }
.delta-pos { color: var(--ok); }
.delta-neg { color: var(--bad); }

/* ===== Badges de veredito: sempre glifo + palavra, nunca só cor ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .8125rem;
  font-weight: 500;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.badge-ok  { color: var(--ok);  background: var(--ok-dim); }
.badge-bad { color: var(--bad); background: var(--bad-dim); }
.badge-pende { color: var(--muted); background: rgba(255, 255, 255, .07); }

/* etiqueta pequena de tipo/objetivo */
.tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 7px;
  white-space: nowrap;
}

/* ===== Gráficos =====
   Barras: um matiz só (magnitude), rótulo direto, ponta 4px,
   vão de 2px garantido pelo gap das linhas. */
.barras { display: grid; gap: 8px; }
.barra { display: grid; grid-template-columns: 82px 1fr 34px; align-items: center; gap: 10px; }
.barra .rotulo { font-size: .8125rem; color: var(--muted); }
.barra .trilho { background: var(--panel-2); border-radius: 4px; height: 12px; }
.barra .fill {
  display: block;
  height: 100%;
  min-width: 4px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}
.barra .valor { text-align: right; font-size: .8125rem; }

/* Sparkline: série única, sem legenda (o título nomeia) */
.spark { display: grid; gap: 6px; }
.spark svg { width: 100%; height: 52px; display: block; }
.spark .linha { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: var(--accent-dim); stroke: none; }
.spark .ponto { fill: var(--accent); }
.spark .grade { stroke: var(--border-soft); stroke-width: 1; }
.spark .extremos {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--faint);
}

/* ===== Kanban (desktop) / lista por status (mobile) ===== */
.kanban { display: grid; gap: 18px; }
.coluna { display: grid; gap: 10px; align-content: start; }
.coluna > h3 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .8125rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .04em;
}
.coluna > h3 .qtd { color: var(--faint); }

.cartao {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: border-color .18s ease-out;
}
.cartao:hover { border-color: var(--border); }
.cartao .titulo { font-weight: 500; }
.cartao .linha-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cartao .data { font-size: .8125rem; color: var(--faint); }

/* mover status sem drag: select nativo dentro do cartão */
.cartao select { margin-top: 2px; }

/* ===== Formulários ===== */
form.form { display: grid; gap: 14px; }
.campo { display: grid; gap: 5px; }
.campo > label { font-size: .875rem; color: var(--muted); }

input, select, textarea {
  font: inherit;
  font-size: 1rem; /* 16px: evita zoom automático no iOS */
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a5a29a' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

fieldset {
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 12px;
  margin: 0;
  display: grid;
  gap: 12px;
}
legend {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .75rem;
  color: var(--faint);
  letter-spacing: .04em;
  padding: 0 6px;
}

.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* segmentado (tipo do post / veredito) */
.segmentado { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmentado label {
  flex: 1;
  text-align: center;
  padding: 10px 6px;
  min-height: 44px;
  display: grid;
  place-content: center;
  font-size: .875rem;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background-color .15s ease-out, color .15s ease-out;
}
.segmentado label:last-child { border-right: none; }
.segmentado input { position: absolute; opacity: 0; pointer-events: none; }
.segmentado input:checked + span { color: var(--ink); }
.segmentado label:has(input:checked) { background: var(--accent-dim); color: var(--ink); }
.segmentado label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ===== Dialog ===== */
dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px var(--gut) calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: none;
  margin: auto 0 0;
  max-height: 88dvh;
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }

dialog .dlg-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
dialog .dlg-topo h2 { font-size: 1.0625rem; }
dialog .dlg-acoes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

/* ===== Estados vazios: ensinam o próximo passo ===== */
.vazio {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 18px 4px;
  color: var(--muted);
  font-size: .9375rem;
}
.vazio .glifo { font-family: 'IBM Plex Mono', monospace; color: var(--faint); }

/* ===== Esqueleto de carregamento (Codex liga depois) ===== */
.esqueleto {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--panel-2) 25%, #1b1b21 45%, var(--panel-2) 65%);
  background-size: 200% 100%;
  animation: brilho 1.4s ease-out infinite;
  min-height: 16px;
  color: transparent;
}
@keyframes brilho { to { background-position: -200% 0; } }

/* ===== Toast ===== */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: .9375rem;
  max-width: min(92vw, 480px);
  transition: opacity .2s ease-out, translate .2s ease-out;
}
#toast[hidden] { display: none; }
#toast.erro { border-color: var(--bad); color: var(--bad); }

/* ===== Desktop ===== */
@media (min-width: 900px) {
  :root { --gut: 28px; }

  nav.tabs {
    position: static;
    display: flex;
    gap: 4px;
    height: auto;
    padding: 0;
    background: none;
    border: none;
    backdrop-filter: none;
  }
  nav.tabs a {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9375rem;
    padding: 8px 14px;
    border-radius: 8px;
    min-height: 0;
  }
  nav.tabs a:hover { color: var(--ink); }
  nav.tabs a[aria-current="page"] { background: var(--panel-2); }

  main { padding-bottom: 48px; }

  .acoes-rapidas { grid-template-columns: 1fr 1fr; }
  .kanban { grid-template-columns: repeat(4, 1fr); }
  .cartao select { display: none; } /* desktop: mover via cartão aberto */

  dialog {
    border-radius: 16px;
    margin: auto;
    width: min(560px, calc(100vw - 48px));
    padding: 24px;
  }
  dialog .dlg-acoes { grid-template-columns: auto auto; justify-content: end; }

  #toast { bottom: 24px; }

  .duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
}

/* ===== Movimento reduzido ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
