/*
 * Chasque UI: Material 3 layout and component structure, skinned by the
 * brandbook. Tokens come from m3-tokens.css (generated from the brandbook).
 *
 * Brand rules this file enforces:
 *   - bordas, não sombras (shadow-float só em menus, sheets, dialogs e toasts)
 *   - radius-sm 4 (badges, inputs), radius-md 8 (botões, código), radius-lg 16 (cards)
 *   - status sempre com palavra + cor (badge em JetBrains Mono, caixa alta, com ponto)
 *   - foco: 2px da cor da página + 2px de brasa (outline com offset)
 *   - ícones Lucide, traço 1.5px, na cor do texto ao lado
 *   - código sempre sobre noite, nos dois temas
 *
 * Window size classes (shared with apps/dashboard/src/app.css; plain CSS has
 * no custom media queries, keep the literals identical):
 *   compact   <  600px   (max-width: 599px)   top app bar + navigation bar
 *   medium    600–839px  (min-width: 600px)   collapsed navigation rail
 *   expanded  840–1199px (min-width: 840px)   collapsed rail, list-detail panes
 *   large     ≥ 1200px   (min-width: 1200px)  expanded navigation rail
 */

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--chq-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--chq-brasa);
  outline-offset: 2px;
}

/* The `hidden` attribute must beat component display values (cards and banners are flex). */
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: hidden has to win over any component class */
  display: none !important;
}

/* Lucide icons: 1.5px stroke, sized by context, colored like the text next to them. */
.md-icon {
  flex-shrink: 0;
  width: var(--md-icon-size, 20px);
  height: var(--md-icon-size, 20px);
}

/* ---------- Typography helpers ---------- */

.md-display {
  font-family: var(--md-sys-typescale-display-large-font);
  font-size: var(--md-sys-typescale-display-large-size);
  line-height: var(--md-sys-typescale-display-large-line-height);
  font-weight: var(--md-sys-typescale-display-large-weight);
  letter-spacing: var(--md-sys-typescale-display-large-tracking);
  margin: 0;
}

.md-headline-large {
  font-family: var(--md-sys-typescale-headline-large-font);
  font-size: var(--md-sys-typescale-headline-large-size);
  line-height: var(--md-sys-typescale-headline-large-line-height);
  font-weight: var(--md-sys-typescale-headline-large-weight);
  letter-spacing: var(--md-sys-typescale-headline-large-tracking);
  margin: 0;
}

.md-headline-small {
  font-family: var(--md-sys-typescale-headline-small-font);
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line-height);
  font-weight: var(--md-sys-typescale-headline-small-weight);
  margin: 0;
}

.md-title-large {
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  font-weight: var(--md-sys-typescale-title-large-weight);
  margin: 0;
}

.md-title-medium {
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  margin: 0;
}

.md-body-small,
.md-supporting {
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  color: var(--md-sys-color-on-surface-variant);
}

.md-label-large {
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
}

/* Eyebrow / method / status label: JetBrains Mono, caixa alta. */
.md-code-label {
  font-family: var(--md-sys-typescale-code-label-font);
  font-size: var(--md-sys-typescale-code-label-size);
  line-height: var(--md-sys-typescale-code-label-line-height);
  font-weight: var(--md-sys-typescale-code-label-weight);
  letter-spacing: var(--md-sys-typescale-code-label-tracking);
  text-transform: uppercase;
}

.mono {
  font-family: var(--md-ref-typeface-mono);
  font-size: 0.93em;
}

/* ---------- Logo (ferradura-mensageira) ---------- */

.chq-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 1;
  color: inherit;
  text-decoration: none;
}

.chq-logo svg {
  display: block;
  height: var(--chq-logo-size, 32px);
  width: auto;
  overflow: visible;
}

/* O símbolo usa currentColor (traço e pontos); a palavra, fill. */
.chq-logo .chq-mark {
  color: var(--chq-brasa);
}

.chq-logo .chq-word {
  fill: var(--md-sys-color-on-surface);
}

.chq-logo--branco .chq-mark {
  color: var(--chq-on-noite);
}

.chq-logo--branco .chq-word {
  fill: var(--chq-on-noite);
}

.chq-logo--noite .chq-mark {
  color: var(--md-sys-color-on-surface);
}

.chq-logo--noite .chq-word {
  fill: var(--md-sys-color-on-surface);
}

/* Enviando/carregando: os três pontos acendem em sequência, 200 ms de intervalo. */
.chq-logo-sending .chq-mark circle {
  animation: chq-sending 600ms steps(1, end) infinite;
}

.chq-logo-sending .chq-mark circle:nth-of-type(2) {
  animation-delay: 200ms;
}

.chq-logo-sending .chq-mark circle:nth-of-type(3) {
  animation-delay: 400ms;
}

@keyframes chq-sending {
  0% {
    opacity: 1;
  }
  34% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chq-logo-sending .chq-mark circle {
    animation: none;
  }
}

/* Ícone de app: ferradura branca no balão brasa de canto vivo. */
.chq-app-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--chq-app-icon-size, 40px);
  height: var(--chq-app-icon-size, 40px);
  border-radius: 25% 25% 25% 0;
  background: var(--chq-brasa);
  color: var(--chq-on-brasa);
  text-decoration: none;
}

.chq-app-icon svg {
  display: block;
  width: 62%;
  height: 62%;
  color: currentColor;
}

/* ---------- Loader: os três cravos acendendo em sequência ---------- */

.md-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
}

.md-dots span {
  width: 8px;
  height: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--chq-brasa);
  opacity: 0.25;
  animation: md-dots 600ms steps(1, end) infinite;
}

.md-dots span:nth-child(2) {
  animation-delay: 200ms;
}

.md-dots span:nth-child(3) {
  animation-delay: 400ms;
}

@keyframes md-dots {
  0% {
    opacity: 1;
  }
  34% {
    opacity: 0.25;
  }
}

/* ---------- Buttons ---------- */

.md-button {
  --_bg: transparent;
  --_fg: var(--chq-brasa);
  --_border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid var(--_border);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--_bg);
  color: var(--_fg);
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
    color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-button .md-icon {
  --md-icon-size: 18px;
  margin-inline-start: -4px;
}

/* Primária: uma por tela, em brasa. */
.md-button--filled {
  --_bg: var(--chq-brasa);
  --_fg: var(--chq-on-brasa);
}

.md-button--filled:hover {
  --_bg: var(--md-sys-color-on-surface);
  --_fg: var(--md-sys-color-surface);
}

/* Secundária: superfície elevada com borda de controle. */
.md-button--tonal,
.md-button--outlined {
  --_bg: var(--md-sys-color-surface-raised);
  --_fg: var(--md-sys-color-on-surface);
  --_border: var(--md-sys-color-outline);
}

.md-button--tonal:hover,
.md-button--outlined:hover {
  --_border: var(--md-sys-color-on-surface);
}

/* Ghost: ações terciárias e links de ação com "→". */
.md-button--text {
  padding: 10px 8px;
}

.md-button--text:hover {
  --_bg: var(--chq-brasa-soft);
}

/* Destrutiva: sempre secundária com o texto explícito, confirmada em diálogo. */
.md-button--danger {
  --_bg: var(--md-sys-color-surface-raised);
  --_fg: var(--chq-alerta);
  --_border: var(--md-sys-color-outline);
}

.md-button--danger:hover {
  --_bg: var(--chq-alerta-soft);
  --_border: var(--chq-alerta);
}

.md-button--text.md-button--danger {
  --_bg: transparent;
  --_border: transparent;
}

.md-button--text.md-button--danger:hover {
  --_bg: var(--chq-alerta-soft);
}

.md-button:disabled,
.md-button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.md-icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--md-sys-shape-corner-small);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard);
}

.md-icon-button:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
  color: var(--md-sys-color-on-surface);
}

/* ---------- Text field ---------- */

.md-text-field {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.md-text-field input,
.md-text-field select,
.md-text-field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 24px;
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-text-field textarea {
  min-height: 112px;
  resize: vertical;
}

.md-text-field select {
  appearance: none;
  padding-inline-end: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 22px,
    calc(100% - 15px) 22px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

.md-text-field select option {
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
}

.md-text-field input:hover,
.md-text-field select:hover,
.md-text-field textarea:hover {
  border-color: var(--md-sys-color-on-surface);
}

.md-text-field input:focus,
.md-text-field select:focus,
.md-text-field textarea:focus {
  border-color: var(--chq-brasa);
  outline: 2px solid var(--chq-brasa);
  outline-offset: 2px;
}

.md-text-field__label {
  position: absolute;
  left: 10px;
  top: 12px;
  padding: 0 4px;
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 24px;
  pointer-events: none;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-text-field select + .md-text-field__label {
  top: -8px;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
}

.md-text-field :is(input, textarea):focus + .md-text-field__label,
.md-text-field :is(input, textarea):not(:placeholder-shown) + .md-text-field__label {
  top: -8px;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
}

.md-text-field :is(input, select, textarea):focus + .md-text-field__label {
  color: var(--chq-brasa);
}

.md-text-field__supporting {
  padding: 4px 14px 0;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  color: var(--md-sys-color-on-surface-variant);
}

/* ---------- Cards ---------- */

.md-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-raised);
  min-width: 0;
}

@media (min-width: 600px) {
  .md-card {
    padding: 20px;
  }
}

.md-card--filled {
  background: var(--md-sys-color-surface);
}

.md-card--elevated {
  background: var(--md-sys-color-surface-raised);
}

/* Card de destaque: o balão, com o canto de onde a mensagem parte. */
.md-card--balao {
  border-radius: var(--chq-radius-balao);
}

.md-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.md-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Table / list ---------- */

.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-raised);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--md-sys-typescale-body-medium-size);
}

.md-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: var(--md-sys-typescale-label-medium-size);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface);
  white-space: nowrap;
}

.md-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  vertical-align: middle;
}

.md-table tr.is-clickable {
  cursor: pointer;
}

.md-table tr.is-selected td {
  background: var(--chq-brasa-soft);
}

.md-table tr.is-clickable:hover:not(.is-selected) td {
  background: var(--md-sys-color-surface);
}

/* Mark low-priority columns: .col-md hides on compact, .col-lg also on medium. */
@media (max-width: 599px) {
  .md-table .col-md {
    display: none;
  }
}

@media (max-width: 839px) {
  .md-table .col-lg {
    display: none;
  }
}

/* With the detail drawer beside it the list loses up to 480px: below 1440px it keeps only its
   main columns (.col-pane marks columns that only make sense without the drawer). Below
   1200px the drawer is modal over the list, which keeps every column. */
@media (min-width: 1200px) and (max-width: 1439px) {
  .has-detail .md-table :is(.col-md, .col-lg, .col-pane) {
    display: none;
  }
}

.md-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.md-list > li {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.md-list > li:first-child {
  border-top: none;
}

/* ---------- Badge (status: palavra + cor) ---------- */

.md-chip {
  --_bg: var(--md-sys-color-surface-raised);
  --_fg: var(--md-sys-color-on-surface-variant);
  --_border: var(--md-sys-color-outline-variant);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--_border);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--_bg);
  color: var(--_fg);
  font-family: var(--md-sys-typescale-code-label-font);
  font-size: var(--md-sys-typescale-code-label-size);
  line-height: var(--md-sys-typescale-code-label-line-height);
  font-weight: var(--md-sys-typescale-code-label-weight);
  letter-spacing: var(--md-sys-typescale-code-label-tracking);
  text-transform: uppercase;
  white-space: nowrap;
}

.md-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--md-sys-shape-corner-full);
  background: currentColor;
}

.md-chip .md-icon {
  --md-icon-size: 14px;
}

.md-chip--success {
  --_bg: var(--chq-erva-soft);
  --_fg: var(--chq-erva);
  --_border: transparent;
}

.md-chip--warning {
  --_bg: var(--chq-ouro-soft);
  --_fg: var(--chq-ouro);
  --_border: transparent;
}

.md-chip--error {
  --_bg: var(--chq-alerta-soft);
  --_fg: var(--chq-alerta);
  --_border: transparent;
}

.md-chip--primary {
  --_bg: var(--chq-brasa-soft);
  --_fg: var(--chq-brasa);
  --_border: transparent;
}

.md-chip--info {
  --_bg: var(--chq-ceu-soft);
  --_fg: var(--chq-ceu);
  --_border: transparent;
}

.md-chip--neutral {
  --_bg: var(--md-sys-color-surface-raised);
  --_fg: var(--md-sys-color-on-surface-variant);
  --_border: var(--md-sys-color-outline-variant);
}

/* ---------- Dialog (native <dialog>) ---------- */

.md-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--chq-shadow-float);
}

.md-dialog--wide {
  width: min(840px, calc(100vw - 32px));
}

.md-dialog::backdrop {
  background: color-mix(in srgb, var(--md-sys-color-scrim) 40%, transparent);
}

.md-dialog[open] {
  animation: md-dialog-in var(--md-sys-motion-duration-short4)
    var(--md-sys-motion-easing-standard-decelerate);
}

@keyframes md-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.md-dialog__content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  overflow: auto;
  max-height: calc(100vh - 48px);
}

.md-dialog__icon {
  color: var(--chq-brasa);
}

.md-dialog__icon .md-icon {
  --md-icon-size: 28px;
}

.md-dialog__headline {
  margin: 0;
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line-height);
  font-weight: var(--md-sys-typescale-headline-small-weight);
}

.md-dialog__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
}

/* A destructive action set apart from Cancel/Save, at the start of the row. */
.md-dialog__action--start {
  margin-right: auto;
}

/* ---------- Snackbar (toast) ---------- */

.md-snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  min-height: 48px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  box-shadow: var(--chq-shadow-float);
  transform: translateX(-50%);
  animation: md-snackbar-in var(--md-sys-motion-duration-short4)
    var(--md-sys-motion-easing-standard-decelerate);
}

.md-snackbar .md-button {
  --_fg: var(--md-sys-color-inverse-primary);
}

.md-snackbar .md-button:hover {
  --_bg: color-mix(in srgb, var(--md-sys-color-inverse-on-surface) 12%, transparent);
}

@keyframes md-snackbar-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

@media (max-width: 599px) {
  .md-snackbar {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

/* ---------- Banner ---------- */

.md-banner {
  --_bg: var(--md-sys-color-surface-raised);
  --_fg: var(--md-sys-color-on-surface);
  --_icon: var(--chq-brasa);
  --_border: var(--md-sys-color-outline-variant);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--_border);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--_bg);
  color: var(--_fg);
}

.md-banner > .md-icon {
  margin-top: 2px;
  color: var(--_icon);
}

.md-banner__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.md-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 -8px;
}

.md-banner--warning {
  --_bg: var(--chq-ouro-soft);
  --_fg: var(--md-sys-color-on-surface);
  --_icon: var(--chq-ouro);
  --_border: transparent;
}

.md-banner--error {
  --_bg: var(--chq-alerta-soft);
  --_fg: var(--md-sys-color-on-surface);
  --_icon: var(--chq-alerta);
  --_border: transparent;
}

.md-banner--info {
  --_bg: var(--chq-ceu-soft);
  --_fg: var(--md-sys-color-on-surface);
  --_icon: var(--chq-ceu);
  --_border: transparent;
}

.md-banner--success {
  --_bg: var(--chq-erva-soft);
  --_fg: var(--md-sys-color-on-surface);
  --_icon: var(--chq-erva);
  --_border: transparent;
}

.md-banner .md-button {
  --_fg: var(--md-sys-color-on-surface);
}

.md-banner .md-button:hover {
  --_bg: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

/* ---------- Linear progress ---------- */

.md-linear-progress {
  position: relative;
  height: 4px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.md-linear-progress__bar {
  height: 100%;
  width: calc(var(--value, 0) * 100%);
  border-radius: inherit;
  background: var(--chq-brasa);
  transition: width var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.md-linear-progress--warning .md-linear-progress__bar {
  background: var(--chq-ouro);
}

.md-linear-progress--error .md-linear-progress__bar {
  background: var(--chq-alerta);
}

/* ---------- Switch ---------- */

.md-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  cursor: pointer;
}

.md-switch input {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  margin: 0;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-raised);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard);
}

.md-switch input::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  transform: translateY(-50%);
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-switch input:checked {
  border-color: var(--chq-brasa);
  background: var(--chq-brasa);
}

.md-switch input:checked::after {
  left: 23px;
  background: var(--chq-on-brasa);
}

/* Disabled: M3's 38%, so an option that can't change doesn't read as a live choice. */
.md-switch:has(input:disabled) {
  cursor: default;
}

.md-switch input:disabled {
  cursor: default;
  opacity: 0.38;
}

/* ---------- Code block (sempre sobre noite) ---------- */

.md-code {
  margin: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--chq-noite);
  color: var(--chq-on-noite);
  overflow: hidden;
}

.md-code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--chq-on-noite) 12%, transparent);
}

.md-code__lang {
  font-family: var(--md-sys-typescale-code-label-font);
  font-size: var(--md-sys-typescale-code-label-size);
  line-height: var(--md-sys-typescale-code-label-line-height);
  font-weight: var(--md-sys-typescale-code-label-weight);
  letter-spacing: var(--md-sys-typescale-code-label-tracking);
  text-transform: uppercase;
  color: var(--chq-on-noite-muted);
}

.md-code__copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--chq-on-noite) 40%, transparent);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: transparent;
  color: var(--chq-on-noite);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.md-code__copy .md-icon {
  --md-icon-size: 14px;
}

.md-code__copy:hover {
  border-color: var(--chq-on-noite);
}

/* Language tabs in the bar: the same example in several languages. */
.md-code__tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  align-self: stretch;
  margin: -6px 8px -6px -16px;
  padding: 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.md-code__tabs::-webkit-scrollbar {
  display: none;
}

.md-code__tab {
  flex: none;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--chq-on-noite-muted);
  font-family: var(--md-sys-typescale-code-label-font);
  font-size: var(--md-sys-typescale-code-label-size);
  line-height: var(--md-sys-typescale-code-label-line-height);
  font-weight: var(--md-sys-typescale-code-label-weight);
  letter-spacing: var(--md-sys-typescale-code-label-tracking);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.md-code__tab:hover {
  color: var(--chq-on-noite);
}

.md-code__tab[aria-selected="true"] {
  color: var(--chq-on-noite);
  border-bottom-color: var(--chq-on-noite);
}

.md-code__tab:focus-visible {
  outline: 2px solid var(--chq-on-noite);
  outline-offset: -2px;
}

.md-code pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--md-sys-typescale-code-font);
  font-size: var(--md-sys-typescale-code-size);
  line-height: var(--md-sys-typescale-code-line-height);
  white-space: pre;
}

code {
  font-family: var(--md-ref-typeface-mono);
  font-size: 0.9em;
  padding: 1px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-container-high);
}

.md-code code {
  padding: 0;
  font-size: inherit;
  background: none;
}

/* ---------- Top app bar (compact only, center-aligned) ---------- */

.md-top-app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(48px, 1fr) minmax(0, auto) minmax(48px, 1fr);
  align-items: center;
  gap: 4px;
  height: 64px;
  padding: 8px 4px;
  border-bottom: 1px solid transparent;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  transition:
    background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.md-top-app-bar.is-scrolled {
  border-bottom-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-raised);
}

.md-top-app-bar__leading,
.md-top-app-bar__trailing {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.md-top-app-bar__leading {
  padding-inline-start: 12px;
}

.md-top-app-bar__trailing {
  justify-content: flex-end;
}

.md-top-app-bar__title {
  min-width: 0;
  margin: 0;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 600px) {
  .md-top-app-bar {
    display: none;
  }
}

/* ---------- Navigation item (shared by rail, bar) ---------- */

.md-nav-item {
  --md-icon-size: 22px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  padding: 0;
  border: none;
  background: none;
  color: var(--md-sys-color-on-surface-variant);
  font: inherit;
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.md-nav-item__indicator {
  position: var(--md-nav-indicator-position, relative);
  display: grid;
  place-items: center;
  width: var(--md-nav-indicator-width, 56px);
  height: var(--md-nav-indicator-height, 32px);
  border-radius: var(--md-sys-shape-corner-small);
  transition: background-color var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard);
}

.md-nav-item:hover .md-nav-item__indicator {
  background: var(--md-nav-indicator-hover, var(--md-sys-color-surface-container-high));
}

.md-nav-item:focus-visible {
  outline: none;
}

.md-nav-item:focus-visible .md-nav-item__indicator {
  outline: 2px solid var(--chq-brasa);
  outline-offset: 2px;
}

.md-nav-item__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Count on a destination (e.g. open contact messages). */
.md-nav-item__badge {
  position: absolute;
  top: -2px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--chq-brasa);
  color: var(--chq-on-brasa);
  font-family: var(--md-ref-typeface-mono);
  font-size: 11px;
  line-height: 18px;
  font-weight: 500;
  text-align: center;
}

/* Collapsed rail and nav bar show the short label; the expanded rail, the full one. */
.md-nav-item__label--full {
  display: none;
}

.md-nav-item.active {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
}

.md-nav-item.active .md-nav-item__indicator {
  background: var(--chq-brasa-soft);
  color: var(--chq-brasa);
}

/* ---------- Navigation rail (medium+; expanded on large) ---------- */

.md-nav-rail {
  position: sticky;
  top: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  width: 80px;
  height: 100dvh;
  padding: 20px 0 16px;
  overflow-y: auto;
  scrollbar-width: none;
}

.md-nav-rail__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  border-radius: var(--md-sys-shape-corner-extra-small);
}

.md-nav-rail__brand .chq-logo--full {
  display: none;
}

.md-nav-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.md-nav-section + .md-nav-section {
  margin-top: 12px;
}

.md-nav-section__title {
  display: none;
}

.md-nav-rail .md-nav-item {
  width: 100%;
  min-height: 56px;
  padding: 0 4px;
}

.md-nav-rail__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-top: auto;
  padding-top: 16px;
}

.md-nav-account {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 56px;
  padding: 8px 4px;
  border: none;
  border-radius: var(--md-sys-shape-corner-small);
  background: none;
  color: var(--md-sys-color-on-surface-variant);
  font: inherit;
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  cursor: pointer;
}

.md-nav-account:hover {
  background: var(--md-sys-color-surface-container-high);
}

.md-nav-account__text {
  display: none;
  min-width: 0;
  text-align: left;
}

.md-nav-account__name {
  display: block;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-nav-account__meta {
  display: block;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface-variant);
  object-fit: cover;
  overflow: hidden;
}

.md-avatar .md-icon {
  --md-icon-size: 18px;
}

.md-avatar--large {
  width: 40px;
  height: 40px;
}

@media (min-width: 600px) {
  .md-nav-rail {
    display: flex;
  }
}

@media (min-width: 1200px) {
  .md-nav-rail {
    width: 240px;
    align-items: stretch;
    gap: 0;
    padding: 20px 12px 16px;
  }

  .md-nav-rail__brand {
    padding: 4px 12px;
  }

  .md-nav-rail__brand .chq-logo--full {
    display: inline-flex;
  }

  .md-nav-rail__brand .chq-logo--mark {
    display: none;
  }

  .md-nav-section {
    align-items: stretch;
    gap: 2px;
  }

  .md-nav-section + .md-nav-section {
    margin-top: 4px;
  }

  .md-nav-section__title {
    display: block;
    padding: 18px 16px 8px;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--md-sys-typescale-code-label-font);
    font-size: var(--md-sys-typescale-code-label-size);
    line-height: var(--md-sys-typescale-code-label-line-height);
    font-weight: var(--md-sys-typescale-code-label-weight);
    letter-spacing: var(--md-sys-typescale-code-label-tracking);
    text-transform: uppercase;
  }

  .md-nav-rail .md-nav-item {
    --md-nav-indicator-width: 24px;
    --md-nav-indicator-height: 24px;
    --md-nav-indicator-hover: transparent;
    --md-nav-indicator-position: static;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--md-sys-shape-corner-small);
    font-size: var(--md-sys-typescale-label-large-size);
    line-height: var(--md-sys-typescale-label-large-line-height);
    letter-spacing: var(--md-sys-typescale-label-large-tracking);
    text-align: left;
    transition: background-color var(--md-sys-motion-duration-short2)
      var(--md-sys-motion-easing-standard);
  }

  .md-nav-rail .md-nav-item:hover {
    background: var(--md-sys-color-surface-container-high);
  }

  .md-nav-rail .md-nav-item:focus-visible {
    outline: 2px solid var(--chq-brasa);
    outline-offset: 2px;
  }

  .md-nav-rail .md-nav-item:focus-visible .md-nav-item__indicator {
    outline: none;
  }

  .md-nav-rail .md-nav-item.active {
    background: var(--chq-brasa-soft);
    color: var(--chq-brasa);
  }

  .md-nav-rail .md-nav-item.active:hover {
    background: var(--chq-brasa-soft);
  }

  .md-nav-rail .md-nav-item.active .md-nav-item__indicator {
    background: transparent;
  }

  .md-nav-rail .md-nav-item__label--short {
    display: none;
  }

  .md-nav-rail .md-nav-item__label--full {
    display: inline;
    flex: 1;
  }

  /* Expanded rail: the count sits at the end of the row, not over the icon. */
  .md-nav-rail .md-nav-item__badge {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
  }

  .md-nav-rail__footer {
    align-items: stretch;
  }

  .md-nav-account {
    flex-direction: row;
    gap: 12px;
    padding: 8px 12px;
    text-align: left;
  }

  .md-nav-account__text {
    display: block;
    flex: 1;
  }
}

/* ---------- Navigation bar (compact only) ---------- */

.md-nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-raised);
}

.md-nav-bar .md-nav-item {
  --md-nav-indicator-width: 64px;
  flex: 1;
  min-width: 0;
  max-width: 128px;
}

@media (min-width: 600px) {
  .md-nav-bar {
    display: none;
  }
}

/* ---------- List items (sheets, menus) ---------- */

.md-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 52px;
  padding: 8px 24px;
  border: none;
  background: none;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 24px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.md-list-item .md-icon {
  color: var(--md-list-icon-color, var(--md-sys-color-on-surface-variant));
}

.md-list-item:hover {
  background: var(--md-sys-color-surface);
}

.md-list-item:focus-visible {
  outline-offset: -3px;
}

.md-list-item.active {
  --md-list-icon-color: currentColor;
  background: var(--chq-brasa-soft);
  color: var(--chq-brasa);
  font-weight: 500;
}

.md-list-item__text {
  flex: 1;
  min-width: 0;
}

.md-list-item__supporting {
  display: block;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}

/* ---------- Bottom sheet (native <dialog>) ---------- */

.md-sheet {
  width: 100%;
  max-width: 640px;
  max-height: calc(100dvh - 72px);
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-bottom: none;
  border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--chq-shadow-float);
}

.md-sheet::backdrop {
  background: color-mix(in srgb, var(--md-sys-color-scrim) 40%, transparent);
}

.md-sheet[open] {
  animation: md-sheet-in var(--md-sys-motion-duration-short4)
    var(--md-sys-motion-easing-standard-decelerate);
}

@keyframes md-sheet-in {
  from {
    transform: translateY(100%);
  }
}

.md-sheet__handle {
  width: 32px;
  height: 4px;
  margin: 12px auto 8px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-outline-variant);
}

.md-sheet__title {
  margin: 0;
  padding: 8px 24px;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
}

.md-sheet__content {
  display: flex;
  flex-direction: column;
  padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  overflow: auto;
}

/* ---------- Menu (native popover) ---------- */

.md-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--chq-shadow-float);
}

.md-menu:popover-open {
  animation: md-menu-in var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard-decelerate);
}

@keyframes md-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.md-menu__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 12px;
}

.md-menu__header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.md-menu__header-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-menu__divider {
  height: 1px;
  margin: 8px 0;
  background: var(--md-sys-color-outline-variant);
}

.md-menu__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
}

.md-menu__label {
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-typescale-code-label-font);
  font-size: var(--md-sys-typescale-code-label-size);
  line-height: var(--md-sys-typescale-code-label-line-height);
  font-weight: var(--md-sys-typescale-code-label-weight);
  letter-spacing: var(--md-sys-typescale-code-label-tracking);
  text-transform: uppercase;
}

.md-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  background: none;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.md-menu__item .md-icon {
  color: var(--md-sys-color-on-surface-variant);
}

.md-menu__item:hover {
  background: var(--md-sys-color-surface);
}

.md-menu__item:focus-visible {
  outline-offset: -3px;
}

.md-menu__item--danger,
.md-menu__item--danger .md-icon {
  color: var(--chq-alerta);
}

/* Account menu: anchored to the top app bar avatar (compact) or the rail footer (medium+). */
.md-menu--account {
  top: 60px;
  right: 8px;
}

@media (min-width: 600px) {
  .md-menu--account {
    top: auto;
    right: auto;
    left: 88px;
    bottom: 16px;
  }
}

@media (min-width: 1200px) {
  .md-menu--account {
    left: 248px;
  }
}

/* ---------- Segmented buttons ---------- */

.md-segmented {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-raised);
  overflow: hidden;
}

.md-segmented__button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: none;
  border-inline-start: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  white-space: nowrap;
  cursor: pointer;
}

.md-segmented__button:first-of-type {
  border-inline-start: none;
}

.md-segmented__button .md-icon {
  --md-icon-size: 16px;
}

.md-segmented__button:hover {
  background: var(--md-sys-color-surface);
}

.md-segmented__button:focus-visible {
  outline-offset: -3px;
}

.md-segmented__button[aria-pressed="true"] {
  background: var(--chq-brasa-soft);
  color: var(--chq-brasa);
}

/* ---------- Filter chips ---------- */

.md-chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}

.md-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-filter-chip .md-icon {
  --md-icon-size: 16px;
  margin-inline-start: -4px;
}

.md-filter-chip:hover {
  border-color: var(--md-sys-color-on-surface);
}

.md-filter-chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--chq-brasa-soft);
  color: var(--chq-brasa);
}

@media (max-width: 599px) {
  /* Chips scroll horizontally on compact instead of stacking into a tall block. */
  .md-chip-set--scroll {
    flex-wrap: nowrap;
    margin: 0 -16px;
    padding: 2px 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }
}

/* ---------- Detail drawer (side sheet, expanded+) ----------
 * A <dialog> anchored to the right edge of the window, full height.
 * Large (1200px+): opened with show(); the shell adds `has-drawer` to <html>
 * so the content shrinks instead of sliding under it.
 * Expanded (840–1199px): opened with showModal(), over a scrim.
 */

:root {
  --md-drawer-width: clamp(360px, 34vw, 480px);
}

.md-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--md-drawer-width);
  max-width: 100vw;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  animation: md-drawer-in var(--md-sys-motion-duration-short4)
    var(--md-sys-motion-easing-standard-decelerate);
}

.md-drawer:not([open]) {
  display: none;
}

.md-drawer::backdrop {
  background: color-mix(in srgb, var(--md-sys-color-scrim) 40%, transparent);
  animation: md-scrim-in var(--md-sys-motion-duration-short4) linear;
}

@keyframes md-scrim-in {
  from {
    opacity: 0;
  }
}

@keyframes md-drawer-in {
  from {
    transform: translateX(100%);
  }
}

/* The drawer takes focus for screen readers; it is not a control, so no ring. */
.md-drawer:focus,
.md-drawer:focus-visible {
  outline: none;
}

.md-drawer__header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 12px 12px 12px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md-drawer__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
}

.md-drawer__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 24px;
  overflow: auto;
  overscroll-behavior: contain;
}

/* Text buttons inside the drawer keep their own width instead of stretching. */
.md-drawer__content > .md-button {
  align-self: flex-start;
}

.md-drawer__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* ---------- Search field ---------- */

.md-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px 0 14px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface-variant);
  transition: border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md-search:hover {
  border-color: var(--md-sys-color-on-surface);
}

.md-search:focus-within {
  border-color: var(--chq-brasa);
  outline: 2px solid var(--chq-brasa);
  outline-offset: 2px;
}

.md-search input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 24px;
  outline: none;
}

/* One clear control, ours; not the browser's. */
.md-search input::-webkit-search-cancel-button,
.md-search input::-webkit-search-decoration {
  appearance: none;
}

.md-search input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.md-search__clear {
  width: 36px;
  height: 36px;
}

/* ---------- Pagination (table footer) ---------- */

.md-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
  padding: 4px 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}

.md-pagination__size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.md-pagination__size select {
  min-height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-raised);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 13px,
    calc(100% - 10px) 13px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

.md-pagination__size select:focus-visible {
  outline: 2px solid var(--chq-brasa);
  outline-offset: 2px;
}

.md-pagination__range {
  font-variant-numeric: tabular-nums;
}

.md-pagination__nav {
  display: inline-flex;
}

.md-pagination__nav .md-icon-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.md-pagination__nav .md-icon-button:disabled:hover {
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
}

/* ---------- Empty state ---------- */

.md-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  border: 1px dashed var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-large);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}

.md-empty__icon {
  --md-icon-size: 28px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: var(--chq-radius-balao);
  background: var(--chq-brasa-soft);
  color: var(--chq-brasa);
}

.md-empty__title {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
}

.md-empty__description {
  max-width: 48ch;
  margin: 0;
}

.md-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 12px 20px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--chq-shadow-float);
}

.skip-link:focus {
  top: 16px;
}

/* ---------- Layout helpers ---------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack--tight {
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.row--between {
  justify-content: space-between;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

.muted {
  color: var(--md-sys-color-on-surface-variant);
}

.nowrap {
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Reduced motion ---------- */

/* Every animation and transition reads a motion token, so zeroing the tokens is enough. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --md-sys-motion-duration-short2: 0.01ms;
    --md-sys-motion-duration-short4: 0.01ms;
    --md-sys-motion-duration-medium2: 0.01ms;
    --md-sys-motion-duration-medium4: 0.01ms;
    --md-sys-motion-duration-long2: 0.01ms;
  }

  .md-dots span {
    animation: none;
    opacity: 0.6;
  }
}
