:root {
  --bg: #0f172a;
  --panel: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #06b6d4;
  --accent-2: #22c55e;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

body.light-theme {
  --bg: #f8fafc;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accent-2: #10b981;
  --danger: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 10% 20%, rgba(6, 182, 212, 0.08), transparent 25%),
    radial-gradient(circle at 90% 10%, rgba(34, 197, 94, 0.1), transparent 25%),
    var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.light-theme {
  background: radial-gradient(circle at 10% 20%, rgba(14, 165, 233, 0.05), transparent 25%),
    radial-gradient(circle at 90% 10%, rgba(16, 185, 129, 0.08), transparent 25%),
    var(--bg);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.5px;
}

.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 50px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.3s;
}

.theme-toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.theme-toggle input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.theme-toggle input:focus + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-label {
  font-size: 20px;
  line-height: 1;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
}

.upload {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.file-label {
  position: relative;
  overflow: hidden;
  display: inline-block;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  color: var(--text);
  cursor: pointer;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(6, 182, 212, 0.05));
  transition: all 0.2s ease;
}

.file-label:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(6, 182, 212, 0.15);
}

.file-label input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.status {
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.cards {
  margin: 24px 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 22px;
  font-weight: 700;
}

.table-wrapper {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: rgba(255, 255, 255, 0.02);
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
  position: relative;
}

th.sortable:hover {
  color: var(--accent);
}

tfoot {
  background: rgba(255, 255, 255, 0.03) !important;
  font-weight: 600;
  display: table-footer-group;
}

body.light-theme tfoot {
  background: rgba(0, 0, 0, 0.02) !important;
}

tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding: 14px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

h2 {
  margin: 28px 0 12px;
  font-size: 20px;
}

.hidden {
  display: none;
}

.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}

.chart-wrapper {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.chart-wrapper h3 {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--muted);
}

.chart-wrapper canvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.chart-legend {
  color: var(--text);
  font-size: 12px;
}

.table-daily {
  overflow-x: auto;
}

.day-header {
  background: rgba(6, 182, 212, 0.12) !important;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  transition: background 0.2s ease;
}

body.light-theme .day-header {
  background: rgba(14, 165, 233, 0.1) !important;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--accent);
}

.day-header:hover {
  background: rgba(6, 182, 212, 0.18) !important;
}

body.light-theme .day-header:hover {
  background: rgba(14, 165, 233, 0.15) !important;
}

.day-header.accordion-header {
  user-select: none;
}

.day-header td {
  font-weight: 600;
  padding: 16px 14px;
  color: var(--text);
}

.day-header td:first-child {
  font-size: 15px;
  color: var(--accent);
  display: table-cell;
}

.day-header-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.accordion-icon {
  display: inline-block;
  font-size: 10px;
  color: var(--accent);
  transition: transform 0.2s ease;
  width: 16px;
  text-align: center;
  line-height: 1;
  opacity: 0.8;
}

.day-header.expanded .accordion-icon {
  transform: rotate(90deg);
}

.day-device-row {
  background: rgba(255, 255, 255, 0.01);
  transition: background 0.2s ease, opacity 0.2s ease;
}

body.light-theme .day-device-row {
  background: rgba(0, 0, 0, 0.01);
}

.day-device-row:hover {
  background: rgba(6, 182, 212, 0.05) !important;
}

body.light-theme .day-device-row:hover {
  background: rgba(14, 165, 233, 0.05) !important;
}

.accordion-content {
  display: none !important;
}

.accordion-content.visible {
  display: table-row !important;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.device-cell {
  padding-left: 32px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-indent {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  opacity: 0.7;
}

.device-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.day-header td:last-child {
  text-align: right;
}

.day-device-row td:last-child {
  text-align: right;
  font-weight: 500;
}

.positive {
  color: var(--accent-2);
  font-weight: 600;
}

.negative {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 768px) {
  .charts-container {
    grid-template-columns: 1fr;
  }
  
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  th, td {
    padding: 10px 12px;
  }
  
  .device-cell {
    padding-left: 20px !important;
    font-size: 12px;
  }
  
  .device-name {
    font-size: 12px;
  }
  
  .day-header td {
    padding: 12px 10px;
    font-size: 14px;
  }
  
  .day-header td:last-child,
  .day-device-row td:last-child {
    text-align: right;
  }
}

