/* --------------------------------------------------------------------------
   Sistema de Componentes: Cards, Subpainéis e KPIs
   -------------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  min-width: 0;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  border-color: var(--color-border-strong);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-card);
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border-card);
}

.subpanel {
  background: var(--color-bg);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4) var(--space-5);
  margin-bottom: 0;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--color-border-strong);
}

.kpi-value {
  margin: var(--space-2) 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-main);
}

.kpi-value.brand {
  color: var(--color-brand-primary);
}

.kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-aux);
  color: var(--color-text-muted);
}

.grid-2, .grid-3, .grid-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  min-width: 0;
}

.grid-2 > *, .grid-3 > *, .grid-4 > * {
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Sistema de Componentes: Formulários, Inputs, Estados de Foco/Erro/Disabled
   -------------------------------------------------------------------------- */
.form-group,
.field-group {
  margin-bottom: var(--space-4);
}

label,
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-label);
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 16px; /* evita zoom automático no iOS */
  line-height: 1.4;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-soft);
}

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--color-border-hover);
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-brand-secondary);
  box-shadow: 0 0 0 3px var(--color-brand-glow);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
.is-disabled {
  color: var(--color-text-muted);
  background: var(--color-surface-subtle);
  border-color: var(--color-border-card);
  cursor: not-allowed;
  box-shadow: none;
}

/* Estados de erro e validação */
input.is-invalid,
select.is-invalid,
textarea.is-invalid,
.field-has-error input,
.field-has-error select,
.field-has-error textarea {
  border-color: var(--badge-danger-text);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-error,
.errorlist {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-aux);
  font-weight: 500;
  color: var(--badge-danger-text);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--color-brand-secondary);
  flex-shrink: 0;
  cursor: pointer;
}

input[type="file"] {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  padding: 6px 0;
}

/* --------------------------------------------------------------------------
   Sistema de Componentes: Botões (Primário, Secundário, Terciário, Destrutivo, Ícone)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.84375rem; /* 13.5px */
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover:not(:disabled) {
  text-decoration: none;
  color: var(--color-text-main);
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-brand-glow);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Botão Primário (#064E40 -> #04382E) */
.btn-primary {
  color: var(--color-text-inverse);
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  box-shadow: 0 1px 2px rgba(6, 78, 64, 0.2);
}

.btn-primary:hover:not(:disabled) {
  color: var(--color-text-inverse);
  background: var(--color-brand-primary-hover);
  border-color: var(--color-brand-primary-hover);
  box-shadow: 0 2px 4px rgba(6, 78, 64, 0.3);
}

/* Botão Secundário Destaque (#0D8067 -> #064E40) */
.btn-dark {
  color: var(--color-text-inverse);
  background: var(--color-brand-secondary);
  border-color: var(--color-brand-secondary);
}

.btn-dark:hover:not(:disabled) {
  color: var(--color-text-inverse);
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
}

/* Botão Secundário Outline */
.btn-secondary,
.btn-outline {
  color: var(--color-text-main);
  background: var(--color-surface);
  border-color: var(--color-border-input);
}

.btn-secondary:hover:not(:disabled),
.btn-outline:hover:not(:disabled) {
  color: var(--color-brand-primary);
  background: var(--color-surface-hover);
  border-color: var(--color-brand-secondary);
}

/* Botão Terciário / Ghost */
.btn-tertiary,
.btn-ghost {
  color: var(--color-text-muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-tertiary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  color: var(--color-text-main);
  background: var(--color-surface-hover);
  border-color: transparent;
}

/* Botão Destrutivo */
.btn-danger {
  color: #FFFFFF;
  background: #DC2626;
  border-color: #DC2626;
}

.btn-danger:hover:not(:disabled) {
  color: #FFFFFF;
  background: #B91C1C;
  border-color: #B91C1C;
}

.btn-danger-outline {
  color: var(--badge-danger-text);
  background: var(--color-surface);
  border-color: var(--badge-danger-border);
}

.btn-danger-outline:hover:not(:disabled) {
  color: var(--badge-danger-text);
  background: var(--badge-danger-bg);
  border-color: #F87171;
}

/* Tamanhos e Botão Somente com Ícone */
.btn-sm {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 0.78125rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
  min-height: 30px;
}

/* --------------------------------------------------------------------------
   Sistema de Componentes: Alertas, Badges, Tooltips, Empty States, Loading
   -------------------------------------------------------------------------- */
.alert {
  margin-bottom: var(--space-3);
  padding: 12px 16px;
  font-size: 0.84375rem;
  color: var(--color-text-main);
  background: var(--badge-neutral-bg);
  border: 1px solid var(--badge-neutral-border);
  border-left: 3px solid var(--color-text-muted);
  border-radius: var(--radius-md);
}

.alert-success {
  color: var(--badge-success-text);
  background: var(--badge-success-bg);
  border-color: var(--badge-success-border);
  border-left-color: var(--color-brand-secondary);
}

.alert-error,
.alert-danger {
  color: var(--badge-danger-text);
  background: var(--badge-danger-bg);
  border-color: var(--badge-danger-border);
  border-left-color: #DC2626;
}

.alert-warning {
  color: var(--badge-warning-text);
  background: var(--badge-warning-bg);
  border-color: var(--badge-warning-border);
  border-left-color: #D97706;
}

/* Banner de aviso de preço referencial */
.price-disclaimer-banner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: 11px 14px;
  font-size: 0.8125rem;
  color: var(--badge-warning-text);
  background: var(--badge-warning-bg);
  border: 1px solid var(--badge-warning-border);
  border-left: 3px solid #D97706;
  border-radius: var(--radius-md);
}

.price-param-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-aux);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--badge-warning-text);
  background: var(--badge-warning-bg);
  border: 1px solid var(--badge-warning-border);
  border-radius: 5px;
}

/* Badges de Status Discretos */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-aux);
  font-weight: 600;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  color: var(--badge-neutral-text);
  background: var(--badge-neutral-bg);
  border: 1px solid var(--badge-neutral-border);
  border-radius: 6px;
  white-space: nowrap;
}

.badge-green,
.badge-success {
  color: var(--badge-success-text);
  background: var(--badge-success-bg);
  border-color: var(--badge-success-border);
}

.badge-blue {
  color: var(--color-brand-secondary);
  background: var(--color-brand-light);
  border-color: var(--color-brand-border);
}

.badge-gray,
.badge-neutral {
  color: var(--badge-neutral-text);
  background: var(--badge-neutral-bg);
  border-color: var(--badge-neutral-border);
}

.badge-warning {
  color: var(--badge-warning-text);
  background: var(--badge-warning-bg);
  border-color: var(--badge-warning-border);
}

.badge-red,
.badge-danger {
  color: var(--badge-danger-text);
  background: var(--badge-danger-bg);
  border-color: var(--badge-danger-border);
}

/* Estado Vazio (Empty State) */
.empty-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}

.empty-state-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Dropdowns, Paginação, Tooltips e Loading */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 80;
  min-width: 180px;
  padding: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8125rem;
  color: var(--color-text-main);
  border-radius: var(--radius-sm);
}

.dropdown-item:hover {
  text-decoration: none;
  background: var(--color-surface-hover);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: var(--space-4);
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-sm);
}

.page-link.active {
  color: #FFFFFF;
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
}

[data-tooltip] {
  position: relative;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(13, 128, 103, 0.25);
  border-top-color: var(--color-brand-secondary);
  border-radius: 50%;
  animation: pj-spin 0.65s linear infinite;
}

.chart-point-hitbox:hover circle:nth-child(2) {
  r: 7.5px;
  stroke-width: 3px;
  filter: drop-shadow(0 2px 5px rgba(13, 128, 103, 0.4));
}

@keyframes pj-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Tabelas de Dados Clínicas e Executivas
   -------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-clean {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84375rem;
}

.table-responsive > .table-clean {
  min-width: 600px;
}

.table-clean th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--text-aux);
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-card);
  white-space: nowrap;
}

.table-clean td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--color-text-main);
  border-bottom: 1px solid var(--color-border-card);
  overflow-wrap: normal;
  word-break: normal;
}

.table-clean tbody tr {
  transition: background-color 0.12s ease;
}

.table-clean tbody tr:hover {
  background: var(--color-surface-subtle);
}

.table-clean tbody tr:last-child td {
  border-bottom: 0;
}

.table-clean .col-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.table-clean th.col-actions,
.table-clean td.col-actions {
  text-align: right;
  white-space: nowrap;
}

.table-clean td.col-actions .btn {
  padding: 5px 11px;
  font-size: 0.78125rem;
  min-height: 32px;
}

.table-clean .price-param-badge,
.table-clean .badge {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Filtros e Visualização Responsiva de Catálogo (Cards no Mobile / Tabela no Desktop)
   -------------------------------------------------------------------------- */
.catalog-filter-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.catalog-filter-form input,
.catalog-filter-form select {
  width: 100%;
}
.catalog-filter-form .filter-actions-wrap {
  display: flex;
  gap: 8px;
}
@media (min-width: 768px) {
  .catalog-filter-form {
    display: grid;
    grid-template-columns: 1.5fr 1fr auto;
    gap: 12px;
    align-items: center;
  }
}

.catalog-mobile-cards {
  display: flex;
  flex-direction: column;
}
.catalog-card-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-card);
  background: var(--color-surface);
}
.catalog-card-item:last-child {
  border-bottom: none;
}
.catalog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.catalog-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-main);
  line-height: 1.35;
}
.catalog-card-comp {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}
.catalog-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  padding-top: 6px;
  border-top: 1px dashed var(--color-border-card);
}

.catalog-desktop-table {
  display: none;
}
.catalog-mobile-cards {
  display: block;
}
@media (min-width: 768px) {
  .catalog-desktop-table {
    display: block;
  }
  .catalog-mobile-cards {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Abas (Tabs) Modernas
   -------------------------------------------------------------------------- */
.tabs-bar {
  display: flex;
  gap: 24px;
  margin-bottom: var(--space-4);
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border-card);
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 2px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  text-decoration: none;
  color: var(--color-text-main);
}

.tab-btn.active {
  color: var(--color-brand-primary);
  border-bottom-color: var(--color-brand-secondary);
}
