/* Power Monitor Dashboard - Dark Theme */
:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #222635;
  --border:     #2d3148;
  --text:       #e2e8f0;
  --text-muted: #8892a4;
  --accent:     #6366f1;
  --accent2:    #818cf8;
  --green:      #10b981;
  --yellow:     #f59e0b;
  --red:        #ef4444;
  --blue:       #3b82f6;
  --orange:     #f97316;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo-icon { font-size: 24px; }

.status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  margin-right: 4px;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }

nav { display: flex; gap: 4px; }
nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  transition: all .15s;
}
nav a:hover, nav a.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.page { padding: 28px 24px; max-width: 1400px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Stat cards grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.green::before { background: var(--green); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.orange::before { background: var(--orange); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.stat-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 3px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Device cards */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Pricing breakdown card */
.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.pricing-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.pricing-card-title { font-size: 14px; font-weight: 600; }
.pricing-timestamp  { font-size: 12px; }

.pricing-grid { display: flex; flex-direction: column; gap: 0; }

.pricing-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(45,49,72,.4);
  font-size: 13px;
}
.pricing-row:last-child { border-bottom: none; }

.pricing-name  { font-weight: 500; }
.pricing-desc  { color: var(--text-muted); font-size: 12px; }
.pricing-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pricing-unit  { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.spot-row     { }
.subtotal-row { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; color: var(--text-muted); }
.vat-row      { color: var(--text-muted); }
.final-row    { background: rgba(99,102,241,.08); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 6px; border-bottom: none; }
.final-row .pricing-name  { color: var(--accent2); font-weight: 700; }
.final-value  { color: var(--accent2); font-size: 15px; }

.tariff-row   { color: var(--text-muted); }
.tariff-row .pricing-value { color: var(--text); }

.pricing-fixed-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.pricing-fixed-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .pricing-row {
    grid-template-columns: 1fr auto auto;
  }
  .pricing-desc { display: none; }
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.device-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.device-name { font-size: 16px; font-weight: 600; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .04em;
}
.badge-online  { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.badge-offline { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }

.device-power {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 16px;
}
.device-power .unit { font-size: 18px; font-weight: 400; color: var(--text-muted); }

.device-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.device-stat-item { }
.device-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.device-stat-val   { font-size: 14px; font-weight: 600; }

/* Charts */
.chart-section { margin-bottom: 24px; }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.chart-title { font-size: 15px; font-weight: 600; }

.chart-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.btn-group button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-group button:hover { background: var(--surface2); color: var(--text); }
.btn-group button.active { background: var(--accent); color: #fff; }

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
select:focus { border-color: var(--accent); }

input[type="date"], input[type="month"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}
input[type="date"]:focus, input[type="month"]:focus { border-color: var(--accent); }

.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }

/* Price bar */
.price-banner {
  background: linear-gradient(135deg, #1e1b4b, #1a1d27);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.price-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.price-value { font-size: 22px; font-weight: 700; color: var(--accent2); }
.price-unit  { font-size: 13px; color: var(--text-muted); }
.price-divider { width: 1px; height: 40px; background: var(--border); }

/* Two column layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* Comparison table */
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.compare-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(45,49,72,.6);
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: rgba(255,255,255,.03); }

.pct-bar-wrap { display: flex; align-items: center; gap: 8px; }
.pct-bar { height: 6px; border-radius: 3px; background: var(--accent); min-width: 2px; transition: width .4s; }

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 16px; font-weight: 600; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Responsive */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .page { padding: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 20px; }
  .device-power { font-size: 28px; }
  nav a { padding: 6px 10px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .chart-controls { gap: 6px; }
}

/* Utility */
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }
.mt-4 { margin-top: 4px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
