/* Paleta global de temas. O visual claro existente permanece como padrão. */
:root {
  color-scheme: light;
  --theme-page: #f3f6f2;
  --theme-page-top: #f8fbf8;
  --theme-surface: #fff;
  --theme-surface-soft: #f5f7f3;
  --theme-surface-hover: #e9eee9;
  --theme-input: #fff;
  --theme-text: #252b27;
  --theme-text-soft: #687168;
  --theme-border: #dfe3da;
  --theme-shadow: 0 12px 36px rgba(38, 76, 61, .10);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-page: #0d1511;
  --theme-page-top: #121d17;
  --theme-surface: #16221c;
  --theme-surface-soft: #1d3026;
  --theme-surface-hover: #243a2e;
  --theme-input: #101b15;
  --theme-text: #edf5f0;
  --theme-text-soft: #afbeb4;
  --theme-border: #344a3e;
  --theme-shadow: 0 16px 42px rgba(0, 0, 0, .34);
  --ink: var(--theme-text);
  --muted: var(--theme-text-soft);
  --line: var(--theme-border);
  --white: var(--theme-surface);
  --blue-950: #dff3e6;
  --blue-800: #b7dfc6;
  --blue-700: #75bd92;
  --blue-600: #83c89f;
  --blue-100: #243c30;
  --blue-50: #1b2d24;
  --danger: #ff9a94;
  --danger-bg: #3a2021;
  --shadow: var(--theme-shadow);
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--theme-page);
  color: var(--theme-text);
}

html[data-theme="dark"] body {
  background-image: linear-gradient(180deg, var(--theme-page-top), var(--theme-page));
}

html[data-theme="dark"] .topbar {
  background: linear-gradient(135deg, #0b1711, #263e31);
  box-shadow: 0 5px 22px rgba(0, 0, 0, .4);
}

.theme-toggle {
  min-width: 42px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 750;
  cursor: pointer;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, .18);
}

.theme-toggle:focus-visible {
  outline-color: #fff;
}

.theme-toggle-icon {
  width: 1.15em;
  font-size: 1.12rem;
  line-height: 1;
  text-align: center;
}

.topbar-content > .brand + .user-actions {
  margin-left: auto;
}

html[data-theme="dark"] .footer,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .integration-card,
html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .wake-day,
html[data-theme="dark"] .seller-nav,
html[data-theme="dark"] .seller-customer-card,
html[data-theme="dark"] .seller-plan,
html[data-theme="dark"] .client-shortcuts a,
html[data-theme="dark"] .document-preview-popover,
html[data-theme="dark"] .receipt-sheet {
  border-color: var(--theme-border);
  background: var(--theme-surface);
  color: var(--theme-text);
  box-shadow: var(--theme-shadow);
}

html[data-theme="dark"] .module-card:hover,
html[data-theme="dark"] .seller-customer-card:hover,
html[data-theme="dark"] .client-shortcuts a:hover {
  border-color: #659a78;
}

html[data-theme="dark"] .footer,
html[data-theme="dark"] .footer a {
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .page-content a:not(.button):not(.module-card):not(.alert-row):not(.seller-customer-card):not(.wake-event) {
  color: #8ed0a8;
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  border-color: #425a4d;
  background: var(--theme-input);
  color: var(--theme-text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #84968b;
  opacity: 1;
}

html[data-theme="dark"] option {
  background: var(--theme-input);
  color: var(--theme-text);
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--theme-text);
  box-shadow: 0 0 0 1000px var(--theme-input) inset;
}

html[data-theme="dark"] .button-primary {
  background: #67aa82;
  color: #07120c;
  box-shadow: 0 7px 20px rgba(0, 0, 0, .28);
}

html[data-theme="dark"] .button-primary:hover {
  background: #83c89f;
  color: #07120c;
}

html[data-theme="dark"] .button-secondary {
  background: #263d31;
  color: #cce8d6;
}

html[data-theme="dark"] .button-secondary:hover {
  background: #304d3d;
}

html[data-theme="dark"] .button-danger {
  border-color: #75403f;
  background: #3a2021;
  color: #ffaaa4;
}

html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .card-link,
html[data-theme="dark"] .table-name,
html[data-theme="dark"] .back-link,
html[data-theme="dark"] .panel-heading a,
html[data-theme="dark"] .calendar-day a,
html[data-theme="dark"] .wake-day > header > a,
html[data-theme="dark"] .bar-value,
html[data-theme="dark"] .metric strong,
html[data-theme="dark"] .plan-price strong,
html[data-theme="dark"] .due-identification > strong,
html[data-theme="dark"] .client-shortcuts a,
html[data-theme="dark"] .seller-nav a {
  color: #9ad6b1;
}

html[data-theme="dark"] .module-icon,
html[data-theme="dark"] .avatar,
html[data-theme="dark"] .ranking-position,
html[data-theme="dark"] .badge,
html[data-theme="dark"] .plan-options span,
html[data-theme="dark"] pre,
html[data-theme="dark"] .service-tag,
html[data-theme="dark"] .receipt-amount,
html[data-theme="dark"] .wake-day > header {
  border-color: var(--theme-border);
  background: var(--theme-surface-soft);
  color: #b9dfc7;
}

html[data-theme="dark"] .alert {
  border-color: #3b5949;
  background: #20382b;
  color: #d5eadc;
}

html[data-theme="dark"] .alert-error {
  border-color: #75403f;
  background: #3a2021;
  color: #ffb1ab;
}

html[data-theme="dark"] .status-active {
  background: #173b29;
  color: #91ddb0;
}

html[data-theme="dark"] .status-muted {
  background: #29342e;
  color: #b4c0b8;
}

html[data-theme="dark"] .status-warning {
  background: #443817;
  color: #f0cf73;
}

html[data-theme="dark"] .status-danger {
  background: #3a2021;
  color: #ffaaa4;
}

html[data-theme="dark"] .deadline-warning {
  --deadline-color: #f1b35a;
}

html[data-theme="dark"] .deadline-attention {
  --deadline-color: #e0ca68;
}

html[data-theme="dark"] .deadline-regular {
  --deadline-color: #75bd92;
}

html[data-theme="dark"] th,
html[data-theme="dark"] td,
html[data-theme="dark"] .form-actions,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .indicator-list > span,
html[data-theme="dark"] .seller-list > a,
html[data-theme="dark"] .seller-list > div,
html[data-theme="dark"] .ranking-list a,
html[data-theme="dark"] .plan-price,
html[data-theme="dark"] .receipt-details div,
html[data-theme="dark"] .bar-chart,
html[data-theme="dark"] .line-chart {
  border-color: var(--theme-border);
}

html[data-theme="dark"] tbody tr:hover {
  background: rgba(117, 189, 146, .055);
}

html[data-theme="dark"] .alert-row:hover,
html[data-theme="dark"] .ranking-list a:hover,
html[data-theme="dark"] .seller-nav a:hover {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .calendar-day-outside {
  background: #111a15;
  color: #738278;
}

html[data-theme="dark"] .calendar-day-holiday,
html[data-theme="dark"] .wake-event-in_progress,
html[data-theme="dark"] .integration-summary-warning {
  background: #342d18;
  color: #eadca8;
}

html[data-theme="dark"] .wake-event {
  background: #193126;
  color: var(--theme-text);
}

html[data-theme="dark"] .seller-metrics .metric-highlight,
html[data-theme="dark"] .benefit-discount {
  border-color: #695b31;
  background: #332d1d;
  color: #efd98e;
}

html[data-theme="dark"] .seller-metrics .metric-highlight strong {
  color: #efd98e;
}

html[data-theme="dark"] .seller-hero {
  background: linear-gradient(120deg, #101e17, #324f3f);
}

html[data-theme="dark"] .nav-submenu,
html[data-theme="dark"] .nav-flyout {
  border-color: var(--theme-border);
  background: #18251f;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .42);
}

html[data-theme="dark"] .nav-submenu a,
html[data-theme="dark"] .nav-subgroup > summary {
  color: var(--theme-text);
}

html[data-theme="dark"] .nav-submenu a:hover,
html[data-theme="dark"] .nav-subgroup > summary:hover,
html[data-theme="dark"] .nav-subgroup[open] > summary {
  background: var(--theme-surface-hover);
  color: #a7dfba;
}

html[data-theme="dark"] .prose-card p {
  color: #c5d1c9;
}

html[data-theme="dark"] .progress {
  background: #2a3931;
}

html[data-theme="dark"] .document-preview-media,
html[data-theme="dark"] #title-preview {
  border-color: var(--theme-border) !important;
  background: #d8ded9 !important;
}

html[data-theme="dark"] .receipt-page {
  background: #0a100d;
}

html[data-theme="dark"] .signature-line {
  border-color: #aebbb2;
}

html[data-theme="dark"] ::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #101913;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  border: 2px solid #101913;
  border-radius: 10px;
  background: #40594b;
}

@media (max-width: 1024px) {
  .theme-toggle-label {
    display: none;
  }

  html[data-theme="dark"] .main-nav {
    background: rgba(10, 25, 17, .98);
  }

  .topbar-content > .user-actions {
    grid-column: 3;
    grid-row: 1;
    margin-left: 0;
  }

  .topbar-content > .main-nav {
    grid-row: 2;
  }
}

@media (max-width: 480px) {
  .theme-toggle {
    min-width: 38px;
    width: 38px;
    padding-inline: 7px;
  }
}

@media print {
  html[data-theme="dark"],
  html[data-theme="dark"] body,
  html[data-theme="dark"] .receipt-page,
  html[data-theme="dark"] .receipt-sheet {
    color-scheme: light;
    background: #fff;
    color: #252b27;
    box-shadow: none;
  }

  html[data-theme="dark"] .receipt-header h1,
  html[data-theme="dark"] .receipt-amount strong {
    color: #18372d;
  }

  html[data-theme="dark"] .receipt-header p,
  html[data-theme="dark"] .receipt-number span,
  html[data-theme="dark"] .receipt-details dt {
    color: #687168;
  }

  html[data-theme="dark"] .receipt-amount {
    border-color: #dfe3da;
    background: #f5f7f3;
    color: #252b27;
  }

  html[data-theme="dark"] .receipt-details div,
  html[data-theme="dark"] .signature-line {
    border-color: #333;
  }
}

/* Controles de leitura e contraste para consultas longas. */
html {
  scroll-behavior: smooth;
}

body {
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 10px 14px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .15s ease;
}

.skip-link:focus {
  color: #fff;
  transform: translateY(0);
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid #d69f24;
  outline-offset: 3px;
}

.reading-tools {
  position: relative;
  flex: none;
}

.reading-tools-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}

.reading-tools-toggle:hover,
.reading-tools-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, .22);
}

.reading-tools-icon {
  font-size: 1rem;
  letter-spacing: -.08em;
}

.reading-tools-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 100;
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid var(--theme-border);
  border-radius: 14px;
  background: var(--theme-surface);
  color: var(--theme-text);
  box-shadow: 0 18px 48px rgba(15, 30, 22, .28);
}

.reading-tools-heading,
.reading-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reading-tools-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--theme-border);
}

.reading-tools-heading > button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--theme-surface-soft);
  color: var(--theme-text);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.reading-setting {
  padding: 14px 0;
  border-bottom: 1px solid var(--theme-border);
}

.reading-setting-label,
.reading-setting-row strong {
  display: block;
  margin-bottom: 8px;
  font-size: .84rem;
  font-weight: 800;
}

.reading-setting-row strong {
  margin-bottom: 1px;
}

.reading-setting-row small {
  display: block;
  color: var(--theme-text-soft);
  font-size: .72rem;
}

.reading-choice,
.reading-size-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.reading-choice button,
.reading-size-controls button,
.reading-reset {
  min-height: 40px;
  border: 1px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-surface-soft);
  color: var(--theme-text);
  font: inherit;
  font-size: .8rem;
  font-weight: 750;
  cursor: pointer;
}

.reading-choice button[aria-pressed="true"] {
  border-color: var(--blue-700);
  background: var(--blue-100);
  color: var(--blue-950);
  box-shadow: inset 0 0 0 1px var(--blue-700);
}

.reading-size-controls {
  grid-template-columns: 1fr 72px 1fr;
}

.reading-size-controls output {
  display: grid;
  place-items: center;
  color: var(--theme-text-soft);
  font-size: .8rem;
  font-weight: 800;
}

.reading-size-controls button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.reading-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--theme-border);
  border-radius: 99px;
  background: var(--theme-surface-soft);
  cursor: pointer;
}

.reading-switch > span:first-child {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--theme-text-soft);
  transition: transform .16s ease, background .16s ease;
}

.reading-switch[aria-pressed="true"] {
  border-color: var(--blue-700);
  background: var(--blue-700);
}

.reading-switch[aria-pressed="true"] > span:first-child {
  background: #fff;
  transform: translateX(18px);
}

.reading-reset {
  width: 100%;
  margin-top: 14px;
  background: transparent;
  color: var(--blue-700);
}

/* Mais separação visual em telas de consulta, sem depender apenas de cor. */
.search-form {
  padding: 12px;
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  background: var(--theme-surface-soft);
}

.table-wrap {
  scrollbar-color: var(--theme-text-soft) var(--theme-surface-soft);
}

.table-wrap th {
  background: var(--theme-surface-soft);
  color: var(--theme-text-soft);
}

.table-wrap tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--theme-surface-soft) 62%, transparent);
}

.table-wrap tbody tr:hover {
  background: var(--theme-surface-hover);
}

.table-wrap td,
.table-wrap th {
  line-height: 1.45;
}

.table-wrap td small {
  color: var(--theme-text-soft);
}

/* Alto contraste: preto/branco, links destacados e contornos explícitos. */
html[data-contrast="high"] {
  --theme-page: #fff;
  --theme-page-top: #fff;
  --theme-surface: #fff;
  --theme-surface-soft: #f1f1f1;
  --theme-surface-hover: #fff1a8;
  --theme-input: #fff;
  --theme-text: #000;
  --theme-text-soft: #222;
  --theme-border: #000;
  --theme-shadow: 0 0 0 2px #000;
  --ink: #000;
  --muted: #222;
  --line: #000;
  --white: #fff;
  --blue-950: #001f4d;
  --blue-800: #003475;
  --blue-700: #004a9f;
  --blue-600: #005bbb;
  --blue-100: #dcecff;
  --blue-50: #f1f7ff;
  --danger: #8b0000;
  --danger-bg: #fff0f0;
  --shadow: var(--theme-shadow);
}

html[data-theme="dark"][data-contrast="high"] {
  --theme-page: #000;
  --theme-page-top: #000;
  --theme-surface: #000;
  --theme-surface-soft: #151515;
  --theme-surface-hover: #2c2c00;
  --theme-input: #000;
  --theme-text: #fff;
  --theme-text-soft: #eee;
  --theme-border: #fff;
  --theme-shadow: 0 0 0 2px #fff;
  --ink: #fff;
  --muted: #eee;
  --line: #fff;
  --white: #000;
  --blue-950: #fff;
  --blue-800: #b9dcff;
  --blue-700: #8cc5ff;
  --blue-600: #70b7ff;
  --blue-100: #002b55;
  --blue-50: #001b35;
  --danger: #ffb3b3;
  --danger-bg: #3d0000;
}

html[data-contrast="high"] body,
html[data-contrast="high"] .topbar,
html[data-contrast="high"] .seller-hero {
  background-image: none;
}

html[data-contrast="high"] .topbar {
  border-bottom: 2px solid currentColor;
  background: #000;
}

html[data-contrast="high"] :where(.panel, .auth-card, .module-card, .metric, .integration-card, .calendar-day, .wake-day, .seller-nav, .seller-customer-card, .seller-plan, .client-shortcuts a, .document-preview-popover) {
  border-color: var(--theme-border);
  background: var(--theme-surface);
  color: var(--theme-text);
  box-shadow: var(--theme-shadow);
}

html[data-contrast="high"] .page-content a:not(.button):not(.module-card) {
  color: var(--blue-700);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

html[data-theme="dark"][data-contrast="high"] .page-content a:not(.button):not(.module-card) {
  color: #8cc5ff;
}

html[data-contrast="high"] :where(input, select, textarea, button, .button, .status, .badge) {
  border-color: var(--theme-border);
}

html[data-contrast="high"] :where(.status-active, .status-muted, .status-warning) {
  border: 2px solid currentColor;
}

html[data-contrast="high"] :where(a, button, input, select, textarea, summary):focus-visible {
  outline-color: #ffb800;
  outline-width: 4px;
}

@media (max-width: 1024px) {
  .reading-tools-label {
    display: none;
  }

  .reading-tools-toggle {
    width: 42px;
    padding-inline: 7px;
  }
}

@media (max-width: 480px) {
  .reading-tools-panel {
    position: fixed;
    top: 72px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  html {
    font-size: 100% !important;
  }

  .skip-link,
  .reading-tools {
    display: none !important;
  }
}
