﻿/* winsig-ui.css — componentes Winsig UI (copiado de docs/Winsig UI — Guidelines.md). Carregar depois de tokens.css. */

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

html, body.ws-app { height: 100%; margin: 0; }
.ws-app { margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.ws-app :focus-visible, .ws-focus:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Tipografia */
.ws-display { font: 700 24px/30px var(--font-sans); margin: 0; }
.ws-h1 { font: 700 24px/30px var(--font-sans); margin: 0; }
.ws-h2 { font: 700 16px/22px var(--font-sans); margin: 0; }
.ws-h3 { font: 700 14px/20px var(--font-sans); margin: 0; }
.ws-mono { font-family: var(--font-mono); font-size: 13px; }
.ws-sec { display: flex; align-items: center; gap: var(--space-2); font: 700 18px/24px var(--font-sans); }
 .ws-sec::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }
.ws-overline { font: 600 11px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); margin: 0; }
.ws-body-sm { font-size: 13px; line-height: 18px; }
.ws-muted { color: var(--ink-muted); }
.ws-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ws-link { color: var(--primary-ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

/* Ícones (máscara CSS; cor = currentColor) */
.ws-i { display: inline-block; flex: none; width: 20px; height: 20px; background-color: currentColor; -webkit-mask: var(--ws-icon) center / contain no-repeat; mask: var(--ws-icon) center / contain no-repeat; }
.ws-i--sm { width: 16px; height: 16px; }

/* Botão */
.ws-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font: 500 13px/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s; }
.ws-btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.ws-btn--primary:hover { background: var(--primary-hover); }
.ws-btn--primary:active { background: var(--primary-pressed); }
.ws-btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.ws-btn--secondary[aria-pressed="true"] { background: var(--primary-subtle); border-color: var(--primary); color: var(--primary-ink); }
.ws-btn--secondary:hover { background: var(--surface-alt); }
.ws-btn--ghost { background: transparent; color: var(--primary-ink); }
.ws-btn--ghost:hover { background: var(--primary-subtle); }
.ws-btn--danger { background: var(--danger); color: var(--on-danger); }
.ws-btn--sm { min-height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.ws-btn--icon { width: var(--control-h); padding: 0; }
.ws-btn--icon.ws-btn--sm { width: 32px; }
.ws-btn--block { width: 100%; }
.ws-btn:disabled, .ws-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.ws-btn__count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--pal-amarelo); color: var(--on-accent); font: 700 12px/20px var(--font-sans); text-align: center; }

/* Campos */
.ws-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ws-label { font: 600 12px/16px var(--font-sans); color: var(--ink-muted); }
.ws-label .ws-req { color: var(--danger); margin-left: 2px; }
.ws-input, .ws-select { width: 100%; min-height: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font: 400 14px/20px var(--font-sans); }
.ws-input::placeholder { color: var(--ink-muted); }
.ws-input:hover, .ws-select:hover { border-color: var(--ink-muted); }
.ws-input:focus-visible, .ws-select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring); }
.ws-select { appearance: none; padding-right: 40px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.ws-help { font-size: 13px; line-height: 18px; color: var(--ink-muted); display: flex; gap: 6px; align-items: center; }
.ws-field--error .ws-input, .ws-field--error .ws-select { border-color: var(--danger); border-width: 2px; }
.ws-field--error .ws-help { color: var(--danger); }
.ws-input-group { position: relative; display: flex; align-items: center; }
.ws-input-group > .ws-i { position: absolute; left: 12px; color: var(--ink-muted); pointer-events: none; }
.ws-input-group > .ws-input { padding-left: 40px; }
@media (max-width: 899px) { .ws-input, .ws-select { font-size: 16px; min-height: var(--touch-target); } .ws-btn { min-height: var(--touch-target); } }

/* Checkbox / radio / switch */
.ws-check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: 14px; min-height: 32px; }
.ws-check input { appearance: none; margin: 0; width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); display: grid; place-content: center; cursor: pointer; flex: none; }
.ws-check input[type="radio"] { border-radius: 50%; }
.ws-check input:checked { background: var(--primary); border-color: var(--primary); }
.ws-check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-primary); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.ws-check input[type="checkbox"]:indeterminate { background: var(--primary); border-color: var(--primary); }
.ws-check input[type="checkbox"]:indeterminate::after { content: ""; width: 9px; height: 2px; background: var(--on-primary); }
.ws-check input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-primary); }
.ws-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; min-height: 32px; }
.ws-switch input { appearance: none; margin: 0; width: 40px; height: 24px; border-radius: var(--radius-pill); background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.ws-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #ffffff; transition: transform .15s; }
.ws-switch input:checked { background: var(--primary); }
.ws-switch input:checked::after { transform: translateX(16px); }

/* Badge de estado */
.ws-badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 22px; padding: 0 8px; border-radius: var(--radius-pill); border: 1px solid var(--neutral-line); font: 600 12px/1 var(--font-sans); white-space: nowrap; background: var(--neutral-subtle); color: var(--ink); }
.ws-badge .ws-i { width: 14px; height: 14px; color: var(--pal-cinzento); }
.ws-badge--success { background: var(--success-subtle); border-color: var(--success-line); } .ws-badge--success .ws-i { color: var(--success); }
.ws-badge--warning { background: var(--warning-subtle); border-color: var(--warning-line); } .ws-badge--warning .ws-i { color: var(--warning); }
.ws-badge--danger { background: var(--danger-subtle); border-color: var(--danger-line); } .ws-badge--danger .ws-i { color: var(--danger); }
.ws-badge--serious { background: var(--serious-subtle); border-color: var(--serious-line); } .ws-badge--serious .ws-i { color: var(--pal-laranja); }
.ws-badge--info { background: var(--info-subtle); border-color: var(--info-line); } .ws-badge--info .ws-i { color: var(--primary-ink); }
.ws-badge--accent { background: var(--accent); border-color: transparent; color: var(--on-accent); }

/* Chip de filtro */
.ws-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: 600 13px/1 var(--font-sans); cursor: pointer; white-space: nowrap; }
.ws-chip:hover { background: var(--surface-alt); }
.ws-chip[aria-pressed="true"], .ws-chip--active { background: var(--primary-subtle); border-color: var(--primary-ink); color: var(--primary-ink); }
.ws-chip__count { min-width: 18px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-alt); color: var(--ink-muted); font-size: 11px; line-height: 18px; text-align: center; }
.ws-chip[aria-pressed="true"] .ws-chip__count { background: var(--primary); color: var(--on-primary); }
.ws-chip__key { font-weight: 400; color: var(--ink-muted); }
.ws-chip--active .ws-chip__key { color: var(--primary-ink); }
.ws-chip__remove { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: -6px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; padding: 0; }
.ws-chip__remove:hover { background: var(--surface); }
.ws-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* Cartão e KPI */
.ws-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-4); }
.ws-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.ws-kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: var(--space-1); }
.ws-kpi::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--primary); }
.ws-kpi--success::before { background: var(--pal-turquesa); }
.ws-kpi--warning::before { background: var(--pal-amarelo); }
.ws-kpi--danger::before { background: var(--pal-vermelho); }
.ws-kpi__label { font: 400 12px/16px var(--font-sans); color: var(--ink-muted); }
.ws-kpi__value { font: 700 24px/30px var(--font-sans); font-variant-numeric: tabular-nums; }
.ws-kpi__delta { display: inline-flex; align-items: center; gap: 4px; font: 700 13px/18px var(--font-sans); }
.ws-kpi__delta--up { color: var(--success); }
.ws-kpi__delta--down { color: var(--danger); }
.ws-kpi--brand, .ws-kpi--brand:visited, .ws-kpi--brand:hover { background: var(--nav-bg); color: var(--nav-ink); border-color: transparent; }
.ws-kpi--brand::before { background: var(--pal-turquesa); }
.ws-kpi--brand .ws-kpi__value, .ws-kpi--brand .ws-h3, .ws-kpi--brand .ws-num { color: var(--nav-ink); }
.ws-kpi--brand .ws-overline, .ws-kpi--brand .ws-muted { color: var(--nav-ink-muted); }

/* Separadores */
.ws-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.ws-tab { position: relative; padding: 0 var(--space-4); height: 44px; border: 0; background: none; color: var(--ink-muted); font: 500 14px/1 var(--font-sans); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-2); }
.ws-tab:hover { color: var(--ink); }
.ws-tab[aria-selected="true"] { color: var(--primary-ink); font-weight: 600; }
.ws-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.ws-tab__count { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-alt); color: var(--ink-muted); }

/* Alerta */
.ws-alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--info-subtle); border: 1px solid var(--info-line); color: var(--ink); }
.ws-alert > .ws-i { margin-top: 1px; color: var(--primary-ink); }
.ws-alert__title { font-weight: 700; display: block; }
.ws-alert--success { background: var(--success-subtle); border-color: var(--success-line); }
.ws-alert--success > .ws-i { color: var(--success); }
.ws-alert--warning { background: var(--warning-subtle); border-color: var(--warning-line); }
.ws-alert--warning > .ws-i { color: var(--warning); }
.ws-alert--danger { background: var(--danger-subtle); border-color: var(--danger-line); }
.ws-alert--danger > .ws-i { color: var(--danger); }

/* Paginação */
.ws-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-muted); flex-wrap: wrap; }
.ws-pager__pages { display: flex; gap: var(--space-1); align-items: center; }
.ws-pager__page { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-md); background: none; color: var(--ink); font: 600 13px/1 var(--font-sans); cursor: pointer; text-decoration: none; }
.ws-pager__page:hover { background: var(--surface-alt); }
.ws-pager__page[aria-current="page"] { background: var(--primary); color: var(--on-primary); }

/* App shell (container queries) */
.ws-shell { container: shell / inline-size; height: 100vh; height: 100dvh; overflow: hidden; }
.ws-shell__frame { display: grid; grid-template-areas: "top" "main" "bottom"; grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100%; background: var(--bg); }
.ws-topbar { grid-area: top; display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); background: var(--topbar-bg); color: var(--topbar-ink); border-bottom: 1px solid var(--border); }
.ws-topbar__logo { height: 48px; width: auto; max-width: 120px; display: block; }
.ws-topbar__spacer { flex: 1; }
.ws-topbar .ws-btn--icon { color: var(--topbar-ink); background: transparent; }
.ws-topbar .ws-btn--icon:hover { background: var(--surface-alt); }
.ws-topbar__user { display: flex; align-items: center; gap: var(--space-2); padding-left: var(--space-2); border-left: 1px solid var(--border); }
.ws-topbar__name { color: var(--topbar-ink); white-space: nowrap; }
.ws-topbar__logout { display: contents; }
.ws-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font: 700 13px/1 var(--font-sans); flex: none; }
.ws-sidenav { grid-area: side; display: none; background: var(--nav-side-bg); color: var(--nav-ink-muted); padding: var(--space-3); flex-direction: column; gap: var(--space-1); overflow-y: auto; min-height: 0; }
.ws-navitem { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--nav-ink-muted); text-decoration: none; font: 400 14px/1 var(--font-sans); white-space: nowrap; }
.ws-navitem:hover { color: var(--nav-ink); background: rgba(255, 255, 255, 0.08); }
.ws-navitem[aria-current="page"] { background: var(--nav-active); color: var(--nav-ink); font-weight: 600; }
.ws-sidenav :focus-visible { outline-color: var(--nav-ink); }
.ws-navgroup { font: 600 11px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--nav-ink-faint); padding: var(--space-4) var(--space-3) var(--space-2); }
.ws-main { grid-area: main; overflow: auto; padding: var(--space-4); min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.ws-main > * { flex-shrink: 0; }
.ws-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.ws-pagehead .ws-h1 { font-size: 24px; line-height: 30px; }
.ws-bottomnav { grid-area: bottom; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--bottomnav-h); background: var(--surface); border-top: 1px solid var(--border); position: sticky; bottom: 0; }
.ws-bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-muted); text-decoration: none; font: 600 11px/1 var(--font-sans); }
.ws-bottomnav a[aria-current="page"] { color: var(--primary-ink); }
.ws-only-wide { display: none !important; }
@container shell (min-width: 900px) {
  .ws-shell__frame { grid-template-areas: "top top" "side main"; grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); grid-template-rows: var(--topbar-h) minmax(0, 1fr); }
  .ws-sidenav { display: flex; }
  .ws-sidenav .ws-navitem span, .ws-sidenav .ws-navgroup { display: none; }
  .ws-sidenav .ws-navitem { justify-content: center; padding: 0; }
  .ws-bottomnav { display: none; }
  .ws-main { padding: var(--space-6); gap: var(--space-6); }
  .ws-pagehead .ws-h1 { font-size: 24px; line-height: 30px; }
  .ws-only-narrow { display: none !important; }
  .ws-only-wide { display: revert !important; }
}
@container shell (min-width: 1200px) {
  .ws-shell__frame { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .ws-sidenav .ws-navitem span, .ws-sidenav .ws-navgroup { display: revert; }
  .ws-sidenav .ws-navitem { justify-content: flex-start; padding: 0 var(--space-3); }
  .ws-brand__name { display: inline; }
}

/* Marca */
.ws-brand { display: flex; align-items: center; gap: var(--space-3); font: 700 15px/1.15 var(--font-sans); color: var(--topbar-ink); text-decoration: none; white-space: nowrap; }
.ws-brand__name { display: none; }
.ws-brand__tile { width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--brand-tile); display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.ws-brand__tile img { width: 20px; height: auto; display: block; }
.ws-navcnt { flex: none; margin-left: auto; min-width: 20px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--pal-amarelo); color: var(--on-accent); font: 700 11px/19px var(--font-sans); text-align: center; }

/* Quadro de tarefas */
.ws-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-2); }
.ws-board__col { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.ws-board__head { display: flex; align-items: center; justify-content: space-between; font: 700 15px/20px var(--font-sans); }
.ws-taskcard { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--pal-cinzento); border-radius: var(--radius-md); padding: var(--space-3); display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.ws-taskcard--danger { border-left-color: var(--pal-vermelho); }
.ws-taskcard--warning { border-left-color: var(--pal-amarelo); }
.ws-taskcard--success { border-left-color: var(--pal-turquesa); }
.ws-taskcard--new { border-left-color: var(--pal-roxo); }

/* Barra de filtros */
.ws-filterbar { display: flex; flex-direction: column; gap: var(--space-3); }
.ws-filterbar__row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.ws-filterbar__row > .ws-field { flex: 1 1 160px; }
.ws-filterbar__search { flex: 1 1 240px; min-width: 0; }
.ws-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ws-filterbar__quick { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ws-filterbar__summary { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: 13px; color: var(--ink-muted); }

/* Gaveta de filtros: bottom sheet (mobile) / painel lateral (desktop) */
.ws-drawer-scrim { position: fixed; inset: 0; background: var(--overlay); }
.ws-drawer { position: fixed; left: 0; right: 0; bottom: 0; max-height: 85%; display: flex; flex-direction: column; background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg); }
.ws-drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); border-bottom: 1px solid var(--border); }
.ws-drawer__body { padding: var(--space-4); overflow: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.ws-drawer__foot { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
.ws-drawer__foot .ws-btn { flex: 1; min-height: var(--touch-target); }
.ws-drawer__grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
.ws-drawer--side { left: auto; top: 0; width: 360px; max-height: none; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }

/* Diálogo modal (<dialog> nativo): formulários de criação/edição em popup */
.ws-dialog { width: min(100% - 2 * var(--space-4), 560px); max-height: calc(100dvh - 2 * var(--space-4)); margin: auto; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-lg); display: none; flex-direction: column; overflow: hidden; }
.ws-dialog[open] { display: flex; }
.ws-dialog::backdrop { background: var(--overlay); }
.ws-dialog--lg { width: min(100% - 2 * var(--space-4), 920px); }
.ws-dialog > form { display: flex; flex-direction: column; min-height: 0; }
.ws-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border); flex: none; }
.ws-dialog__head .ws-h2 { font-size: 20px; line-height: 28px; }
.ws-dialog__body { padding: var(--space-6); overflow: auto; display: flex; flex-direction: column; gap: var(--space-4); min-height: 0; background: var(--bg); }
.ws-dialog__body > .ws-alert { order: -1; }
.ws-dialog__section { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ws-dialog__section > .ws-h3 { padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
.ws-dialog__section .ws-grid-wrap { box-shadow: none; }
.ws-dialog__foot { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-6); border-top: 1px solid var(--border); background: var(--surface-alt); flex: none; }
.ws-dialog .ws-grid-toolbar, .ws-dialog .ws-grid-wrap { container-type: inline-size; }
@media (max-width: 899px) {
  .ws-dialog { width: 100%; max-width: none; max-height: 94dvh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
  .ws-dialog__head, .ws-dialog__body, .ws-dialog__foot { padding-left: var(--space-4); padding-right: var(--space-4); }
  .ws-dialog__body { padding-top: var(--space-4); padding-bottom: var(--space-4); }
  .ws-dialog__section { padding: var(--space-3); }
  .ws-dialog__foot { padding-bottom: max(var(--space-3), env(safe-area-inset-bottom)); }
  .ws-dialog__foot .ws-btn { flex: 1; }
  .ws-dialog .ws-field, .ws-dialog .ws-input, .ws-dialog .ws-select { width: 100%; }
}

/* Popover de filtro de coluna */
.ws-popover { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); width: 260px; color: var(--ink); }
.ws-popover__list { display: flex; flex-direction: column; max-height: 180px; overflow: auto; }

/* Grelha de dados: >=640px de contentor tabela; <640px cartões */
.ws-grid-wrap { container: grid / inline-size; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.ws-grid-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws-grid-scroll { overflow-x: auto; }
.ws-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.ws-grid th { position: sticky; top: 0; z-index: 1; text-align: left; vertical-align: middle; white-space: nowrap; height: 44px; padding: 0 var(--space-4); background: var(--surface-alt); color: var(--ink-muted); font: 600 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.ws-grid th.ws-num { text-align: right; }
.ws-th { display: inline-flex; align-items: center; gap: 4px; }
.ws-th__sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.ws-th__sort[aria-sort="ascending"], .ws-th__sort[aria-sort="descending"] { color: var(--primary-ink); }
.ws-th__filter { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-muted); cursor: pointer; }
.ws-th__filter:hover { background: var(--border); }
.ws-th__filter[data-active="true"] { color: var(--on-primary); background: var(--primary); }
.ws-grid td { height: 44px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: middle; }
.ws-grid tbody tr:hover td { background: var(--surface-alt); }
.ws-grid tbody tr[aria-selected="true"] td { background: var(--primary-subtle); }
.ws-grid .ws-col-check { width: 48px; padding-right: 0; }
.ws-grid .ws-col-actions { width: 56px; text-align: right; }
.ws-grid__primary { font-weight: 600; }
.ws-grid__sub { display: block; font-size: 13px; color: var(--ink-muted); }
.ws-grid__sub--narrow { display: none; }
.ws-grid-empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--ink-muted); }
@container grid (max-width: 639px) {
  .ws-grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ws-grid, .ws-grid tbody, .ws-grid tr, .ws-grid td { display: block; width: 100%; }
  .ws-grid tbody tr { position: relative; padding: var(--space-3) var(--space-4) var(--space-3) 52px; border-bottom: 1px solid var(--border); }
  .ws-grid tbody tr:hover td { background: none; }
  .ws-grid tbody tr[aria-selected="true"] { background: var(--primary-subtle); }
  .ws-grid tbody tr[aria-selected="true"] td { background: none; }
  .ws-grid td { height: auto; padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: var(--space-3); text-align: right; }
  .ws-grid td::before { content: attr(data-label); color: var(--ink-muted); font-size: 13px; text-align: left; }
  .ws-grid td.ws-card-title { display: block; font-size: 15px; padding-bottom: 4px; padding-right: 40px; text-align: left; }
  .ws-grid td.ws-card-title::before, .ws-grid td.ws-col-check::before, .ws-grid td.ws-col-actions::before { content: none; }
  .ws-grid td.ws-col-check { position: absolute; left: 16px; top: 14px; width: auto; padding: 0; }
  .ws-grid td.ws-col-actions { position: absolute; right: 8px; top: 8px; width: auto; padding: 0; }
  .ws-grid td.ws-hide-narrow { display: none; }
  .ws-grid__sub--narrow { display: block; }
  .ws-grid-toolbar .ws-only-wide { display: none; }
}

/* v2: grelha, filtros e menu */
.ws-grid td.ws-cell-edit { background: var(--edit-bg); box-shadow: inset 1px 0 0 var(--edit-line), inset -1px 0 0 var(--edit-line); }
.ws-grid tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 var(--primary); }
.ws-grid tfoot td { font-weight: 700; background: var(--surface-alt); position: sticky; bottom: 0; }
.ws-input--cell { width: 84px; min-height: 30px; padding: 0 6px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; border-color: var(--edit-line); background: var(--surface); }
.ws-filterbar__search { flex: 1; min-width: 0; }
.ws-filterbar__quick { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ws-filterbar__summary { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: 13px; color: var(--ink-muted); }
.ws-filterbar__summary--on { padding: var(--space-2) var(--space-3); border: 1px solid var(--primary); border-radius: var(--radius-lg); background: var(--primary-subtle); color: var(--ink); }
.ws-btn--sm { min-height: 30px; }
.ws-sidenav .ws-navcnt { margin-left: auto; }
@container shell (min-width: 900px) and (max-width: 1199px) { .ws-sidenav .ws-navitem { position: relative; } .ws-sidenav .ws-navcnt { position: absolute; top: 2px; right: 2px; } }
@media (max-width: 899px) { .ws-btn--sm { min-height: 36px; } }

.ws-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }
a.ws-kpi { color: inherit; text-decoration: none; cursor: pointer; }
a.ws-kpi:hover, .ws-kpi[aria-pressed="true"] { border-color: var(--primary); }
.ws-kpi[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--primary); }
.ws-kpi__label { color: var(--ink-muted); }
