/* =========================================================
   Kit visual das demos — minimalista preto e branco
   ========================================================= */
:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b6b66;
  --line: #e2e2dc;
  --soft: #ececE6;
  --ok: #1f7a4d;
  --warn: #9a6400;
  --danger: #b42318;
  --radius: 14px;
  --f-display: "Space Grotesk", system-ui, sans-serif;
  --f-body: "Inter", system-ui, sans-serif;
  --f-serif: "Instrument Serif", Georgia, serif;
  --ease: cubic-bezier(.76, 0, .24, 1);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
}
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #121212;
  --fg: #f2f2ee;
  --muted: #8f8f88;
  --line: #262624;
  --soft: #1a1a19;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--f-body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px; /* espaço da barra de assinatura */
  min-height: 100vh;
}
a { color: inherit; }
[hidden] { display: none !important; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
em { font-family: var(--f-serif); font-style: italic; font-weight: 400; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 4px; }

.kd-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.kd-center { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.kd-muted { color: var(--muted); }
.kd-small { font-size: 13px; }
.kd-sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kd-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.kd-logo { width: 28px; height: 28px; stroke: currentColor; stroke-width: 3.5; stroke-linecap: square; flex: none; }

/* ---------- Tipografia ---------- */
.kd-h1 { font-family: var(--f-display); font-weight: 500; font-size: clamp(32px, 5vw, 56px); line-height: 1; letter-spacing: -.04em; }
.kd-h2 { font-family: var(--f-display); font-weight: 500; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.1; letter-spacing: -.03em; }
.kd-h3 { font-family: var(--f-display); font-weight: 500; font-size: 18px; letter-spacing: -.02em; }
.kd-eyebrow { font-family: var(--f-display); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- Topbar ---------- */
.kd-topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.kd-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.kd-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--f-display); font-weight: 600; font-size: 18px; letter-spacing: -.02em; }
.kd-brand__mark { width: 30px; height: 30px; border-radius: 8px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font-size: 14px; }
.kd-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kd-nav a { text-decoration: none; padding: 8px 12px; border-radius: 100px; font-size: 14px; color: var(--muted); transition: background .3s, color .3s; }
.kd-nav a:hover, .kd-nav a[aria-current="page"] { color: var(--fg); background: var(--soft); }

/* ---------- Botões ---------- */
.kd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 100px; border: 1px solid var(--fg);
  background: var(--fg); color: var(--bg); text-decoration: none; cursor: pointer;
  font-family: var(--f-display); font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: opacity .3s, background .3s, color .3s;
}
.kd-btn:hover { opacity: .85; }
.kd-btn:disabled { opacity: .4; cursor: not-allowed; }
.kd-btn--ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.kd-btn--ghost:hover { border-color: var(--fg); opacity: 1; }
.kd-btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.kd-btn--block { width: 100%; }
.kd-btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---------- Formulários ---------- */
.kd-form { display: grid; gap: 16px; }
.kd-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kd-field { display: grid; gap: 6px; }
.kd-field label, .kd-label { font-size: 13px; font-weight: 500; }
.kd-input, .kd-select, .kd-textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color .3s, box-shadow .3s; font-size: 16px; /* 16px evita zoom no iOS */
}
.kd-textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.kd-input:focus, .kd-select:focus, .kd-textarea:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 8%, transparent); }
.kd-field.has-error .kd-input, .kd-field.has-error .kd-select { border-color: var(--danger); }
.kd-error-text { color: var(--danger); font-size: 13px; }
.kd-help { font-size: 12px; color: var(--muted); }
.kd-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; }
.kd-consent input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--fg); flex: none; }
.kd-consent a { color: var(--fg); }

/* ---------- Superfícies ---------- */
.kd-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.kd-card--flat { box-shadow: none; }
.kd-grid { display: grid; gap: 16px; }
/* 4 indicadores: 4 colunas, 2×2 em telas médias e pequenas (nunca sobra um card sozinho) */
.kd-stats { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .kd-stats { gap: 10px; }
  .kd-stats .kd-stat { padding: 14px; }
  .kd-stats .kd-stat__value { font-size: 16px; white-space: nowrap; letter-spacing: -.02em; }
  .kd-stats .kd-stat__meta { font-size: 11px; }
}
.kd-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.kd-stat__label { font-size: 13px; color: var(--muted); }
.kd-stat__value { font-family: var(--f-display); font-size: 28px; font-weight: 500; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kd-stat__meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tabela ---------- */
/* position:relative prende elementos absolutos (ex.: .kd-sr) dentro da rolagem */
.kd-table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.kd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kd-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.kd-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.kd-table tr:last-child td { border-bottom: 0; }
.kd-table tbody tr { transition: background .2s; }
.kd-table tbody tr:hover { background: var(--bg); }
.kd-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Badges ---------- */
.kd-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 100px; font-size: 12px; font-weight: 500; background: var(--soft); white-space: nowrap; }
.kd-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.kd-badge--ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.kd-badge--warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.kd-badge--danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.kd-badge--dark { color: var(--bg); background: var(--fg); }

/* ---------- Mensagens ---------- */
.kd-flashes { display: grid; gap: 8px; margin: 16px 0; }
.kd-flash { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; animation: kdIn .4s ease; }
.kd-flash--success { border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.kd-flash--error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
@keyframes kdIn { from { opacity: 0; } to { opacity: 1; } }
.kd-empty { text-align: center; padding: 48px 20px; color: var(--muted); }

/* ---------- Painel (layout com sidebar) ---------- */
.kd-panel { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.kd-side { background: var(--fg); color: var(--bg); padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.kd-side .kd-brand__mark { background: var(--bg); color: var(--fg); }
.kd-side nav { display: grid; gap: 4px; }
.kd-side nav a { text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 14px; opacity: .65; transition: opacity .3s, background .3s; }
.kd-side nav a:hover, .kd-side nav a[aria-current="page"] { opacity: 1; background: rgba(255,255,255,.08); }
.kd-side__user { margin-top: auto; font-size: 13px; opacity: .7; }
.kd-side__logout { background: none; border: 0; padding: 4px 0; color: inherit; cursor: pointer; text-decoration: underline; font: inherit; }
.kd-main { padding: 28px clamp(16px, 3vw, 40px); min-width: 0; }
.kd-main__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
@media (max-width: 860px) {
  .kd-panel { grid-template-columns: 1fr; }
  .kd-side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 14px 16px; gap: 12px; }
  .kd-side nav { display: flex; flex-wrap: wrap; }
  .kd-side__user { margin: 0 0 0 auto; }
}

/* ---------- Login dos painéis ---------- */
.kd-login { width: min(420px, 100%); display: grid; gap: 20px; }
.kd-login__demo { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 8px; justify-items: start; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 2px 6px; border-radius: 6px; }

/* ---------- Assinatura (sempre visível) ---------- */
.kd-sign {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 14px; border-radius: 100px;
  background: #0a0a0a; color: #f2f2ee; border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font-family: var(--f-display); font-size: 13px; white-space: nowrap;
  max-width: calc(100vw - 24px);
}
.kd-sign__brand { display: flex; align-items: center; gap: 8px; text-decoration: none; padding-right: 6px; }
.kd-sign__brand .kd-logo { width: 22px; height: 22px; stroke-width: 4; }
.kd-sign__brand strong { font-weight: 600; }
.kd-sign__sep { width: 1px; height: 18px; background: rgba(255,255,255,.18); margin: 0 4px; }
.kd-sign__link { background: none; border: 0; cursor: pointer; text-decoration: none; padding: 7px 10px; border-radius: 100px; color: rgba(242,242,238,.75); transition: background .3s, color .3s; font: inherit; }
.kd-sign__link:hover { background: rgba(255,255,255,.1); color: #fff; }
.kd-sign__reset { display: contents; }
.kd-sign__info { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: none; color: inherit; cursor: pointer; flex: none; }
.kd-sign__note {
  position: absolute; bottom: calc(100% + 10px); right: 0; width: min(340px, calc(100vw - 24px));
  background: #0a0a0a; color: #f2f2ee; border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  padding: 16px; white-space: normal; font-family: var(--f-body); font-size: 13px; line-height: 1.5;
  display: grid; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.kd-sign__note a { color: #fff; }
@media (max-width: 560px) {
  .kd-sign { bottom: 10px; font-size: 12px; padding-left: 10px; gap: 2px; }
  .kd-hide-sm { display: none !important; }
  .kd-sign__link { padding: 7px 10px; font-size: 15px; }
  .kd-sign__info { width: 28px; height: 28px; }
}

/* ---------- Aviso de cookies ---------- */
.kd-cookies {
  position: fixed; left: 16px; bottom: 76px; z-index: 999; max-width: 380px;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.12); font-size: 13px; display: grid; gap: 12px;
  animation: kdIn .4s ease;
}
.kd-cookies[hidden] { display: none; }
@media (max-width: 560px) { .kd-cookies { left: 10px; right: 10px; bottom: 66px; max-width: none; } }

/* ---------- Página de erro / legal ---------- */
.kd-error { max-width: 480px; text-align: center; display: grid; gap: 16px; }
.kd-error h1 { font-family: var(--f-display); font-weight: 500; letter-spacing: -.03em; }
.kd-legal { max-width: 760px; margin: 0 auto; padding: 48px 20px; }
.kd-legal h1 { margin-bottom: 8px; }
.kd-legal h2 { font-family: var(--f-display); font-weight: 500; font-size: 20px; margin: 32px 0 8px; letter-spacing: -.02em; }
.kd-legal p, .kd-legal li { color: var(--muted); }
.kd-legal ul { padding-left: 20px; display: grid; gap: 4px; }
.kd-legal strong { color: var(--fg); font-weight: 500; }

/* ---------- Dialog ---------- */
/* margin:auto recentraliza o modal (o reset global "* { margin: 0 }" removia isso) */
.kd-dialog { margin: auto; max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--fg); width: min(520px, calc(100vw - 24px)); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.kd-dialog::backdrop { background: rgba(10,10,10,.45); backdrop-filter: blur(2px); }
.kd-dialog[open] { animation: kdIn .3s ease; }
.kd-dialog__head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.kd-dialog__body { padding: 24px; }
.kd-close { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: none; cursor: pointer; font-size: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Menus do topo em celulares: uma linha só, com rolagem lateral se precisar */
@media (max-width: 560px) {
  .kd-topbar .kd-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; min-width: 0; }
  .kd-topbar .kd-nav::-webkit-scrollbar { display: none; }
  .kd-topbar .kd-nav a { white-space: nowrap; padding: 8px 9px; }
  .kd-topbar__inner { gap: 10px; }
}

/* ---------- Preloader (logo do cabeçalho de cada demo) ---------- */
.kd-preloader {
  position: fixed; inset: 0; z-index: 3000;
  display: grid; place-items: center; align-content: center; gap: 22px;
  background: var(--bg); color: var(--fg);
  transition: opacity .55s ease, visibility .55s ease;
  /* segurança sem JavaScript: some sozinho em até 3s */
  animation: kdPreAuto .4s ease 3s forwards;
}
.kd-preloader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.kd-preloader__logo { transform: scale(1.35); animation: kdPreIn .7s cubic-bezier(.16, 1, .3, 1) both; }
.kd-preloader__logo .kd-brand { font-size: 22px; gap: 12px; }
.kd-preloader__logo .kd-brand__mark { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; }
.kd-preloader__bar { width: 120px; height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--fg) 15%, transparent); overflow: hidden; position: relative; }
.kd-preloader__bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--fg); border-radius: 2px; animation: kdPreBar 1s cubic-bezier(.65, 0, .35, 1) infinite; }
.kd-pre-vitrine { font-family: var(--f-display); font-weight: 600; font-size: 30px !important; letter-spacing: -.04em; gap: 0 !important; }
.kd-pre-vitrine em { font-size: 1.2em; }
.kd-pre-lumen { gap: 12px; font-weight: 600; }
.kd-pre-lumen__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 18px 3px rgba(255,255,255,.55); }
.kd-pre-pet svg { width: 40px; height: 40px; color: var(--fg); }
body.kd-preloading { overflow: hidden; }
@keyframes kdPreIn { from { opacity: 0; transform: scale(1.15) translateY(8px); } }
@keyframes kdPreBar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes kdPreAuto { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@media (prefers-reduced-motion: reduce) {
  .kd-preloader__logo { animation: none; }
  .kd-preloader__bar::after { animation: none; width: 100%; opacity: .4; }
}
