/* ULTRAPRINTER Design System v3.0 — Editorial Papel, Cupom Fiscal & DANFE.
   Fonte única: design-system/ds.css. Rode sync-ds.ps1 após editar. */
@layer reset, tokens, base, components, utilities, motion;

@font-face { font-family: "Fraunces Variable"; src: url("/fonts/fraunces-var.woff2") format("woff2-variations"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces Variable"; src: url("/fonts/fraunces-italic-var.woff2") format("woff2-variations"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter Variable"; src: url("/fonts/inter-var.woff2") format("woff2-variations"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono Variable"; src: url("/fonts/jetbrains-mono-var.woff2") format("woff2-variations"); font-weight: 100 800; font-style: normal; font-display: swap; }

/* ───────────────────────── reset ───────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 76px; }
  body { min-height: 100dvh; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
  img, svg, video { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
  ul, ol { padding: 0; list-style: none; }
  table { border-collapse: collapse; width: 100%; }
  summary { list-style: none; }
  summary::-webkit-details-marker { display: none; }
  :where([hidden]) { display: none !important; }
}

/* ───────────────────────── tokens (PAPEL CLARO por padrão) ───────────────────────── */
@layer tokens {
  :root {
    color-scheme: light dark;
    /* paleta editorial papel */
    --paper: #f6f3ec;
    --card: #fffdf7;
    --ink: #1b1b18;
    --line: #cfc9bb;
    --muted: #5d5a50;
    --tint: #ece7da;
    --ok: #1d6b3a;
    --danger: #a62626;
    --warning: #9a5b0c;
    --info: #1f3a64;
    /* acento (override por site em site.css) */
    --acc: #8f3d14;
    --onacc: #ffffff;
    --acc-hover: #732f0e;
    --acc-soft: rgba(143, 61, 20, .14);
    /* aliases de compatibilidade v2 */
    --bg-canvas: var(--paper);
    --bg-panel: var(--tint);
    --bg-elevated: var(--card);
    --bg-raised: var(--card);
    --surface-1: var(--card);
    --surface-2: var(--tint);
    --surface-3: #e1dac8;
    --border-subtle: #e2dccd;
    --border: var(--line);
    --border-strong: var(--ink);
    --text: var(--ink);
    --text-2: #2f2e28;
    --text-3: var(--muted);
    --text-4: #878273;
    --success: var(--ok);
    --accent-solid: var(--acc);
    --accent-fg: var(--onacc);
    --accent-hover: var(--acc-hover);
    --accent-text: var(--acc);
    --accent-soft: var(--acc-soft);
    --overlay: rgba(27, 27, 24, .55);
    --shadow-modal: 6px 6px 0 var(--ink);
    /* tipografia */
    --font-serif: "Fraunces Variable", Georgia, "Times New Roman", serif;
    --font-sans: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --fs-h1: clamp(2.1rem, 1.35rem + 2.4vw, 3.45rem);
    --fs-h2: clamp(1.45rem, 1.2rem + .75vw, 1.875rem);
    --fs-h3: 1.2rem;
    --fs-body: .9375rem;
    --fs-small: .875rem;
    --fs-caption: .8125rem;
    --fs-micro: .75rem;
    /* espaço / raios (2px editorial nítido) */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
    --container: 1200px; --container-wide: 1200px; --pad-x: clamp(16px, 3vw, 32px);
    --radius-xs: 2px; --radius-sm: 2px; --radius-md: 2px; --radius-lg: 2px; --radius-xl: 2px; --radius-2xl: 2px; --radius-pill: 2px;
    --z-header: 40; --z-overlay: 60; --z-modal: 70; --z-toast: 80;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --dur-fast: 120ms;
    --dur-base: 180ms;
  }

  :root[data-theme="dark"] {
    --paper: #1a1b1d;
    --card: #222326;
    --ink: #ece8dd;
    --line: #3b3c40;
    --muted: #a39f93;
    --tint: #2b2c30;
    --ok: #6fcf97;
    --danger: #f07178;
    --warning: #e5b567;
    --info: #7aa6e0;
    --surface-3: #34353a;
    --border-subtle: #2d2e33;
    --text-2: #d8d4c8;
    --text-4: #79766d;
    --overlay: rgba(10, 11, 13, .72);
    --shadow-modal: 6px 6px 0 #090a0b;
  }
}

/* ───────────────────────── base ───────────────────────── */
@layer base {
  html { scrollbar-width: thin; scrollbar-color: var(--line) transparent; background: var(--paper); }
  body { background: var(--paper); color: var(--ink); font-family: var(--font-sans); font-size: var(--fs-body); line-height: 1.5; overflow-x: clip; }
  h1, h2, h3 { font-family: var(--font-serif); color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: break-word; }
  h4 { font-family: var(--font-sans); color: var(--ink); font-weight: 600; min-width: 0; }
  h1 { font-size: var(--fs-h1); line-height: 1.04; letter-spacing: -.02em; text-wrap: balance; }
  h1 em, h2 em { font-style: italic; font-weight: 500; }
  h2 { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: -.01em; }
  h3 { font-size: var(--fs-h3); line-height: 1.25; letter-spacing: -.01em; }
  strong, b { font-weight: 600; color: var(--ink); }
  ::selection { background: var(--acc-soft); color: var(--ink); }
  :focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: 2px; }
  ::-webkit-scrollbar { width: 7px; height: 7px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted); }
  .ds-skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--acc); color: var(--onacc); border: 1.5px solid var(--ink); padding: 8px 14px; font-weight: 600; font-size: var(--fs-small); }
  .ds-skip:focus { top: 12px; }
  .ds-layer { position: relative; }
}

/* ───────────────────────── components ───────────────────────── */
@layer components {
  .ds-container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--pad-x); }
  .ds-container--wide { max-width: var(--container-wide); }
  .ds-section { padding-block: var(--s-7); }
  .ds-section--tight { padding-block: var(--s-5); }
  .ds-lead { font-size: 1.0625rem; line-height: 1.55; color: var(--muted); max-width: 58ch; }
  .ds-accent-text { color: var(--acc); }

  /* link animado editorial */
  .ds-lnk { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100%/0 1.5px no-repeat; transition: background-size 160ms ease; }
  .ds-lnk:hover { background-size: 100% 1.5px; }
  .ds-link { color: var(--ink); font-weight: 600; background: linear-gradient(currentColor, currentColor) 0 100%/100% 1.5px no-repeat; padding-bottom: 1px; transition: color var(--dur-fast); }
  .ds-link:hover { color: var(--acc); }

  /* header com régua dupla */
  .ds-header { position: sticky; top: 0; z-index: var(--z-header); background: var(--paper); border-bottom: 1.5px solid var(--ink); }
  .ds-header::after { content: ""; display: block; height: 3px; background: var(--paper); border-bottom: 1px solid var(--ink); }
  .ds-header__in { display: flex; align-items: center; gap: 16px 28px; min-height: 66px; padding-block: 10px; }
  .ds-logo { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; flex: none; }
  .ds-mark { width: 28px; height: 28px; background: var(--ink); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-serif); font-weight: 600; font-size: 17px; line-height: 1; border-radius: 2px; flex: none; }
  .ds-logo__name { font-family: var(--font-serif); font-weight: 600; font-size: 21px; letter-spacing: -.01em; color: var(--ink); line-height: 1; }
  .ds-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 14px; font-weight: 500; flex-grow: 1; }
  .ds-nav a { color: var(--ink); padding-bottom: 2px; background: linear-gradient(currentColor, currentColor) 0 100%/0 1.5px no-repeat; transition: background-size 160ms ease; white-space: nowrap; }
  .ds-nav a:hover { background-size: 100% 1.5px; }
  .ds-nav a[aria-current="page"] { border-bottom: 2px solid var(--ink); background: none; font-weight: 600; }
  .ds-header__cta { display: flex; align-items: center; gap: 16px; margin-left: auto; }
  .ds-switcher { display: inline-flex; align-items: center; gap: 16px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
  .ds-switcher a { color: var(--muted); background: linear-gradient(currentColor, currentColor) 0 100%/0 1.5px no-repeat; transition: background-size 160ms ease, color var(--dur-fast); white-space: nowrap; padding-bottom: 1px; }
  .ds-switcher a:hover { color: var(--ink); background-size: 100% 1.5px; }
  .ds-switcher a[aria-current="page"] { color: var(--ink); border-bottom: 1.5px solid var(--ink); background: none; }
  .ds-burger { display: none; flex: none; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 2px; color: var(--ink); border: 1.5px solid var(--ink); background: var(--card); }
  .ds-burger svg { width: 20px; height: 20px; }
  .ds-drawer { position: fixed; inset: 0; z-index: var(--z-overlay); display: none; }
  .ds-drawer.is-open { display: block; }
  .ds-drawer__scrim { position: absolute; inset: 0; background: var(--overlay); animation: ds-fade var(--dur-base) var(--ease) both; }
  .ds-drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(86vw, 320px); background: var(--paper); border-left: 1.5px solid var(--ink); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-1); animation: ds-fade var(--dur-base) var(--ease) both; overflow-y: auto; }
  .ds-drawer__panel a { padding: 12px; border-radius: 2px; font-weight: 500; color: var(--ink); min-height: 44px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
  .ds-drawer__panel a:hover { background: var(--tint); }
  .ds-drawer__close { align-self: flex-end; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 2px; border: 1.5px solid var(--ink); background: var(--card); margin-bottom: 8px; }
  @media (max-width: 1024px) {
    .ds-switcher { display: none; }
  }
  @media (max-width: 860px) {
    .ds-header__in { gap: 10px; }
    .ds-logo { gap: 8px; }
    .ds-logo__name { font-size: 18px; }
    .ds-nav, .ds-header__cta .ds-hide-m { display: none; }
    .ds-header__cta { margin-left: auto; gap: 8px; }
    .ds-burger { display: inline-flex; margin-left: 0; }
  }

  /* cabeçalho editorial de página / seção numerada */
  .ds-sec { font: 500 12px var(--font-mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 0 0 12px; }
  .ds-hero-ed { padding: 40px 0 28px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
  .ds-hero-ed__main { max-width: 740px; min-width: 0; }
  .ds-hero-ed__sub { margin-top: 16px; color: var(--muted); font-size: 1.0625rem; max-width: 58ch; line-height: 1.5; }
  .ds-hero-ed__meta { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: right; line-height: 1.7; }
  .ds-hero-ed__meta strong { display: block; color: var(--ink); font-weight: 500; }
  @media (max-width: 760px) {
    .ds-hero-ed { padding: 28px 0 20px; }
    .ds-hero-ed__meta { text-align: left; }
  }
  .ds-sec-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; border-bottom: 1.5px solid var(--ink); padding-bottom: 10px; margin-bottom: 4px; }
  .ds-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-bottom: 12px; }
  .ds-crumbs a:hover { color: var(--ink); text-decoration: underline; }
  .ds-crumbs svg { width: 12px; height: 12px; opacity: .7; }

  /* faixa de KPIs com régua superior forte */
  .ds-kpi-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line); }
  .ds-kpi-strip__item { padding: 16px 24px 16px 0; min-width: 0; }
  .ds-kpi-strip__item + .ds-kpi-strip__item { padding-left: 24px; border-left: 1px solid var(--line); }
  .ds-kpi-strip__label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .ds-kpi-strip__val { margin-top: 2px; font-family: var(--font-mono); font-size: clamp(1.35rem, 1.1rem + .8vw, 1.75rem); font-weight: 500; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
  @media (max-width: 680px) {
    .ds-kpi-strip { grid-template-columns: minmax(0, 1fr); }
    .ds-kpi-strip__item { padding: 12px 0; }
    .ds-kpi-strip__item + .ds-kpi-strip__item { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  }

  /* botões táteis com sombra rígida */
  .ds-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 2px; font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; border: 1.5px solid transparent; transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background-color var(--dur-fast) ease; user-select: none; }
  .ds-btn svg { width: 15px; height: 15px; flex: none; }
  .ds-btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
  .ds-btn--lg { min-height: 44px; padding: 0 18px; font-size: 14px; }
  .ds-btn--primary { background: var(--acc); color: var(--onacc); border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
  .ds-btn--primary:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
  .ds-btn--primary:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
  .ds-btn--secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
  .ds-btn--secondary:hover { background: var(--tint); }
  .ds-btn--ghost { color: var(--ink); border-color: transparent; }
  .ds-btn--ghost:hover { background: var(--tint); }
  .ds-btn--danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
  .ds-btn--danger:hover { background: rgba(166, 38, 38, .08); }
  .ds-btn--icon { width: 38px; min-height: 38px; padding: 0; border-color: var(--line); background: transparent; color: var(--ink); }
  .ds-btn--icon:hover { border-color: var(--ink); background: var(--tint); }
  .ds-btn--icon.ds-btn--sm { width: 34px; min-height: 34px; }
  .ds-btn:disabled, .ds-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }

  /* cards editoriais (borda ink nítida) */
  .ds-card { background: var(--card); border: 1.5px solid var(--ink); border-radius: 2px; padding: var(--s-5); min-width: 0; }
  .ds-card--muted { background: var(--paper); border: 1.5px solid var(--ink); }
  .ds-card--soft { background: var(--card); border: 1px solid var(--line); }
  .ds-card h3 { margin-bottom: var(--s-2); }
  .ds-card p { color: var(--muted); font-size: var(--fs-small); }

  /* campos de formulário (borda 1.5px ink, 2px radius) */
  .ds-form { display: grid; gap: 20px; }
  .ds-form--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-form--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ds-form--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  @media (max-width: 720px) { .ds-form--2, .ds-form--3, .ds-form--4 { grid-template-columns: minmax(0, 1fr); } }
  @media (min-width: 721px) and (max-width: 1080px) { .ds-form--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .ds-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .ds-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  .ds-hint { font-size: 12.5px; color: var(--muted); }
  .ds-error { font-size: 12.5px; color: var(--danger); min-height: 1.2em; }
  .ds-input, .ds-select, .ds-textarea { width: 100%; min-width: 0; height: 44px; padding: 0 12px; background: var(--card); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 2px; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
  .ds-textarea { height: auto; padding: 10px 12px; min-height: 112px; resize: vertical; line-height: 1.5; }
  .ds-input::placeholder, .ds-textarea::placeholder { color: var(--text-4); font-weight: 400; }
  .ds-input:focus, .ds-select:focus, .ds-textarea:focus, .ds-wrap:focus-within { outline: 2px solid var(--acc); outline-offset: 2px; }
  .ds-select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%235d5a50' stroke-width='2' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
  .ds-select option { background: var(--card); color: var(--ink); }
  .ds-input[type="number"]::-webkit-inner-spin-button, .ds-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .ds-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
  .ds-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .ds-wrap { display: flex; align-items: stretch; min-width: 0; height: 44px; background: var(--card); border: 1.5px solid var(--ink); border-radius: 2px; overflow: hidden; }
  .ds-wrap--lg { height: 48px; }
  .ds-wrap .ds-input { border: 0; background: transparent; border-radius: 0; height: 100%; font-family: var(--font-mono); font-size: 16px; }
  .ds-wrap .ds-input:focus { outline: none; }
  .ds-addon { display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; font: 500 13px var(--font-mono); color: var(--ink); background: var(--tint); user-select: none; flex: none; }
  .ds-addon:first-child { border-right: 1.5px solid var(--ink); }
  .ds-addon:last-child { border-left: 1.5px solid var(--ink); }
  .ds-addon--btn { width: 48px; padding: 0; cursor: pointer; transition: background-color var(--dur-fast); }
  .ds-addon--btn:hover { background: var(--line); }

  /* abas sublinhadas (editorial) */
  .ds-seg { display: flex; flex-wrap: wrap; gap: 4px 28px; border-bottom: 1px solid var(--line); max-width: 100%; }
  .ds-seg__btn { padding: 10px 0; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--dur-fast), border-color var(--dur-fast); display: inline-flex; align-items: center; gap: 6px; }
  .ds-seg__btn:hover { color: var(--ink); }
  .ds-seg__btn.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

  /* tags / badges editoriais */
  .ds-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 2px; font-size: 11.5px; line-height: 1.35; font-weight: 600; border: 1px solid var(--ink); background: transparent; color: var(--ink); white-space: nowrap; max-width: 100%; }
  @media (max-width: 640px) { .ds-badge { white-space: normal; } }
  .ds-badge--success { border-color: var(--ok); color: var(--ok); background: transparent; }
  .ds-badge--warning { border-color: var(--warning); color: var(--warning); background: transparent; }
  .ds-badge--danger { border-color: var(--danger); color: var(--danger); background: transparent; }
  .ds-badge--ml { border-color: var(--ink); color: var(--ink); background: transparent; font-size: 12px; font-weight: 500; }
  .ds-badge--shopee { border-color: var(--ink); color: var(--ink); background: transparent; font-size: 12px; font-weight: 500; }
  .ds-badge--pro { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; padding: 1px 5px; border: 1px solid currentColor; background: transparent; color: inherit; }

  /* tabelas editoriais com réguas horizontais */
  .ds-table-wrap { overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
  .ds-table { min-width: 560px; font-size: 14px; font-variant-numeric: tabular-nums; }
  .ds-table--compact { min-width: 0; }
  .ds-table th { padding: 12px 8px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
  .ds-table th:first-child, .ds-table td:first-child { padding-left: 0; }
  .ds-table th:last-child, .ds-table td:last-child { padding-right: 0; }
  .ds-table td { padding: 13px 8px; border-top: 1px solid var(--line); color: var(--ink); vertical-align: middle; }
  .ds-table tbody tr:last-child td { border-bottom: 1px solid var(--line); }
  .ds-table tbody tr:hover td { background: var(--tint); }
  .ds-table .ds-num, .ds-table th.ds-num { text-align: right; font-family: var(--font-mono); }
  .ds-pos { color: var(--acc); font-weight: 600; }
  .ds-neg { color: var(--danger); font-weight: 600; }
  .ds-warn { color: var(--warning); font-weight: 600; }
  .ds-table-input { width: 100%; max-width: 220px; min-height: 30px; padding: 0 6px; background: transparent; border: 1px solid transparent; border-radius: 2px; font-weight: 500; color: var(--ink); }
  .ds-table-input:hover { background: var(--card); border-color: var(--line); }
  .ds-table-input:focus { outline: none; background: var(--card); border-color: var(--ink); }
  .ds-icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 2px; color: var(--muted); transition: color var(--dur-fast), background-color var(--dur-fast); }
  .ds-icon-btn:hover { color: var(--ink); background: var(--tint); }
  .ds-icon-btn--danger:hover { color: var(--danger); }
  .ds-icon-btn svg { width: 15px; height: 15px; }
  .ds-rows { display: grid; }
  .ds-rows__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
  .ds-rows__row:last-child { border-bottom: 0; }
  .ds-rows__row span { color: var(--muted); }

  /* layouts de colunas */
  .ds-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 40px; align-items: start; }
  .ds-split--5-5 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
  .ds-split--danfe { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 40px; }
  .ds-split--8-4 { grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 40px; }
  @media (max-width: 960px) { .ds-split, .ds-split--5-5, .ds-split--danfe, .ds-split--8-4 { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
  .ds-sticky { position: sticky; top: 84px; }
  @media (max-width: 960px) { .ds-sticky { position: static; } }

  /* ── CUPOM FISCAL TÉRMICO (sempre papel claro #fffdf7) ── */
  .ed-receipt { width: 100%; max-width: 400px; }
  @media (max-width: 960px) { .ed-receipt { max-width: 100%; } }
  .ed-receipt__top { height: 10px; background-color: #fffdf7; background-image: radial-gradient(circle at 8px 5px, var(--paper) 2.6px, transparent 3px); background-size: 16px 10px; border: 1px solid #cfc9bb; border-bottom: 0; }
  .ed-receipt__body { background: #fffdf7; border: 1px solid #cfc9bb; border-top: 0; border-bottom: 0; padding: 22px 26px 8px; font-family: var(--font-mono); font-size: 13px; color: #1b1b18; }
  .ed-receipt__brand { margin: 0; text-align: center; font-weight: 600; letter-spacing: .14em; font-size: 12px; color: #1b1b18; }
  .ed-receipt__sub { margin: 2px 0 0; text-align: center; color: #5d5a50; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
  .ed-receipt__sku { margin: 7px 0 0; text-align: center; color: #5d5a50; font-size: 11px; }
  .ed-receipt__dash { border-top: 1px dashed #1b1b18; margin: 14px 0 10px; }
  .ed-receipt__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
  .ed-receipt__row--muted { color: #5d5a50; }
  .ed-receipt__total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .ed-receipt__total-lbl { font-weight: 600; letter-spacing: .06em; font-size: 12px; color: #1b1b18; }
  .ed-receipt__big { font-family: var(--font-mono); font-size: clamp(1.65rem, 1.3rem + 1vw, 2.125rem); font-weight: 600; letter-spacing: -.03em; padding: 0 4px; color: #0f6b5c; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .ed-receipt__big.ds-big--neg { color: #a62626; }
  .ed-receipt__big.ds-big--pos { color: #0f6b5c; }
  .ed-receipt__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 0 18px; }
  .ed-receipt__note { font-size: 10px; color: #5d5a50; letter-spacing: .08em; }
  .ed-receipt__saw { display: block; width: 100%; height: 10px; }
  .ed-receipt__comp { display: flex; height: 6px; margin: 14px 0 8px; background: #ece7da; overflow: hidden; }
  .ed-receipt__comp > i { display: block; height: 100%; min-width: 0; transition: width 180ms var(--ease); }
  .ds-seg-cost { background: #8a8576; }
  .ds-seg-fees { background: #b4492f; }
  .ds-seg-tax { background: #c28a1e; }
  .ds-seg-profit { background: #0f6b5c; }
  .ed-receipt__leg { margin: 0; font-size: 11px; color: #5d5a50; display: flex; flex-wrap: wrap; gap: 2px 12px; }
  .ed-receipt__ideal { border: 1px dashed #0f6b5c; background: rgba(15, 107, 92, .07); padding: 10px 12px; margin-bottom: 12px; }

  /* ── DANFE GRADE 4 COLUNAS + ETIQUETA CODE 128C ── */
  .ed-danfe { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--ink); border: 1.5px solid var(--ink); }
  .ed-cell { background: var(--card); padding: 10px 12px; min-width: 0; }
  .ed-cell--2 { grid-column: span 2; }
  .ed-cell--4 { grid-column: span 4; }
  .ed-cell__k { margin: 0; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .ed-cell__v { margin: 2px 0 0; font: 500 15.5px var(--font-mono); color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  @media (max-width: 600px) {
    .ed-danfe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ed-cell--4 { grid-column: span 2; }
  }
  .ed-barcode { margin-top: 24px; border: 1.5px solid var(--ink); background: #fffdf7; color: #1b1b18; padding: 16px 20px 14px; border-radius: 2px; }
  .ed-barcode__lbl { margin: 0 0 10px; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #5d5a50; }
  .ed-barcode__svg { display: block; width: 100%; height: 72px; }
  .ed-barcode__key { margin: 10px 0 0; text-align: center; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .07em; word-spacing: .35em; color: #1b1b18; overflow-wrap: anywhere; }

  /* ── CARIMBO, MARCA-TEXTO, REPLAY, FÓRMULA ── */
  .ed-hl { background: linear-gradient(rgba(15, 107, 92, .2), rgba(15, 107, 92, .2)) 0 90%/100% 38% no-repeat; }
  .ed-hl.ds-big--neg { background: linear-gradient(rgba(166, 38, 38, .18), rgba(166, 38, 38, .18)) 0 90%/100% 38% no-repeat; }
  .ed-stamp { display: inline-block; border: 2px solid #1d6b3a; color: #1d6b3a; padding: 4px 10px; font: 600 11px var(--font-mono); letter-spacing: .12em; border-radius: 2px; opacity: .92; transform: rotate(-6deg); text-transform: uppercase; }
  .ed-stamp--dark-aware { border-color: var(--ok); color: var(--ok); }
  .ed-stamp--neg { border-color: #a62626 !important; color: #a62626 !important; }
  :root[data-theme="dark"] .ed-stamp--dark-aware.ed-stamp--neg { border-color: var(--danger) !important; color: var(--danger) !important; }
  .ed-replay { cursor: pointer; margin-top: 14px; font: 500 13px var(--font-mono); color: var(--ink); border-bottom: 1.5px solid var(--ink); padding-bottom: 1px; display: inline-block; transition: color var(--dur-fast), border-color var(--dur-fast); }
  .ed-replay:hover { color: var(--acc); border-bottom-color: var(--acc); }
  .ed-formula { margin: 16px 0 0; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; border-left: 3px solid var(--ink); padding-left: 14px; color: var(--ink); }

  /* resultado genérico para outros painéis (Simples / DIFAL / Lote) */
  .ds-ink { background: var(--card); border: 1.5px solid var(--ink); border-radius: 2px; padding: var(--s-5); }
  .ds-big { font-family: var(--font-mono); font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem); line-height: 1.1; font-weight: 600; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; display: block; }
  .ds-big--pos { color: var(--acc); }
  .ds-big--neg { color: var(--danger); }
  .ds-val-tick { animation: ds-tick 180ms var(--ease); }

  /* modal / toast */
  .ds-modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--s-4); background: var(--overlay); animation: ds-fade var(--dur-base) var(--ease) both; overflow-y: auto; }
  .ds-modal.hidden { display: none; }
  .ds-modal__panel { width: 100%; max-width: 500px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--card); border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: var(--shadow-modal); padding: var(--s-5); display: grid; gap: var(--s-4); animation: ds-modal-in var(--dur-base) var(--ease) both; }
  .ds-modal__panel--wide { max-width: 600px; }
  .ds-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
  .ds-toasts { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-toast); display: grid; gap: 8px; pointer-events: none; }
  .ds-toast { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--card); border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: 3px 3px 0 var(--ink); color: var(--ink); font-family: var(--font-mono); font-size: 13px; animation: ds-fade var(--dur-base) var(--ease) both; }

  /* accordion editorial */
  .ds-acc { display: grid; border-top: 1.5px solid var(--ink); }
  .ds-acc details { border-bottom: 1px solid var(--line); interpolate-size: allow-keywords; }
  .ds-acc summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 14px 0; min-height: 48px; cursor: pointer; font-weight: 600; font-size: 15px; color: var(--ink); }
  .ds-acc summary::after { content: "+"; font-family: var(--font-mono); font-size: 18px; line-height: 1; color: var(--muted); transition: transform var(--dur-base) var(--ease); flex: none; }
  .ds-acc details[open] summary::after { transform: rotate(45deg); color: var(--ink); }
  .ds-acc details::details-content { block-size: 0; overflow: clip; transition: block-size var(--dur-base) var(--ease), content-visibility var(--dur-base) allow-discrete; }
  .ds-acc details[open]::details-content { block-size: auto; }
  .ds-acc__body { padding: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 68ch; }

  /* listas e utilitários de conteúdo */
  .ds-list { display: grid; gap: 7px; list-style: disc; padding-left: 1.1rem; }
  .ds-list li { font-size: 14px; color: var(--muted); line-height: 1.5; }
  .ds-list li strong { color: var(--ink); }
  .ds-empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-6) var(--s-4); text-align: center; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .ds-divider { height: 1px; background: var(--line); border: 0; }
  .ds-notice { padding: 12px 14px; border: 1.5px solid var(--ink); border-left: 4px solid var(--acc); background: var(--tint); border-radius: 2px; font-size: 13px; line-height: 1.5; color: var(--ink); }
  .ds-notice--danger { border-color: var(--danger); border-left: 4px solid var(--danger); background: var(--card); color: var(--danger); }
  .ds-price { display: flex; align-items: baseline; gap: 6px; }
  .ds-price b { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 600; color: var(--ink); }

  /* páginas legais (editorial) */
  .ds-legal { display: grid; grid-template-columns: 200px minmax(0, 68ch); gap: clamp(24px, 5vw, 64px); justify-content: center; align-items: start; }
  .ds-toc { position: sticky; top: 88px; display: grid; gap: 2px; font-family: var(--font-mono); font-size: 12px; }
  .ds-toc a { padding: 6px 10px; border-left: 2px solid var(--line); color: var(--muted); }
  .ds-toc a:hover { color: var(--ink); }
  .ds-toc a.is-active { color: var(--ink); border-left-color: var(--ink); font-weight: 600; }
  .ds-prose { font-size: 1rem; line-height: 1.7; color: var(--text-2); }
  .ds-prose h2 { margin-top: var(--s-6); margin-bottom: var(--s-2); font-size: 1.4rem; }
  .ds-prose h2 .ds-anchor { margin-left: 6px; color: var(--text-4); opacity: 0; font-weight: 400; font-family: var(--font-mono); }
  .ds-prose h2:hover .ds-anchor { opacity: 1; }
  .ds-prose p + p, .ds-prose ul { margin-top: var(--s-3); }
  .ds-prose ul { list-style: disc; padding-left: 1.2rem; display: grid; gap: 6px; }
  .ds-prose a { color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
  @media (max-width: 900px) { .ds-legal { grid-template-columns: minmax(0, 1fr); } .ds-toc { display: none; } }

  /* rodapé minimalista com régua superior forte */
  .ds-footer { border-top: 1.5px solid var(--ink); margin-top: var(--s-7); background: var(--paper); }
  .ds-footer__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding: 18px 0 30px; font: 400 12px var(--font-mono); color: var(--muted); }
  .ds-footer__bar a { color: var(--muted); background: linear-gradient(currentColor, currentColor) 0 100%/0 1.5px no-repeat; transition: background-size 160ms ease, color var(--dur-fast); }
  .ds-footer__bar a:hover { color: var(--ink); background-size: 100% 1.5px; }
}

/* ───────────────────────── utilities ───────────────────────── */
@layer utilities {
  .hidden { display: none !important; }
  .ds-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .ds-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
  .ds-row--between { justify-content: space-between; }
  .ds-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .ds-stack--lg { gap: var(--s-6); } .ds-stack--sm { gap: var(--s-2); }
  .ds-grid { display: grid; gap: var(--s-5); }
  .ds-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  @media (max-width: 820px) { .ds-grid--3 { grid-template-columns: minmax(0, 1fr); } }
  @media (max-width: 720px) { .ds-grid--2 { grid-template-columns: minmax(0, 1fr); } }
  .ds-muted { color: var(--muted); } .ds-small { font-size: var(--fs-small); } .ds-caption { font-size: var(--fs-caption); }
  .ds-right { text-align: right; } .ds-w-full { width: 100%; } .ds-min-0 { min-width: 0; }
}

/* ───────────────────────── motion (impressão térmica, barra, carimbo) ───────────────────────── */
@layer motion {
  @keyframes ds-fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes ds-modal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  @keyframes ds-tick { 0% { opacity: .6; } 100% { opacity: 1; } }
  @keyframes ed-printA { from { opacity: 0; transform: translateY(-8px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
  @keyframes ed-printB { from { opacity: 0; transform: translateY(-8px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
  @keyframes ed-hlA { from { background-size: 0 38%; } to { background-size: 100% 38%; } }
  @keyframes ed-hlB { from { background-size: 0 38%; } to { background-size: 100% 38%; } }
  @keyframes ed-drawA { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes ed-drawB { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes ed-stampA { from { opacity: 0; transform: rotate(-6deg) scale(1.75); } to { opacity: .92; transform: rotate(-6deg) scale(1); } }
  @keyframes ed-stampB { from { opacity: 0; transform: rotate(-6deg) scale(1.75); } to { opacity: .92; transform: rotate(-6deg) scale(1); } }

  .ed-pr { animation-duration: 380ms; animation-timing-function: cubic-bezier(.16, 1, .3, 1); animation-fill-mode: both; }
  .ed-hl { animation-duration: 700ms; animation-delay: 980ms; animation-timing-function: cubic-bezier(.16, 1, .3, 1); animation-fill-mode: backwards; }
  .ed-draw { animation-duration: 950ms; animation-timing-function: cubic-bezier(.65, 0, .35, 1); animation-fill-mode: both; }
  .ed-stamp { animation-duration: 420ms; animation-delay: 1260ms; animation-timing-function: cubic-bezier(.34, 1.4, .64, 1); animation-fill-mode: backwards; }

  .ed-flipA .ed-pr { animation-name: ed-printA; }
  .ed-flipB .ed-pr { animation-name: ed-printB; }
  .ed-flipA .ed-hl { animation-name: ed-hlA; }
  .ed-flipB .ed-hl { animation-name: ed-hlB; }
  .ed-flipA .ed-draw { animation-name: ed-drawA; }
  .ed-flipB .ed-draw { animation-name: ed-drawB; }
  .ed-flipA .ed-stamp { animation-name: ed-stampA; }
  .ed-flipB .ed-stamp { animation-name: ed-stampB; }

  @media (prefers-reduced-motion: reduce) {
    .ed-pr, .ed-hl, .ed-draw, .ed-stamp { animation: none !important; }
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  }
  @media print { .ds-header, .ds-footer, .ds-toasts, .ed-replay { display: none !important; } }
}
