/* E-Comece Família Stores — base e componentes. Só tokens (assets/tokens.css). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--c-bg); color: var(--c-text); font-family: var(--font-sans); font-size: var(--fs-base); line-height: var(--lh-base); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 var(--s-3); line-height: 1.2; color: var(--c-text); }
h1 { font-size: var(--fs-xl); font-weight: var(--fw-xl); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-lg); }
h3 { font-size: var(--fs-base); font-weight: 700; }
p { margin: 0 0 var(--s-3); }
a { color: var(--c-primary); }
img, svg { max-width: 100%; }
.ico { flex: none; vertical-align: middle; }
.muted { color: var(--c-text-muted); }
.small { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--c-primary); color: var(--c-on-primary); padding: var(--s-2) var(--s-4); border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-md);
  border: 1px solid transparent; font: inherit; font-weight: 700; font-size: var(--fs-sm); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--m-fast) var(--m-ease), transform var(--m-fast) var(--m-ease); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-accent { background: var(--c-accent); color: var(--c-on-accent); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary { background: var(--c-bg); color: var(--c-text); border-color: var(--c-border-input); }
.btn-secondary:hover:not(:disabled) { background: var(--c-surface); }
.btn-ghost { background: transparent; color: var(--c-text); }
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-2); }
.btn-danger { background: var(--c-danger); color: var(--c-bg); }
.btn-sm { min-height: 32px; padding: 0 var(--s-3); }
.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-base); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }

/* Formulários */
.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); min-width: 0; }
.field label, .label { font-size: var(--fs-sm); font-weight: 700; }
.field .hint { font-size: var(--fs-xs); color: var(--c-text-muted); font-weight: 400; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3); border: 1px solid var(--c-border-input); border-radius: var(--r-sm); background: var(--c-bg);
  color: var(--c-text); font: inherit; }
.field textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); margin-bottom: var(--s-3); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--c-primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 var(--s-4); }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.form-error { background: var(--c-surface); border-left: 4px solid var(--c-danger); color: var(--c-danger); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); margin-bottom: var(--s-4); font-size: var(--fs-sm); font-weight: 700; }
.input-search { position: relative; }
.input-search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); }
.input-search input { padding-left: 36px !important; }

/* Cartões e badges */
.card { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: var(--s-5); min-width: 0; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; line-height: 18px;
  background: var(--c-surface-2); color: var(--c-text); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok, .badge-pago, .badge-concluida, .badge-concluido { color: var(--c-success); }
.badge-pendente, .badge-baixo, .badge-aberto, .badge-novo, .badge-aceito { color: var(--c-warning); }
.badge-zerado, .badge-vencido, .badge-cancelada, .badge-cancelado { color: var(--c-danger); }
.badge-demo { color: var(--c-info); }
.badge-plain::before { display: none; }

/* Tabelas */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-bg); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); background: var(--c-surface); padding: var(--s-2) var(--s-3); white-space: nowrap; }
.table td { padding: var(--s-3); border-top: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:hover { background: var(--c-surface); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--c-text-muted); }
.empty .ico { color: var(--c-text-muted); margin-bottom: var(--s-2); }
.empty h3 { color: var(--c-text); }

/* Modal */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--c-bg); color: var(--c-text); box-shadow: var(--sh-pop); }
dialog.modal-sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal-lg { width: min(820px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 14, 18, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; background: var(--c-bg); z-index: 1; }
.modal-head h2 { margin: 0; }
.modal-body { padding: var(--s-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--c-border); flex-wrap: wrap; position: sticky; bottom: 0; background: var(--c-bg); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: var(--s-2); z-index: 1000; max-width: calc(100vw - 32px); }
.toast { display: flex; gap: var(--s-2); align-items: center; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--c-text); color: var(--c-bg); box-shadow: var(--sh-pop); font-size: var(--fs-sm); font-weight: 600; transition: opacity var(--m-base); }
.toast.out { opacity: 0; }
.toast-error { background: var(--c-danger); }

/* Abas */
.tabs { position: relative; display: flex; gap: var(--s-1); border-bottom: 1px solid var(--c-border); margin-bottom: var(--s-5); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: var(--s-2) var(--s-3); font: inherit; font-weight: 700; font-size: var(--fs-sm); color: var(--c-text-muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* Gráficos */
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--c-border); stroke-width: 1; }
.chart .axis-label { fill: var(--c-text-muted); font-size: 11px; font-family: var(--font-sans); }
.chart .bar-fill { fill: var(--c-primary); opacity: .9; }
.chart .bar.on .bar-fill, .chart .bar:focus .bar-fill { opacity: 1; filter: brightness(1.15); }
.chart .bar:focus { outline: none; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--c-text); color: var(--c-bg); padding: 4px 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; pointer-events: none; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.hbars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; background: var(--c-surface-2); border-radius: var(--r-pill); overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--c-primary); border-radius: var(--r-pill); }
.hb-val { font-variant-numeric: tabular-nums; font-weight: 700; }

.demo-banner { background: var(--c-primary-soft); color: var(--c-text); font-size: var(--fs-xs); font-weight: 700; text-align: center; padding: 6px var(--s-4); border-bottom: 1px solid var(--c-border); }
.demo-banner strong { color: var(--c-primary); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print { .no-print { display: none !important; } }
.logo-slot, .brand .logo-slot, .brand-text .logo-slot { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background: var(--c-primary); color: var(--c-on-primary); font-family: var(--font-sans); font-weight: 800; letter-spacing: .04em; box-shadow: inset 0 0 0 2px var(--c-accent); }
.brand-logo { flex: none; display: inline-block; border-radius: 50%; object-fit: contain; aspect-ratio: 1 / 1; box-shadow: 0 0 0 1px var(--c-border); }
/* Escolha de variante (tamanho) */
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s-2); }
.variant-btn { flex-direction: column; height: auto; min-height: 56px; padding: var(--s-2); gap: 2px; white-space: normal; text-align: center; }
.variant-btn[disabled] { opacity: .55; cursor: not-allowed; }
