/* ==========================================================================
   Componentes Reutilizables — Tarjetas, Tablas, Botones, Inputs, Modales
   ========================================================================== */
.card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Botones (7 estados) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
}

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

.btn-outline {
  background-color: var(--bg-surface);
  border-color: var(--brand-border);
  color: var(--brand-primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--brand-soft);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-input);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--status-danger);
  color: var(--text-inverse);
}

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

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-link {
  background: none;
  border: none;
  padding: 4px 6px;
  color: var(--brand-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover {
  color: var(--brand-primary-hover);
}

/* Badges y Placas */
.plate-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius-sm);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  background-color: var(--bg-surface);
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-urgent {
  background-color: var(--status-urgent-bg);
  color: var(--status-urgent-text);
}

.pill-info {
  border: 1.5px solid var(--status-info-border);
  color: var(--status-info-text);
  background-color: var(--bg-surface);
}

.pill-ok {
  background-color: var(--status-ok-bg);
  color: var(--status-ok-text);
}

.pill-success {
  background-color: var(--status-success-bg);
  color: var(--status-success);
}

.pill-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger);
}

/* Formularios e Inputs */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.input,
.select,
.textarea {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  font-size: 13.5px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

.input.is-error,
.select.is-error {
  border-color: var(--status-danger);
  background-color: var(--status-danger-bg);
}

.field-error {
  font-size: 11.5px;
  color: var(--status-danger);
  font-weight: 500;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Tablas */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead tr {
  background-color: var(--bg-table-head);
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table th:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.data-table th:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-divider);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.num-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-footer {
  margin-top: var(--space-4);
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Tabs */
.tabs-bar {
  display: inline-flex;
  gap: var(--space-2);
  background-color: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tab-btn.active {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--bg-table-head);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background-color: var(--text-primary);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
}

.toast.success {
  background-color: #0F5132;
}

.toast.error {
  background-color: #991B1B;
}
