:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-blue: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-red: #ef4444;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: 80px; /* Space for bottom nav */
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #059669, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--accent-green-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.pulsing {
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

/* Card base */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Tariff Banner */
.tariff-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.tariff-banner.tariff-nt {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 78, 59, 0.3));
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.tariff-banner.tariff-vt {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(120, 53, 15, 0.3));
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.tariff-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 4px;
}

.tariff-nt .tariff-tag {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.tariff-vt .tariff-tag {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.tariff-price {
  font-size: 1.25rem;
  font-weight: 800;
}

.tariff-countdown {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.countdown-val {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* Hero Charging Card */
.hero-card {
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  background: #334155;
  color: #cbd5e1;
  margin-bottom: 14px;
}

.hero-status-pill.charging {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.hero-status-pill.delayed {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.hero-status-pill.waiting {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.action-banner {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

.btn-action-override {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-action-override:active {
  transform: scale(0.96);
}

.btn-action-delay {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.5);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-car-tab {
  transition: all 0.2s ease;
}

.btn-car-tab:active {
  transform: scale(0.97);
}

.btn-car-tab.active {
  background: rgba(59, 130, 246, 0.25) !important;
  border-color: #3b82f6 !important;
  color: white !important;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.hero-power {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 4px;
}

.hero-unit {
  font-size: 1.4rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Phase Grid */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.phase-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
}

.phase-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.phase-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.phase-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Secondary telemetry stats */
.telemetry-row {
  display: flex;
  justify-content: space-around;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.telemetry-row span strong {
  color: var(--text-primary);
}

/* Active Session Card */
.active-session-card {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(180deg, rgba(30, 41, 59, 1), rgba(15, 23, 42, 0.95));
}

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

.session-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.session-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.session-item {
  background: rgba(15, 23, 42, 0.5);
  padding: 10px;
  border-radius: var(--radius-sm);
}

.session-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.session-val {
  font-size: 1.25rem;
  font-weight: 800;
}

/* Form Controls & Toggles */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.control-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.control-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* iOS-style Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #475569;
  transition: .3s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-green);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Current limit dropdown */
.amps-select {
  background: #0f172a;
  color: var(--accent-blue);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.amps-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

/* HDO Timeline Bar */
.hdo-timeline-wrapper {
  margin-top: 12px;
}

.hdo-bar {
  height: 20px;
  border-radius: 10px;
  display: flex;
  overflow: hidden;
  position: relative;
  background: #334155;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.hdo-segment {
  height: 100%;
}

.hdo-segment.nt {
  background: var(--accent-green);
}

.hdo-segment.vt {
  background: var(--accent-amber);
}

.hdo-time-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: #ffffff;
  box-shadow: 0 0 6px #ffffff;
  border-radius: 2px;
}

.hdo-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  transition: all 0.2s ease;
  width: 25%;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  margin-bottom: 3px;
}

.nav-item.active {
  color: var(--accent-green);
}

/* Views display */
.view-tab {
  display: none;
}

.view-tab.active {
  display: block;
}

/* Table styles for history */
.session-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-card-item:hover {
  background: var(--bg-card-hover);
  border-color: #475569;
}

.sci-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sci-middle {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.sci-kwh {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.sci-cost {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-green);
}

.sci-bottom {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

/* Modal for session chart */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
