/* =============================================================================
   Criative Links · Componentes (Criative Design System)
   Reset, tipografia, botoes, campos, cards, badges, tabelas, menus, alertas, toasts, dialog...
   Somente tokens de tokens.css. Sem estilos inline (CSP style-src 'self').
   ============================================================================= */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--surface);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (prefers-reduced-motion: no-preference) {
  body {
    transition: background 0.25s ease, color 0.25s ease;
  }
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
}

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

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted-foreground);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: var(--space-2);
  text-decoration: none;
}

/* ---- Icones (sprite inline; herdam currentColor) ---- */
.icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---- Botoes ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn .icon {
  font-size: 16px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--accent);
  filter: none;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-sm {
  height: 28px;
  font-size: 12px;
  padding: 0 10px;
}

.btn-sm.btn-icon {
  width: 28px;
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--ring);
  padding: var(--space-4);
  min-width: 0;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-title);
  line-height: var(--leading-title);
}

.card-sub {
  color: var(--muted-foreground);
  font-size: 13px;
  margin-bottom: var(--space-4);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge .dotc {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-outline {
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

.badge-success {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}

.badge-danger {
  background: color-mix(in srgb, var(--chart-2) 18%, transparent);
  color: var(--chart-2);
}

/* Contraste AA do texto pequeno sobre o fundo translucido: rosa claro (chart-1) no escuro, verde mais fechado no claro */
[data-theme="dark"] .badge-danger {
  color: var(--chart-1);
}

[data-theme="light"] .badge-success {
  color: #166534;
}

[data-theme="light"] .badge-danger {
  color: var(--primary);
}

/* ---- Campos ---- */
.field {
  display: block;
  min-width: 0;
}

.field > label,
.field-label {
  display: block;
  font-weight: 500;
  font-size: var(--text-label);
  margin-bottom: 6px;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 18px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--chart-2);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.select-wrap {
  position: relative;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
}

.select-wrap .caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 16px;
  pointer-events: none;
}

.select option {
  background: var(--background);
  color: var(--foreground);
}

.input-icon {
  position: relative;
}

.input-icon .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 16px;
  pointer-events: none;
}

.input-icon .input {
  padding-left: 34px;
}

input[type="file"].input {
  padding: 6px 8px;
}

/* Campo com prefixo/sufixo (ex.: dominio do encurtador + slug) */
.pfx {
  display: flex;
  align-items: stretch;
  min-height: 36px;
  border-radius: var(--radius);
  background: var(--input);
  border: 1px solid var(--input-border);
  overflow: hidden;
}

.pfx:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.pfx .pre {
  display: flex;
  align-items: center;
  padding: 0 4px 0 10px;
  color: var(--muted-foreground);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 62%;
}

.pfx input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0 10px 0 2px;
}

.pfx[data-invalid="true"] {
  border-color: var(--chart-2);
}

.field-hint {
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 17px;
  margin-top: 6px;
}

.field-error {
  color: var(--chart-2);
  font-size: 12px;
  line-height: 17px;
  margin-top: 6px;
}

[data-theme="light"] .field-error {
  color: var(--primary);
}

/* Checkbox e radio nativos com a aparencia do design system */
.checkbox,
.radio {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  border: 1.5px solid var(--input-border);
  background: transparent;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}

.checkbox {
  border-radius: 5px;
}

.radio {
  border-radius: 50%;
}

.checkbox:checked,
.radio:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--primary-foreground);
  border-bottom: 2px solid var(--primary-foreground);
  transform: translateY(-1px) rotate(-45deg);
}

.radio:checked::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-foreground);
}

.opt {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.opt label {
  cursor: pointer;
}

/* Switch: <label class="switch"><input type="checkbox"><span class="track"></span><span class="thumb"></span></label> */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: 0 0 auto;
  display: inline-block;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--secondary);
  border-radius: 999px;
}

.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--foreground);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .switch .track {
    transition: background 0.2s ease;
  }

  .switch .thumb {
    transition: transform 0.2s ease;
  }
}

.switch input:checked + .track {
  background: var(--primary);
}

.switch input:checked + .track + .thumb {
  transform: translateX(18px);
  background: var(--primary-foreground);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

.setrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.setrow .sm {
  flex: 1;
  min-width: 0;
}

.setrow .st {
  font-weight: 500;
  font-size: 13px;
}

.setrow .ss {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* Cartoes de opcao (radio): input antes, .optcard-box depois */
.optcards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.optcard {
  position: relative;
  display: block;
  cursor: pointer;
}

.optcard input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.optcard-box {
  display: flex;
  gap: 10px;
  height: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.optcard-box .rr {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--input-border);
  flex: 0 0 auto;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.optcard input:checked + .optcard-box {
  border-color: var(--primary);
  background: var(--input);
}

.optcard input:checked + .optcard-box .rr {
  border-color: var(--primary);
}

.optcard input:checked + .optcard-box .rr::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.optcard input:focus-visible + .optcard-box {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

.optcard .ot {
  font-weight: 500;
  font-size: 13px;
}

.optcard .os {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ---- Segmented e tabs (links ou botoes) ---- */
.segment {
  display: inline-flex;
  background: var(--muted);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.segment > * {
  background: transparent;
  border: 0;
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}

.segment > [aria-pressed="true"],
.segment > [aria-current="true"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 0 0 1px var(--ring);
}

.tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a,
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 2px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.tabs a:hover {
  color: var(--foreground);
}

.tabs [aria-current="page"],
.tabs [aria-selected="true"] {
  color: var(--foreground);
  border-bottom-color: var(--primary);
}

.tabs .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-foreground);
}

/* ---- Breadcrumb ---- */
.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 13px;
  list-style: none;
}

.crumb li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb a {
  color: var(--muted-foreground);
}

.crumb a:hover {
  color: var(--foreground);
  text-decoration: none;
}

.crumb .sep {
  font-size: 14px;
  opacity: 0.7;
}

.crumb [aria-current="page"] {
  color: var(--foreground);
  font-weight: 500;
}

/* ---- Alertas inline ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 18px;
}

.alert .icon {
  font-size: 16px;
  margin-top: 1px;
}

.alert-body {
  min-width: 0;
}

.alert.info {
  background: var(--muted);
  border: 1px solid var(--border);
}

.alert.info .icon {
  color: var(--muted-foreground);
}

.alert.ok {
  background: color-mix(in srgb, var(--ok) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--ok);
}

.alert.err {
  background: color-mix(in srgb, var(--chart-2) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--chart-2) 30%, transparent);
  color: var(--chart-2);
}

[data-theme="dark"] .alert.err {
  color: var(--chart-1);
}

[data-theme="light"] .alert.ok {
  color: #166534;
}

[data-theme="light"] .alert.err {
  color: var(--primary);
}

/* ---- Toast ---- */
.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--background);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}

.toast .ic {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.toast .ic.ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}

.toast .ic.err {
  background: color-mix(in srgb, var(--chart-2) 14%, transparent);
  color: var(--chart-2);
}

.toast .tmain {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast .tt {
  font-weight: 500;
  font-size: 13px;
}

.toast .ts {
  color: var(--muted-foreground);
  font-size: 12px;
}

.toast .x {
  color: var(--muted-foreground);
  font-size: 16px;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
}

.toast .x:hover {
  color: var(--foreground);
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 0.2s ease;
  }

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

/* ---- Dialog (confirmacao de acoes destrutivas) ---- */
.dialog {
  margin: auto;
  border: 0;
  padding: 20px;
  width: min(400px, calc(100vw - 32px));
  background: var(--card);
  color: var(--foreground);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--ring), var(--shadow-dialog);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog .di {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--chart-2) 16%, transparent);
  color: var(--chart-2);
  font-size: 20px;
  margin-bottom: var(--space-3);
}

.dialog h2 {
  font-size: var(--text-title);
  line-height: var(--leading-title);
}

.dialog p {
  color: var(--muted-foreground);
  margin-top: 4px;
}

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

/* ---- Dropdown (details) ---- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown > summary {
  list-style: none;
  cursor: pointer;
}

.dropdown > summary::-webkit-details-marker {
  display: none;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 210px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-pop);
}

.menu form {
  display: contents;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--foreground);
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.menu-item .icon {
  font-size: 16px;
  color: var(--muted-foreground);
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--accent);
  text-decoration: none;
}

.menu-item:hover .icon {
  color: var(--foreground);
}

.menu-item[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.menu-item .sc {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-foreground);
}

.menu-item.danger,
.menu-item.danger .icon {
  color: var(--chart-2);
}

[data-theme="light"] .menu-item.danger,
[data-theme="light"] .menu-item.danger .icon {
  color: var(--primary);
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ---- Tooltip CSS (icon buttons) ---- */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--foreground);
  color: var(--background);
  font-size: 12px;
  line-height: 16px;
  padding: 6px 10px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 60;
  /* display (nao visibility): o balao escondido nao pode aumentar a area rolavel da pagina */
  display: none;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  display: block;
}

/* ---- Tabela de dados (DS: cabecalho mono caixa-alta, linhas com divisor) ---- */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--ring);
  padding: var(--space-4);
}

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

.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 500;
}

.table th.num {
  font-weight: 400;
}

.table .cell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.table .cell-main .nm {
  font-weight: 500;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
}

.table .cell-main .sb {
  color: var(--muted-foreground);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table .trunc {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table .actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---- Paginacao ---- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.pager ul {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  list-style: none;
}

.page {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  color: var(--foreground);
  text-decoration: none;
}

a.page:hover {
  background: var(--accent);
  text-decoration: none;
}

.page.on {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}

.page.gap {
  border: 0;
  color: var(--muted-foreground);
}

.page[aria-disabled="true"] {
  opacity: 0.45;
}

/* ---- Estado vazio ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 36px 16px;
}

.empty .icon {
  font-size: 26px;
  color: var(--muted-foreground);
}

.empty .et {
  font-weight: 500;
  font-size: 15px;
}

.empty .es {
  color: var(--muted-foreground);
  font-size: 13px;
  max-width: 44ch;
}

.empty .btn {
  margin-top: 6px;
}

/* ---- Stat card, progress, avatar ---- */
.stat .lab {
  color: var(--muted-foreground);
  font-size: var(--text-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .big {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  line-height: 36px;
  margin-top: 6px;
  letter-spacing: -0.01em;
}

.stat .sub {
  color: var(--muted-foreground);
  font-size: 12px;
  margin-top: 2px;
}

progress.progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--secondary);
  color: var(--primary);
}

progress.progress::-webkit-progress-bar {
  background: var(--secondary);
}

progress.progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

progress.progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--foreground);
  flex: 0 0 auto;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar.xl {
  width: 72px;
  height: 72px;
  font-size: 24px;
  border-radius: var(--radius-lg);
}

/* ---- Dropzone ---- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--input-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  color: var(--muted-foreground);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.dropzone .icon {
  font-size: 24px;
}

.dropzone .dz-name {
  color: var(--foreground);
  font-weight: 500;
  word-break: break-all;
}

.js .dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.js .dropzone:focus-within {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

/* ---- QR (somente o container; a geracao do QR entra na Fase 7) ---- */
.qr {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  width: fit-content;
}

[data-theme="light"] .qr {
  border: 1px solid var(--border);
}

/* ---- Teclas ---- */
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--foreground);
}

/* ---- Pagina 404 / erro ---- */
.nf {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 22px 8px;
}

.nf .code {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 52px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--primary);
}

[data-theme="dark"] .nf .code {
  color: var(--chart-2);
}

.nf .nt {
  font-weight: 500;
  font-size: 15px;
}

.nf .ns {
  color: var(--muted-foreground);
  font-size: 13px;
  max-width: 40ch;
}

.nf pre {
  text-align: left;
  max-width: 100%;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--muted);
}

/* ---- Lista de definicao (detalhes) ---- */
.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-6);
}

.kv dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 2px;
}

.kv dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv .wide {
  grid-column: 1 / -1;
}

/* ---- Cabecalho de pagina ---- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.page-header .titles {
  min-width: 0;
}

.page-header h1 {
  font-size: var(--text-display);
  line-height: var(--leading-display);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  overflow-wrap: anywhere;
}

.page-header .subtitle {
  color: var(--muted-foreground);
  margin-top: 2px;
  max-width: 70ch;
}

.page-header .actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-header .crumb {
  margin-bottom: var(--space-2);
}

/* ---- Utilidades ---- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.nowrap {
  white-space: nowrap;
}

@media (max-width: 760px) {
  .optcards,
  .cols-2,
  .cols-3,
  .kv {
    grid-template-columns: 1fr;
  }

  .cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cols-4 .stat .big {
    font-size: 24px;
    line-height: 30px;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.nf .nf-icon {
  font-size: 32px;
  color: var(--muted-foreground);
}

/* ---- Graficos (SVG: atributos de apresentacao, sem estilo inline) ---- */
.chart {
  margin: 0;
}

.chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 10px;
}

.chart .bar {
  fill: var(--primary);
}

[data-theme="dark"] .chart .bar {
  fill: var(--chart-2);
}

.chart .bar:hover {
  fill: var(--chart-1);
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.donut {
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
}

.donut-ring {
  stroke: var(--secondary);
}

.donut .seg {
  stroke: var(--chart-2);
}

.donut .seg-1 { stroke: var(--chart-2); }
.donut .seg-2 { stroke: var(--chart-4); }
.donut .seg-3 { stroke: var(--chart-1); }
.donut .seg-4 { stroke: var(--chart-5); }
.donut .seg-5 { stroke: var(--muted-foreground); }

.donut-total {
  fill: var(--foreground);
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 500;
}

.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 8px;
}

.seg-bg-1 { background: var(--chart-2); }
.seg-bg-2 { background: var(--chart-4); }
.seg-bg-3 { background: var(--chart-1); }
.seg-bg-4 { background: var(--chart-5); }
.seg-bg-5 { background: var(--muted-foreground); }

.legend .mono {
  color: var(--muted-foreground);
  margin-left: 6px;
}

/* Tooltip longo (texto explicativo, nao rotulo de icone) */
[data-tip-wide]::after {
  white-space: normal;
  width: min(260px, calc(100vw - 48px));
  text-align: left;
  left: auto;
  right: -8px;
  transform: none;
}

.tipicon {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  color: var(--muted-foreground);
  cursor: help;
}

.rank .ul {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-filter {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.period-filter .segment {
  flex-wrap: wrap;
}

.period-custom {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}
