body {
  background: var(--rs-background);
  color: var(--rs-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.app-container,
.os-page,
.stock-page,
.financial-page,
.billing-notes-page,
.customers-page,
.technicians-page,
.system-events-page,
.rh-page,
.sector-page,
.home-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.ds-page-header,
.os-page-header,
.stock-header,
.financial-header,
.billing-notes-header,
.customers-header,
.technicians-header,
.system-events-header,
.rh-page-header,
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0;
}

.ds-page-header h1,
.os-page-header h1,
.os-page-header h2,
.stock-header h1,
.stock-header h2,
.financial-header h1,
.financial-header h2,
.billing-notes-header h1,
.billing-notes-header h2,
.customers-header h1,
.customers-header h2,
.technicians-header h1,
.technicians-header h2,
.system-events-header h1,
.system-events-header h2,
.rh-page-header h1,
.page-header h1 {
  margin: 0;
  color: var(--rs-text);
  font-size: clamp(26px, 2.4vw, 32px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.ds-page-header p,
.os-page-header p,
.stock-header p,
.financial-header p,
.billing-notes-header p,
.customers-header p,
.technicians-header p,
.system-events-header p,
.rh-page-header p,
.page-header p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--rs-text-secondary);
  font-size: 15px;
}

.page-header__eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--rs-primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-header__actions,
.section-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-card,
.filter-card,
.sector-dashboard,
.empty-page,
.os-card,
.financial-panel,
.stock-panel,
.billing-notes-panel,
.customers-panel,
.technicians-panel,
.system-events-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--rs-surface);
  border: 1px solid var(--rs-border-light);
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-shadow-sm);
}

.section-card__header,
.financial-panel > header,
.stock-panel > header,
.billing-notes-panel > header,
.customers-panel > header,
.technicians-panel > header,
.system-events-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--rs-border-light);
}

.section-card__header h2,
.section-card__header h3,
.financial-panel h3,
.stock-panel h3,
.billing-notes-panel h3 {
  margin: 0;
  color: var(--rs-text);
  font-size: 16px;
  font-weight: 600;
}

.section-card__header p,
.financial-panel header p,
.stock-panel header p,
.billing-notes-panel header p {
  margin: 4px 0 0;
  color: var(--rs-text-secondary);
  font-size: 13px;
}

.section-card__body {
  padding: 24px;
}

.kpi-grid,
.stock-summary-grid,
.financial-summary-grid,
.billing-notes-summary-grid,
.customers-summary-grid,
.technicians-summary-grid,
.system-events-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-card,
.stock-summary-card,
.financial-summary-card,
.billing-notes-summary-card,
.customers-summary-card,
.technicians-summary-card,
.system-events-summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 100px;
  padding: 20px;
  background: var(--rs-surface);
  border: 1px solid var(--rs-border-light);
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-shadow-sm);
}

.dashboard-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  background: var(--rs-primary-light);
  color: var(--rs-primary);
  font-size: 20px;
}

.dashboard-card--success .dashboard-card__icon { background: var(--rs-success-light); color: var(--rs-success); }
.dashboard-card--warning .dashboard-card__icon { background: var(--rs-warning-light); color: var(--rs-warning); }
.dashboard-card--neutral .dashboard-card__icon { background: #f3f0ff; color: #7c3aed; }

.dashboard-card__label,
.stock-summary-card span,
.financial-summary-card span,
.billing-notes-summary-card span,
.customers-summary-card span,
.technicians-summary-card span,
.system-events-summary-card span {
  display: block;
  color: var(--rs-text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.dashboard-card__value,
.stock-summary-card strong,
.financial-summary-card strong,
.billing-notes-summary-card strong,
.customers-summary-card strong,
.technicians-summary-card strong,
.system-events-summary-card strong {
  display: block;
  margin-top: 2px;
  color: var(--rs-text);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dashboard-card small {
  display: block;
  margin-top: 3px;
  color: var(--rs-text-secondary);
  font-size: 12px;
}

.filter-card,
.os-list-filters,
.stock-toolbar,
.financial-toolbar,
.billing-notes-toolbar,
.customers-toolbar,
.technicians-toolbar,
.system-events-toolbar,
.stock-filters,
.billing-notes-filters {
  padding: 20px 24px 24px;
  background: var(--rs-surface);
  border: 1px solid var(--rs-border-light);
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-shadow-sm);
}

.filter-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 28px;
  margin-bottom: 20px;
}

.filter-card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--rs-text);
  font-size: 15px;
}

.filter-card__title > span { color: var(--rs-text-secondary); font-size: 20px; }

.filter-card__fields,
.os-list-filters,
.stock-toolbar,
.financial-toolbar,
.billing-notes-toolbar,
.customers-toolbar,
.technicians-toolbar,
.system-events-toolbar,
.stock-filters,
.billing-notes-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
  gap: 16px;
}

.field-control,
.os-filter-field,
.stock-filter-field,
.financial-field,
.billing-notes-field,
.customers-field,
.technicians-field,
.system-events-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--rs-text);
  font-size: 13px;
  font-weight: 500;
}

.field-control__input-wrap {
  position: relative;
  display: block;
}

.field-control__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rs-text-secondary);
  font-size: 20px;
  pointer-events: none;
}

.field-control__input-wrap input { padding-left: 44px; }

input,
select,
textarea,
.os-product-use-input {
  width: 100%;
  min-height: var(--rs-control-height);
  padding: 11px 14px;
  background: var(--rs-surface);
  border: 1px solid var(--rs-border-medium);
  border-radius: 8px;
  color: var(--rs-text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--rs-text-muted); }

input:hover,
select:hover,
textarea:hover { border-color: var(--rs-border-strong); }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--rs-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.danger-button,
.os-table-actions button,
.stock-table button,
.financial-table button,
.billing-notes-table button,
.customers-table button,
.technicians-table button,
.system-events-table button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
  transform: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-button {
  min-height: 46px;
  background: var(--rs-primary);
  border: 1px solid var(--rs-primary);
  color: #fff;
}

.primary-button:hover { background: var(--rs-primary-hover); border-color: var(--rs-primary-hover); box-shadow: none; transform: none; }
.primary-button:active { background: var(--rs-primary-active); }

.secondary-button,
.os-table-actions button,
.stock-table button,
.financial-table button,
.billing-notes-table button,
.customers-table button,
.technicians-table button,
.system-events-table button {
  background: var(--rs-surface);
  border: 1px solid var(--rs-border-medium);
  color: #374151;
}

.secondary-button:hover,
.os-table-actions button:hover,
.stock-table button:hover,
.financial-table button:hover,
.billing-notes-table button:hover,
.customers-table button:hover,
.technicians-table button:hover,
.system-events-table button:hover {
  background: var(--rs-surface-subtle);
  border-color: var(--rs-border-strong);
}

.text-button {
  min-height: 36px;
  padding-inline: 8px;
  background: transparent;
  border: 0;
  color: var(--rs-primary);
}

.text-button:hover { background: var(--rs-primary-light); }

.danger-button {
  background: var(--rs-surface);
  border: 1px solid #fecaca;
  color: var(--rs-danger);
}

.danger-button:hover { background: var(--rs-danger-light); }

.icon-button {
  width: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--rs-text-secondary);
  font-size: 18px;
}

.icon-button:hover { background: var(--rs-surface-subtle); border-color: var(--rs-border-light); color: var(--rs-text); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.data-table-wrap,
.os-table-wrapper,
.stock-table-wrapper,
.financial-table-wrapper,
.billing-notes-table-wrapper,
.customers-table-wrapper,
.technicians-table-wrapper,
.system-events-table-wrapper,
.os-products-table-wrapper {
  width: 100%;
  overflow-x: auto;
  background: var(--rs-surface);
}

.data-table,
.os-table,
.stock-table,
.financial-table,
.billing-notes-table,
.customers-table,
.technicians-table,
.system-events-table,
.os-products-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  border-spacing: 0;
}

.data-table th,
.os-table th,
.stock-table th,
.financial-table th,
.billing-notes-table th,
.customers-table th,
.technicians-table th,
.system-events-table th,
.os-products-table th {
  height: 48px;
  padding: 12px 16px;
  background: var(--rs-surface-subtle);
  border-bottom: 1px solid var(--rs-border-light);
  color: #4b5563;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td,
.os-table td,
.stock-table td,
.financial-table td,
.billing-notes-table td,
.customers-table td,
.technicians-table td,
.system-events-table td,
.os-products-table td {
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f3;
  color: #374151;
  font-size: 13px;
  vertical-align: middle;
}

.data-table tbody tr:hover,
.os-table tbody tr:hover,
.stock-table tbody tr:hover,
.financial-table tbody tr:hover,
.billing-notes-table tbody tr:hover,
.customers-table tbody tr:hover,
.technicians-table tbody tr:hover,
.system-events-table tbody tr:hover { background: #f9fbff; }

.data-table tbody tr:last-child td,
.os-table tbody tr:last-child td,
.stock-table tbody tr:last-child td,
.financial-table tbody tr:last-child td,
.billing-notes-table tbody tr:last-child td,
.customers-table tbody tr:last-child td,
.technicians-table tbody tr:last-child td,
.system-events-table tbody tr:last-child td { border-bottom: 0; }

.status-badge,
.os-status-badge,
.financial-status,
.billing-notes-status,
.stock-status,
.customers-status,
.technicians-status,
.system-events-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.status-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge--success, .os-status-badge.is-finalizada, .financial-status.is-pago { background: var(--rs-success-light); color: #15803d; }
.status-badge--warning, .os-status-badge.is-pendente, .os-status-badge.is-falta-finalizar, .financial-status.is-em-aberto { background: var(--rs-warning-light); color: #b45309; }
.status-badge--danger, .os-status-badge.is-cancelada, .financial-status.is-cancelado { background: var(--rs-danger-light); color: #b91c1c; }
.status-badge--neutral { background: #f3f4f6; color: #4b5563; }

.empty-state,
.os-empty-state,
.stock-empty,
.financial-empty,
.billing-notes-empty,
.customers-empty,
.technicians-empty,
.system-events-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 180px;
  place-content: center;
  padding: 32px;
  color: var(--rs-text-secondary);
  text-align: center;
}

.empty-state__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--rs-surface-subtle);
  color: var(--rs-text-secondary);
  font-size: 20px;
}

.empty-state strong { color: var(--rs-text); font-size: 15px; }
.empty-state p { max-width: 420px; margin: 0; }

.loading-skeleton { display: grid; gap: 1px; overflow: hidden; background: var(--rs-surface); }
.loading-skeleton__row { display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)); gap: 24px; padding: 18px 16px; border-bottom: 1px solid #eef0f3; }
.loading-skeleton__row span { height: 12px; border-radius: 999px; background: #eef1f5; animation: skeleton-loading 1.2s ease-in-out infinite alternate; }
@keyframes skeleton-loading { to { opacity: 0.42; } }

.os-message,
.stock-message,
.financial-message,
.billing-notes-message,
.customers-message,
.technicians-message,
.system-events-message,
.error-message {
  padding: 12px 16px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: var(--rs-danger-light);
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
}

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-shadow-lg);
}

.confirm-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.confirm-dialog__panel { display: grid; grid-template-columns: 44px 1fr; gap: 16px; max-width: none; margin: 0; padding: 24px; border: 0; }
.confirm-dialog__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--rs-warning-light); color: var(--rs-warning); font-size: 20px; font-weight: 600; }
.confirm-dialog h2 { margin: 0; font-size: 18px; }
.confirm-dialog p { margin: 8px 0 0; color: var(--rs-text-secondary); }
.confirm-dialog__actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast-region { position: fixed; top: 24px; right: 24px; z-index: 3000; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; max-width: 420px; padding: 12px 16px; border: 1px solid #bbf7d0; border-radius: 8px; background: #f0fdf4; color: #166534; box-shadow: var(--rs-shadow-lg); opacity: 0; transform: translateY(-8px); transition: opacity 0.18s ease, transform 0.18s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--error { border-color: #fecaca; background: var(--rs-danger-light); color: #991b1b; }

.action-menu { position: relative; }
.action-menu summary { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--rs-text-secondary); cursor: pointer; list-style: none; font-size: 20px; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary:hover { background: var(--rs-surface-subtle); color: var(--rs-text); }
.action-menu__popover { position: absolute; z-index: 20; right: 0; top: calc(100% + 6px); display: grid; min-width: 170px; padding: 6px; background: var(--rs-surface); border: 1px solid var(--rs-border-light); border-radius: 10px; box-shadow: var(--rs-shadow-lg); }
.action-menu__popover button { justify-content: flex-start; width: 100%; min-height: 36px; border: 0; background: transparent; }

@media (max-width: 1100px) {
  .kpi-grid,
  .stock-summary-grid,
  .financial-summary-grid,
  .billing-notes-summary-grid,
  .customers-summary-grid,
  .technicians-summary-grid,
  .system-events-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-container,
  .os-page,
  .stock-page,
  .financial-page,
  .billing-notes-page,
  .customers-page,
  .technicians-page,
  .system-events-page,
  .rh-page,
  .sector-page,
  .home-page { gap: 16px; }

  .ds-page-header,
  .os-page-header,
  .stock-header,
  .financial-header,
  .billing-notes-header,
  .customers-header,
  .technicians-header,
  .system-events-header,
  .rh-page-header,
  .page-header { align-items: flex-start; flex-direction: column; gap: 16px; }

  .page-header__actions { width: 100%; }
  .page-header__actions > button { flex: 1; }

  .kpi-grid,
  .stock-summary-grid,
  .financial-summary-grid,
  .billing-notes-summary-grid,
  .customers-summary-grid,
  .technicians-summary-grid,
  .system-events-summary-grid { grid-template-columns: 1fr; gap: 12px; }

  .dashboard-card,
  .stock-summary-card,
  .financial-summary-card,
  .billing-notes-summary-card,
  .customers-summary-card,
  .technicians-summary-card,
  .system-events-summary-card { min-height: 84px; padding: 16px; }

  .filter-card,
  .os-list-filters,
  .stock-toolbar,
  .financial-toolbar,
  .billing-notes-toolbar,
  .customers-toolbar,
  .technicians-toolbar,
  .system-events-toolbar,
  .stock-filters,
  .billing-notes-filters { padding: 16px; grid-template-columns: 1fr; }

  .section-card__header,
  .section-card__body { padding: 16px; }
  .toast-region { inset: 16px 16px auto; }
  .toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
