:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --surface: #08100f;
  --surface-card: #0e1c19;
  --border: #28594d;
  --grid: #203a34;
  --accent: #68e0bd;
  --text-primary: #effcf8;
  --text-secondary: #b7cbc6;
  --text-muted: #88a59d;
  /* Cores das séries validadas no fundo escuro (contraste >= 3:1, separação para daltonismo). */
  --series-temperature: #d95926;
  --series-humidity: #3987e5;
  background: var(--surface);
  color: var(--text-primary);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, #17483d, transparent 38%), var(--surface); }
.shell { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0; }
.eyebrow, .label { color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .14em; }
h1.eyebrow { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.status { margin: 4px 0 0; color: #9fb8b1; font-size: .9rem; }
.current { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 20px 0 28px; padding: 20px 24px; border: 1px solid var(--border); border-radius: 18px; background: #10201dcc; }
.current strong { display: block; margin-top: 8px; font-size: clamp(2.6rem, 9vw, 4.5rem); line-height: 1; }
.humidity { display: block; margin-top: 8px; color: var(--text-secondary); font-size: 1.25rem; }
.humidity b { color: var(--text-primary); font-size: 1.75rem; }
.metadata { display: grid; justify-items: end; gap: 6px; color: var(--text-secondary); text-align: right; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
button { border: 1px solid var(--accent); border-radius: 999px; padding: 10px 18px; color: var(--surface); background: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
button:focus-visible, select:focus-visible, .chart svg:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.range { display: inline-flex; padding: 3px; border: 1px solid var(--grid); border-radius: 999px; background: var(--surface-card); }
.range button { min-width: 52px; padding: 8px 12px; border: 0; color: var(--text-secondary); background: transparent; font-weight: 700; }
.range button:hover { color: var(--text-primary); background: #ffffff0d; }
.range button[aria-pressed="true"] { color: var(--surface); background: var(--accent); }

.charts { position: relative; display: grid; gap: 16px; margin-top: 16px; transition: opacity .2s; }
.charts.loading { opacity: .7; }
.chart { margin: 0; padding: 16px 16px 8px; border: 1px solid var(--grid); border-radius: 14px; background: var(--surface-card); }
.chart figcaption { color: var(--text-primary); font-weight: 700; }
.chart figcaption span { color: var(--text-muted); font-weight: 400; }
.plot { min-height: 170px; margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .grid .baseline { stroke: #2d4d46; }
.chart .grid text, .chart .empty { fill: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; stroke: none; }
.chart .end-dot, .chart .crosshair circle, .chart .dot { stroke: var(--surface-card); stroke-width: 2; }
.chart .end-label { fill: var(--text-primary); font-size: 13px; font-weight: 700; }
.chart .crosshair line { stroke: var(--text-muted); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }

.chart-tooltip { position: absolute; z-index: 1; min-width: 150px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #0b1714f2; box-shadow: 0 8px 24px #0008; pointer-events: none; }
.tooltip-time { margin-bottom: 6px; color: var(--text-muted); font-size: .8rem; }
.tooltip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tooltip-row strong { color: var(--text-primary); }
.tooltip-row span:last-child { color: var(--text-secondary); font-size: .85rem; }
.tooltip-key { width: 12px; height: 2px; border-radius: 1px; }
.tooltip-samples { margin-top: 4px; color: var(--text-muted); font-size: .75rem; }

.network { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.signal rect.on { fill: var(--accent); }
.signal rect.off { fill: #2d4d46; }
.muted { color: var(--text-muted); font-size: .85rem; }

.wifi-choice select { max-width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); background: var(--surface-card); font: inherit; font-size: .9rem; cursor: pointer; }
.wifi-choice select:disabled { opacity: .6; cursor: wait; }
.wifi-feedback { max-width: 320px; color: var(--text-muted); font-size: .8rem; }
.wifi-feedback:empty { display: none; }

.wifi { margin-top: 28px; }
.wifi-panel { min-width: 0; margin: 12px 0 0; padding: 8px 16px; border: 1px solid var(--grid); border-radius: 14px; background: var(--surface-card); }
.wifi-name { overflow-wrap: anywhere; color: var(--text-primary); }
.wifi-text small { color: var(--text-muted); }
.wifi-networks { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.wifi-networks li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--grid); }
.wifi-networks li:last-child { border-bottom: 0; }
.wifi-text { display: grid; flex: 1; min-width: 0; }
.wifi-tag { flex: none; padding: 2px 8px; border: 1px solid var(--grid); border-radius: 999px; color: var(--text-muted); font-size: .75rem; }
.wifi-tag.is-current { border-color: var(--accent); color: var(--accent); }

.data-table { margin-top: 16px; }
.data-table summary { width: fit-content; color: var(--text-secondary); cursor: pointer; }
.data-table .table-wrap { max-height: 360px; margin-top: 12px; overflow: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--grid); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; background: var(--surface-card); }
tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 620px) {
  .shell { width: calc(100% - 32px); padding: 20px 0; }
  .current { align-items: start; flex-direction: column; gap: 12px; margin: 16px 0 20px; padding: 16px; }
  .metadata { justify-items: start; text-align: left; }
  .network { justify-content: flex-start; }
  .wifi { margin-top: 20px; }
  .humidity { font-size: 1.1rem; }
  .humidity b { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  .toolbar { width: 100%; justify-content: space-between; }
  .range button { min-width: 0; padding: 8px 10px; }
  .chart { padding: 12px 8px 4px; }
  .chart figcaption { padding-left: 8px; }
  /* Tabela em cartões: cada linha vira um bloco com rótulo e valor, sem rolagem lateral. */
  .data-table .table-wrap { border: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 12px; padding: 14px 16px; border: 1px solid var(--grid); border-radius: 14px; background: #10201d99; }
  tbody tr:last-child { margin-bottom: 0; }
  td { padding: 0; border: 0; }
  td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--text-muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  td[colspan] { grid-column: 1 / -1; }
}
