/* ============================================================
   Mesa Spot — design system (noite de terminal)
   Assinatura: faixa KPI tipo ticker com varrimento âmbar.
   ============================================================ */

:root {
  /* Tinta / painéis */
  --bg: #080c12;
  --panel: #10171f;
  --panel-soft: #0b1017;
  --line: rgba(140, 160, 185, 0.14);
  --line-strong: rgba(140, 160, 185, 0.26);

  /* Texto */
  --text: #eef3f8;
  --muted: #8b98ab;

  /* Sinais de mercado */
  --good: #4ec9a8;
  --bad: #d97b68;
  --gold: #e2b34a;
  --warn: #d4a017;

  /* Escala */
  --radius: 8px;
  --radius-sm: 6px;
  --space: 1rem;
  --space-lg: 1.5rem;
  --maxw: 1100px;

  /* Tipografia — grotesk angular + plex utilitário + mono para preços */
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-x: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
}

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

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.45;
  background:
    radial-gradient(820px 420px at 12% -8%, rgba(226, 179, 74, 0.06), transparent 55%),
    radial-gradient(640px 380px at 100% 8%, rgba(78, 201, 168, 0.035), transparent 50%),
    linear-gradient(180deg, #0a1018 0%, var(--bg) 42%, #070a0f 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono, .num,
.kpi .value,
.market .price,
.pos-rail .val,
th, td {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid rgba(226, 179, 74, 0.75);
  outline-offset: 2px;
}

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

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding:
    calc(1.2rem + var(--safe-t))
    max(1rem, var(--safe-x))
    calc(2.6rem + var(--safe-b));
}

/* Header */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.brand-title {
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
  font-weight: 650;
  letter-spacing: -0.04em;
  text-align: center;
  justify-self: center;
  white-space: nowrap;
}

.brand-mark {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  justify-self: start;
  opacity: 0.95;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-icon:hover {
  background: rgba(226, 179, 74, 0.1);
  border-color: rgba(226, 179, 74, 0.45);
  color: var(--gold);
}

.btn-icon.active {
  border-color: rgba(226, 179, 74, 0.5);
  background: rgba(226, 179, 74, 0.12);
  color: var(--gold);
}

.btn-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.alert {
  display: none;
  margin-bottom: var(--space);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(217, 123, 104, 0.1);
  color: #f0b4a8;
  border: 1px solid rgba(217, 123, 104, 0.32);
  font-size: 0.84rem;
}

.alert.show { display: block; }

.block { margin-bottom: var(--space-lg); }

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.block-head h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 550;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.block-head span {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.empty {
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.table-scroll {
  overflow: auto;
  max-height: calc(2.55rem + 4 * 2.85rem);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.8rem;
}

th {
  text-align: left;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 500;
}

td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(140, 160, 185, 0.08);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(226, 179, 74, 0.03); }

.r { text-align: right; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

@media (max-width: 640px) {
  header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 0.45rem;
    margin-bottom: 1rem;
  }
  .brand-mark,
  .brand-title,
  .header-actions {
    justify-self: center;
  }
}
