:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3a;
  --accent:   #4f8ef7;
  --accent2:  #34d399;
  --text:     #e2e8f0;
  --muted:    #8892a4;
  --red:      #f87171;
  --radius:   8px;
  --gap:      16px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select, input[type="text"], input[type="datetime-local"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input:focus {
  border-color: var(--accent);
}

select[multiple] {
  height: auto;
  min-height: 80px;
  padding: 4px;
}

select[multiple] option {
  padding: 3px 6px;
  border-radius: 4px;
}

select[multiple] option:checked {
  background: var(--accent);
  color: #fff;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

button:hover { opacity: 0.85; }

#btn-reset {
  background: var(--border);
  color: var(--muted);
}

/* USER-NAV (Header rechts) */
.user-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-role {
  background: var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  padding: 2px 7px;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 12px;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
  opacity: 1;
}

.btn-admin {
  background: var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  padding: 5px 12px;
  text-decoration: none;
  white-space: nowrap;
}

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

/* LAYOUT */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* DEVICE LIST */
aside#device-list {
  width: 220px;
  min-width: 180px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

#device-list-items {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.device-card:hover {
  border-color: var(--accent);
  background: #1e2333;
}

.device-card.active {
  border-color: var(--accent);
  background: #1e2742;
}

.device-card .sn {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
}

.device-card .meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.device-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.badge-GAN  { background: #1e3a5f; color: #60a5fa; }
.badge-GaMi { background: #1a3a2a; color: #34d399; }

/* DETAIL */
main#detail {
  flex: 1;
  overflow-y: auto;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.placeholder-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.placeholder { color: var(--muted); padding: 12px; text-align: center; }

/* INFO CARD */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* CHART */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-date-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.chart-row {
  display: flex;
  gap: 16px;
  margin-top: 14px;
}

.chart-row-select {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-row-select label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-row-select select[multiple] {
  flex: 1;
  min-height: 130px;
  height: 100%;
}

.chart-row-canvas {
  flex: 1;
  position: relative;
  height: 200px;
}

/* LATEST TABLE */
.latest-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.latest-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

thead th {
  text-align: left;
  padding: 6px 10px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:hover { background: #1e2333; }

tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody td:nth-child(2) {
  font-family: 'Cascadia Code', monospace;
  color: var(--accent2);
}

/* CALIBRATION TOGGLE */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  padding-bottom: 2px;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-label input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-label input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: #fff;
}

/* REPORTS BAR */
.reports-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.reports-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 2px;
}

.reports-separator {
  width: 1px;
  height: 28px;
  background: var(--border);
  align-self: flex-end;
  margin: 0 4px;
}

.btn-report {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-quality {
  background: var(--accent2);
}

.btn-calib {
  background: var(--accent);
}

.btn-report:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
