/* Nex Store · base: reset, tipografia, botões, formulários e componentes comuns à loja e ao painel */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); scrollbar-color: var(--line-2) transparent; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
  caret-color: var(--blue);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; letter-spacing: -0.035em; text-wrap: balance; font-family: var(--font-display); font-weight: 700; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; }
table { border-collapse: collapse; }
::selection { background: var(--sky); color: var(--ink); }
.on-dark ::selection { background: var(--sky); color: var(--ink); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.on-dark :focus-visible { outline-color: var(--sky); }
main:focus { outline: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

.skip-link {
  position: fixed; left: 16px; top: 12px; z-index: 100; padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-3);
  transform: translateY(-200%); transition: transform .2s var(--ease);
}
.skip-link:focus { transform: none; }

/* Texto */
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.num { font-variant-numeric: tabular-nums; }
.err-text { color: var(--red); font-size: var(--fs-sm); font-weight: 500; }
.link { color: var(--blue); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.link .icon { transition: transform .2s var(--ease); }
.link:hover { color: var(--blue-strong); }
.link:hover .icon { transform: translateX(3px); }
.prose a, .inline-link { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover, .inline-link:hover { color: var(--blue-strong); text-decoration-thickness: 2px; }

/* Botões: pílula, como nas lojas de referência */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5); border-radius: var(--r-pill);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: -0.005em; line-height: 1.2; text-align: center;
  transition: background-color .18s var(--ease-out), border-color .18s var(--ease-out), color .18s var(--ease-out), box-shadow .25s var(--ease), transform .12s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn .icon { transition: transform .25s var(--ease); }
.btn:hover { --btn-bd: var(--ink); }
.btn:hover .icon-arrow, .btn:hover [data-arrow] { transform: translateX(3px); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { --btn-bg: var(--ink); --btn-fg: #fff; --btn-bd: var(--ink); }
.btn-primary:hover { --btn-bg: var(--ink-2); --btn-bd: var(--ink-2); box-shadow: 0 8px 22px rgba(11, 27, 63, .22); }
.btn-sky { --btn-bg: var(--sky); --btn-fg: var(--ink); --btn-bd: var(--sky); }
.btn-sky:hover { --btn-bg: #fff; --btn-bd: #fff; box-shadow: 0 10px 30px rgba(191, 224, 255, .28); }
.btn-ghost-dark { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(234, 242, 255, .42); }
.btn-ghost-dark:hover { --btn-bg: rgba(234, 242, 255, .1); --btn-bd: #fff; }
.btn-quiet { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn-quiet:hover { --btn-bg: var(--surface-2); --btn-bd: transparent; color: var(--text); }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--red); --btn-bd: #F3C2BE; }
.btn-danger:hover { --btn-bg: var(--red-soft); --btn-bd: var(--red); }
.btn-sm { min-height: 36px; padding: 0 var(--s4); font-size: var(--fs-xs); }
.btn-lg { min-height: 54px; padding: 0 var(--s6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { min-height: var(--tap); min-width: var(--tap); padding: 0; }
.btn .spinner { width: 16px; height: 16px; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-width: var(--tap); min-height: var(--tap); padding: 0 var(--s2); border: 0; border-radius: var(--r-pill);
  background: none; color: var(--ink); font-size: var(--fs-sm); font-weight: 500;
  transition: background-color .15s var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); }

/* Formulários */
.field { display: grid; gap: 6px; min-width: 0; font-size: var(--fs-sm); }
.field > label, .label { font-weight: 600; color: var(--text); }
.field .hint { color: var(--text-3); font-size: var(--fs-xs); }
.field .err { color: var(--red); font-size: var(--fs-xs); font-weight: 500; }
.field .err:empty { display: none; }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .select {
  width: 100%; min-height: 48px; padding: 0 var(--s4); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-md);
  transition: border-color .15s var(--ease-out), box-shadow .2s var(--ease);
}
.field textarea, textarea.input { min-height: 112px; padding-block: var(--s3); resize: vertical; line-height: 1.5; }
.select, .field select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%230B1B3F' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.field [aria-invalid="true"] { border-color: var(--red); background: #FFFAF9; }
.field [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(217, 43, 36, .18); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.check { display: flex; align-items: flex-start; gap: var(--s3); font-size: var(--fs-sm); cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
.fields > * { grid-column: span 6; }
@media (min-width: 600px) {
  .fields .w-half { grid-column: span 3; }
  .fields .w-third { grid-column: span 2; }
  .fields .w-2third { grid-column: span 4; }
}
.row-input { display: flex; gap: var(--s2); }
.row-input > .input, .row-input > input { flex: 1; min-width: 0; }

/* Etiquetas e avisos */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .02em; line-height: 1.4;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge-ink { background: var(--ink); color: #fff; }
.badge-blue { background: var(--blue-soft); color: var(--blue-strong); }
.badge-sky { background: var(--sky); color: var(--ink); }
.badge-save { background: var(--red); color: #fff; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red-strong); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.notice {
  display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-sm); color: var(--text-2);
}
.notice .icon { margin-top: 1px; }
.notice b, .notice strong { color: var(--text); }
.notice-info { background: var(--sky-soft); border-color: #C9E2FB; color: #1E3D73; }
.notice-info .icon { color: var(--blue); }
.notice-warn { background: var(--amber-soft); border-color: #F3D9A9; color: #5B3A00; }
.notice-warn .icon { color: var(--amber); }
.notice-error { background: var(--red-soft); border-color: #F5C6C2; color: #7A1712; }
.notice-error .icon { color: var(--red); }
.notice-ok { background: var(--green-soft); border-color: #BCE2CF; color: #0B4F37; }
.notice-ok .icon { color: var(--green); }

/* Cartões e listas utilitárias */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); box-shadow: var(--shadow-1); min-width: 0; }
.stack { display: grid; gap: var(--s4); min-width: 0; grid-template-columns: minmax(0, 1fr); }
.stack-sm { display: grid; gap: var(--s2); min-width: 0; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.line-item { display: flex; justify-content: space-between; gap: var(--s3); padding-block: 10px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.line-item:last-child { border-bottom: 0; }
.line-item > :last-child { white-space: nowrap; }
.line-item.total { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.02em; color: var(--ink); border-bottom: 0; padding-top: var(--s3); }
.line-item .free { color: var(--red); font-weight: 700; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* Carregamento */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-xs); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Aviso flutuante */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px)); z-index: 90;
  display: flex; align-items: center; gap: var(--s3); width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 20px; border-radius: var(--r-pill); background: var(--ink); color: #fff;
  font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-3);
  transform: translate(-50%, 16px) scale(.98); opacity: 0; transition: opacity .2s var(--ease-out), transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--red); }
.toast a { color: var(--sky); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Diálogo */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-md); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-3); color: var(--text); background: var(--surface); }
dialog.modal::backdrop { background: rgba(11, 27, 63, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: var(--fs-lg); }
.modal-body { padding: var(--s5); display: grid; gap: var(--s4); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); background: var(--bg); }

/* Tabelas */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; font-size: var(--fs-sm); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; background: var(--bg); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--sky-wash); }
.table .right { text-align: right; }
.table a.row-link { font-weight: 600; color: var(--text); }
.table a.row-link:hover { color: var(--blue); }

.empty { display: grid; gap: var(--s3); justify-items: center; text-align: center; padding: var(--s8) var(--s5); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--text-2); }
.empty h2, .empty h3 { color: var(--ink); font-size: var(--fs-xl); }
.empty .icon { width: 36px; height: 36px; color: var(--text-3); }

details.acc { border-top: 1px solid var(--line); }
details.acc > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; cursor: pointer; font-weight: 600; font-size: var(--fs-sm); }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg) translateY(-3px); transition: transform .3s var(--ease); flex: none; margin-right: 6px; }
details.acc[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
details.acc > div { padding-bottom: var(--s4); color: var(--text-2); font-size: var(--fs-sm); display: grid; gap: var(--s2); }

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