/* ================================================================
   Cotacoes Rural — Dashboard Styles v3 (with gauges)
   ================================================================ */

:root {
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", ui-serif, Georgia, "Times New Roman", Times, serif;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
  --bg-body: #080b10;
  --bg-body-gradient: radial-gradient(ellipse 80% 60% at 20% 0%, rgba(30,50,80,0.25) 0%, transparent 70%),
                      radial-gradient(ellipse 60% 50% at 80% 100%, rgba(40,20,60,0.15) 0%, transparent 70%),
                      #080b10;
  --bg-header: rgba(10, 14, 20, 0.88);
  --bg-panel: rgba(16, 20, 28, 0.92);
  --bg-panel-header: rgba(255, 255, 255, 0.02);
  --bg-table-header: rgba(255, 255, 255, 0.04);
  --bg-table-hover: rgba(255, 255, 255, 0.025);
  --bg-statusbar: rgba(8, 11, 16, 0.95);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #3d444d;

  --border-primary: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.035);

  --color-up: #2dd272;
  --color-down: #f85149;
  --color-flat: #6e7681;

  --accent-kc: #d4943c;
  --accent-rc: #3ecf6e;
  --accent-fx: #58a6ff;
  --accent-wdo: #2dd4bf;

  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: 20px;

  --shadow-panel: 0 2px 20px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255,255,255,0.05) inset;
  --flash-up: rgba(45, 210, 114, 0.18);
  --flash-down: rgba(248, 81, 73, 0.18);

  --logo-bg: linear-gradient(135deg, rgba(212,148,60,0.16), rgba(62,207,110,0.14));
  --summary-bg: rgba(255, 255, 255, 0.025);
  --noise-opacity: 0.03;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg-body: #f6f3ee;
  --bg-body-gradient: radial-gradient(ellipse 80% 50% at 15% 0%, rgba(210,180,130,0.18) 0%, transparent 65%),
                      radial-gradient(ellipse 60% 50% at 85% 100%, rgba(150,200,160,0.12) 0%, transparent 65%),
                      #f6f3ee;
  --bg-header: rgba(255, 255, 255, 0.82);
  --bg-panel: rgba(255, 255, 255, 0.72);
  --bg-panel-header: rgba(0, 0, 0, 0.015);
  --bg-table-header: rgba(0, 0, 0, 0.025);
  --bg-table-hover: rgba(0, 0, 0, 0.015);
  --bg-statusbar: rgba(240, 236, 228, 0.95);

  --text-primary: #17191c;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  --border-primary: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);

  --color-up: #059669;
  --color-down: #dc2626;
  --color-flat: #6b7280;

  --accent-kc: #92642c;
  --accent-rc: #16a34a;
  --accent-fx: #2563eb;
  --accent-wdo: #0f766e;

  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-blur: 14px;

  --shadow-panel: 0 2px 16px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0,0,0,0.03);
  --flash-up: rgba(5, 150, 105, 0.12);
  --flash-down: rgba(220, 38, 38, 0.1);

  --logo-bg: linear-gradient(135deg, rgba(146,100,44,0.12), rgba(22,163,74,0.10));
  --summary-bg: rgba(0, 0, 0, 0.02);
  --noise-opacity: 0.015;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; -webkit-text-size-adjust: 100%; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg-body-gradient);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Subtle noise overlay (no external assets) */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  z-index: 9999;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 62px;
  background: var(--bg-header);
  backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border-primary);
  z-index: 100;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

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

.header__logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--logo-bg);
  border: 1px solid var(--border-primary);
  color: var(--accent-kc);
  font-weight: 700;
  font-size: 18px;
  transition: all var(--transition);
}

.header__brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header__title {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Last update indicator */
.header__update {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding-right: 14px;
  border-right: 1px solid var(--border-primary);
}

.header__update-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.header__update-time {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.header__update.pulse .header__update-time {
  color: var(--color-up);
}

/* Theme toggle */
.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}

.theme-btn:hover {
  background: var(--bg-table-header);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Connection status */
.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-primary);
  background: transparent;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: all var(--transition);
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.4s;
}

.conn-status.connected { color: var(--color-up); border-color: rgba(45,210,114,0.2); }
.conn-status.connected .conn-dot {
  background: var(--color-up);
  box-shadow: 0 0 6px var(--color-up);
  animation: pulse-dot 2s ease-in-out infinite;
}

.conn-status.offline { color: var(--color-down); }
.conn-status.offline .conn-dot { background: var(--color-down); }
.conn-status.connecting { color: var(--text-muted); }
.conn-status.connecting .conn-dot { background: var(--text-muted); }
.conn-status.demo { color: var(--text-secondary); border-color: rgba(255,255,255,0.12); }
[data-theme="light"] .conn-status.demo { border-color: rgba(0,0,0,0.10); }
.conn-status.demo .conn-dot { background: var(--text-secondary); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px rgba(45, 210, 114, 0.3); }
  50%      { box-shadow: 0 0 14px rgba(45, 210, 114, 0.6); }
}

.header__clock {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 72px;
  text-align: right;
  letter-spacing: -0.01em;
}

/* ===== DASHBOARD GRID ===== */
.dashboard {
  flex: 1;
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Watermark area (inside arabica panel) */
.watermark-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: visible;
  margin-top: -28px;
}

.watermark-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transform: rotate(-22deg);
  user-select: none;
}

.watermark {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(60px, 9vw, 140px);
  letter-spacing: 0.06em;
  white-space: nowrap;
  line-height: 1;
}

.watermark-sub {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(16px, 2.5vw, 32px);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.watermark-info {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(11px, 1.5vw, 20px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-top: 2px;
}

.watermark-tel {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(10px, 1.2vw, 16px);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.watermark-sep {
  margin: 0 4px;
}

.whatsapp-link {
  color: #25d366;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
  transition: color 0.2s, text-shadow 0.2s;
  position: relative;
  text-shadow: 0 0 6px rgba(37, 211, 102, 0.2);
}

.whatsapp-link:hover {
  color: #2be86f;
  text-shadow: 0 0 12px rgba(37, 211, 102, 0.5);
}

[data-theme="dark"] .watermark,
[data-theme="dark"] .watermark-sub {
  color: rgba(255, 255, 255, 0.14);
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .watermark-info,
[data-theme="dark"] .watermark-tel {
  color: rgba(255, 255, 255, 0.25);
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .watermark,
[data-theme="light"] .watermark-sub {
  color: rgba(0, 0, 0, 0.10);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .watermark-info,
[data-theme="light"] .watermark-tel {
  color: rgba(0, 0, 0, 0.18);
  text-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

.right-stack {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  overflow: hidden;
  min-height: 0;
}

/* ===== PANEL ===== */
.panel {
  position: relative;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  display: flex;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  animation: panel-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  min-height: 0;
}

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

.panel--arabica  { animation-delay: 0.05s; }
.panel--dolar    { animation-delay: 0.1s; }
.panel--wdo      { animation-delay: 0.15s; }
.panel--robusta  { animation-delay: 0.2s; }

/* Left accent bar */
.panel__accent {
  width: 4px;
  flex-shrink: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}

.panel--arabica .panel__accent  { background: linear-gradient(180deg, var(--accent-kc), rgba(212,148,60,0.3)); }
.panel--robusta .panel__accent  { background: linear-gradient(180deg, var(--accent-rc), rgba(62,207,110,0.3)); }
.panel--dolar   .panel__accent  { background: linear-gradient(180deg, var(--accent-fx), rgba(88,166,255,0.3)); }
.panel--wdo     .panel__accent  { background: linear-gradient(180deg, var(--accent-wdo), rgba(45,212,191,0.28)); }

.panel__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel__title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel__tag {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 6px;
}

.tag--kc  { color: var(--accent-kc);  background: rgba(212,148,60,0.1); }
.tag--rc  { color: var(--accent-rc);  background: rgba(62,207,110,0.1); }
.tag--fx  { color: var(--accent-fx);  background: rgba(88,166,255,0.1); }
.tag--wdo { color: var(--accent-wdo); background: rgba(45,212,191,0.10); }

.panel__exchange {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.panel__flag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  letter-spacing: 0.04em;
}

/* ===== CHART AREA ===== */
.panel__chart-area {
  height: 120px;
  padding: 6px 14px 2px;
  position: relative;
  flex-shrink: 0;
}

.panel__chart-area--sm { height: 90px; }

.panel__chart-area canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-overlay {
  position: absolute;
  top: 10px;
  right: 18px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== SUMMARY (R$/saca) ===== */
.panel__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--summary-bg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.summary__main {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.summary__currency {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 18px;
  color: var(--text-secondary);
}

.summary__price {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 38px;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
  transition: color 0.3s;
}

.summary__unit {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ===== GAUGES (Indicadores Tecnicos) ===== */
.gauges-section {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.gauges-section__title {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-left: 6px;
}

.gauges-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
}

.gauge-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0;
}

.gauge-canvas {
  width: 100%;
  height: 180px;
  display: block;
}

.gauge-label {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  margin-top: -2px;
  text-align: center;
  min-height: 18px;
  line-height: 18px;
}

.gauge-label.text-up   { color: var(--color-up); }
.gauge-label.text-down { color: var(--color-down); }
.gauge-label.text-flat { color: var(--color-flat); }

/* ===== QUOTE TABLE ===== */
.table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
}

.quote-table th {
  background: var(--bg-table-header);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-primary);
}

.quote-table th.col-left { text-align: left; }

.quote-table td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 18px;
  transition: color 0.2s;
}

.quote-table td.col-left {
  text-align: left;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
}

.quote-table td.col-last {
  font-weight: 700;
  font-size: 22px;
}

.quote-table tbody tr { transition: background 0.15s; }
.quote-table tbody tr:hover { background: var(--bg-table-hover); }
.quote-table tbody tr:last-child td { border-bottom: none; }

/* Vencimento dots */
.venc-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.panel--arabica .dot--1 { background: var(--accent-kc); }
.panel--arabica .dot--2 { background: rgba(212,148,60,0.6); }
.panel--arabica .dot--3 { background: rgba(212,148,60,0.35); }

.panel--robusta .dot--1 { background: var(--accent-rc); }
.panel--robusta .dot--2 { background: rgba(62,207,110,0.6); }
.panel--robusta .dot--3 { background: rgba(62,207,110,0.35); }

/* Min/Max columns */
.quote-table td[data-field="low"],
.quote-table td[data-field="high"] {
  font-size: 15px;
  color: var(--text-secondary);
}

/* Change colors */
.col-change { font-weight: 600; font-size: 16px !important; }
.col-change.text-up   { color: var(--color-up) !important; }
.col-change.text-down { color: var(--color-down) !important; }
.col-change.text-flat { color: var(--color-flat) !important; }

/* Flash animation */
@keyframes flash-green {
  0%   { background-color: var(--flash-up); }
  100% { background-color: transparent; }
}
@keyframes flash-red {
  0%   { background-color: var(--flash-down); }
  100% { background-color: transparent; }
}

.quote-table tr.flash-up   { animation: flash-green 700ms ease-out; }
.quote-table tr.flash-down { animation: flash-red 700ms ease-out; }

/* ===== DOLAR GRID ===== */
.dolar-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1fr 1fr;
  padding: 14px 0;
}

.dolar-cell {
  padding: 2px 16px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dolar-cell:last-child { border-right: none; }

.dolar-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.dolar-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 20px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.dolar-value--big {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dolar-value.text-up   { color: var(--color-up); }
.dolar-value.text-down { color: var(--color-down); }

/* ===== STATUS BAR ===== */
.statusbar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-statusbar);
  border-top: 1px solid var(--border-primary);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

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

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

.statusbar__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.statusbar__dot.connected { background: var(--color-up); }
.statusbar__sep { color: var(--border-primary); }

.statusbar__clock {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 12px;
}

/* ===== RESPONSIVE ===== */

/* ---------- TABLET (<=1024px) ---------- */
@media (max-width: 1024px) {
  body { overflow: auto; overflow-x: hidden; }

  .dashboard {
    grid-template-columns: 1fr;
    overflow: visible;
    padding: 6px;
    gap: 6px;
    height: auto;
    flex: none;
  }

  .right-stack {
    grid-template-rows: auto auto auto;
    overflow: visible;
    height: auto;
  }

  /* Panels need auto height, not flex shrink */
  .panel {
    overflow: visible;
    min-height: auto;
  }

  .panel__content {
    overflow: visible;
  }

  .summary__price { font-size: 32px; }
  .dolar-value--big { font-size: 28px; }
}

/* ---------- MOBILE (<=640px) ---------- */
@media (max-width: 640px) {
  /* --- HEADER: compact --- */
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }

  .header__brand {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .header__logo {
    width: 34px;
    height: 34px;
    font-size: 14px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .header__title { font-size: 16px; }

  .header__subtitle {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
  }

  .header__actions {
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .header__update { display: none; }

  .header__clock {
    font-size: 13px;
    min-width: auto;
  }

  .conn-status {
    padding: 3px 8px;
    font-size: 10px;
    gap: 5px;
  }

  .conn-label { display: none; }
  .conn-dot { width: 8px; height: 8px; }

  .theme-btn {
    width: 30px;
    height: 30px;
  }

  .theme-btn svg {
    width: 14px;
    height: 14px;
  }

  /* --- DASHBOARD: full scroll --- */
  .dashboard {
    padding: 4px;
    gap: 4px;
  }

  /* --- PANELS: allow natural height --- */
  .panel {
    border-radius: 10px;
  }

  .panel__accent { width: 3px; }

  .panel__header {
    padding: 6px 10px;
  }

  .panel__tag {
    font-size: 11px;
    padding: 3px 7px;
  }

  .panel__exchange { font-size: 9px; }

  .panel__flag {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* --- HIDE: Gauges, Robusta chart, Dolar panel on mobile --- */
  .gauges-section { display: none !important; }
  .panel--robusta .panel__chart-area { display: none !important; }
  .panel--dolar { display: none !important; }

  /* --- CHART (only Arabica visible) --- */
  .panel__chart-area {
    height: 70px;
    padding: 4px 8px 2px;
  }

  .chart-overlay {
    font-size: 8px;
    top: 6px;
    right: 10px;
  }

  /* --- SUMMARY (R$/saca) --- */
  .panel__summary {
    padding: 4px 10px;
  }

  .summary__currency { font-size: 14px; }
  .summary__price { font-size: 26px; }
  .summary__unit { font-size: 9px; }

  /* --- TABLES: fit screen --- */
  .table-wrap {
    overflow: visible;
  }

  .quote-table {
    width: 100%;
    min-width: 0;
  }

  .quote-table th {
    font-size: 8px;
    padding: 4px 3px;
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  .quote-table td {
    padding: 6px 3px;
    font-size: 12px;
  }

  .quote-table td.col-left {
    font-size: 10px;
    padding-left: 6px;
  }

  .quote-table td.col-last {
    font-size: 15px;
  }

  .col-change {
    font-size: 10px !important;
  }

  /* Hide Fechamento column on mobile (keep Min/Max visible) */
  .quote-table th:nth-child(6),
  .quote-table td:nth-child(6) {
    display: none;
  }

  .quote-table td[data-field="low"],
  .quote-table td[data-field="high"] {
    font-size: 11px;
    color: var(--text-secondary);
  }

  .venc-dot {
    width: 5px;
    height: 5px;
    margin-right: 3px;
  }

  /* --- DOLAR GRID: 2x2 --- */
  .dolar-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 8px 0;
  }

  .dolar-cell {
    border-right: none;
    padding: 3px 10px;
  }

  .dolar-cell:nth-child(1),
  .dolar-cell:nth-child(2) {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
  }

  .dolar-cell:nth-child(3),
  .dolar-cell:nth-child(4) {
    padding-top: 4px;
  }

  .dolar-cell:nth-child(odd) {
    border-right: 1px solid var(--border-subtle);
  }

  .dolar-label { font-size: 8px; margin-bottom: 2px; }
  .dolar-value { font-size: 15px; }
  .dolar-value--big { font-size: 22px; }

  /* --- WATERMARK: compact --- */
  .watermark-area {
    margin-top: -4px;
    min-height: 50px;
  }

  .watermark {
    font-size: clamp(24px, 10vw, 44px);
  }

  .watermark-sub {
    font-size: clamp(8px, 2.5vw, 13px);
  }

  .watermark-info {
    font-size: clamp(7px, 2vw, 10px);
  }

  .watermark-tel {
    font-size: clamp(6px, 1.8vw, 9px);
  }

  .watermark-block {
    transform: rotate(-16deg);
  }

  /* --- STATUS BAR --- */
  .statusbar {
    height: 24px;
    padding: 0 8px;
    font-size: 9px;
    flex-shrink: 0;
  }

  .statusbar__left { gap: 4px; }
  .statusbar__right { gap: 6px; }
  .statusbar__clock { font-size: 10px; }
  .statusbar__sep,
  #ws-url { display: none; }

  /* Market closed: keep readable on mobile */
  .panel--market-closed {
    opacity: 0.7;
  }
}

/* ---------- VERY SMALL (<=380px) ---------- */
@media (max-width: 380px) {
  .header__subtitle { display: none; }
  .header__title { font-size: 14px; }

  .summary__price { font-size: 22px; }
  .summary__currency { font-size: 12px; }

  .gauge-canvas { height: 70px; }
  .gauge-label { font-size: 7px; }
  .gauge-title { font-size: 6px; }

  .dolar-value--big { font-size: 18px; }
  .dolar-value { font-size: 13px; }

  .quote-table td { font-size: 11px; padding: 5px 2px; }
  .quote-table td.col-last { font-size: 13px; }
  .quote-table th { font-size: 7px; padding: 3px 2px; }

  /* Hide Min/Max on very small screens (Fechamento already hidden) */
  .quote-table th:nth-child(4),
  .quote-table td:nth-child(4),
  .quote-table th:nth-child(5),
  .quote-table td:nth-child(5) {
    display: none;
  }
}

/* ===== MARKET CLOSED ===== */
.panel--market-closed {
  opacity: 0.7;
}

.panel--market-closed .panel__accent {
  background: var(--text-muted) !important;
}

/* Badge "FECHADA" inside the panel header — never blocks content */
.panel--market-closed .panel__flag::after {
  content: " FECHADA";
  color: var(--color-down);
  font-weight: 800;
  letter-spacing: 0.04em;
  animation: glow-red 2s ease-in-out infinite;
}

@keyframes glow-red {
  0%, 100% {
    text-shadow: 0 0 4px rgba(248, 81, 73, 0.3), 0 0 8px rgba(248, 81, 73, 0.15);
  }
  50% {
    text-shadow: 0 0 8px rgba(248, 81, 73, 0.6), 0 0 20px rgba(248, 81, 73, 0.3), 0 0 30px rgba(248, 81, 73, 0.1);
  }
}

/* ===== SAFE AREA (iPhone notch) ===== */
@supports (padding: env(safe-area-inset-top)) {
  .header { padding-top: max(8px, env(safe-area-inset-top)); }
  .statusbar {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    height: calc(28px + env(safe-area-inset-bottom));
  }
  .dashboard {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
}

/* ===== SCROLLBAR ===== */
[data-theme="dark"] ::-webkit-scrollbar { width: 5px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
