/* Componentes "ui" (components/ui/ui.py). Independentes do main.css, que é
   um Tailwind purgado. Tema escuro: classe .dark no <html>. */

/* ---------- badge ---------- */
.ui-badge {
  display: inline-block; border-radius: 9999px; padding: .0625rem .5rem;
  font-size: var(--ui-text-xs); font-weight: 600; line-height: 1rem; white-space: nowrap;
}
.ui-badge--neutral { background: #e5e7eb; color: #4b5563; }
.ui-badge--info { background: #dbeafe; color: #1d4ed8; }
.ui-badge--success { background: #dcfce7; color: #15803d; }
.ui-badge--danger { background: #fee2e2; color: #b91c1c; }
.ui-badge--variable { background: #e0f2fe; color: #0369a1; }
.ui-badge--attribute { background: #f3e8ff; color: #7e22ce; }
.dark .ui-badge--neutral { background: #4b5563; color: #e5e7eb; }
.dark .ui-badge--info { background: rgba(37, 99, 235, .3); color: #93c5fd; }
.dark .ui-badge--success { background: rgba(21, 128, 61, .3); color: #86efac; }
.dark .ui-badge--danger { background: rgba(185, 28, 28, .3); color: #fca5a5; }
.dark .ui-badge--variable { background: rgba(3, 105, 161, .35); color: #7dd3fc; }
.dark .ui-badge--attribute { background: rgba(126, 34, 206, .35); color: #d8b4fe; }

/* ---------- group_title ---------- */
.ui-group-title {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; color: #111827;
}
.ui-group-title--sm { font-size: var(--ui-text-sm); }
.ui-group-title--md { font-size: var(--ui-text-md); }
.ui-group-title-count { font-weight: 400; color: #9ca3af; }
.dark .ui-group-title { color: #fff; }

/* ---------- search_field ---------- */
.ui-search { position: relative; }
.ui-search svg {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: #9ca3af; pointer-events: none;
}
.ui-input {
  display: block; width: 100%; border-radius: .5rem; border: 1px solid #d1d5db;
  background: #f9fafb; padding: .5rem .75rem; font-size: var(--ui-text-sm); color: #111827;
}
.ui-search .ui-input { padding-left: 2.25rem; }
.ui-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, .3); }
.dark .ui-input { border-color: #4b5563; background: #374151; color: #fff; }
.dark .ui-input::placeholder { color: #9ca3af; }

/* ---------- list_item ---------- */
.ui-list-item {
  display: block; width: 100%; text-align: left; border-radius: .5rem;
  padding: .625rem .75rem; border: 1px solid transparent; transition: background-color .15s;
}
.ui-list-item:hover { background: #f3f4f6; }
.ui-list-item.is-selected { background: #eff6ff; border-color: #60a5fa; }
.dark .ui-list-item:hover { background: #374151; }
.dark .ui-list-item.is-selected { background: rgba(30, 64, 175, .35); border-color: #3b82f6; }
.ui-list-item-title {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--ui-text-sm); font-weight: 600; line-height: 1.25rem; color: #111827;
}
.ui-list-item-sub {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--ui-text-xs); line-height: 1rem; color: #6b7280;
}
.dark .ui-list-item-title { color: #fff; }
.dark .ui-list-item-sub { color: #9ca3af; }
.ui-list-item-tags { display: flex; gap: .25rem; margin-top: .375rem; }

/* ---------- segmented_toggle ---------- */
.ui-toggle-label { margin-bottom: .25rem; font-size: var(--ui-text-xs); font-weight: 500; color: #6b7280; }
.dark .ui-toggle-label { color: #9ca3af; }
.ui-toggle {
  display: inline-flex; gap: .125rem; padding: .1875rem; border-radius: .5rem;
  background: #f3f4f6; border: 1px solid #e5e7eb;
}
.dark .ui-toggle { background: #111827; border-color: #4b5563; }
.ui-toggle button {
  border-radius: .375rem; padding: .375rem .875rem; font-size: var(--ui-text-sm); font-weight: 500;
  color: #4b5563; transition: background-color .15s, color .15s;
}
.ui-toggle button:hover { color: #111827; }
.ui-toggle button[aria-pressed="true"] {
  background: #2563eb; color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.dark .ui-toggle button { color: #d1d5db; }
.dark .ui-toggle button:hover { color: #fff; }
.ui-toggle-wrap .ui-hint { max-width: 16rem; }

/* ---------- entity_header ---------- */
.ui-entity-eyebrow {
  font-size: var(--ui-text-xs); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: #9ca3af;
}
.ui-entity-title { font-size: var(--ui-text-lg); font-weight: 600; line-height: 1.75rem; color: #111827; }
.ui-entity-sub { font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-entity-title { color: #fff; }
.dark .ui-entity-sub { color: #9ca3af; }

/* ---------- empty_state ---------- */
.ui-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 16rem; padding: 2rem; text-align: center;
  border: 1px dashed #d1d5db; border-radius: .5rem; background: #fff;
}
.dark .ui-empty { border-color: #4b5563; background: #1f2937; }
.ui-empty-icon { margin-bottom: .75rem; font-size: 2.25rem; }
.ui-empty-title { font-size: var(--ui-text-md); font-weight: 600; color: #111827; }
.ui-empty-text { margin-top: .25rem; max-width: 24rem; font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-empty-title { color: #fff; }
.dark .ui-empty-text { color: #9ca3af; }

/* ---------- collapsible ---------- */
.ui-collapsible { border: 1px solid #e5e7eb; border-radius: .5rem; background: #fff; }
.ui-collapsible summary {
  cursor: pointer; user-select: none; padding: .75rem 1rem;
  font-size: var(--ui-text-sm); font-weight: 500; color: #374151;
}
.ui-collapsible-body { overflow-x: auto; padding: 1rem; border-top: 1px solid #e5e7eb; }
.dark .ui-collapsible { border-color: #374151; background: #1f2937; }
.dark .ui-collapsible summary { color: #e5e7eb; }
.dark .ui-collapsible-body { border-color: #374151; }

/* ---------- config_section ---------- */
.ui-section {
  border: 1px solid #e5e7eb; border-radius: .75rem; padding: 1rem 1.25rem 1.25rem; background: #fff;
}
.dark .ui-section { border-color: #374151; background: #1f2937; }
.ui-section-head { margin-bottom: 1rem; }
.ui-section-head h4 { font-size: var(--ui-text-sm); font-weight: 600; color: #1f2937; }
.ui-section-head p { margin-top: .125rem; font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-section-head h4 { color: #f3f4f6; }
.dark .ui-section-head p { color: #9ca3af; }

/* ---------- config_field / check_field ---------- */
.ui-fields { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
@media (min-width: 768px) { .ui-fields { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .ui-fields { grid-template-columns: repeat(3, 1fr); } }
.ui-field--wide { grid-column: 1 / -1; }
.ui-field label {
  display: block; margin-bottom: .25rem; font-size: var(--ui-text-sm); font-weight: 500; color: #374151;
}
.dark .ui-field label { color: #d1d5db; }
.ui-field input:not([type=checkbox]):not([type=radio]),
.ui-field select,
.ui-field textarea,
.ui-matrix input { width: 100%; max-width: none; }
.ui-field textarea { height: 5.5rem; min-height: 3rem; resize: vertical; }

/* Campos com cantos arredondados, no mesmo formato dos botões (as cores vêm do style.css global). */
.ui-input,
.ui-field input:not([type=checkbox]):not([type=radio]):not([type=file]),
.ui-field select {
  min-height: 2.5rem; border: 1px solid #d1d5db; border-radius: .5rem;
  padding: .5rem .875rem; font-size: var(--ui-text-sm); line-height: 1.25rem;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.ui-field select { padding-right: 2.5rem; text-overflow: ellipsis; cursor: pointer; }
.ui-field textarea, textarea.ui-input { border: 1px solid #d1d5db; border-radius: .5rem; padding: .625rem .875rem; }
.ui-input:focus,
.ui-field input:not([type=checkbox]):not([type=radio]):focus,
.ui-field select:focus,
.ui-field textarea:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .25);
}
.ui-field--wide select { max-width: 36rem; }

.ui-check { padding-top: .25rem; }
.ui-check label, .ui-rule-main {
  display: flex; align-items: flex-start; gap: .625rem; cursor: pointer;
  font-size: var(--ui-text-sm); color: #374151; line-height: 1.25rem;
}
.dark .ui-check label, .dark .ui-rule-main { color: #d1d5db; }
.ui-check input, .ui-rule-main input { margin-top: .125rem; flex-shrink: 0; }

/* ---------- rule_row ---------- */
.ui-rules { display: flex; flex-direction: column; }
.ui-rule {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1rem; padding: .625rem 0; border-top: 1px solid #f3f4f6;
}
.ui-rule:first-child { border-top: 0; padding-top: 0; }
.dark .ui-rule { border-color: #374151; }
.ui-rule-main { flex: 1 1 18rem; }
.ui-rule-tag {
  flex-shrink: 0; border-radius: .375rem; padding: 0 .375rem;
  font-size: var(--ui-text-xs); font-weight: 600; background: #eff6ff; color: #1d4ed8;
}
.dark .ui-rule-tag { background: rgba(37, 99, 235, .25); color: #93c5fd; }
.ui-rule-amount { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--ui-text-sm); color: #6b7280; }
.ui-rule-amount input { width: 5.5rem !important; }
.ui-rule .ui-error { flex-basis: 100%; }

/* ---------- limits_matrix ---------- */
.ui-matrix-wrap { overflow-x: auto; }
.ui-matrix { width: 100%; border-collapse: separate; border-spacing: .5rem .375rem; margin: -.375rem -.5rem; }
.ui-matrix th { font-size: var(--ui-text-xs); font-weight: 600; color: #6b7280; text-align: left; white-space: nowrap; }
.ui-matrix tbody th { font-size: var(--ui-text-sm); color: #374151; padding-right: .5rem; }
.dark .ui-matrix tbody th { color: #d1d5db; }
.ui-matrix td { min-width: 8rem; }

/* ---------- textos auxiliares ---------- */
.ui-hint { margin-top: .375rem; font-size: var(--ui-text-xs); color: #6b7280; }
.dark .ui-hint { color: #9ca3af; }
.ui-error { margin-top: .25rem; font-size: var(--ui-text-xs); color: #dc2626; }
.dark .ui-error { color: #f87171; }

.ui-required { color: #dc2626; }

/* ---------- panel ---------- */
.ui-panel {
  min-width: 0; overflow: hidden; border: 1px solid #e5e7eb; border-radius: .5rem;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.dark .ui-panel { border-color: #374151; background: #1f2937; }
.ui-panel-head { padding: 1.25rem 1.5rem; border-bottom: 1px solid #e5e7eb; }
.dark .ui-panel-head { border-color: #374151; }
.ui-panel-head h2 { font-size: var(--ui-text-lg); font-weight: 600; color: #111827; }
.ui-panel-head p { margin-top: .25rem; font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-panel-head h2 { color: #fff; }
.dark .ui-panel-head p { color: #9ca3af; }
.ui-panel-body { padding: 1.25rem 1.5rem 1.5rem; }

/* ---------- confirm_form / form_errors ---------- */
.ui-form { display: flex; flex-direction: column; gap: 1rem; }
.ui-form-errors {
  border: 1px solid #fca5a5; border-radius: .5rem; background: #fef2f2;
  padding: .75rem 1rem; font-size: var(--ui-text-sm); color: #991b1b;
}
.dark .ui-form-errors { border-color: #991b1b; background: rgba(127, 29, 29, .3); color: #fca5a5; }

/* ---------- choice_field ---------- */
.ui-choice { border: 0; padding: 0; margin: 0; min-width: 0; }
.ui-choice legend { margin-bottom: .375rem; font-size: var(--ui-text-sm); font-weight: 500; color: #374151; }
.dark .ui-choice legend { color: #d1d5db; }
.ui-choice-options { display: flex; flex-wrap: wrap; gap: .5rem; }
.ui-choice-option input { flex-shrink: 0; margin: 0; }
.ui-choice-option {
  display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  border: 1px solid #d1d5db; border-radius: .5rem; padding: .5rem .875rem;
  font-size: var(--ui-text-sm); color: #374151; background: #fff;
}
.ui-choice-option:has(input:checked) { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.dark .ui-choice-option { border-color: #4b5563; background: #374151; color: #e5e7eb; }
.dark .ui-choice-option:has(input:checked) { border-color: #3b82f6; background: rgba(30, 64, 175, .35); color: #bfdbfe; }

/* ---------- data_table ---------- */
.ui-table-wrap { overflow-x: auto; }
.ui-table { width: 100%; text-align: left; font-size: var(--ui-text-sm); color: #4b5563; }
.ui-table thead { background: #f9fafb; }
.ui-table th {
  padding: .75rem 1rem; font-size: var(--ui-text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; color: #374151; white-space: nowrap;
}
.ui-table td { padding: .75rem 1rem; border-top: 1px solid #e5e7eb; vertical-align: top; }
.ui-table .ui-table-strong { font-weight: 600; color: #111827; }
.ui-table .ui-table-muted { font-size: var(--ui-text-xs); color: #9ca3af; }
.ui-table .ui-table-nowrap { white-space: nowrap; }
.ui-table .ui-table-empty td { padding: 2.5rem 1.5rem; text-align: center; color: #6b7280; }
.dark .ui-table { color: #9ca3af; }
.dark .ui-table thead { background: #374151; }
.dark .ui-table th { color: #d1d5db; }
.dark .ui-table td { border-color: #374151; }
.dark .ui-table .ui-table-strong { color: #fff; }

/* ---------- form_fields / dynamic_filters / subsections ---------- */
.ui-stack { display: flex; flex-direction: column; gap: 1rem; }
.ui-subsection { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid #e5e7eb; }
.dark .ui-subsection { border-color: #374151; }
.ui-subsection-title { margin-bottom: .75rem; font-size: var(--ui-text-sm); font-weight: 600; color: #111827; }
.dark .ui-subsection-title { color: #fff; }
.ui-fields--2 { grid-template-columns: 1fr 1fr !important; }
.ui-choice-options--vertical { flex-direction: column; align-items: stretch; }
.ui-choice-option:has(input:disabled) { opacity: .5; cursor: not-allowed; }
[data-field].is-hidden { display: none; }
.ui-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- toggle_chips ---------- */
.ui-chips-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.ui-chips-field legend { padding: 0; }
.ui-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.ui-chip {
  border: 1px solid #d1d5db; border-radius: 9999px; padding: .375rem .875rem;
  font-size: var(--ui-text-sm); font-weight: 500; color: #374151; background: #fff;
  transition: background-color .15s, border-color .15s, color .15s;
}
.ui-chip:hover { background: #f3f4f6; }
.ui-chip[aria-pressed="true"] { border-color: #2563eb; background: #2563eb; color: #fff; }
.dark .ui-chip { border-color: #4b5563; background: #374151; color: #e5e7eb; }
.dark .ui-chip[aria-pressed="true"] { border-color: #3b82f6; background: #2563eb; color: #fff; }

/* ---------- ui_button ---------- */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  border: 1px solid transparent; border-radius: .5rem; font-weight: 600; line-height: 1.25rem;
  letter-spacing: .01em; white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease,
    box-shadow .15s ease, transform .15s ease;
}
.ui-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, .10); }
.ui-btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.ui-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, .4); }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; transform: none; box-shadow: none;
}
.ui-btn--sm { min-width: 2rem; min-height: 2rem; padding: .375rem .875rem; font-size: var(--ui-text-xs); }
.ui-btn--md { min-height: 2.5rem; padding: .5625rem 1.25rem; font-size: var(--ui-text-sm); }
.ui-btn--block { width: 100%; }
/* Só ícone ou um caractere (ex.: + e −): botão quadrado. */
.ui-btn--icon { width: 2rem; height: 2rem; min-width: 0; padding: 0; font-size: var(--ui-text-md); line-height: 1; }
.ui-btn--primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); color: #fff;
  box-shadow: 0 1px 2px rgba(29, 78, 216, .25), 0 4px 12px rgba(37, 99, 235, .22);
}
.ui-btn--primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 2px 4px rgba(29, 78, 216, .25), 0 8px 18px rgba(37, 99, 235, .30);
}
.ui-btn--outline { border-color: #d1d5db; background: #fff; color: #374151; }
.ui-btn--outline:hover { border-color: #9ca3af; background: #f9fafb; color: #111827; }
.ui-btn--accent { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.ui-btn--accent:hover { border-color: #3b82f6; background: #dbeafe; }
.ui-btn--danger { border-color: #fca5a5; background: #fff; color: #dc2626; }
.ui-btn--danger:hover { border-color: #dc2626; background: #fef2f2; }
.ui-btn--ghost { background: transparent; color: #374151; box-shadow: none; }
.ui-btn--ghost:hover { background: #f3f4f6; box-shadow: none; }
.dark .ui-btn--outline { border-color: #4b5563; background: #1f2937; color: #e5e7eb; }
.dark .ui-btn--outline:hover { border-color: #6b7280; background: #374151; color: #fff; }
.dark .ui-btn--ghost { color: #e5e7eb; }
.dark .ui-btn--ghost:hover { background: #374151; }
.dark .ui-btn--accent { border-color: #3b82f6; background: rgba(30, 58, 138, .35); color: #bfdbfe; }
.dark .ui-btn--accent:hover { background: rgba(30, 58, 138, .6); }
.dark .ui-btn--danger { border-color: #f87171; background: transparent; color: #fca5a5; }
.dark .ui-btn--danger:hover { background: rgba(127, 29, 29, .4); }
@media (prefers-reduced-motion: reduce) {
  .ui-btn, .ui-btn:hover, .ui-btn:active { transition: none; transform: none; }
}
.ui-actions { display: flex; flex-wrap: wrap; gap: .375rem; }
.ui-actions--end { justify-content: flex-end; }

/* ---------- modal_dialog ---------- */
.ui-modal {
  width: 100%; max-width: 28rem; padding: 0; border: 1px solid #e5e7eb; border-radius: .5rem;
  background: #fff; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .15);
}
.ui-modal::backdrop { background: rgba(17, 24, 39, .5); }
.ui-modal--danger { border-color: #fca5a5; }
.dark .ui-modal { border-color: #374151; background: #1f2937; }
.ui-modal-body { padding: 1.5rem; }
.ui-modal-title { font-size: var(--ui-text-lg); font-weight: 600; color: #111827; }
.ui-modal--danger .ui-modal-title { color: #b91c1c; }
.dark .ui-modal-title { color: #fff; }
.dark .ui-modal--danger .ui-modal-title { color: #fca5a5; }
.ui-modal-message { margin-top: .5rem; font-size: var(--ui-text-sm); color: #4b5563; }
.dark .ui-modal-message { color: #d1d5db; }
.ui-modal-actions { display: flex; justify-content: flex-end; margin-top: 1.25rem; }

/* ---------- notice ---------- */
.ui-notice { border: 1px solid; border-radius: .5rem; padding: .75rem 1rem; font-size: var(--ui-text-sm); }
.ui-notice p + p { margin-top: .25rem; }
.ui-notice-title { font-weight: 600; }
.ui-notice--info { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.ui-notice--success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.ui-notice--warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.ui-notice--error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.dark .ui-notice--info { border-color: #1e40af; background: rgba(30, 64, 175, .2); color: #bfdbfe; }
.dark .ui-notice--success { border-color: #166534; background: rgba(22, 101, 52, .2); color: #bbf7d0; }
.dark .ui-notice--warning { border-color: #92400e; background: rgba(146, 64, 14, .2); color: #fde68a; }
.dark .ui-notice--error { border-color: #991b1b; background: rgba(153, 27, 27, .2); color: #fecaca; }

/* ---------- detail_list ---------- */
.ui-details { display: flex; flex-direction: column; gap: .375rem; font-size: var(--ui-text-sm); }
.ui-details-row { display: flex; gap: .5rem; }
.ui-details dt { flex: 0 0 7.5rem; color: #6b7280; }
.ui-details dd { min-width: 0; color: #111827; overflow-wrap: anywhere; }
.dark .ui-details dt { color: #9ca3af; }
.dark .ui-details dd { color: #f3f4f6; }

/* ---------- layout de página ---------- */
.ui-page { padding: var(--ui-space-4); }
@media (min-width: 640px) { .ui-page { padding: var(--ui-space-6); } }
.ui-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (min-width: 1024px) {
  .ui-layout--sidebar { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
}
.ui-layout-main { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.ui-link { color: #2563eb; text-decoration: none; }
.ui-link:hover { text-decoration: underline; }
.dark .ui-link { color: #60a5fa; }

/* ---------- pagination ---------- */
.ui-pagination {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  padding-top: 1rem; font-size: var(--ui-text-sm); color: #4b5563;
}
.dark .ui-pagination { color: #9ca3af; }

/* ---------- check_list ---------- */
.ui-check-list-actions { margin-bottom: .5rem; }
.ui-check-list {
  display: flex; flex-direction: column; gap: .5rem; max-height: 13rem; overflow-y: auto;
  border: 1px solid #d1d5db; border-radius: .5rem; background: #f9fafb; padding: .75rem;
}
.dark .ui-check-list { border-color: #4b5563; background: #374151; }
.ui-check-list label {
  display: flex; align-items: center; gap: .5rem; cursor: pointer; margin: 0;
  font-size: var(--ui-text-sm); font-weight: 400; color: #111827;
}
.dark .ui-check-list label { color: #f3f4f6; }
.ui-check-list-empty { font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-check-list-empty { color: #9ca3af; }

/* Rádios dentro de choice_field: neutraliza classes de campo de texto que
   alguns formulários aplicam ao widget (largura, fundo, padding). */
.ui-choice-option { flex-direction: row; }
.ui-choice-option input[type=radio] {
  appearance: auto; display: inline-block; width: 1rem !important; height: 1rem !important;
  min-width: 1rem; margin: 0 !important; padding: 0 !important; border: 0 !important;
  background: none !important; box-shadow: none !important; flex: 0 0 auto;
}

.ui-panel-body--flush > .ui-empty { border: 0; border-radius: 0; }

/* ---------- file_drop ---------- */
.ui-drop {
  position: relative; display: flex !important; flex-direction: column; align-items: center; gap: .375rem;
  margin: 0 !important; padding: 1.5rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed #cbd5e1; border-radius: .75rem; background: #f8fafc;
  transition: border-color .15s, background-color .15s;
}
.ui-drop:hover, .ui-drop.is-dragging { border-color: #3b82f6; background: #eff6ff; }
.ui-drop.has-file { border-style: solid; border-color: #22c55e; background: #f0fdf4; }
.ui-drop svg { width: 2rem; height: 2rem; color: #64748b; }
.ui-drop.has-file svg { color: #16a34a; }
.ui-drop-title { font-size: var(--ui-text-sm); font-weight: 500; color: #1f2937; overflow-wrap: anywhere; }
.ui-drop-hint { font-size: var(--ui-text-xs); font-weight: 400; color: #6b7280; }
.ui-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dark .ui-drop { border-color: #4b5563; background: #111827; }
.dark .ui-drop:hover, .dark .ui-drop.is-dragging { border-color: #3b82f6; background: rgba(30, 64, 175, .2); }
.dark .ui-drop.has-file { border-color: #16a34a; background: rgba(22, 101, 52, .2); }
.dark .ui-drop-title { color: #f3f4f6; }
.dark .ui-drop-hint { color: #9ca3af; }

/* ---------- guia de formato (listas de colunas) ---------- */
.ui-code-list { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.ui-code {
  border-radius: .25rem; padding: .0625rem .375rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--ui-text-xs); background: #f1f5f9; color: #0f172a; border: 1px solid #e2e8f0;
}
.dark .ui-code { background: #111827; color: #e5e7eb; border-color: #374151; }
.ui-error-list { max-height: 16rem; overflow-y: auto; margin: 0; padding-left: 1.25rem; list-style: disc; font-size: var(--ui-text-sm); }
.ui-error-list li + li { margin-top: .25rem; }

/* ---------- barra de filtros / rodapé de painel ---------- */
.ui-filter-bar {
  display: grid; grid-template-columns: 1fr; gap: .75rem; align-items: end;
  padding: 1rem 1.5rem; border-bottom: 1px solid #e5e7eb;
}
@media (min-width: 768px) { .ui-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; } }
.dark .ui-filter-bar { border-color: #374151; }
.ui-table-caption { padding: .75rem 1rem 0; font-size: var(--ui-text-sm); color: #6b7280; }
.dark .ui-table-caption { color: #9ca3af; }
.ui-panel-foot { padding: 0 1rem 1rem; }

/* ---------- user_menu ---------- */
.ui-user { display: flex; align-items: center; margin-left: .75rem; }
.ui-user-trigger { display: flex; border-radius: 9999px; background: #1f2937; }
.ui-user-trigger:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(209, 213, 219, .6); }
.ui-user-avatar { width: 2rem; height: 2rem; border-radius: 9999px; }
.ui-user-menu {
  z-index: 50; width: 16rem; overflow: hidden; border: 1px solid #e5e7eb; border-radius: .5rem;
  background: #fff; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .12);
}
.dark .ui-user-menu { border-color: #374151; background: #1f2937; }
.ui-user-head { display: flex; flex-direction: column; gap: .25rem; padding: .875rem 1rem; border-bottom: 1px solid #e5e7eb; }
.dark .ui-user-head { border-color: #374151; }
.ui-user-name { font-size: var(--ui-text-sm); font-weight: 600; color: #111827; overflow-wrap: anywhere; }
.ui-user-email { font-size: var(--ui-text-sm); color: #6b7280; overflow-wrap: anywhere; }
.dark .ui-user-name { color: #fff; }
.dark .ui-user-email { color: #9ca3af; }
.ui-user-head .ui-actions { margin-top: .25rem; }
.ui-user-logout { margin: 0; }
.ui-user-item {
  display: flex; align-items: center; gap: .5rem; width: 100%; padding: .625rem 1rem;
  font-size: var(--ui-text-sm); text-align: left; text-decoration: none; color: #374151; background: none;
}
.ui-user-item:hover { background: #f3f4f6; }
.ui-user-item--danger { color: #b91c1c; }
.ui-user-item--danger:hover { background: #fef2f2; }
.dark .ui-user-item { color: #e5e7eb; }
.dark .ui-user-item:hover { background: #374151; }
.dark .ui-user-item--danger { color: #fca5a5; }
.dark .ui-user-item--danger:hover { background: rgba(127, 29, 29, .35); }

/* ---------- pdf_preview ---------- */
.ui-pdf { display: flex; flex-direction: column; }
.ui-pdf-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 1rem; border-bottom: 1px solid #e5e7eb; background: #f9fafb;
}
.dark .ui-pdf-bar { border-color: #374151; background: #111827; }
.ui-pdf-title { font-size: var(--ui-text-sm); font-weight: 600; color: #374151; }
.dark .ui-pdf-title { color: #e5e7eb; }
.ui-pdf-frame { display: block; width: 100%; height: calc(100vh - 12rem); min-height: 36rem; border: 0; background: #525659; }

/* Linha selecionada em data_table */
.ui-table tr.is-selected td { background: #eff6ff; }
.ui-table tr.is-selected td:first-child { box-shadow: inset 3px 0 0 #2563eb; }
.dark .ui-table tr.is-selected td { background: rgba(30, 64, 175, .3); }
.ui-collapsible-body > [data-live-id] { margin: -1rem; }

/* ---------- topbar ---------- */
.ui-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; padding: .875rem 1rem; }
.ui-topbar-start, .ui-topbar-end { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.ui-topbar-brand {
  font-size: 1.25rem; font-weight: 700; letter-spacing: .01em; color: #fff; text-decoration: none; white-space: nowrap;
}
.ui-topbar-brand:hover { color: #fff; opacity: .9; }
.ui-topbar-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  border-radius: .5rem; color: rgba(255, 255, 255, .85); background: transparent; transition: background-color .15s;
}
.ui-topbar-icon:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.ui-topbar-icon:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .45); }
.ui-topbar-icon svg { width: 1.25rem; height: 1.25rem; color: inherit !important; }
.ui-topbar-icon svg.hidden { display: none; }
@media (min-width: 1024px) { .ui-topbar-menu { display: none; } }
.ui-topbar-search { position: relative; display: none; margin: 0; }
@media (min-width: 768px) { .ui-topbar-search { display: block; } }
.ui-topbar-search svg {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: rgba(255, 255, 255, .7); pointer-events: none;
}
/* !important: o style.css global pinta input de busca de branco. */
.ui-topbar .ui-topbar-search input {
  width: 20rem; max-width: 40vw; height: 2.25rem; margin: 0 !important;
  border: 1px solid rgba(255, 255, 255, .3) !important; border-radius: .5rem !important;
  background: rgba(255, 255, 255, .14) !important; box-shadow: none !important;
  padding: .5rem .75rem .5rem 2.25rem !important; font-size: var(--ui-text-sm); color: #fff !important;
}
.ui-topbar .ui-topbar-search input::placeholder { color: rgba(255, 255, 255, .75) !important; }
.ui-topbar .ui-topbar-search input:focus {
  outline: none; background: rgba(255, 255, 255, .22) !important; border-color: rgba(255, 255, 255, .7) !important;
}
.ui-topbar .ui-user { margin-left: 0; }
