/* Peças compartilhadas (ui/ + tokens) entre a Central de notas e a Conciliação V2 (MOGOE2E-1064).
   Design do claude.design (preset shadcn compacto, Geist) — exceção aprovada pelo dono ao Mogo DS:
   ver AGENTS.md desta pasta. Carregado por <link> ANTES do CSS de cada tela, que só acrescenta
   o que é dela. Cores só por variável --cn-* (o prefixo ficou da Central, onde nasceu): hex como
   base e oklch quando o navegador suporta. Tema claro. Sombra só em camada flutuante. */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/admin/geist-sans-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/admin/geist-mono-var.woff2') format('woff2');
}

:root {
  --cn-font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cn-mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --cn-radius: 0.625rem;          /* 10px: cartões, faixa, menus */
  --cn-radius-md: 8px;            /* botões, inputs, caixa */
  --cn-radius-sm: 6px;            /* itens de menu, segmento */

  --cn-fg: #151a26;               /* oklch(0.22 0.025 265) */
  --cn-muted: #666c78;            /* oklch(0.53 0.02 265) */
  --cn-text-2: #424853;           /* oklch(0.40 0.02 265) */
  --cn-text-3: #505561;           /* oklch(0.45 0.02 265) */
  --cn-placeholder: #828690;      /* oklch(0.62 0.015 265) */
  --cn-border: #e4e6ea;           /* oklch(0.925 0.006 265) */
  --cn-input: #dde0e5;            /* oklch(0.905 0.008 265) */
  --cn-hover: #f2f3f7;            /* oklch(0.965 0.005 265) */
  --cn-subtle: #f5f7fa;           /* oklch(0.975 0.004 265) */
  --cn-surface-2: #f9fafc;        /* oklch(0.985 0.003 265) */
  --cn-off-bg: #e9ebef;           /* oklch(0.94 0.006 265) */
  --cn-row-hover: #f7fbf8;        /* oklch(0.985 0.006 152) */
  --cn-row-sel: #edfbf0;          /* oklch(0.975 0.022 152) */

  --cn-primary: #00A653;          /* verde Mogo — ação */
  --cn-primary-hover: #009549;
  --cn-brand: #00D26E;            /* ponto "A manifestar" e barra da seleção */
  --cn-ring: rgba(183, 238, 196, 0.5); /* oklch(0.9 0.08 152 / 0.5) */

  --cn-success: #14874e;          /* oklch(0.55 0.13 155) */
  --cn-success-fg: #036639;       /* oklch(0.45 0.11 155) */
  --cn-warning: #dc932e;          /* oklch(0.72 0.14 70) */
  --cn-warning-fg: #915200;       /* oklch(0.50 0.12 65) */
  --cn-danger: #d33a3c;           /* oklch(0.58 0.19 25) */
  --cn-danger-fg: #ba2b2e;        /* oklch(0.52 0.18 25) */
  --cn-info: #3a84ca;             /* oklch(0.60 0.13 250) */
  --cn-ia-bg: #dcfbe3;            /* oklch(0.96 0.045 152) */
  --cn-ia-fg: #00682e;            /* oklch(0.45 0.13 152) */
  --cn-warn-bg: #fff5e1;          /* oklch(0.975 0.03 80) */
  --cn-err-bg: #fff0ee;           /* oklch(0.97 0.02 25) */
  --cn-info-bg: #ebf7ff;          /* oklch(0.97 0.02 250) */
  --cn-link: #0267c7;             /* oklch(0.52 0.17 255) */
  --cn-link-hover: #004ead;       /* oklch(0.44 0.17 255) */

  --cn-shadow-overlay: 0 8px 24px rgba(21, 26, 38, 0.12);
  --cn-shadow-flutuante: 0 16px 48px rgba(21, 26, 38, 0.22);
  --cn-shadow-seg: 0 1px 2px rgba(21, 26, 38, 0.06);
  --cn-shadow-toast: 0 8px 24px rgba(21, 26, 38, 0.25);
}

@supports (color: oklch(0 0 0)) {
  :root {
    --cn-fg: oklch(0.22 0.025 265);
    --cn-muted: oklch(0.53 0.02 265);
    --cn-text-2: oklch(0.4 0.02 265);
    --cn-text-3: oklch(0.45 0.02 265);
    --cn-placeholder: oklch(0.62 0.015 265);
    --cn-border: oklch(0.925 0.006 265);
    --cn-input: oklch(0.905 0.008 265);
    --cn-hover: oklch(0.965 0.005 265);
    --cn-subtle: oklch(0.975 0.004 265);
    --cn-surface-2: oklch(0.985 0.003 265);
    --cn-off-bg: oklch(0.94 0.006 265);
    --cn-row-hover: oklch(0.985 0.006 152);
    --cn-row-sel: oklch(0.975 0.022 152);
    --cn-ring: oklch(0.9 0.08 152 / 0.5);
    --cn-success: oklch(0.55 0.13 155);
    --cn-success-fg: oklch(0.45 0.11 155);
    --cn-warning: oklch(0.72 0.14 70);
    --cn-warning-fg: oklch(0.5 0.12 65);
    --cn-danger: oklch(0.58 0.19 25);
    --cn-danger-fg: oklch(0.52 0.18 25);
    --cn-info: oklch(0.6 0.13 250);
    --cn-ia-bg: oklch(0.96 0.045 152);
    --cn-ia-fg: oklch(0.45 0.13 152);
    --cn-warn-bg: oklch(0.975 0.03 80);
    --cn-err-bg: oklch(0.97 0.02 25);
    --cn-info-bg: oklch(0.97 0.02 250);
    --cn-link: oklch(0.52 0.17 255);
    --cn-link-hover: oklch(0.44 0.17 255);
    --cn-shadow-overlay: 0 8px 24px oklch(0.22 0.025 265 / 0.12);
    --cn-shadow-flutuante: 0 16px 48px oklch(0.22 0.025 265 / 0.22);
    --cn-shadow-seg: 0 1px 2px oklch(0.22 0.025 265 / 0.06);
    --cn-shadow-toast: 0 8px 24px oklch(0.22 0.025 265 / 0.25);
  }
}

/* Tons semânticos: qualquer elemento com data-tom define ponto, texto e fundo. */
[data-tom] { --tom-ponto: var(--cn-muted); --tom-texto: var(--cn-fg); --tom-fundo: var(--cn-subtle); --tom-selo: var(--cn-text-2); }
[data-tom="marca"] { --tom-ponto: var(--cn-brand); }
[data-tom="info"] { --tom-ponto: var(--cn-info); --tom-fundo: var(--cn-info-bg); }
[data-tom="ok"] { --tom-ponto: var(--cn-success); --tom-texto: var(--cn-success-fg); }
[data-tom="ia"] { --tom-ponto: var(--cn-success); --tom-fundo: var(--cn-ia-bg); --tom-selo: var(--cn-ia-fg); }
[data-tom="aviso"] { --tom-ponto: var(--cn-warning); --tom-texto: var(--cn-warning-fg); --tom-fundo: var(--cn-warn-bg); --tom-selo: var(--cn-warning-fg); }
[data-tom="perigo"] { --tom-ponto: var(--cn-danger); --tom-texto: var(--cn-danger-fg); --tom-fundo: var(--cn-err-bg); --tom-selo: var(--cn-danger-fg); }

.cn-menu, .cn-menu * { box-sizing: border-box; }

/* ------------------------------------------------------------ botões --- */
.cn-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  height: 32px; padding: 0 12px; border-radius: var(--cn-radius-md); border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 500; color: inherit; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.cn-btn:focus-visible { outline: 0; border-color: var(--cn-primary); box-shadow: 0 0 0 3px var(--cn-ring); }
.cn-btn--contorno { background: #fff; border-color: var(--cn-input); }
.cn-btn--contorno:hover:not(:disabled) { background: var(--cn-subtle); }
.cn-btn--fantasma { background: transparent; padding: 0 10px; }
.cn-btn--fantasma:hover:not(:disabled) { background: var(--cn-hover); }
.cn-btn--primario { background: var(--cn-primary); border-color: var(--cn-primary); color: #fff; }
.cn-btn--primario:hover:not(:disabled) { background: var(--cn-primary-hover); border-color: var(--cn-primary-hover); }
.cn-btn--perigo { background: var(--cn-danger); border-color: var(--cn-danger); color: #fff; }
.cn-btn--perigo:hover:not(:disabled) { background: var(--cn-danger-fg); border-color: var(--cn-danger-fg); }
.cn-btn--link { background: transparent; padding: 0 8px; color: var(--cn-link); }
.cn-btn--link:hover:not(:disabled) { color: var(--cn-link-hover); text-decoration: underline; }
.cn-btn--sm { height: 28px; }
.cn-btn--xs { height: 26px; padding: 0 10px; border-radius: 7px; }
.cn-btn:disabled { cursor: not-allowed; background: var(--cn-off-bg); border-color: transparent; color: var(--cn-muted); }
.cn-btn[aria-busy="true"] { cursor: progress; }
.cn-btn--fantasma:disabled, .cn-btn--link:disabled { background: transparent; }

/* ---------------------------------------------------- pontos e selos --- */
.cn-ponto { display: inline-block; width: 6px; height: 6px; border-radius: 99px; flex: none; background: var(--tom-ponto, var(--cn-muted)); }
.cn-estado { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--tom-texto); font-weight: 500; }
.cn-selo {
  display: block; flex: none; height: 18px; line-height: 18px; padding: 0 6px; border-radius: 5px;
  font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--tom-fundo); color: var(--tom-selo);
}
.cn-selo[data-tom="neutro"] { background: var(--cn-hover); }
.cn-selo--lg { display: inline-flex; align-items: center; height: 20px; line-height: 20px; padding: 0 7px; border-radius: 6px; }

/* -------------------------------------------------------- segmentado --- */
.cn-seg {
  height: 32px; padding: 2px; display: flex; gap: 2px; background: var(--cn-subtle);
  border: 1px solid var(--cn-border); border-radius: var(--cn-radius-md);
}
.cn-seg-item {
  height: 100%; padding: 0 10px; display: flex; align-items: center; gap: 6px; border: 0; border-radius: var(--cn-radius-sm);
  background: transparent; font: inherit; font-size: 13px; font-weight: 500; color: var(--cn-muted); white-space: nowrap; cursor: pointer;
}
.cn-seg-item:hover { color: var(--cn-fg); }
.cn-seg-item[aria-pressed="true"] { background: #fff; color: var(--cn-fg); box-shadow: var(--cn-shadow-seg), 0 0 0 1px var(--cn-border); }
.cn-seg-item:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--cn-ring); }
.cn-seg-num { font-size: 12px; font-weight: 500; color: var(--cn-muted); }

/* ------------------------------------------------------------- campo --- */
.cn-input {
  height: 32px; padding: 0 10px; border: 1px solid var(--cn-input); border-radius: var(--cn-radius-md); background: #fff;
  font: inherit; font-size: 13px; color: inherit; outline: 0;
}
.cn-input::placeholder { color: var(--cn-placeholder); }
.cn-input:focus { border-color: var(--cn-primary); box-shadow: 0 0 0 3px var(--cn-ring); }

/* --------------------------------------------------- menu de escolha --- */
.cn-filtro {
  height: 32px; padding: 0 10px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--cn-input);
  border-radius: var(--cn-radius-md); background: #fff; font: inherit; font-size: 13px; color: inherit; cursor: pointer;
}
.cn-filtro:hover { background: var(--cn-subtle); }
.cn-filtro:focus-visible { outline: 0; border-color: var(--cn-primary); box-shadow: 0 0 0 3px var(--cn-ring); }
.cn-filtro-k { color: var(--cn-muted); }
.cn-filtro-v { font-weight: 500; }
.cn-chevron {
  width: 6px; height: 6px; margin-left: 4px; border-right: 1.5px solid var(--cn-muted); border-bottom: 1.5px solid var(--cn-muted);
  transform: translateY(-2px) rotate(45deg);
}

/* ------------------------------------------------------------- menus --- */
.cn-menu {
  z-index: 50; background: #fff; border: 1px solid var(--cn-border); border-radius: var(--cn-radius);
  box-shadow: var(--cn-shadow-overlay); font-family: var(--cn-font); font-size: 13px; line-height: 1.45; color: var(--cn-fg);
}
.cn-menu { padding: 4px; display: flex; flex-direction: column; }
.cn-menu-item { height: 32px; padding: 0 10px; border-radius: var(--cn-radius-sm); display: flex; align-items: center; cursor: pointer; outline: 0; user-select: none; }
.cn-menu-item[data-highlighted] { background: var(--cn-hover); }
.cn-menu-item--escolha { height: 30px; padding: 0 8px; justify-content: space-between; gap: 12px; }
.cn-menu-item--escolha[data-state="checked"] { font-weight: 500; }
.cn-menu-check { color: var(--cn-primary); font-weight: 600; }

/* --------------------------------------------------------- esqueleto --- */
.cn-skel { display: block; max-width: 100%; border-radius: 4px; background: var(--cn-hover); animation: cn-pulso 1.2s ease-in-out infinite; }
@keyframes cn-pulso { 50% { opacity: 0.45; } }

/* ------------------------------------------------------------- vazio --- */
.cn-vazio { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px; text-align: center; }
.cn-vazio-titulo { font-size: 14px; font-weight: 500; }
.cn-vazio[data-erro] .cn-vazio-titulo { color: var(--cn-danger-fg); }
.cn-vazio-texto { max-width: 420px; color: var(--cn-muted); text-wrap: pretty; }
.cn-vazio-texto--estreito { max-width: 260px; }

/* --------------------------------------------------- caixa de estado --- */
.cn-caixa { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--cn-radius-md); background: var(--tom-fundo); }
.cn-caixa-titulo { font-weight: 600; }
.cn-caixa-texto { color: var(--cn-text-2); text-wrap: pretty; }

/* ----------------------------------------------------------- diálogo --- */
.cn-dlg-fundo { position: fixed; inset: 0; z-index: 60; background: rgba(21, 26, 38, 0.32); }
.cn-dlg {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 61;
  max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--cn-border); border-radius: var(--cn-radius); box-shadow: var(--cn-shadow-flutuante);
  font-family: var(--cn-font); font-size: 13px; color: var(--cn-fg);
}
.cn-dlg:focus { outline: 0; }
.cn-dlg, .cn-dlg * { box-sizing: border-box; }
.cn-dlg-cab { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px 12px; }
.cn-dlg-titulos { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cn-dlg-titulo { margin: 0; font-size: 16px; font-weight: 600; }
.cn-dlg-sub { font-size: 13px; color: var(--cn-muted); }
.cn-dlg-corpo { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 18px; }
.cn-dlg-rodape { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--cn-border); background: var(--cn-surface-2); border-radius: 0 0 var(--cn-radius) var(--cn-radius); }

/* ------------------------------------------------------- formulários --- */
.cn-form { display: flex; flex-direction: column; gap: 12px; }
.cn-form--linha { flex-direction: row; }
.cn-form--linha > .cn-campo { flex: 1; }
.cn-campo { display: flex; flex-direction: column; gap: 6px; }
.cn-campo-rot { font-size: 12px; font-weight: 500; }
.cn-campo-dica { font-size: 12px; color: var(--cn-muted); text-wrap: pretty; }
.cn-campo-dica[data-tom] { color: var(--tom-texto); }
.cn-campo .cn-input { width: 100%; }
.cn-textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.45; resize: vertical; }
.cn-input--mono { font-family: var(--cn-mono); letter-spacing: 0.02em; }
select.cn-input { padding-right: 6px; cursor: pointer; }
.cn-form-erro { padding: 8px 10px; border-radius: var(--cn-radius-md); background: var(--cn-err-bg); color: var(--cn-danger-fg); font-size: 12px; text-wrap: pretty; }

/* ------------------------------------------------------------- toast --- */
.cn-toast-area { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; pointer-events: none; }
.cn-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(720px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px; border-radius: var(--cn-radius); background: var(--cn-fg); color: #fff; font-size: 13px;
  box-shadow: var(--cn-shadow-toast);
}
.cn-toast-icone {
  width: 18px; height: 18px; flex: none; border-radius: 99px; display: flex; align-items: center; justify-content: center;
  background: var(--cn-success); color: #fff; font-size: 11px; font-weight: 700;
}
.cn-toast[data-tipo="warning"] .cn-toast-icone { background: var(--cn-warning); }
.cn-toast[data-tipo="error"] .cn-toast-icone { background: var(--cn-danger); }
.cn-toast-texto { padding: 2px 0; text-wrap: pretty; }
.cn-toast-acao {
  flex: none; height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: #fff;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--cn-fg); cursor: pointer;
}
.cn-toast-fechar { flex: none; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; font: inherit; font-size: 15px; color: #fff; cursor: pointer; }
.cn-toast-acao:focus-visible, .cn-toast-fechar:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------------------------------------------------------- combobox --- */
/* Combobox com lista local (a Central usa para produto). */
.cn-combo { position: relative; min-width: 0; }
.cn-combo .cn-input { width: 100%; }
.cn-combo .cn-input[aria-invalid="true"] { border-color: var(--cn-warning); }
.cn-combo-lista {
  position: absolute; z-index: 70; top: calc(100% + 4px); left: 0; right: 0; max-height: 240px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--cn-border);
  border-radius: var(--cn-radius); box-shadow: var(--cn-shadow-overlay);
}
.cn-combo-opcao { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: var(--cn-radius-sm); cursor: pointer; }
.cn-combo-opcao[data-ativo] { background: var(--cn-hover); }
.cn-combo-detalhe { flex: none; font-size: 12px; color: var(--cn-muted); }
.cn-combo-vazio { padding: 8px; font-size: 12px; color: var(--cn-muted); }

@media (prefers-reduced-motion: reduce) {
  .cn-skel { animation: none; }
  .cn-btn { transition: none; }
}

/* ------------------------------------------- seletor de período (ui/periodo.jsx) --- */
/* O mesmo do Dashboard: setas ‹ › em volta do botão, popover com Fixa/Desde/Últimos e atalhos. */
.cn-periodo { display: flex; align-items: center; gap: 4px; }
.cn-periodo-seta {
  width: 32px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--cn-input); border-radius: var(--cn-radius-md); background: #fff; cursor: pointer;
}
.cn-periodo-seta:hover:not(:disabled) { background: var(--cn-subtle); }
.cn-periodo-seta:focus-visible { outline: 0; border-color: var(--cn-primary); box-shadow: 0 0 0 3px var(--cn-ring); }
.cn-periodo-seta:disabled { cursor: not-allowed; opacity: .45; }
.cn-periodo-chev { width: 7px; height: 7px; border-right: 1.5px solid var(--cn-text-2); border-bottom: 1.5px solid var(--cn-text-2); }
.cn-periodo-chev--esq { transform: translateX(1px) rotate(135deg); }
.cn-periodo-chev--dir { transform: translateX(-1px) rotate(-45deg); }
.cn-periodo-texto { font-family: var(--cn-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cn-periodo-pop { width: 340px; max-width: calc(100vw - 16px); padding: 0; gap: 0; overflow: hidden; }
.cn-periodo-abas { display: flex; border-bottom: 1px solid var(--cn-border); }
.cn-periodo-aba {
  flex: 1; height: 40px; border: 0; border-bottom: 2px solid transparent; background: transparent; font: inherit; font-size: 13px;
  font-weight: 500; color: var(--cn-muted); cursor: pointer;
}
.cn-periodo-aba:hover { color: var(--cn-fg); background: var(--cn-subtle); }
.cn-periodo-aba[aria-selected="true"] { color: var(--cn-primary); border-bottom-color: var(--cn-primary); }
.cn-periodo-aba:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--cn-ring); }
.cn-periodo-corpo { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.cn-periodo-linha { display: flex; gap: 8px; }
.cn-periodo-linha > * { flex: 1; min-width: 0; }
.cn-periodo-campo { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.cn-periodo-campo .cn-input, .cn-periodo-linha .cn-input { width: 100%; }
.cn-periodo-rot { font-size: 12px; color: var(--cn-muted); }
.cn-periodo-num { max-width: 96px; }
.cn-periodo-erro { font-size: 12px; color: var(--cn-danger-fg); }
.cn-periodo-sep { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; color: var(--cn-muted); }
.cn-periodo-sep::after { content: ''; flex: 1; height: 1px; background: var(--cn-border); }
.cn-periodo-atalhos { display: flex; flex-wrap: wrap; gap: 6px; }
.cn-periodo-atalho {
  height: 28px; padding: 0 10px; border: 1px solid var(--cn-input); border-radius: 999px; background: #fff;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--cn-text-2); cursor: pointer;
}
.cn-periodo-atalho:hover { background: var(--cn-subtle); color: var(--cn-fg); }
.cn-periodo-atalho:focus-visible { outline: 0; border-color: var(--cn-primary); box-shadow: 0 0 0 3px var(--cn-ring); }
.cn-periodo-atalho[data-sel] { background: var(--cn-ia-bg); border-color: var(--cn-primary); color: var(--cn-ia-fg); }
.cn-periodo-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--cn-border); }
