:root {
  --bg:        #0d0f12;
  --surface:   #151820;
  --border:    #252a35;
  --border-hi: #353d4f;
  --text:      #c8d0de;
  --text-dim:  #5a6478;
  --text-hi:   #edf0f7;
  --accent:    #3b82f6;
  --accent-dim:#1e3a5f;
  --green:     #22c55e;
  --red:       #ef4444;
  --mono:      'Roboto';
  --sans:      'Roboto';
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Top bar ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

header h1 {
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 600;
  color: var(--text-hi);
}

.header-tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 3px;
}

/* ── Main layout ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ── Controls card ── */
.controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px 32px;
  margin-bottom: 36px;
}

.controls-title {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .controls-grid { grid-template-columns: 1fr; }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#sensorGroup {
  display: none; /* shown via JS after box selected */
}

label {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

select {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text-hi);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6478' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color 0.15s;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

select option {
  background: #1e2332;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  padding: 20px 44px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { opacity: 0.88; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-hi);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Result area ── */
#result { animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.error-msg {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--red);
  padding: 14px 18px;
  border: 1px solid #3d1414;
  background: #1c0a0a;
  border-radius: 4px;
}

.loading-msg {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  padding: 14px 0;
}

/* ── Table header row ── */
.table-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}

.table-header h2 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-hi);
}

.table-header h2 span {
  font-family: var(--mono);
  color: var(--accent);
}

.row-count {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ── Data table ── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

thead tr {
  background: var(--surface);
  border-bottom: 1px solid var(--border-hi);
}

th {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #181d28; }

td {
  padding: 12px 16px;
  vertical-align: top;
}

.sensor-num {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.date-cell {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
}

.values-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 14px;
}

.badge strong {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}