:root {
  --ml-bg: #f4f6fa;
  --ml-card: #ffffff;
  --ml-card-soft: #f8fafc;
  --ml-border: #e2e8f0;
  --ml-border-strong: #cbd5e1;
  --ml-text: #16202f;
  --ml-muted: #64748b;
  --ml-primary: #16273f;
  --ml-primary-hover: #1e3554;
  --ml-accent: #0e7c86;
  --ml-accent-soft: #e6f6f7;
  --ml-success: #047857;
  --ml-warning: #b45309;
  --ml-danger: #b91c1c;
  --ml-sidebar: #0b1220;
  --ml-sidebar-2: #121b2e;
  --ml-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --ml-shadow-strong: 0 18px 44px rgba(15, 23, 42, 0.14);
  --ml-radius: 12px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--ml-bg);
  color: var(--ml-text);
}

#app-shell.app-shell,
#app-shell .content {
  background: var(--ml-bg);
}

#app-shell.app-shell {
  grid-template-columns: 276px minmax(0, 1fr);
}

#app-shell.app-shell.sidebar-collapsed {
  grid-template-columns: 60px minmax(0, 1fr);
}

#app-shell .content {
  padding: 22px;
  overflow-x: hidden;
}

.login-screen {
  background:
    radial-gradient(circle at 20% 18%, rgba(14, 124, 134, 0.28), transparent 30%),
    linear-gradient(135deg, #08101d 0%, #16273f 52%, #0e7c86 100%);
  color: #ffffff;
}

.login-screen .login-copy,
.login-screen .brand span {
  color: rgba(255, 255, 255, 0.74);
}

.login-screen .eyebrow {
  color: #7dd3dc;
}

.login-card {
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ml-text);
  box-shadow: var(--ml-shadow-strong);
}

.login-card h2,
.login-card label {
  color: var(--ml-text);
}

.login-card input {
  background: #ffffff;
  color: var(--ml-text);
}

.login-toggle-password {
  border-color: var(--ml-border);
  background: var(--ml-card-soft);
  color: var(--ml-primary);
}

#app-shell .sidebar {
  padding: 14px 10px 12px;
  border-right: 1px solid #dbe4f0;
  background: #ffffff;
  box-shadow: none;
  color: #0b2341;
  gap: 8px;
  overflow: hidden;
}

#app-shell .sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 0 2px 0 0;
}

#app-shell .sidebar-brand {
  min-width: 0;
  flex: 1;
}

#app-shell .brand-logo,
.login-screen .brand-logo,
#app-shell .brand-icon {
  display: block;
  height: auto;
  max-width: 100%;
}

.login-screen .brand-logo-login {
  width: min(236px, 78vw);
}

.login-screen .login-logo {
  display: grid;
  gap: 10px;
}

.login-screen > *,
.login-screen .login-card,
.login-screen .login-brand {
  min-width: 0;
  max-width: 100%;
}

#app-shell .brand-logo-sidebar {
  width: 168px;
}

#app-shell .brand-icon-sidebar {
  display: none;
  width: 42px;
  height: 42px;
}

#app-shell .brand strong {
  color: #001b3d;
  display: block;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell .brand span,
#app-shell .sidebar-stats span,
#app-shell .policy-panel,
#app-shell .policy-panel p {
  color: #5a6f8f;
}

#app-shell .sidebar-brand span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell .sidebar-toggle,
#app-shell .mobile-menu-button,
#app-shell .sidebar-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #f7faff;
  color: #001b3d;
  box-shadow: none;
}

#app-shell .sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

#app-shell .topbar .mobile-menu-button {
  border-color: var(--ml-border);
  background: #ffffff;
  color: var(--ml-primary);
  box-shadow: var(--ml-shadow);
}

#app-shell .side-nav {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  margin-top: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

#app-shell .side-nav::-webkit-scrollbar {
  width: 6px;
}

#app-shell .side-nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d5deea;
}

#app-shell .side-nav::-webkit-scrollbar-track {
  background: transparent;
}

#app-shell .side-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

#app-shell .side-nav-group:not(:has(a:not(.is-hidden))) {
  display: none;
}

#app-shell .side-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 24px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #536987;
  cursor: pointer;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1;
  text-align: left;
}

#app-shell .side-nav-heading:hover {
  color: #001b3d;
}

#app-shell .side-nav-heading-indicator {
  font-weight: 600;
}

#app-shell .side-nav-group.is-collapsed > a {
  display: none;
}

#app-shell .side-nav-group.is-collapsed .side-nav-heading-indicator {
  transform: rotate(90deg);
}

#app-shell .side-nav a {
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  color: #496384;
  font-size: 0.93rem;
  font-weight: 500;
  line-height: 1.15;
}

#app-shell .nav-icon {
  background: transparent;
  color: currentColor;
}

#app-shell .side-nav a.active,
#app-shell .side-nav a:hover {
  background: #f0f4f9;
  color: #001b3d;
  transform: none;
}

#app-shell .side-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  min-width: 20px;
  height: 20px;
  flex-shrink: 0;
}

#app-shell .side-nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app-shell .side-nav a.active::before {
  display: none;
}

#app-shell .side-nav a.active .nav-icon,
#app-shell .side-nav a:hover .nav-icon {
  background: transparent;
  color: currentColor;
}

#app-shell.sidebar-collapsed .side-nav a:hover::after,
#app-shell.sidebar-collapsed .side-nav a:focus-visible::after {
  border-color: var(--ml-border);
  background: #ffffff;
  color: var(--ml-text);
  box-shadow: var(--ml-shadow-strong);
}

#app-shell.sidebar-collapsed .sidebar {
  padding: 12px 8px;
}

#app-shell.sidebar-collapsed .sidebar-header {
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 0;
}

#app-shell.sidebar-collapsed .side-nav-heading,
#app-shell.sidebar-collapsed .nav-text,
#app-shell.sidebar-collapsed .nav-badge,
#app-shell.sidebar-collapsed .sidebar-user-block,
#app-shell.sidebar-collapsed .sidebar-logout .logout-label {
  display: none !important;
}

#app-shell.sidebar-collapsed .sidebar-brand {
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  width: 100%;
}

#app-shell.sidebar-collapsed .brand-logo-sidebar {
  display: none;
}

#app-shell.sidebar-collapsed .brand-icon-sidebar {
  display: block;
}

#app-shell.sidebar-collapsed .sidebar-toggle {
  margin: 0;
}

#app-shell.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

#app-shell.sidebar-collapsed .side-nav-group {
  margin-top: 4px;
}

#app-shell.sidebar-collapsed .side-nav a {
  justify-content: center;
  padding: 8px 6px;
}

#app-shell.sidebar-collapsed .side-nav a[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  z-index: 100;
  min-width: max-content;
  padding: 6px 10px;
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  background: #1e293b;
  color: #f8fafc;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 0.15s, visibility 0.15s;
  visibility: hidden;
  white-space: nowrap;
}

#app-shell.sidebar-collapsed .side-nav a[data-tooltip]:hover::after,
#app-shell.sidebar-collapsed .side-nav a[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

#app-shell .topbar {
  min-height: 48px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.82);
}

#app-shell .topbar h1,
#app-shell #page-title {
  color: var(--ml-text);
  font-weight: 800;
  letter-spacing: 0;
}

#app-shell .topbar-eyebrow,
#app-shell .eyebrow,
#app-shell .decision-engine-card span {
  color: var(--ml-accent);
}

#app-shell .user-pill,
#app-shell .company-selector select,
#app-shell .live-pill {
  border-color: var(--ml-border);
  background: #ffffff;
  color: var(--ml-text);
}

#app-shell .live-pill {
  background: #ecfdf5;
  color: var(--ml-success);
}

#app-shell .panel,
#app-shell .dashboard-group,
#app-shell .metric,
#app-shell .decision-engine-card,
#app-shell .permission-denied-card,
#app-shell .setup-alert,
#app-shell .credit-analysis-box,
#app-shell .credit-summary,
#app-shell .sale-guidance,
#app-shell .sale-summary-card,
#app-shell .customer-form-content,
#app-shell .details-content,
#app-shell .external-report-section,
#app-shell .policy-negative-card,
#app-shell .receivable-card,
#app-shell .sale-list-card,
#app-shell .customer-card,
#app-shell .audit-card,
#app-shell .collection-card,
#app-shell .numbers div {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-card);
  color: var(--ml-text);
  box-shadow: var(--ml-shadow);
}

#app-shell .dashboard-group {
  padding: 18px;
}

#app-shell .content > #dashboard.dashboard-groups:not(.active-section) {
  display: none;
}

#app-shell .content > #dashboard.dashboard-groups[hidden] {
  display: none !important;
}

#app-shell #dashboard.dashboard-groups.active-section {
  display: grid;
  gap: 18px;
  align-content: start;
}

#app-shell #dashboard .dashboard-group {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 12px;
  box-shadow: var(--ml-shadow);
}

#app-shell #dashboard .dashboard-group:nth-of-type(2) { border-top: 3px solid #0e7c86; }
#app-shell #dashboard .dashboard-group:nth-of-type(3) { border-top: 3px solid #16273f; }
#app-shell #dashboard .dashboard-group.risk-group { border-top: 3px solid #b45309; }
#app-shell #dashboard .dashboard-group.decision-engine-group { border-top: 3px solid #37afd0; }

#app-shell #dashboard .group-heading {
  display: grid;
  gap: 4px;
  margin: 0;
}

#app-shell #dashboard .group-heading .eyebrow {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

#app-shell #dashboard .group-heading h2 {
  margin: 0;
  font-size: clamp(1rem, 1.3vw, 1.18rem);
  font-weight: 800;
  line-height: 1.2;
}

#app-shell #dashboard .metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

#app-shell #dashboard .metric {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 116px;
  padding: 15px;
  border-radius: 12px;
  border-top: 3px solid var(--ml-border);
}

#app-shell #dashboard .metric:nth-child(1) { border-top-color: #0e7c86; }
#app-shell #dashboard .metric:nth-child(2) { border-top-color: #37afd0; }
#app-shell #dashboard .metric:nth-child(3) { border-top-color: #94a3b8; }
#app-shell #dashboard .metric:nth-child(4) { border-top-color: #16273f; }
#app-shell #dashboard .metric.risk-card { border-top-color: #b45309; }

#app-shell #dashboard .metric span {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1.2;
  text-transform: uppercase;
}

#app-shell #dashboard .metric strong {
  font-size: clamp(1.32rem, 1.8vw, 1.75rem);
  font-weight: 800;
  line-height: 1.1;
}

#app-shell #dashboard .metric small {
  max-width: 28ch;
  font-size: 0.8rem;
  line-height: 1.35;
}

#app-shell #dashboard .decision-engine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

#app-shell #dashboard .decision-engine-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 145px;
  padding: 15px;
  border-radius: 12px;
  border-top: 3px solid #37afd0;
}

#app-shell #dashboard .decision-engine-card span {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

#app-shell #dashboard .decision-engine-card strong {
  font-size: 0.98rem;
  line-height: 1.25;
}

#app-shell #dashboard .decision-engine-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

#app-shell .group-heading,
#app-shell .panel-heading {
  gap: 12px;
}

#app-shell .group-heading h2,
#app-shell .panel-heading h2,
#app-shell .customers-panel-heading h2 {
  color: var(--ml-text);
  letter-spacing: 0;
}

#app-shell .panel-subtitle,
#app-shell .field-hint,
#app-shell .row-muted,
#app-shell .metric span,
#app-shell .metric small,
#app-shell .numbers span,
#app-shell .confirmation-copy,
#app-shell .decision-engine-card p {
  color: var(--ml-muted);
}

#app-shell .content > section[id].active-section:not(#dashboard) {
  max-width: 100%;
}

#app-shell .content > section[id]:not(.active-section),
#app-shell .content > section[id][hidden],
#app-shell .content > .panel:not(.active-section) {
  display: none !important;
}

#app-shell .panel {
  gap: 16px;
  padding: 22px;
  border-radius: 16px;
  overflow-x: hidden;
}

#app-shell .content > .panel.active-section {
  display: grid;
}

#app-shell .panel-heading,
#app-shell .customers-panel-heading,
#app-shell .panel-heading--actions,
#app-shell .table-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ml-border);
}

#app-shell .panel-heading > div,
#app-shell .customers-panel-heading > div {
  min-width: 0;
}

#app-shell .panel-heading h2,
#app-shell .customers-panel-heading h2 {
  margin: 0;
  font-size: clamp(1.08rem, 1.35vw, 1.28rem);
  font-weight: 800;
  line-height: 1.2;
}

#app-shell .panel-subtitle {
  max-width: 72ch;
  margin: 5px 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

#app-shell .panel-actions,
#app-shell .customers-panel-actions,
#app-shell .panel-heading-actions,
#app-shell .admin-form-actions,
#app-shell .company-toolbar,
#app-shell .user-toolbar,
#app-shell .customer-whatsapp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

#app-shell .form-grid,
#app-shell .compact-grid,
#app-shell .filters,
#app-shell .customer-filters,
#app-shell .receivables-filters,
#app-shell .history-filters,
#app-shell .credit-leads-filters,
#app-shell .client-requests-filters {
  gap: 12px;
}

#app-shell .compact-grid,
#app-shell .filters,
#app-shell .customer-filters,
#app-shell .receivables-filters,
#app-shell .history-filters,
#app-shell .credit-leads-filters,
#app-shell .client-requests-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

#app-shell label {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

#app-shell input,
#app-shell select,
#app-shell textarea {
  min-height: 40px;
  padding-inline: 11px;
  font-size: 0.9rem;
}

#app-shell textarea {
  min-height: 84px;
  padding-block: 10px;
  line-height: 1.45;
}

#app-shell .form-message {
  margin: 2px 0 0;
  font-size: 0.84rem;
}

#app-shell .customers-list-panel,
#app-shell .customer-form-content,
#app-shell .sale-form-shell,
#app-shell .sale-form-compact,
#app-shell .sale-summary-card,
#app-shell .sale-guidance,
#app-shell .credit-policy-admin,
#app-shell .integration-card,
#app-shell .integration-section,
#app-shell .user-form-block,
#app-shell .user-permissions-panel,
#app-shell .customer-history-summary,
#app-shell .credit-accordion {
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--ml-shadow);
}

#app-shell .customers-list-panel,
#app-shell .customer-form-content,
#app-shell .sale-form-shell,
#app-shell .sale-form-compact,
#app-shell .sale-summary-card,
#app-shell .sale-guidance,
#app-shell .credit-policy-admin,
#app-shell .integration-card,
#app-shell .integration-section,
#app-shell .user-form-block,
#app-shell .user-permissions-panel,
#app-shell .customer-history-summary,
#app-shell .credit-accordion {
  padding: 16px;
}

#app-shell .receivables-cards,
#app-shell .customers-cards,
#app-shell .admin-cards,
#app-shell .audit-cards,
#app-shell .companies-cards,
#app-shell .client-requests-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

#app-shell #clientes .customers-cards {
  display: none;
}

#app-shell #clientes .customers-list-panel {
  display: grid;
  gap: 14px;
}

#app-shell #clientes .customer-filters-panel {
  display: grid;
  gap: 10px;
}

#app-shell #clientes .customer-filters-panel:not(.is-expanded) {
  gap: 0;
}

#app-shell #clientes .customer-filters {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

#app-shell #clientes .customers-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

#app-shell #clientes .customers-table {
  min-width: 0;
  table-layout: fixed;
}

#app-shell #clientes .customers-table th,
#app-shell #clientes .customers-table td {
  height: 34px;
  padding: 4px 6px;
  font-size: 0.74rem;
  line-height: 1.18;
  white-space: nowrap;
}

#app-shell #clientes .customers-table th:nth-child(1),
#app-shell #clientes .customers-table td:nth-child(1) {
  width: 30%;
}

#app-shell #clientes .customers-table th:nth-child(2),
#app-shell #clientes .customers-table td:nth-child(2),
#app-shell #clientes .customers-table th:nth-child(3),
#app-shell #clientes .customers-table td:nth-child(3) {
  width: 14%;
}

#app-shell #clientes .customers-table th:nth-child(4),
#app-shell #clientes .customers-table td:nth-child(4) {
  width: 12%;
}

#app-shell #clientes .customers-table th:nth-child(5),
#app-shell #clientes .customers-table td:nth-child(5) {
  width: 10%;
}

#app-shell #clientes .customers-table th:nth-child(6),
#app-shell #clientes .customers-table td:nth-child(6) {
  width: 12%;
}

#app-shell #clientes .customers-table th:nth-child(7),
#app-shell #clientes .customers-table td:nth-child(7) {
  width: 6%;
  min-width: 0;
  max-width: none;
  padding-inline: 4px;
  text-align: right;
}

#app-shell #clientes .customers-table th:nth-child(7) {
  color: transparent;
  font-size: 0;
}

#app-shell #clientes .customer-row-menu-button,
#app-shell #clientes .icon-menu-button.customer-row-menu-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #d8e2ef;
  border-radius: 10px;
  background: #ffffff;
  color: #16273f;
  font-size: 1rem;
  line-height: 1;
  box-shadow: none;
}

#app-shell #clientes .customer-row-menu-button:hover,
#app-shell #clientes .customer-row-menu-button.is-active {
  border-color: var(--ml-accent);
  background: var(--ml-accent-soft);
}

#app-shell .customer-floating-menu {
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--ml-shadow-strong);
}

#app-shell .customer-floating-menu .ghost-action {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--ml-primary);
  justify-content: flex-start;
}

#app-shell .customer-floating-menu .ghost-action:hover {
  border-color: var(--ml-border);
  background: var(--ml-accent-soft);
}

#app-shell .receivable-card,
#app-shell .sale-list-card,
#app-shell .customer-card,
#app-shell .audit-card,
#app-shell .collection-card,
#app-shell .decision-card,
#app-shell .policy-negative-card,
#app-shell .external-report-section {
  padding: 15px;
  border-radius: 12px;
}

#app-shell .metric {
  min-height: 118px;
  padding: 16px;
  overflow: hidden;
}

#app-shell .metric::after {
  display: none;
}

#app-shell .metric strong,
#app-shell .decision-engine-card strong,
#app-shell .client-name,
#app-shell .external-report-section h4,
#app-shell .final-sale-summary strong {
  color: var(--ml-text);
}

#app-shell .metric strong {
  font-size: clamp(1.38rem, 2vw, 1.9rem);
  line-height: 1.18;
}

#app-shell .decision-engine-grid,
#app-shell .metric-grid,
#app-shell .collection-metrics,
#app-shell .sale-mini-metrics {
  gap: 14px;
}

#app-shell .primary-action,
#app-shell .secondary-action,
#app-shell .details-button,
#app-shell .icon-button,
#app-shell .health-link,
#app-shell .ghost-action,
#app-shell .row-actions-menu summary {
  min-height: 40px;
  border-radius: 10px;
  box-shadow: none;
  font-weight: 700;
}

#app-shell .primary-action {
  border: 1px solid var(--ml-primary);
  background: var(--ml-primary);
  color: #ffffff;
}

#app-shell .primary-action:hover {
  border-color: var(--ml-primary-hover);
  background: var(--ml-primary-hover);
  box-shadow: 0 10px 22px rgba(22, 39, 63, 0.18);
}

#app-shell .primary-action.success-action {
  border-color: var(--ml-accent);
  background: var(--ml-accent);
}

#app-shell .primary-action.danger-action {
  border-color: var(--ml-danger);
  background: var(--ml-danger);
}

#app-shell .secondary-action,
#app-shell .details-button,
#app-shell .icon-button,
#app-shell .health-link,
#app-shell .ghost-action,
#app-shell .row-actions-menu summary {
  border: 1px solid var(--ml-border-strong);
  background: #ffffff;
  color: var(--ml-primary);
}

#app-shell .secondary-action:hover,
#app-shell .details-button:hover,
#app-shell .icon-button:hover,
#app-shell .health-link:hover,
#app-shell .ghost-action:hover,
#app-shell .row-actions-menu summary:hover {
  border-color: var(--ml-accent);
  background: var(--ml-accent-soft);
  color: var(--ml-primary);
  transform: none;
}

#app-shell input,
#app-shell select,
#app-shell textarea {
  border-color: var(--ml-border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ml-text);
}

#app-shell input:focus,
#app-shell select:focus,
#app-shell textarea:focus {
  border-color: var(--ml-accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.12);
  outline: none;
}

#app-shell .table-wrap,
#app-shell .customers-table-wrap,
#app-shell .sales-table-wrap,
#app-shell .receivables-table-wrap,
#app-shell .collection-table-wrap,
#app-shell .history-table-wrap,
#app-shell .intelligence-table-wrap,
#app-shell .policy-band-table-wrap,
#app-shell .credit-leads-table-wrap,
#app-shell .sellers-table-wrap,
#app-shell .admin-table-wrap,
#app-shell .companies-table-wrap {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: #ffffff;
  box-shadow: var(--ml-shadow);
  overflow-x: auto;
}

#app-shell .receivables-table-wrap {
  overflow: visible;
}

#app-shell table,
#app-shell .data-table {
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ml-text);
}

#app-shell th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

#app-shell th,
#app-shell td {
  padding: 6px 8px;
  vertical-align: middle;
}

#app-shell td {
  border-color: var(--ml-border);
  color: #1f2937;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
}

#app-shell td strong {
  font-weight: 600;
}

#app-shell tbody tr:hover {
  background: #f8fafc;
}

#app-shell .pagination-bar,
#app-shell .customers-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

#app-shell .content > .panel.active-section {
  border-top: 3px solid #16273f;
}

#app-shell #clientes.active-section,
#app-shell #vendas.active-section,
#app-shell #vendedores.active-section {
  border-top-color: #0e7c86;
}

#app-shell #credit-intelligence.active-section,
#app-shell #credit-leads.active-section,
#app-shell #client-requests.active-section {
  border-top-color: #37afd0;
}

#app-shell .intelligence-table-wrap {
  overflow-x: hidden;
}

#app-shell .intelligence-table th,
#app-shell .intelligence-table td {
  padding: 4px 4px;
  font-size: 0.68rem;
  line-height: 1.15;
}

#app-shell .intelligence-table .money-cell,
#app-shell .intelligence-table .count-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#app-shell #recebimentos.active-section,
#app-shell #cobranca.active-section {
  border-top-color: #b45309;
}

#app-shell #empresas.active-section,
#app-shell #usuarios.active-section,
#app-shell #integracoes.active-section {
  border-top-color: #16273f;
}

#app-shell #historico.active-section {
  border-top-color: #94a3b8;
}

#app-shell .filters,
#app-shell .customer-filters,
#app-shell .receivables-filters,
#app-shell .history-filters,
#app-shell .sales-filters,
#app-shell .sellers-filters,
#app-shell .intelligence-filters,
#app-shell .collection-notification-filters,
#app-shell .credit-leads-filters,
#app-shell .client-requests-filters {
  padding: 14px;
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #f8fafc;
}

#app-shell .customer-filters-toolbar,
#app-shell .admin-list-header,
#app-shell .compact-list-header,
#app-shell .integration-card-header,
#app-shell .receivable-card-header,
#app-shell .customer-card-header,
#app-shell .sale-details-header,
#app-shell .details-header {
  border-bottom-color: var(--ml-border);
}

#app-shell .sale-summary-grid,
#app-shell .final-sale-summary,
#app-shell .customer-history-summary-grid,
#app-shell .receivable-card-grid,
#app-shell .credit-summary-grid,
#app-shell .credit-source-grid,
#app-shell .credit-decision-options,
#app-shell .company-public-link-grid,
#app-shell .user-company-access-summary {
  display: grid;
  gap: 10px;
}

#app-shell .sale-summary-grid,
#app-shell .final-sale-summary,
#app-shell .customer-history-summary-grid,
#app-shell .receivable-card-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

#app-shell .sale-summary-grid div,
#app-shell .final-sale-summary div,
#app-shell .customer-history-summary-item,
#app-shell .credit-summary-metric,
#app-shell .sale-mini-metric,
#app-shell .numbers div {
  border: 1px solid var(--ml-border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  box-shadow: none;
}

#app-shell .sale-summary-grid span,
#app-shell .final-sale-summary span,
#app-shell .customer-history-summary-item span,
#app-shell .credit-summary-metric small,
#app-shell .sale-mini-metric span,
#app-shell .sale-mini-metric small,
#app-shell .receivable-card-grid span {
  color: var(--ml-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

#app-shell .sale-summary-grid strong,
#app-shell .final-sale-summary strong,
#app-shell .customer-history-summary-item strong,
#app-shell .credit-summary-metric strong,
#app-shell .sale-mini-metric strong,
#app-shell .receivable-card-grid strong {
  color: var(--ml-text);
  font-weight: 800;
}

#app-shell .empty-state {
  color: var(--ml-muted);
  background: #f8fafc;
  border: 1px dashed var(--ml-border-strong);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

#app-shell td.empty-state {
  border-radius: 0;
  border: 0;
  background: transparent;
}

#app-shell .badge,
#app-shell .score-chip,
#app-shell .status-pill,
#app-shell .nav-badge,
#app-shell .permission-badge,
#app-shell .sale-exception-badge,
#app-shell .credit-chosen-option-badge,
#app-shell .credit-pdf-applied-badge {
  min-height: 24px;
  border: 1px solid var(--ml-border);
  background: #f8fafc;
  color: #334155;
  padding: 4px 9px;
  font-size: 0.72rem;
  line-height: 1;
}

#app-shell .status-pill.approved,
#app-shell .status-pill.sale-paid,
#app-shell .status-pill.installment-paid,
#app-shell .status-pill.paid,
#app-shell .status-pill.active,
#app-shell .status-pill.ok,
#app-shell .sale-entry-badge.ok {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #047857;
}

#app-shell .status-pill.pending,
#app-shell .status-pill.conditional,
#app-shell .status-pill.sale-active,
#app-shell .status-pill.installment-pending,
#app-shell .sale-entry-badge.pending,
#app-shell .sale-entry-badge.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

#app-shell .status-pill.rejected,
#app-shell .status-pill.sale-overdue,
#app-shell .status-pill.installment-overdue,
#app-shell .status-pill.overdue,
#app-shell .status-pill.blocked,
#app-shell .sale-entry-badge.blocked {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

#app-shell .status-pill.sale-canceled,
#app-shell .status-pill.installment-canceled,
#app-shell .status-pill.inactive,
#app-shell .status-pill.neutral {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #64748b;
}

#app-shell .integration-card,
#app-shell .credit-accordion,
#app-shell .user-form-block,
#app-shell .customers-list-panel,
#app-shell .sale-summary-card,
#app-shell .sale-guidance,
#app-shell .credit-policy-admin {
  border-top: 3px solid var(--ml-border);
}

#app-shell .integration-card:nth-of-type(1),
#app-shell .customer-form-content,
#app-shell .sale-form-compact,
#app-shell .user-form-block--data {
  border-top-color: #0e7c86;
}

#app-shell .integration-card:nth-of-type(2),
#app-shell .customers-list-panel,
#app-shell .sale-summary-card,
#app-shell .user-permissions-panel {
  border-top-color: #37afd0;
}

#app-shell .integration-card:nth-of-type(3),
#app-shell .sale-guidance,
#app-shell .credit-policy-admin {
  border-top-color: #b45309;
}

#app-shell .integration-card:nth-of-type(4) {
  border-top-color: #16273f;
}

#app-shell .row-actions-menu summary,
#app-shell .icon-menu-button {
  border-radius: 10px;
}

#app-shell .icon-menu-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ml-border-strong);
  background: #ffffff;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

#app-shell .icon-menu-button:hover,
#app-shell .icon-menu-button:focus-visible,
#app-shell .icon-menu-button.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

#app-shell .status-badge,
#app-shell .status-pill,
#app-shell .badge,
#app-shell .tag,
#app-shell .score-badge {
  border-radius: 999px;
  font-weight: 800;
}

#app-shell .setup-alert {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

#app-shell .details-dialog,
#app-shell dialog,
#app-shell .confirmation-dialog {
  border-radius: 16px;
}

#app-shell .payment-entry-dialog,
#app-shell .collection-contact-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
}

#app-shell .payment-entry-form,
#app-shell .collection-contact-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  overflow-x: hidden;
}

#app-shell .modal-section-title {
  grid-column: 1 / -1;
  margin: 0;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

#app-shell .payment-entry-form .payment-readonly-grid,
#app-shell .payment-entry-form .payment-edit-grid,
#app-shell .collection-contact-form .payment-readonly-grid,
#app-shell .collection-contact-form .payment-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: #f8fafc;
}

#app-shell .payment-entry-form .payment-readonly-grid > div,
#app-shell .collection-contact-form .payment-readonly-grid > div,
#app-shell .payment-entry-form .payment-confirmation-summary > div {
  min-width: 0;
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  background: #ffffff;
}

#app-shell .payment-entry-form .payment-readonly-grid span,
#app-shell .collection-contact-form .payment-readonly-grid span,
#app-shell .payment-entry-form .payment-confirmation-summary span {
  display: block;
  color: var(--ml-muted);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.15;
  text-transform: uppercase;
}

#app-shell .payment-entry-form .payment-readonly-grid strong,
#app-shell .collection-contact-form .payment-readonly-grid strong,
#app-shell .payment-entry-form .payment-confirmation-summary strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ml-text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell .payment-entry-form .payment-edit-grid label,
#app-shell .collection-contact-form .payment-edit-grid label {
  min-width: 0;
  gap: 4px;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-transform: uppercase;
}

#app-shell .payment-entry-form input,
#app-shell .payment-entry-form select,
#app-shell .collection-contact-form input,
#app-shell .collection-contact-form select {
  min-height: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 500;
}

#app-shell .payment-entry-form textarea,
#app-shell .collection-contact-form textarea {
  min-height: 72px;
  padding: 9px 10px;
  font-size: 0.84rem;
  line-height: 1.35;
}

#app-shell .payment-entry-form .wide-field,
#app-shell .collection-contact-form .wide-field,
#app-shell .payment-entry-form .payment-card-fields,
#app-shell .payment-entry-form .payment-waiver-controls {
  grid-column: 1 / -1;
}

#app-shell .payment-entry-form .payment-card-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

#app-shell .payment-entry-form .payment-waiver-controls {
  display: grid;
  grid-template-columns: repeat(2, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 8px 14px;
  padding: 10px;
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  background: #ffffff;
}

#app-shell .payment-entry-form .payment-waiver-controls .modal-section-title,
#app-shell .payment-entry-form .payment-waiver-controls .field-hint {
  grid-column: 1 / -1;
}

#app-shell .payment-entry-form .inline-option {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  width: max-content;
  gap: 6px;
  text-transform: none;
}

#app-shell .payment-entry-form .payment-confirmation {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #bfdbfe;
  border-radius: var(--ml-radius);
  background: #eff6ff;
}

#app-shell .payment-entry-form .payment-confirmation.is-hidden {
  display: none !important;
}

#app-shell .payment-entry-form .payment-confirmation-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

#app-shell .payment-entry-form .payment-actions,
#app-shell .collection-contact-form .payment-actions,
#app-shell .payment-entry-form .payment-confirmation .confirmation-actions {
  position: sticky;
  bottom: -14px;
  z-index: 2;
  margin: 0 -16px -14px;
  padding: 10px 16px;
  border-top: 1px solid var(--ml-border);
  background: #ffffff;
  justify-content: flex-end;
}

#app-shell .collection-contact-form .payment-readonly-grid > div:nth-child(1),
#app-shell .collection-contact-form .payment-edit-grid label.wide-field {
  grid-column: span 2;
}

#app-shell .users-table .user-name-cell,
#app-shell .users-table .col-email,
#app-shell .users-table .col-company,
#app-shell .users-table .col-role,
#app-shell .users-table .col-access {
  color: var(--ml-text);
  font-weight: 500;
}

#app-shell .users-table th,
#app-shell .users-table td,
#app-shell .history-table th,
#app-shell .history-table td {
  height: 34px;
  padding: 5px 7px;
  font-size: 0.74rem;
  line-height: 1.18;
}

#app-shell .users-table th,
#app-shell .history-table th {
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
}

#app-shell .users-table .status-pill {
  min-height: 22px;
  padding: 3px 8px;
  font-size: 0.68rem;
}

#app-shell .user-form-block,
#app-shell .user-permissions-panel {
  padding: 12px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: #f8fafc;
}

#app-shell .history-table-wrap {
  overflow-x: hidden;
}

#app-shell .history-table-wrap table {
  min-width: 0;
  width: calc(100% - 12px);
  max-width: 100%;
  table-layout: fixed;
}

#app-shell .history-table .client-name,
#app-shell .history-table .audit-date-cell span:first-child,
#app-shell .history-table .audit-description-cell {
  color: var(--ml-text);
  font-weight: 500;
}

#app-shell .history-table .row-muted {
  margin-top: 2px;
  color: var(--ml-muted);
  font-size: 0.66rem;
}

#app-shell .history-table .status-pill.audit-action {
  max-width: 100%;
  min-height: 22px;
  padding: 3px 7px;
  overflow: hidden;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell .audit-detail-button,
#app-shell .user-card-actions-btn {
  margin-left: auto;
}

@media (max-width: 920px) {
  #app-shell .payment-entry-form .payment-readonly-grid,
  #app-shell .payment-entry-form .payment-edit-grid,
  #app-shell .collection-contact-form .payment-readonly-grid,
  #app-shell .collection-contact-form .payment-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #app-shell .payment-entry-form .payment-confirmation-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #app-shell.app-shell {
    grid-template-columns: 1fr;
  }

  #app-shell .sidebar-toggle.desktop-only {
    display: none;
  }

  #app-shell .content {
    padding: 0 14px 18px;
  }

  #app-shell .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 -14px 12px;
    padding: 10px 14px;
    background: rgba(244, 246, 250, 0.96);
    backdrop-filter: blur(16px);
  }

  #app-shell .dashboard-group,
  #app-shell .panel,
  #app-shell .metric,
  #app-shell .decision-engine-card {
    border-radius: 10px;
  }

  #app-shell .metric-grid,
  #app-shell .decision-engine-grid,
  #app-shell .collection-metrics,
  #app-shell .sale-mini-metrics {
    grid-template-columns: 1fr;
  }

  #app-shell #dashboard.dashboard-groups {
    gap: 12px;
  }

  #app-shell #dashboard .dashboard-group {
    gap: 12px;
    padding: 14px;
  }

  #app-shell #dashboard .metric-grid,
  #app-shell #dashboard .decision-engine-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #app-shell #dashboard .metric,
  #app-shell #dashboard .decision-engine-card {
    min-height: auto;
    padding: 13px;
  }

  #app-shell .panel-heading,
  #app-shell .customers-panel-heading {
    align-items: stretch;
    gap: 10px;
    padding-bottom: 12px;
  }

  #app-shell .panel-actions,
  #app-shell .customers-panel-actions,
  #app-shell .sale-actions,
  #app-shell .admin-form-actions,
  #app-shell .panel-heading-actions,
  #app-shell .company-toolbar,
  #app-shell .user-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  #app-shell .primary-action,
  #app-shell .secondary-action {
    width: 100%;
    justify-content: center;
  }

  #app-shell .panel {
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
  }

  #app-shell .form-grid,
  #app-shell .compact-grid,
  #app-shell .filters,
  #app-shell .customer-filters,
  #app-shell .receivables-filters,
  #app-shell .history-filters,
  #app-shell .credit-leads-filters,
  #app-shell .client-requests-filters {
    grid-template-columns: 1fr;
  }

  #app-shell .customers-list-panel,
  #app-shell .customer-form-content,
  #app-shell .sale-form-shell,
  #app-shell .sale-form-compact,
  #app-shell .sale-summary-card,
  #app-shell .sale-guidance,
  #app-shell .credit-policy-admin,
  #app-shell .integration-card,
  #app-shell .integration-section,
  #app-shell .user-form-block,
  #app-shell .user-permissions-panel,
  #app-shell .customer-history-summary,
  #app-shell .credit-accordion {
    padding: 12px;
    border-radius: 10px;
  }

  #app-shell .receivables-cards,
  #app-shell .customers-cards,
  #app-shell .admin-cards,
  #app-shell .audit-cards,
  #app-shell .companies-cards,
  #app-shell .client-requests-cards {
    grid-template-columns: 1fr;
  }

  #app-shell #clientes .customers-table-wrap {
    display: none;
  }

  #app-shell #clientes .customers-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #app-shell #clientes .customer-card {
    display: grid;
    gap: 10px;
  }

  #app-shell #clientes .customer-card-footer {
    display: grid;
    gap: 4px;
    align-items: start;
  }

  #app-shell .filters,
  #app-shell .customer-filters,
  #app-shell .receivables-filters,
  #app-shell .history-filters,
  #app-shell .sales-filters,
  #app-shell .sellers-filters,
  #app-shell .intelligence-filters,
  #app-shell .collection-notification-filters,
  #app-shell .credit-leads-filters,
  #app-shell .client-requests-filters {
    padding: 12px;
  }

  #app-shell .sale-summary-grid,
  #app-shell .final-sale-summary,
  #app-shell .customer-history-summary-grid,
  #app-shell .receivable-card-grid {
    grid-template-columns: 1fr;
  }

  #app-shell .pagination-bar,
  #app-shell .customers-pagination {
    align-items: stretch;
  }

  #app-shell .pagination-actions,
  #app-shell .pagination-bar > div {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }
}

@media (max-width: 640px) {
  #app-shell .payment-entry-dialog,
  #app-shell .collection-contact-dialog {
    width: 100vw;
    max-width: 100vw;
    min-height: 100svh;
    max-height: 100svh;
    border-radius: 0;
  }

  #app-shell .payment-entry-form,
  #app-shell .collection-contact-form {
    padding: 12px;
  }

  #app-shell .payment-entry-form .payment-readonly-grid,
  #app-shell .payment-entry-form .payment-edit-grid,
  #app-shell .collection-contact-form .payment-readonly-grid,
  #app-shell .collection-contact-form .payment-edit-grid,
  #app-shell .payment-entry-form .payment-confirmation-summary,
  #app-shell .payment-entry-form .payment-card-fields,
  #app-shell .payment-entry-form .payment-waiver-controls {
    grid-template-columns: 1fr;
  }

  #app-shell .collection-contact-form .payment-readonly-grid > div:nth-child(1),
  #app-shell .collection-contact-form .payment-edit-grid label.wide-field {
    grid-column: auto;
  }

  #app-shell .payment-entry-form .payment-actions,
  #app-shell .collection-contact-form .payment-actions,
  #app-shell .payment-entry-form .payment-confirmation .confirmation-actions {
    bottom: -12px;
    margin: 0 -12px -12px;
    padding: 10px 12px;
  }

  #app-shell .payment-entry-form .payment-actions button,
  #app-shell .collection-contact-form .payment-actions button,
  #app-shell .payment-entry-form .payment-confirmation .confirmation-actions button {
    flex: 1 1 0;
  }

  .login-screen {
    width: 100%;
    max-width: 100vw;
    grid-template-columns: 1fr;
    padding: 22px;
    overflow-x: hidden;
  }

  .login-brand {
    width: calc(100vw - 44px);
    max-width: calc(100vw - 44px);
    gap: 24px;
  }

  .login-brand > div,
  .login-brand h1,
  .login-copy {
    width: 100%;
    max-width: 100%;
  }

  .login-brand h1 {
    overflow-wrap: break-word;
  }

  .login-card {
    width: calc(100vw - 44px);
    max-width: calc(100vw - 44px);
    padding: 20px;
  }

  #app-shell .dashboard-group {
    padding: 12px;
  }

  #app-shell #dashboard .group-heading h2 {
    font-size: 1rem;
  }

  #app-shell #dashboard .metric strong {
    font-size: 1.28rem;
  }

  #app-shell .topbar h1,
  #app-shell #page-title {
    font-size: 1.05rem;
  }
}

@media print {
  #app-shell .sidebar,
  #app-shell .topbar,
  #app-shell .panel-actions,
  #app-shell .customers-panel-actions,
  #app-shell .primary-action,
  #app-shell .secondary-action,
  #app-shell .icon-button,
  #app-shell .row-actions-menu {
    display: none !important;
  }

  #app-shell.app-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  #app-shell .content,
  #app-shell .panel,
  #app-shell .dashboard-group {
    padding: 0;
    background: #ffffff;
    box-shadow: none;
  }
}

/* Operational sale form layout. Keep this after the theme rules so the Nova venda
   screen is not flattened by the generic Metas card/grid styles above. */
#app-shell #vendas .sale-form-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

#app-shell #vendas .sale-heading-customer {
  min-width: 0;
  width: min(390px, 100%);
}

#app-shell #vendas .sale-form-compact {
  display: grid;
  gap: 12px;
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#app-shell #vendas .sale-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

#app-shell #vendas .sale-step-card {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--ml-shadow);
}

#app-shell #vendas .sale-step-summary-panel {
  position: sticky;
  top: 14px;
  align-self: start;
}

#app-shell #vendas .sale-grid-row1 {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(140px, 180px) minmax(170px, 220px) minmax(240px, 1fr);
  gap: 12px;
  align-items: end;
}

#app-shell #vendas .sale-grid-row2 {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
}

#app-shell #vendas .sale-form-compact label {
  gap: 6px;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
}

#app-shell #vendas .sale-form-compact input,
#app-shell #vendas .sale-form-compact select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 12px;
  border-color: #cbd5e1;
  border-radius: 11px;
  background: #ffffff;
}

#app-shell #vendas .sale-form-compact input:focus,
#app-shell #vendas .sale-form-compact select:focus {
  border-color: var(--ml-accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.12);
  outline: none;
}

#app-shell #vendas .sale-mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#app-shell #vendas .sale-mini-metric {
  min-width: 0;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #f8fafc;
  overflow-wrap: anywhere;
}

#app-shell #vendas .sale-mini-metric span,
#app-shell #vendas .sale-mini-metric small {
  color: var(--ml-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: none;
}

#app-shell #vendas .sale-mini-metric strong {
  color: var(--ml-text);
  font-size: clamp(0.9rem, 1vw, 1rem);
  line-height: 1.15;
}

#app-shell #vendas .sale-summary-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#app-shell #vendas .summary-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

#app-shell #vendas .summary-heading strong {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 0.72rem;
  line-height: 1.1;
  text-align: center;
}

#app-shell #vendas .sale-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#app-shell #vendas .sale-summary-grid div {
  min-width: 0;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
}

#app-shell #vendas .sale-summary-grid span {
  color: var(--ml-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: none;
}

#app-shell #vendas .sale-summary-grid strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ml-text);
  font-size: clamp(0.86rem, 1.05vw, 0.98rem);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #vendas .sale-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

#app-shell #vendas .sale-actions .primary-action,
#app-shell #vendas .sale-actions .secondary-action {
  width: 100%;
  min-height: 46px;
  border-radius: 11px;
  font-weight: 800;
}

#app-shell #vendas .sale-actions .primary-action:disabled {
  border-color: #cbd5e1;
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

@media (max-width: 1180px) {
  #app-shell #vendas .sale-sections {
    grid-template-columns: minmax(0, 1fr);
  }

  #app-shell #vendas .sale-step-summary-panel {
    position: static;
  }

  #app-shell #vendas .sale-grid-row2,
  #app-shell #vendas .sale-mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  #app-shell #vendas .sale-form-heading {
    flex-direction: column;
    gap: 12px;
  }

  #app-shell #vendas .sale-heading-customer {
    width: 100%;
  }

  #app-shell #vendas .sale-grid-row1,
  #app-shell #vendas .sale-grid-row2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #app-shell #vendas .sale-step-card {
    padding: 14px;
  }

  #app-shell #vendas .sale-actions,
  #app-shell #vendas .sale-summary-grid,
  #app-shell #vendas .sale-mini-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .login-screen {
    display: block !important;
    width: 100vw !important;
    max-width: 100vw !important;
    padding: 22px !important;
    overflow-x: hidden !important;
  }

  .login-screen .login-brand,
  .login-screen .login-card {
    width: min(346px, calc(100vw - 44px)) !important;
    max-width: min(346px, calc(100vw - 44px)) !important;
  }

  .login-screen .login-brand {
    margin-bottom: 80px;
  }

  .login-screen .login-brand h1 {
    max-width: min(346px, calc(100vw - 44px)) !important;
    font-size: clamp(1.75rem, 8vw, 2rem);
    line-height: 1.08;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .login-screen .login-copy {
    max-width: min(346px, calc(100vw - 44px)) !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
}
