:root {
  --bg-page: #1c1c1e;
  --bg-panel: #6b7055;
  --bg-panel-darker: #5d6349;
  --text-cream: #f0ead6;
  --text-cream-dim: rgba(240, 234, 214, 0.6);
  --text-cream-muted: rgba(240, 234, 214, 0.4);
  --accent-1: #c8c3a7;
  --accent-2: #a8a47e;
  --accent-3: #8a8660;
  --status-ok: #a8c686;
  --status-warning: #d4a843;
  --status-critical: #c65d5d;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 18px;
  --radius-sm: 10px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-cream);
  min-height: 100vh;
  padding: 24px;
}

/* Connection indicator */
.connection-dot {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--status-critical);
  z-index: 100;
}

.connection-dot.connected {
  background: var(--status-ok);
}

/* Page title */
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
  text-transform: uppercase;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.tab-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  background: var(--bg-panel-darker);
  color: var(--text-cream-muted);
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  color: var(--text-cream-dim);
}

.tab-btn.active {
  background: var(--bg-panel);
  color: var(--text-cream);
}

.tab-content.hidden {
  display: none;
}

/* History view */
.history-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.history-controls label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-cream-dim);
}

.history-controls select {
  background: var(--bg-panel-darker);
  border: 1px solid rgba(240, 234, 214, 0.2);
  border-radius: 6px;
  color: var(--text-cream);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}

.history-controls select:focus {
  border-color: var(--text-cream-dim);
}

.history-chart-panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  height: 400px;
  position: relative;
}

.history-chart-panel canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Dashboard grid: 3 columns, 2 rows */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  grid-template-rows: auto auto;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Panel base */
.panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 0;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-cream);
  margin-bottom: 12px;
}

/* Boiler Temp panel */
.panel-boiler {
  position: relative;
  display: flex;
  flex-direction: column;
}

.boiler-readouts {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 8px;
}

.boiler-value {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-cream);
}

.boiler-value .unit {
  font-size: 22px;
  font-weight: 400;
}

.boiler-setpoint {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: rgba(240, 234, 214, 0.5);
}

.boiler-setpoint .unit {
  font-size: 13px;
}

.boiler-chart-wrap {
  flex: 1;
  min-height: 80px;
  position: relative;
}

.boiler-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Status coloring */
.status-ok .boiler-value { color: var(--text-cream); }
.status-warning .boiler-value { color: var(--status-warning); }
.status-critical .boiler-value { color: var(--status-critical); }

/* Shots Pulled panel (doughnut) */
.panel-shots {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel-shots canvas {
  max-width: 200px;
  max-height: 200px;
}

/* Shot Profile panel (3 mini charts) */
.panel-profile {
  display: flex;
  flex-direction: column;
}

.mini-charts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  flex: 1;
}

.mini-chart {
  position: relative;
  display: flex;
  flex-direction: column;
}

.mini-chart-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text-cream);
  background: var(--bg-panel-darker);
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-block;
  align-self: center;
}

.mini-chart-wrap {
  flex: 1;
  min-height: 80px;
  position: relative;
}

.mini-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-cream-dim);
  font-family: var(--font-mono);
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-line-solid {
  display: inline-block;
  width: 20px;
  height: 2px;
  background: var(--text-cream);
}

.legend-line-dashed {
  display: inline-block;
  width: 20px;
  height: 0;
  border-top: 2px dashed var(--text-cream);
}

/* Recipe panel */
.panel-recipe {
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}

.recipe-display {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.recipe-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-cream-dim);
  min-width: 70px;
}

.recipe-pill {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  padding: 6px 16px;
  background: var(--bg-panel-darker);
  border-radius: var(--radius-sm);
  color: var(--text-cream);
  text-transform: uppercase;
}

/* Recipe edit form (hidden by default) */
.recipe-edit {
  display: none;
}

.recipe-edit.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recipe-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-edit-row label {
  font-size: 12px;
  color: var(--text-cream-dim);
  min-width: 70px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-edit-row input {
  flex: 1;
  background: var(--bg-panel-darker);
  border: 1px solid rgba(240, 234, 214, 0.2);
  border-radius: 6px;
  color: var(--text-cream);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 6px 10px;
  outline: none;
  -moz-appearance: textfield;
}

.recipe-edit-row input::-webkit-inner-spin-button,
.recipe-edit-row input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.recipe-edit-row input:focus {
  border-color: var(--text-cream-dim);
}

.recipe-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-save, .btn-cancel {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-save {
  background: var(--accent-1);
  color: var(--bg-panel-darker);
}

.btn-save:hover { opacity: 0.85; }

.btn-cancel {
  background: transparent;
  border: 1px solid rgba(240, 234, 214, 0.3);
  color: var(--text-cream-dim);
}

.btn-cancel:hover { opacity: 0.85; }

/* Shot Log panel */
.panel-log {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shot-log-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
}

.shot-log-scroll::-webkit-scrollbar {
  width: 6px;
}

.shot-log-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.shot-log-scroll::-webkit-scrollbar-thumb {
  background: var(--text-cream-muted);
  border-radius: 3px;
}

.shot-log-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-cream-dim);
}

.shot-log-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  table-layout: fixed;
}

.shot-log-table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-cream-dim);
  padding: 0 8px 10px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(240, 234, 214, 0.15);
}

.shot-log-table tbody td {
  padding: 6px 8px;
  color: var(--text-cream);
  border: none;
}

.shot-log-table tbody tr:first-child td {
  padding-top: 10px;
}

.shot-log-empty {
  text-align: center;
  padding: 24px 0;
  color: var(--text-cream-muted);
  font-size: 12px;
  font-style: italic;
}

/* Shot Accuracy panel */
.panel-accuracy {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.accuracy-value {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 16px;
  color: var(--text-cream);
}

.accuracy-gauge {
  width: 100%;
  max-width: 180px;
  height: 24px;
  background: var(--bg-panel-darker);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}

.accuracy-gauge-fill {
  height: 100%;
  background: var(--accent-1);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.accuracy-gauge-ticks {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-evenly;
  pointer-events: none;
}

.accuracy-gauge-ticks span {
  width: 1px;
  height: 100%;
  background: rgba(0, 0, 0, 0.15);
}

.accuracy-subtitle {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-cream-dim);
}

/* CPU temperature */
.cpu-temp {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-cream-muted);
  margin-bottom: 8px;
}

/* Auth button */
.auth-btn {
  background: var(--bg-panel-darker);
  border: 1px solid rgba(240, 234, 214, 0.2);
  color: var(--text-cream-muted);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  padding: 2px 8px;
  border-radius: 3px;
  vertical-align: middle;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-btn:hover {
  border-color: var(--status-warning);
  color: var(--status-warning);
}

.auth-btn.authenticated {
  border-color: var(--status-warning);
  color: var(--status-warning);
}

.auth-btn.authenticating {
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.3; }
  to { opacity: 0.7; }
}

/* Auth modal */
.auth-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.auth-modal.active {
  display: flex;
}

.auth-modal-content {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 28px 32px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-modal-content h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-cream);
  margin: 0;
}

.auth-modal-content input {
  background: var(--bg-panel-darker);
  border: 1px solid rgba(240, 234, 214, 0.2);
  border-radius: 6px;
  color: var(--text-cream);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
}

.auth-modal-content input:focus {
  border-color: var(--text-cream-dim);
}

.auth-error {
  color: var(--status-critical);
  font-size: 12px;
  min-height: 16px;
}

/* Errors tab */
.errors-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.errors-controls label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-cream-dim);
}

.errors-controls select {
  background: var(--bg-panel-darker);
  border: 1px solid rgba(240, 234, 214, 0.2);
  border-radius: 6px;
  color: var(--text-cream);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}

.errors-controls select:focus {
  border-color: var(--text-cream-dim);
}

.errors-panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.error-log-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  table-layout: fixed;
}

.error-log-table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-cream-dim);
  padding: 0 8px 10px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(240, 234, 214, 0.15);
}

.error-log-table thead th:nth-child(1) { width: 16%; }
.error-log-table thead th:nth-child(2) { width: 9%; }
.error-log-table thead th:nth-child(3) { width: 22%; }
.error-log-table thead th:nth-child(4) { width: 46%; }
.error-log-table thead th:nth-child(5) { width: 7%; }

.error-log-table tbody td {
  padding: 6px 8px;
  color: var(--text-cream);
  border: none;
  word-break: break-word;
}

.error-log-table tbody tr:first-child td {
  padding-top: 10px;
}

.error-log-scroll {
  max-height: 600px;
  overflow-y: auto;
}

.error-log-scroll::-webkit-scrollbar {
  width: 6px;
}

.error-log-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.error-log-scroll::-webkit-scrollbar-thumb {
  background: var(--text-cream-muted);
  border-radius: 3px;
}

.error-log-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-cream-dim);
}

.error-message {
  color: var(--text-cream-dim);
}

.error-level-critical { color: var(--status-critical); font-weight: 700; }
.error-level-error    { color: var(--status-critical); }
.error-level-warn     { color: var(--status-warning); }
.error-level-info     { color: var(--text-cream-dim); }

/* Responsive: single column below 960px */
@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .mini-charts {
    grid-template-columns: 1fr;
  }
}
