/* ASGROWHUB — painel do revendedor. Preto quente e dourado, OKLCH, neutros tingidos para o ouro. */

:root {
  --ink-0: oklch(0.145 0.008 80);
  --ink-1: oklch(0.178 0.010 80);
  --ink-2: oklch(0.212 0.012 80);
  --ink-3: oklch(0.255 0.014 80);
  --line: oklch(0.29 0.014 80);
  --line-strong: oklch(0.37 0.02 82);

  --text: oklch(0.935 0.014 86);
  --text-2: oklch(0.79 0.018 84);
  --text-3: oklch(0.66 0.02 82);

  --gold: oklch(0.82 0.125 84);
  --gold-hi: oklch(0.88 0.12 90);
  --gold-lo: oklch(0.62 0.10 78);
  --gold-ink: oklch(0.2 0.035 75);
  --gold-wash: oklch(0.82 0.125 84 / 0.08);
  --gold-line: oklch(0.82 0.125 84 / 0.38);

  --danger: oklch(0.7 0.16 30);
  --danger-ink: oklch(0.2 0.04 30);
  --danger-wash: oklch(0.7 0.16 30 / 0.1);

  --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --step-4: 3.25rem;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --radius: 6px;
  --radius-lg: 10px;
  --rail-width: 248px;
  --actions-width: 400px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-lift: 0 18px 48px -12px oklch(0.08 0.01 80 / 0.7), 0 2px 6px oklch(0.08 0.01 80 / 0.5);
  --focus: 0 0 0 2px var(--ink-0), 0 0 0 4px var(--gold);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--gold); text-underline-offset: 3px; }
code { font-family: var(--font-mono); }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }

.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;
}

.skip {
  position: absolute; left: var(--s4); top: -100px; z-index: 10;
  background: var(--gold); color: var(--gold-ink); padding: var(--s2) var(--s4); border-radius: var(--radius);
}
.skip:focus { top: var(--s4); }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Marca ---------- */

.wordmark {
  display: inline-flex; align-items: center; gap: var(--s3);
  font-family: var(--font-ui); font-weight: 600; font-size: var(--step-0);
  letter-spacing: 0.22em; color: var(--text);
}
.wordmark__mark { width: 28px; height: 28px; flex: none; }
.wordmark--lg { font-size: var(--step-1); }
.wordmark--lg .wordmark__mark { width: 40px; height: 40px; }

/* ---------- Botões e campos ---------- */

.btn {
  --btn-bg: transparent; --btn-fg: var(--text); --btn-line: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  font: 500 var(--step-0)/1 var(--font-ui);
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-line); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }

.btn--primary { --btn-bg: var(--gold); --btn-fg: var(--gold-ink); font-weight: 600; }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--gold-hi); }

.btn--ghost { --btn-line: var(--line-strong); --btn-fg: var(--text); }
.btn--ghost:hover:not(:disabled) { --btn-line: var(--gold-line); --btn-bg: var(--gold-wash); }

.btn--quiet { --btn-fg: var(--text-2); }
.btn--quiet:hover:not(:disabled) { --btn-fg: var(--text); --btn-bg: var(--ink-3); }

.btn--danger { --btn-bg: var(--danger); --btn-fg: var(--danger-ink); font-weight: 600; }
.btn--danger:hover:not(:disabled) { --btn-bg: oklch(0.75 0.15 30); }
.btn--danger-quiet:hover:not(:disabled) { --btn-fg: var(--danger); --btn-bg: var(--danger-wash); }

.btn--sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--step--1); gap: 6px; }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--block { width: 100%; }

.btn[data-copy-state="done"] { --btn-line: var(--gold-line); --btn-fg: var(--gold); }
.btn[data-copy-state="error"] { --btn-fg: var(--danger); }

.field { display: grid; gap: var(--s2); }
.field__label { font-size: var(--step--1); font-weight: 500; color: var(--text-2); letter-spacing: 0.01em; }

.input {
  width: 100%; min-height: 46px; padding: 0 var(--s4);
  font: 400 var(--step-0)/1.2 var(--font-ui); color: var(--text);
  background: var(--ink-0); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: oklch(0.45 0.03 82); }
.input:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); border-radius: var(--radius); }
.input--sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--step--1); }

.notice {
  display: flex; gap: var(--s2); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--radius); font-size: var(--step--1);
}
.notice--error { color: oklch(0.86 0.07 35); background: var(--danger-wash); border: 1px solid oklch(0.7 0.16 30 / 0.35); }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 0.85fr); }

.login__brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s7);
  padding: var(--s7) clamp(var(--s6), 6vw, 96px);
  background:
    radial-gradient(120% 70% at 0% 100%, oklch(0.82 0.125 84 / 0.11), transparent 60%),
    var(--ink-1);
  border-right: 1px solid var(--line);
}
.login__claim {
  max-width: 15ch;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2.5rem, 4.4vw, 4.25rem); line-height: 1.04; letter-spacing: -0.02em;
  color: var(--text);
}
.login__ledger {
  display: flex; flex-wrap: nowrap; overflow: hidden; gap: var(--s5);
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--gold-lo);
}
.login__ledger span::after { content: '••••••'; color: var(--line-strong); margin-left: 2px; }

.login__panel {
  display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 460px; margin: 0 auto;
  padding: var(--s7) var(--s6);
}
.login__mobile-mark { display: none; margin-bottom: var(--s7); }
.login__title { font-family: var(--font-display); font-weight: 500; font-size: var(--step-3); line-height: 1.1; letter-spacing: -0.015em; }
.login__lead { margin-top: var(--s2); color: var(--text-2); }
.login__panel .form { margin-top: var(--s6); display: grid; gap: var(--s5); }
.login__foot { margin-top: var(--s6); font-size: var(--step--1); color: var(--text-3); }

.captcha { min-height: 65px; }
.captcha__demo {
  display: flex; align-items: center; gap: var(--s3);
  height: 65px; padding: 0 var(--s4); max-width: 340px;
  font-size: var(--step--1); color: var(--text-2);
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.captcha__tick {
  width: 22px; height: 22px; border-radius: 4px; flex: none;
  border: 1.5px solid var(--gold); background: var(--gold-wash);
}

/* ---------- Casca do painel ---------- */

.shell {
  display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--ink-1) calc(var(--rail-width) - 1px), var(--line) calc(var(--rail-width) - 1px) var(--rail-width), transparent var(--rail-width));
}

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s7);
  padding: var(--s6) var(--s4) var(--s5);
  background: var(--ink-1); border-right: 1px solid var(--line);
}
.rail__mark { padding: 0 var(--s3); font-size: var(--step--1); }
.rail__nav { display: grid; gap: var(--s1); }
.rail__link {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 44px; padding: 0 var(--s3); border-radius: var(--radius);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.rail__link:hover { color: var(--text); background: var(--ink-2); }
.rail__link[aria-current="page"] { color: var(--gold); background: var(--gold-wash); }
.rail__account { margin-top: auto; display: grid; gap: var(--s2); padding: var(--s4) var(--s3) 0; border-top: 1px solid var(--line); }
.rail__account .btn { justify-self: start; margin-left: calc(var(--s3) * -1); }
.rail__email { font-size: var(--step--1); color: var(--text-3); overflow-wrap: anywhere; }

.main { padding: var(--s7) clamp(var(--s5), 4.5vw, 72px) var(--s8); min-width: 0; outline: none; }
.view { max-width: 1120px; }

.demo-flag {
  max-width: 1120px; margin-bottom: var(--s6);
  font-size: var(--step--1); color: var(--gold-lo);
  padding-bottom: var(--s3); border-bottom: 1px dashed var(--line-strong);
}

.view__head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); flex-wrap: wrap;
  padding-bottom: var(--s5); border-bottom: 1px solid var(--line);
}
.view__title { font-family: var(--font-display); font-weight: 400; font-size: var(--step-4); line-height: 1; letter-spacing: -0.025em; }

/* Vagas de chave ativa: uma marca por vaga do teto. */
.capacity { display: grid; justify-items: end; gap: var(--s2); }
.capacity__text { color: var(--text-2); font-size: var(--step-0); }
.capacity__text strong { font-family: var(--font-display); font-size: var(--step-2); font-weight: 500; color: var(--gold); margin-right: 2px; }
.capacity__slots { display: flex; gap: 4px; }
.capacity__slot { width: 10px; height: 18px; border-radius: 2px; border: 1px solid var(--line-strong); }
.capacity__slot.is-on { background: var(--gold); border-color: var(--gold); }

/* ---------- Criar chave ---------- */

.create { display: grid; gap: var(--s2); margin-top: var(--s6); max-width: 680px; }
.create__row { display: flex; gap: var(--s3); }
.create__row .input { flex: 1; }
.create__hint { font-size: var(--step--1); color: var(--text-3); }
.create__hint.is-warning { color: var(--gold); }

#keys-error { margin-top: var(--s5); }

/* Chave recém-criada: o único momento em que a chave aparece em destaque. */
.new-key {
  margin-top: var(--s6); padding: var(--s5) var(--s5) var(--s5);
  background: linear-gradient(180deg, oklch(0.82 0.125 84 / 0.07), oklch(0.82 0.125 84 / 0.02)), var(--ink-1);
  border: 1px solid var(--gold-line); border-radius: var(--radius-lg);
  outline: none; animation: rise 420ms var(--ease-out);
}
.new-key:focus { box-shadow: none; }
.new-key__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); }
.new-key__title { font-family: var(--font-display); font-weight: 500; font-size: var(--step-2); line-height: 1.2; }
.new-key__secret { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); }
.new-key__note { margin-top: var(--s4); max-width: 68ch; font-size: var(--step--1); color: var(--text-2); }

.secret {
  flex: 1; min-width: 0; word-break: break-all;
  padding: var(--s3) var(--s4);
  font-size: var(--step--1); color: var(--gold-hi);
  background: var(--ink-0); border: 1px solid var(--line); border-radius: var(--radius);
  user-select: all;
}
.secret--lg { font-size: var(--step-0); padding: var(--s4); letter-spacing: 0.02em; }
.btn--copy-lg { min-height: 52px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ---------- Lista de chaves ---------- */

.keys { margin-top: var(--s7); }
.keys__loading { color: var(--text-3); padding: var(--s5) 0; }

.keys__head, .key-row__main {
  display: grid; align-items: center; gap: var(--s4);
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 96px 104px var(--actions-width);
}
.keys__head {
  padding: 0 var(--s4) var(--s3);
  font-size: var(--step--1); color: var(--text-3); letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
}
.keys__list { list-style: none; margin: 0; padding: 0; }

.key-row { border-bottom: 1px solid var(--line); transition: background-color 160ms var(--ease-out); }
.key-row:hover { background: oklch(0.178 0.01 80 / 0.6); }
.key-row__main { padding: var(--s3) var(--s4); min-height: 64px; }
.key-row__name { font-weight: 500; overflow-wrap: anywhere; }
.key-row.is-paused .key-row__name, .key-row.is-paused .key-code { color: var(--text-3); }
.key-row__date { font-size: var(--step--1); color: var(--text-3); font-variant-numeric: tabular-nums; }
.key-row__actions { display: flex; justify-content: flex-end; gap: 2px; flex-wrap: nowrap; }
.key-row__secret { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4) var(--s4); animation: rise 300ms var(--ease-out); }

.key-code { font-size: var(--step--1); color: var(--text-2); letter-spacing: 0.01em; }
.key-code__mask { color: var(--line-strong); margin-left: 1px; letter-spacing: 0.08em; }

.status { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--step--1); font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.status--active { color: var(--gold); }
.status--active::before { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }
.status--paused { color: var(--text-3); }
.status--paused::before { border: 1.5px solid var(--text-3); }

.rename { display: flex; gap: var(--s2); align-items: center; }
.rename .input { flex: 1; min-width: 0; }

.empty { padding: var(--s7) var(--s4); max-width: 52ch; color: var(--text-2); }
.empty__title { font-family: var(--font-display); font-size: var(--step-2); color: var(--text); margin-bottom: var(--s2); }

/* ---------- Confirmação de exclusão ---------- */

.confirm {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  color: var(--text); background: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
}
.confirm[open] { animation: rise 260ms var(--ease-out); }
.confirm::backdrop { background: oklch(0.1 0.008 80 / 0.72); backdrop-filter: blur(2px); }
.confirm__body { display: grid; gap: var(--s4); padding: var(--s6); }
.confirm__title { font-family: var(--font-display); font-weight: 500; font-size: var(--step-2); line-height: 1.2; overflow-wrap: anywhere; }
.confirm__text { color: var(--text-2); }
.confirm__actions { display: flex; justify-content: flex-end; gap: var(--s3); margin-top: var(--s2); }

/* ---------- Documentação ---------- */

.view__head--docs { align-items: flex-end; }
.base-url { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.base-url__label { font-size: var(--step--1); color: var(--text-3); }
.base-url__value { font-size: var(--step--1); color: var(--gold-hi); padding: 6px var(--s3); background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--radius); }

#docs-error { margin-top: var(--s5); }

.docs > * { min-width: 0; }
.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s7); margin-top: var(--s6); }
.docs__nav { position: sticky; top: var(--s6); align-self: start; }
.docs__toc { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-left: 1px solid var(--line); }
.docs__toc a {
  display: block; padding: 6px var(--s4); margin-left: -1px;
  color: var(--text-3); text-decoration: none; font-size: var(--step--1);
  border-left: 1px solid transparent;
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.docs__toc a:hover { color: var(--text); }
.docs__toc a[aria-current="true"] { color: var(--gold); border-left-color: var(--gold); }

.doc-section { padding-bottom: var(--s7); scroll-margin-top: var(--s6); }
.doc-section + .doc-section { padding-top: var(--s6); border-top: 1px solid var(--line); }

.prose { max-width: 72ch; color: var(--text-2); }
.prose h2 { font-family: var(--font-display); font-weight: 500; font-size: var(--step-3); line-height: 1.1; letter-spacing: -0.015em; color: var(--text); margin-bottom: var(--s4); }
.prose h3 { font-size: var(--step-1); font-weight: 600; color: var(--text); margin: var(--s6) 0 var(--s3); }
.prose h4, .prose h5 { font-size: var(--step-0); font-weight: 600; color: var(--text); margin: var(--s5) 0 var(--s2); }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose .codeblock, .prose .table-wrap { margin: 0 0 var(--s4); }
.prose ul, .prose ol { padding-left: var(--s5); }
.prose li + li { margin-top: var(--s1); }
.prose li::marker { color: var(--gold-lo); }
.prose strong { color: var(--text); font-weight: 600; }
.prose :not(pre) > code {
  font-size: 0.86em; color: var(--gold-hi);
  padding: 1px 6px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 4px;
  overflow-wrap: anywhere;
}
.prose blockquote { padding: var(--s3) var(--s4); background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }

.codeblock { background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.codeblock__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s1) var(--s1) var(--s1) var(--s4); border-bottom: 1px solid var(--line);
}
.codeblock__lang { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-3); text-transform: lowercase; }
.codeblock pre { margin: 0; padding: var(--s4); overflow-x: auto; }
.codeblock code { font-size: var(--step--1); line-height: 1.65; color: var(--text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.prose th, .prose td { text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--text); font-weight: 600; background: var(--ink-1); }
.prose tr:last-child td { border-bottom: 0; }

/* ---------- Responsivo ---------- */

@media (max-width: 1180px) {
  .keys__head { display: none; }
  .key-row__main {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'label status' 'key date' 'actions actions';
    row-gap: var(--s2); padding: var(--s4);
  }
  .key-row__label { grid-area: label; }
  .key-row__key { grid-area: key; }
  .key-row__status { grid-area: status; justify-self: end; }
  .key-row__date { grid-area: date; justify-self: end; }
  .key-row__actions { grid-area: actions; justify-content: flex-start; flex-wrap: wrap; margin-left: calc(var(--s3) * -1); }
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login__brand { display: none; }
  .login__mobile-mark { display: inline-flex; }

  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky; z-index: 5; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4);
    padding: var(--s3) var(--s4);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .rail__mark { padding: 0; }
  .rail__mark .wordmark__mark { width: 24px; height: 24px; }
  .rail__nav { order: 3; width: 100%; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .rail__link { justify-content: center; }
  .rail__account { margin: 0 0 0 auto; padding: 0; border: 0; }
  .rail__email { display: none; }
  .rail__account .btn { margin: 0; }

  .main { padding: var(--s5) var(--s4) var(--s7); }
  .view__title { font-size: var(--step-3); }
  .view__head { align-items: flex-start; flex-direction: column; }
  .capacity { justify-items: start; }

  .shell { background: none; }
  .docs { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .docs__nav { position: static; overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
  .docs__toc { display: flex; gap: var(--s1); border-left: 0; border-bottom: 1px solid var(--line); width: max-content; }
  .docs__toc a { margin: 0 0 -1px; border-left: 0; border-bottom: 1px solid transparent; padding: var(--s2) var(--s3); white-space: nowrap; }
  .docs__toc a[aria-current="true"] { border-bottom-color: var(--gold); }
  .prose h2 { font-size: var(--step-2); }
}

@media (max-width: 520px) {
  .key-row__actions { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; margin: 0 calc(var(--s2) * -1); }
  .key-row__actions .btn { padding: 0 var(--s2); }
  .key-row__actions .icon { display: none; }
  .create__row, .new-key__secret, .key-row__secret { flex-direction: column; align-items: stretch; }
  .new-key__head { align-items: flex-start; }
  .confirm__actions { flex-direction: column-reverse; }
  .confirm__actions .btn { width: 100%; }
  .base-url__value { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
