/* ── Design system: WattVision ── */
:root {
  --bg:        #121212;
  --surface:   #1e1e1e;
  --border:    #2c2c2e;
  --border-hover: #3a3a3c;

  --cyan:      #00e5ff;
  --cyan-dim:  rgba(0, 229, 255, 0.15);
  --cyan-glow: rgba(0, 229, 255, 0.35);
  --green:     #32d74b;
  --green-dim: rgba(50, 215, 75, 0.15);
  --red:       #ff453a;
  --red-dim:   rgba(255, 69, 58, 0.15);
  --red-border: rgba(255, 69, 58, 0.40);

  --text:      #ffffff;
  --text-muted:#98989d;

  --radius-card: 16px;
  --radius-btn:  8px;
  --radius-pill: 9999px;

  --font:  'Inter', ui-sans-serif, system-ui, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, monospace;

  --fast:  150ms;
  --ease:  cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ── Header ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.live-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-live 2s ease-in-out infinite;
}

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

.header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.header-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Workspace ── */
.workspace {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── KPI row ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1;
}

/* ── Map card ── */
.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.map-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.btn-clear {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 4px 12px;
  cursor: pointer;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.btn-clear:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.btn-clear:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Map container ── */
.map-container {
  position: relative;
  width: 100%;
  height: 280px;
  background: #0a0a0a;
}

#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── SVG marker ── */
.map-marker {
  position: absolute;
  width: 24px;
  height: 24px;
  top: 0;
  left: 0;
  pointer-events: none;
  display: none;
}

.map-marker.visible { display: block; }

.marker-ring {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.5;
  opacity: 0.5;
  animation: marker-pulse 1.8s ease-in-out infinite;
}

.marker-dot {
  fill: var(--cyan);
  filter: drop-shadow(0 0 4px var(--cyan));
}

@keyframes marker-pulse {
  0%, 100% { r: 10; opacity: 0.5; }
  50%       { r: 13; opacity: 0.15; }
}

/* ── Map empty state ── */
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.map-empty svg { opacity: 0.3; }
.map-empty.hidden { display: none; }

/* ── Controls card ── */
.controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn-primary {
  flex: 1;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  height: 40px;
  cursor: pointer;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.30; cursor: not-allowed; }
.btn-primary.loading { animation: btn-blink 1s ease-in-out infinite; }

@keyframes btn-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.btn-secondary {
  flex: 1;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  height: 40px;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
  white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) { background: var(--cyan-dim); }
.btn-secondary:disabled { opacity: 0.30; cursor: not-allowed; }

.btn-danger {
  flex: 0 0 auto;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  height: 40px;
  padding: 0 16px;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
  white-space: nowrap;
}

.btn-danger:hover:not(:disabled) { background: var(--red-dim); }
.btn-danger:disabled { opacity: 0.30; cursor: not-allowed; }

.controls-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.controls-hint strong { color: var(--text); font-weight: 600; }

/* ── Data card ── */
.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.data-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--border);
  color: var(--text-muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.status-badge.active { background: var(--green-dim); color: var(--green); }
.status-badge.watching { background: var(--cyan-dim); color: var(--cyan); }
.status-badge.error { background: var(--red-dim); color: var(--red); }

.coords-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coord-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.coord-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 32px;
}

.coord-val {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--cyan);
  flex: 1;
}

.coord-unit {
  font-size: 11px;
  color: var(--text-muted);
}

.maps-link {
  font-size: 12px;
  color: var(--cyan);
  text-decoration: none;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  text-align: right;
  display: block;
}

.maps-link:hover { opacity: 0.75; }

/* ── Alert box ── */
.alert-box {
  background: #3a1c1c;
  border-left: 4px solid var(--red);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--red);
}

.alert-box[hidden] { display: none; }

/* ── Desktop ── */
@media (min-width: 600px) {
  .workspace { padding: 24px 32px 64px; }
  .kpi-value { font-size: 22px; }
  .map-container { height: 360px; }
}
