/* Reset + base */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #f3f4f6; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111827; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* Cores semânticas */
:root {
  --emdia: #16a34a; --emdia-bg: #dcfce7;
  --aviso: #eab308; --aviso-bg: #fef9c3; --aviso-fg: #854d0e;
  --vencido: #dc2626; --vencido-bg: #fee2e2;
  --info: #3b82f6; --info-bg: #dbeafe;
  --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-700: #374151;
  --brand: #2563eb;
}

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 9999px; font-size: 12px; font-weight: 600; }
.btn { min-height: 44px; border: none; border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 16px; transition: filter .15s; }
.btn:active { filter: brightness(.9); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-aviso { background: var(--aviso); color: #fff; }
.btn-vencido { background: var(--vencido); color: #fff; }
.btn-emdia { background: var(--emdia); color: #fff; }
.btn-ghost { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-block { width: 100%; }
.btn:disabled { background: var(--gray-300); color: var(--gray-500); cursor: not-allowed; }

.card { background: #fff; border-radius: 16px; padding: 16px; border: 1px solid var(--gray-200); }
.card-aviso { border: 2px solid color-mix(in oklab, var(--aviso) 40%, transparent); }
.card-vencido { border: 2px solid color-mix(in oklab, var(--vencido) 50%, transparent); }

/* Loading */
.spinner { width: 40px; height: 40px; border: 4px solid var(--gray-200); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 24px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 9999; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }
.toast.error { background: var(--vencido); }
.toast.success { background: var(--emdia); }

/* ---------- DataTable (ordenação + filtro por coluna) ---------- */
.dt-count { font-size: 12px; color: var(--gray-500); padding: 8px 16px; }
.dt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dt-table thead th { background: var(--gray-100); padding: 8px 16px; text-align: left; font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.dt-table tbody td { padding: 10px 16px; border-top: 1px solid var(--gray-200); }
.dt-table tbody tr:hover { background: var(--gray-100); }
.dt-th-inner { display: inline-flex; align-items: center; gap: 10px; }
.dt-th-label.sortable { cursor: pointer; user-select: none; }
.dt-th-label.sortable:hover { color: var(--brand); }
.dt-arrow { color: var(--brand); font-size: 10px; }
.dt-funnel { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; cursor: pointer; background: var(--gray-200); color: var(--gray-700); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; border: none; }
.dt-funnel:hover { background: var(--gray-300); }
.dt-funnel.on { background: var(--brand); color: #fff; }

.dt-popover { position: absolute; z-index: 200; background: #fff; border: 1px solid var(--gray-300); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 12px; width: 260px; }
.dt-pop-list { max-height: 220px; overflow-y: auto; margin: 8px 0; border: 1px solid var(--gray-200); border-radius: 8px; padding: 6px; }
.dt-pop-list label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 13px; cursor: pointer; border-radius: 4px; }
.dt-pop-list label:hover { background: var(--gray-100); }
.dt-pop-field { display: block; font-size: 12px; color: var(--gray-500); margin-bottom: 10px; }
.dt-pop-field input { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; }
.dt-pop-actions { display: flex; gap: 8px; justify-content: space-between; }
.dt-pop-actions button, .dt-pop-apply { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--gray-300); background: #fff; font-size: 13px; cursor: pointer; }
.dt-pop-apply { background: var(--brand); color: #fff; border-color: var(--brand); width: 100%; margin-top: 4px; }

/* ---------- Toggle switch ---------- */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: var(--gray-300); border-radius: 9999px; transition: background .15s; }
.toggle .thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track + .thumb { transform: translateX(20px); }
.toggle input:disabled + .track { opacity: .5; cursor: not-allowed; }
