/* Botões, badges, seletor de visão, cards, estados vazios e painel lateral. */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.btn--sm { height: var(--control-h-sm); padding: 0 var(--space-3); }
.btn--primary { background: var(--brand); color: var(--brand-contrast); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--secondary { border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--danger { background: var(--down); color: var(--on-danger); }
.btn--danger:hover { filter: brightness(1.08); }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge--demo {
  background: var(--brand-soft);
  color: var(--brand-text);
  border: 1px solid var(--brand);
  letter-spacing: var(--tracking-label);
  font-weight: 600;
}
.badge--up { background: var(--up-bg); color: var(--up); }
.badge--down { background: var(--down-bg); color: var(--down); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--faint { color: var(--text-faint); }

/* ---------- Seletor de visão (controle segmentado) ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.segmented__opt {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.segmented__opt:hover { color: var(--text); }
.segmented__opt[aria-checked="true"] { background: var(--surface-2); color: var(--text); }
.segmented__opt[data-view="admin"][aria-checked="true"] { color: var(--mode-admin); }

@media (max-width: 640px) {
  .segmented__opt { padding: 0 var(--space-2); }
  .segmented__text { display: none; }
}

/* ---------- Botão do robô ---------- */
.robot-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background var(--dur-hover) var(--ease);
}
.robot-btn:hover { background: var(--surface-2); }
.robot-btn[aria-pressed="true"] { color: var(--up); }
.robot-btn[aria-pressed="false"] { color: var(--text-faint); }

@media (max-width: 1100px) {
  .robot-btn { width: var(--control-h); padding: 0; justify-content: center; }
}

/* ---------- Sino de alertas ---------- */
.bell-count {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}
.bell-count[data-critical="true"] { background: var(--down); color: var(--on-danger); }
.bell-count[hidden] { display: none; }

/* ---------- Origem das cotações ---------- */
.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.source-dot[data-state="live"] { background: var(--up); animation: pulse 2s var(--ease) infinite; }
.source-dot[data-state="reconnecting"] { background: var(--warn); animation: blink 1s steps(2, start) infinite; }
.source-dot[data-state="simulated"] { background: var(--warn); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--up-bg); }
  50% { box-shadow: 0 0 0 5px var(--up-bg); }
}
@keyframes blink { to { visibility: hidden; } }

/* ---------- Monograma de moeda (cor da moeda a 18% + sigla na cor cheia) ---------- */
.monogram {
  --coin: var(--text-muted);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--coin) 18%, transparent);
  color: var(--coin);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.02em;
}
.monogram--sm { width: 18px; height: 18px; font-size: 10px; }

/* ---------- Minigráfico (sparkline) ---------- */
.spark {
  display: block;
  width: 100%;
  overflow: visible;
  color: var(--text-muted);
}
.spark[data-dir="up"] { color: var(--up); }
.spark[data-dir="down"] { color: var(--down); }
.spark__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.spark__area { fill: currentColor; opacity: .12; stroke: none; }

/* ---------- Esqueleto de carregamento ---------- */
.skeleton {
  display: inline-block;
  height: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

/* ---------- Estado vazio ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty__title { font-weight: 600; }
.empty__text { color: var(--text-muted); max-width: 46ch; }
.empty__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ---------- Painel lateral (alertas) ---------- */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--panel-w), 100vw);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--dur-open) var(--ease), visibility 0s linear var(--dur-open);
}
.panel.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--dur-open) var(--ease), visibility 0s;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--space-2) 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}
.panel__body { flex: 1; overflow-y: auto; }

/* ---------- Avisos no alto do conteúdo ---------- */
.notices {
  max-width: var(--content-max);
  margin: 0 auto;
}
.notices:empty { display: none; }
.notices + #view { margin-top: var(--space-4); }
.notices:empty + #view { margin-top: 0; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.notice--warn { background: var(--warn-bg); border-color: transparent; }
.notice__icon { color: var(--warn); display: inline-flex; padding-top: 2px; }
.notice__body { flex: 1; min-width: 0; }
.notice__title { font-weight: 600; }
.notice__text { color: var(--text-muted); margin-top: var(--space-1); }
.notice .btn { flex-shrink: 0; }
@media (max-width: 640px) {
  .notice { flex-wrap: wrap; }
  .notice .btn { margin-left: calc(var(--space-3) + 16px); }
}

/* ---------- Esqueleto da tela de carregamento ---------- */
.skeleton--block { display: block; }
.skeleton { animation: skeleton-pulse 1.4s var(--ease) infinite; }
@keyframes skeleton-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.loading__text { color: var(--text-muted); margin-top: var(--space-1); }
.loading__kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gutter);
}
.loading__kpi { display: grid; gap: var(--space-3); }
.loading__table { display: grid; gap: var(--space-4); }
.loading__row { display: flex; gap: var(--space-4); align-items: center; }

/* ---------- Resumo de números (provisório nas telas em construção) ---------- */
.summary { display: grid; gap: var(--space-4); }
.summary__title { font-size: var(--fs-h2); line-height: var(--lh-h2); }
.summary .stats + .summary__title { padding-top: var(--space-4); border-top: 1px solid var(--border); }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4) var(--gutter);
}
.stat { display: grid; gap: var(--space-1); align-content: start; }
.stat__value { font-size: 16px; line-height: 24px; color: var(--text); white-space: nowrap; }
.stat__extra { color: var(--text-muted); font-size: var(--fs-label); line-height: var(--lh-label); }

/* ---------- Travar compras (topo, só na visão Administrador) ---------- */
[data-view="cliente"] .lock-btn { display: none; }
.lock-btn:disabled { opacity: .5; cursor: default; }
.lock-btn.is-locked { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.lock-btn.is-locked:hover { background: var(--warn-bg); filter: brightness(1.1); }
@media (max-width: 1100px) {
  .lock-btn__text { display: none; }
  .lock-btn { width: var(--control-h-sm); padding: 0; justify-content: center; }
}

/* ======================================================================
   Componentes da visão Cliente (F3)
   ====================================================================== */

/* ---------- Seletor "Visualizando como" (topo) ---------- */
.client-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-h);
  margin-left: var(--space-2);
  padding: 0 var(--space-2) 0 var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
  max-width: 230px;
  transition: background var(--dur-hover) var(--ease);
}
.client-picker:hover { background: var(--surface-2); }
.client-picker:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
[data-view="admin"] .client-picker { display: none; }

.client-picker__avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.client-picker[data-status="pausado"] .client-picker__avatar { background: var(--warn-bg); color: var(--warn); }
.client-picker[data-status="inativo"] .client-picker__avatar { background: var(--surface-2); color: var(--text-faint); }

.client-picker__text { display: grid; min-width: 0; line-height: 1.1; }
.client-picker__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-label); }
.client-picker__name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-picker__chevron { color: var(--text-muted); flex-shrink: 0; }

/* O <select> nativo cobre o controle inteiro: o clique abre a lista do sistema. */
.client-picker__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  font-size: 16px; /* evita o zoom do iOS ao focar */
}
.client-picker__select:disabled { cursor: default; }

@media (max-width: 1100px) {
  .client-picker { padding: 0 var(--space-1); border-color: transparent; margin-left: var(--space-1); }
  .client-picker__text, .client-picker__chevron { display: none; }
}

/* ---------- Campos, filtros e chips ---------- */
.input {
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  min-width: 0;
}
.input:hover { border-color: var(--text-faint); }
.input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="date"].input { font-size: var(--fs-num); }

.field { display: grid; gap: var(--space-1); align-content: start; min-width: 0; }
.field__label {
  font-size: var(--fs-label);
  line-height: var(--lh-label);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4) var(--space-5);
}
.filters__period {
  display: grid;
  grid-template-columns: minmax(200px, 240px) repeat(2, minmax(140px, 160px));
  gap: var(--space-3);
}
.filters__coins { flex: 1 1 320px; }

.segmented--field { background: var(--surface-2); }
.segmented--field .segmented__opt { height: 28px; }
.segmented--field .segmented__opt[aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--space-3) 0 var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 500;
  transition: border-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.chip:first-child { padding-left: var(--space-3); }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip[aria-pressed="true"] { border-color: var(--brand); color: var(--brand-text); background: var(--brand-soft); }

@media (max-width: 640px) {
  .filters__period { grid-template-columns: 1fr 1fr; width: 100%; }
  .filters__period .field:first-child { grid-column: 1 / -1; }
  .filters > .field { width: 100%; }
  .segmented--field { display: flex; }
  .segmented--field .segmented__opt { flex: 1; justify-content: center; }
}

/* ---------- Moeda (monograma + sigla) ---------- */
.coin { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.coin__sym { font-weight: 600; }
.monogram { font-size: 11px; }
.monogram--base { --coin: var(--chart-7); }

/* ---------- Tabela ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap {
  overflow: auto;
  max-height: max(420px, calc(100vh - var(--chrome-h) - 140px));
  overscroll-behavior: contain;
}
.table-wrap[hidden] { display: none; }
.table-wrap:focus-visible { outline-offset: -2px; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-body);
}
.table th,
.table td {
  height: 40px;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
.table th:first-child, .table td:first-child { padding-left: var(--space-4); }
.table th:last-child, .table td:last-child { padding-right: var(--space-4); }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  background: var(--surface);
  font-size: var(--fs-label);
  line-height: var(--lh-label);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}
.table .is-num { text-align: right; }
.table td.num { font-size: var(--fs-num); }
.table tbody tr { transition: background var(--dur-hover) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom-color: transparent; }
.table tfoot th, .table tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 0;
  font-weight: 600;
}
.table tfoot td.muted { font-weight: 500; }
.table--compact th, .table--compact td { height: 32px; }
.table--links tbody tr { cursor: pointer; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}
.th-sort:hover { color: var(--text); }
.th-sort__icon { width: 8px; height: 10px; position: relative; opacity: .35; }
.th-sort__icon::before,
.th-sort__icon::after {
  content: "";
  position: absolute;
  left: 0;
  border: 4px solid transparent;
}
.th-sort__icon::before { top: -4px; border-bottom-color: currentColor; }
.th-sort__icon::after { bottom: -4px; border-top-color: currentColor; }
th[aria-sort="ascending"] .th-sort,
th[aria-sort="descending"] .th-sort { color: var(--text); }
th[aria-sort="ascending"] .th-sort__icon,
th[aria-sort="descending"] .th-sort__icon { opacity: 1; }
th[aria-sort="ascending"] .th-sort__icon::after { display: none; }
th[aria-sort="descending"] .th-sort__icon::before { display: none; }
th.is-num .th-sort { flex-direction: row-reverse; }

/* Linha nova: fundo âmbar a 10% desvanecendo em 2 s + barra âmbar à esquerda. */
.table tbody tr.is-new { animation: row-new var(--dur-highlight) var(--ease); }
.table tbody tr.is-new > td:first-child { animation: row-new-bar var(--dur-highlight) var(--ease); }
@keyframes row-new { from { background: var(--brand-soft); } to { background: transparent; } }
@keyframes row-new-bar { from { box-shadow: inset 3px 0 0 var(--brand); } to { box-shadow: inset 3px 0 0 transparent; } }

.table-empty .empty { padding: var(--space-6) var(--space-5); }

/* Celular: cada linha vira um cartão empilhado, com o nome da coluna à esquerda (data-label). */
@media screen and (max-width: 640px) {
  .table-wrap { max-height: none; overflow: visible; }
  .table, .table tbody, .table tfoot, .table tr, .table td, .table tfoot th { display: block; width: 100%; }
  .table thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .table tbody tr,
  .table tfoot tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tfoot tr { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
  .table th, .table td,
  .table--compact th, .table--compact td,
  .table th:first-child, .table td:first-child,
  .table th:last-child, .table td:last-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    height: auto;
    min-height: 28px;
    padding: 2px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }
  .table td > * { min-width: 0; }
  .table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    max-width: 50%;
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    line-height: var(--lh-label);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    text-align: left;
  }
  .table td[data-label=""]::before { content: none; }
  .table td[data-label=""] { justify-content: flex-end; }
  .table td:empty { display: none; }
  .table tfoot th, .table tfoot td { position: static; background: none; border-top: 0; }
  .table tfoot th { justify-content: flex-start; padding-bottom: var(--space-1); }
  .table tbody tr.is-new > td:first-child { animation: none; }
  .table tbody tr.is-new { animation: row-new-card var(--dur-highlight) var(--ease); }
  .table td .hist-alert { min-width: 0; text-align: right; }
  .table td .cell-sub { text-align: right; }
}
@keyframes row-new-card {
  from { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
  to { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}

/* Linha clicável com o foco do teclado. */
.table tbody tr[tabindex]:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 0; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
}
.pager[hidden] { display: none; }
.pager__info { color: var(--text-muted); font-size: var(--fs-label); font-variant-numeric: tabular-nums; }
.pager__btns { display: flex; gap: var(--space-1); }
.pager .btn { width: var(--control-h-sm); padding: 0; }
.pager .btn:disabled { opacity: .4; }

/* ---------- KPI ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gutter);
}
.kpis--main { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpis--inline { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.kpi { display: grid; gap: var(--space-1); align-content: start; min-width: 0; }
.kpi__value {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 600;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi__value .num { font-family: inherit; font-size: inherit; line-height: inherit; font-weight: inherit; }
.kpi__value.up { color: var(--up); }
.kpi__value.down { color: var(--down); }
.kpi__unit { margin-left: 6px; font-size: var(--fs-label); font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.kpi__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-2);
  min-height: var(--lh-label);
  font-size: var(--fs-label);
  line-height: var(--lh-label);
  color: var(--text-muted);
}
.kpi__meta [data-campo]:empty { display: none; }
.kpi__chg { font-size: var(--fs-label); line-height: var(--lh-label); }
.kpi__chg[data-dir="up"] { color: var(--up); }
.kpi__chg[data-dir="down"] { color: var(--down); }
.kpi__spark { margin-top: var(--space-2); }
.kpi--sm { padding: var(--space-3); background: var(--surface-2); border-color: transparent; box-shadow: none; }
.kpi--sm .kpi__value { font-size: 18px; line-height: 26px; }

/* ---------- Barra de uso da banca ---------- */
.bankbar { display: grid; gap: var(--space-3); }
.bankbar__track {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-2);
}
.bankbar__seg { height: 100%; min-width: 2px; }
.bankbar__seg--operacao, .bankbar__key--operacao { background: var(--brand); }
.bankbar__seg--programado, .bankbar__key--programado { background: color-mix(in srgb, var(--info) 60%, transparent); }
.bankbar__seg--disponivel, .bankbar__key--disponivel { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.bankbar__seg--reserva, .bankbar__key--reserva {
  background: repeating-linear-gradient(135deg, var(--text-faint) 0 2px, transparent 2px 5px);
}
.bankbar__legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-2) var(--space-4);
}
.bankbar__item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-areas: "key name pct" "key val val";
  align-items: center;
  gap: 0 var(--space-2);
  font-size: var(--fs-label);
  line-height: var(--lh-label);
}
.bankbar__key { grid-area: key; width: 10px; height: 10px; border-radius: 3px; align-self: start; margin-top: 3px; }
.bankbar__name { grid-area: name; color: var(--text-muted); }
.bankbar__val { grid-area: val; color: var(--text); }
.bankbar__pct { grid-area: pct; color: var(--text-muted); font-size: var(--fs-label); }

/* ---------- Distância até o alvo ---------- */
.dist { display: grid; gap: 4px; min-width: 110px; }
.dist__text { font-size: var(--fs-num); text-align: right; }
.dist__bar { display: block; height: 4px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.dist__bar > span { display: block; height: 100%; background: var(--info); border-radius: inherit; transition: width var(--dur-open) var(--ease); }
.dist.is-done .dist__bar > span { background: var(--up); }
.dist.is-done .dist__text { color: var(--up); }

.target { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.target__kind { font-family: var(--font-sans); font-size: var(--fs-label); color: var(--text-muted); }

/* ---------- Faixa crítica / de aviso ---------- */
.band {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--warn-bg);
}
.band__icon { display: inline-flex; padding-top: 2px; color: var(--warn); }
.band--critical { background: var(--down-bg); box-shadow: inset 3px 0 0 var(--down); }
.band--critical .band__icon { color: var(--down); }
.band__title { font-weight: 600; }
.band__text { color: var(--text-muted); margin-top: var(--space-1); }

/* ---------- Gráficos ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box--md { height: 220px; }
.chart-box--lg { height: 280px; }
.chart-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- Badges extras ---------- */
.badge .icon { width: 12px; height: 12px; }

/* Celular estreito: o seletor de cliente precisa do espaço. */
@media (max-width: 480px) {
  .client-picker { margin-left: 0; padding: 0; }
}

/* ---------- Central de alertas (painel) ---------- */
.panel__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.panel__tools:empty { display: none; }
.panel__tools .chip:first-child { padding-left: var(--space-3); }
.panel__tools .chip { padding: 0 var(--space-3); }
.panel__foot {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}
.panel__foot[hidden] { display: none; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list > li + li { border-top: 1px solid var(--border); }
.alert-item {
  --sev: var(--info);
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-5) var(--space-3) var(--space-4);
  border-left: 3px solid var(--sev);
  text-align: left;
  transition: background var(--dur-hover) var(--ease);
}
.alert-item:hover { background: var(--surface-2); }
.alert-item[data-sev="atencao"] { --sev: var(--warn); }
.alert-item[data-sev="critico"] { --sev: var(--down); }
.alert-item[data-unread="false"] .alert-item__title { font-weight: 500; }
.alert-item[data-unread="false"] { border-left-color: color-mix(in srgb, var(--sev) 40%, transparent); }
.alert-item__icon { color: var(--sev); display: inline-flex; padding-top: 2px; }
.alert-item__body { display: grid; gap: 2px; min-width: 0; }
.alert-item__title { display: block; font-weight: 600; }
.alert-item__text { display: block; color: var(--text-muted); overflow-wrap: anywhere; }
.alert-item__action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: 2px;
  color: var(--warn);
  font-size: var(--fs-label);
  font-weight: 500;
}
.alert-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) 6px;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: var(--fs-label);
}
.alert-item__coin { display: inline-flex; align-items: center; gap: 4px; }
.alert-item__dot {
  position: absolute;
  top: var(--space-4);
  right: var(--space-3);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sev);
}
.alerts__more, .alerts__note { padding: var(--space-3) var(--space-4); font-size: var(--fs-label); }
.panel__foot .alerts__note { padding: 0; }
.alerts__soon { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-label); }

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
  cursor: pointer;
}
.switch-row input { width: 16px; height: 16px; accent-color: var(--brand); }
.switch-row input:disabled + span { color: var(--text-faint); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  width: min(360px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}
.toast {
  --tom: var(--info);
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  width: 100%;
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tom);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-open) var(--ease);
}
.toast[data-tom="up"] { --tom: var(--up); }
.toast[data-tom="down"] { --tom: var(--down); }
.toast[data-tom="warn"] { --tom: var(--warn); }
.toast__icon { color: var(--tom); display: inline-flex; padding-top: 2px; }
.toast__title { font-weight: 600; }
.toast__text { color: var(--text-muted); overflow-wrap: anywhere; }
.toast__close { width: 28px; height: 28px; margin-top: -4px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@media print { .toasts { display: none; } }


/* ======================================================================
   Componentes da visão Administrador (F5)
   ====================================================================== */

/* ---------- Faixa "Compras travadas" ---------- */
.band__body { flex: 1; min-width: 0; }
.band > .btn { flex-shrink: 0; align-self: center; }
.band--lock { box-shadow: inset 3px 0 0 var(--warn); }
.notices { display: grid; gap: var(--space-3); }
@media (max-width: 640px) {
  .band { flex-wrap: wrap; }
  .band > .btn { width: 100%; }
}

/* ---------- Modal ---------- */
.modal {
  width: min(560px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100vh - 2 * var(--space-6));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal--sm { width: min(440px, calc(100vw - 2 * var(--space-4))); }
.modal--lg { width: min(820px, calc(100vw - 2 * var(--space-4))); }
.modal[open] { animation: modal-in var(--dur-open) var(--ease); }
.modal::backdrop { background: var(--overlay); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
.modal__box { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: inherit; margin: 0; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3) var(--space-5);
}
.modal__head h2 { font-size: var(--fs-h2); }
.modal__body { display: grid; gap: var(--space-4); padding: 0 var(--space-5) var(--space-4); overflow-y: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-top: 1px solid var(--border);
}
.modal__impact {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
}
.modal__text { color: var(--text-muted); }
.modal__text a { margin-left: var(--space-1); }
@media (max-width: 480px) {
  .modal__foot .btn { flex: 1; }
}

/* ---------- Interruptor (checkbox) ---------- */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 18px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.switch:checked { background: var(--brand); box-shadow: none; }
.switch:checked::after { transform: translateX(14px); background: var(--brand-contrast); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-field { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); cursor: pointer; }
.switch-field > span { color: var(--text-muted); }
.switch-field--compact { min-height: 0; }
.switch-row .switch { width: 32px; height: 18px; }

/* ---------- Campos ---------- */
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group .input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .input:only-child { border-radius: var(--radius-sm); }
.input-group__suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-label);
  white-space: nowrap;
}
.input[aria-invalid="true"] { border-color: var(--down); }
.input:disabled { opacity: .6; cursor: not-allowed; }
.field--inline { grid-auto-flow: column; align-items: center; gap: var(--space-2); }
.field--inline .field__label { white-space: nowrap; }

.pfields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-4); }
.pfield { display: grid; gap: var(--space-1); align-content: start; min-width: 0; }
.pfield__label { display: inline-flex; align-items: center; gap: var(--space-2); }
.pfield__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.pfield__dot[hidden] { display: none; }
.pfield__help { color: var(--text-muted); font-size: var(--fs-label); line-height: var(--lh-label); }
.pfield__erro { color: var(--down); font-size: var(--fs-label); line-height: var(--lh-label); }
.pfield__erro[hidden], .pfield__reset[hidden] { display: none; }
.pfield.is-changed .input { border-color: var(--brand); }
.link-btn { color: var(--brand-text); font-size: var(--fs-label); line-height: var(--lh-label); text-align: left; justify-self: start; }
.link-btn:hover { text-decoration: underline; }

.check { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }

/* ---------- Botões e badges extras ---------- */
.icon-btn--sm { width: 28px; height: 28px; }
.btn--danger-outline { color: var(--down); }
.btn--danger-outline:hover { background: var(--down-bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.badge--admin { background: var(--mode-admin-bg); color: var(--mode-admin); }
.badge--strike { text-decoration: line-through; }
.chip__count { color: var(--text-muted); font-size: 11px; }
.chip__count:empty { display: none; }
.chips--sm .chip { height: 26px; }
.kpi__value.warn { color: var(--warn); }

/* ---------- Avatar (iniciais) ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
  font-size: 13px;
}
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }
.avatar[data-status="pausado"] { background: var(--warn-bg); color: var(--warn); }
.avatar[data-status="inativo"] { background: var(--surface-2); color: var(--text-faint); }


/* ======================================================================
   Polimento (F6): tour "Como apresentar", rodapé e atalho de teclado
   ====================================================================== */

/* ---------- Tour ---------- */
.tour { position: fixed; inset: 0; z-index: var(--z-tour); }
.tour[hidden] { display: none; }
.tour__veil { position: absolute; inset: 0; }
.tour--centro .tour__veil { background: var(--overlay); }
.tour__spot {
  position: fixed;
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--brand), 0 0 0 9999px var(--overlay);
  pointer-events: none;
  transition: left var(--dur-open) var(--ease), top var(--dur-open) var(--ease), width var(--dur-open) var(--ease), height var(--dur-open) var(--ease);
}
.tour__spot[hidden] { display: none; }
.tour__card {
  position: fixed;
  width: min(380px, calc(100vw - 2 * var(--space-4)));
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transition: left var(--dur-open) var(--ease), top var(--dur-open) var(--ease);
}
.tour__card:focus { outline: none; }
.tour--centro .tour__card { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour__head { display: flex; align-items: center; justify-content: space-between; margin-right: calc(-1 * var(--space-2)); }
.tour__step { color: var(--brand-text); }
.tour__title { font-size: var(--fs-h2); line-height: var(--lh-h2); }
.tour__text { color: var(--text-muted); }
.tour__foot { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.tour__dots { display: flex; gap: 6px; margin-right: auto; }
.tour__dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.tour__dots span.is-on { background: var(--brand); }
.tour__foot .btn:disabled { opacity: .4; }
@media (max-width: 640px) {
  .tour__card,
  .tour--centro .tour__card { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); top: auto; width: auto; transform: none; }
}
@media print { .tour { display: none; } }

/* ---------- Pular para o conteúdo ---------- */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-tour);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; text-decoration: none; }

/* ---------- Rodapé ---------- */
.site-footer {
  max-width: var(--content-max);
  margin: var(--space-7) auto 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  color: var(--text-muted);
  font-size: var(--fs-label);
  line-height: var(--lh-label);
}
.site-footer__links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); }
.site-footer__links button { color: var(--brand-text); }
.site-footer__links button:hover { text-decoration: underline; }
@media print { .site-footer, .skip-link { display: none; } }
