/* App-only UI layer for Capacitor builds. Keeps website intact. */
:root {
  --app-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-surface-2: #f8fafc;
  --app-text: #0f172a;
  --app-text-muted: #64748b;
  --app-border: rgba(15, 23, 42, 0.08);
  --app-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --app-radius: 16px;
  --app-radius-sm: 12px;
  --app-electric: #FFD600;
  --app-cheap: #22c55e;
  --app-amber: #f59e0b;
  --app-expensive: #ef4444;
  --app-nav-height: 56px;
}

html.app-mode,
html.app-mode body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--app-font);
}

html.app-mode body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--app-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
}

.app-main,
.app-bottom-nav {
  display: none;
}

html.app-mode .app-main {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
  max-width: 430px;
  margin: 0 auto;
  padding: 16px 16px 12px;
}

html.app-mode .app-bottom-nav {
  display: flex !important;
}

html.app-mode .lang-btn,
html.app-mode footer,
html.app-mode .site-footer,
html.app-mode .content-block,
html.app-mode .seo-content,
html.app-mode .alert-banner,
html.app-mode .breadcrumb,
html.app-mode .cookie-banner,
html.app-mode #cookie-consent-banner,
html.app-mode .footer-inner,
html.app-mode .footer-top,
html.app-mode .footer-live,
html.app-mode .footer-trust,
html.app-mode .footer-grid,
html.app-mode .footer-bottom,
html.app-mode .footer-links,
html.app-mode .footer-col,
html.app-mode .compare-card,
html.app-mode .explain-panel,
html.app-mode .bottom-content,
html.app-mode .tools-tiles,
html.app-mode #page-provider .compare-card,
html.app-mode #page-provider .explain-panel,
html.app-mode #page-provider .bottom-content,
html.app-mode #siteFooter {
  display: none !important;
}

.app-card,
.price-hero,
.avoid-window {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.price-hero {
  padding: 18px 18px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.price-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top center, rgba(255, 214, 0, 0.16), transparent 52%);
  pointer-events: none;
}

.price-hero-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.price-hero-eyebrow {
  font-size: 13px;
  color: var(--app-text-muted);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.price-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  min-height: 28px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #06121f;
  background: rgba(255, 214, 0, 0.9);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.06);
}

.price-badge.cheap { background: rgba(34, 197, 94, 0.16); color: #15803d; }
.price-badge.normal { background: rgba(245, 158, 11, 0.18); color: #b45309; }
.price-badge.expensive { background: rgba(239, 68, 68, 0.16); color: #b91c1c; }

.current-price {
  position: relative;
  z-index: 1;
  font-size: clamp(56px, 18vw, 72px);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--app-text);
}

.price-unit,
.price-time {
  position: relative;
  z-index: 1;
}

.price-unit {
  margin-top: 8px;
  font-size: 15px;
  color: var(--app-text-muted);
}

.price-time {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text);
}

.app-refresh-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-text-muted);
  font-size: 17px;
}

.app-card {
  padding: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--app-text);
}

.price-chart-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.price-chart {
  position: relative;
  height: 170px;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(to top, rgba(255,255,255,0.02), rgba(255,255,255,0.22)),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0.01));
}

.price-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font-size: 11px;
  color: var(--app-text-muted);
}

.best-times-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.time-card {
  padding: 14px 10px;
  border-radius: var(--app-radius-sm);
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
  text-align: center;
}

.time-card-label {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.time-card-value {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--app-text);
}

.time-card-price {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--app-cheap);
}

.avoid-window {
  padding: 16px;
  background: linear-gradient(180deg, rgba(239,68,68,0.08), rgba(239,68,68,0.04)), var(--app-surface);
}

.avoid-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.avoid-icon,
.avoid-title {
  color: var(--app-expensive);
}

.avoid-title {
  font-size: 14px;
  font-weight: 800;
}

.avoid-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--app-text);
}

.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--app-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--app-bg);
  border-top: 1px solid var(--app-border);
  z-index: 10000;
}

.app-bottom-nav .nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--app-text-muted);
  position: relative;
}

.app-bottom-nav .nav-item.active {
  color: var(--app-text);
}

.app-bottom-nav .nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: var(--app-electric);
}

.app-bottom-nav .nav-icon {
  font-size: 18px;
  line-height: 1;
}

.app-bottom-nav .nav-label {
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
}

/* ========== PROVIDER LIST CARDS ========== */
.provider-card {
  background: var(--app-surface, #fff);
  border: 1px solid var(--app-border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.provider-card.best {
  border-color: var(--app-cheap, #22c55e);
  border-width: 2px;
}

.provider-card.worst {
  border-color: var(--app-expensive, #ef4444);
  border-width: 2px;
}

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

.provider-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.provider-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}

.provider-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--app-text);
}

.provider-type {
  font-size: 12px;
  color: var(--app-text-muted);
}

.provider-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.provider-badge.best {
  background: rgba(34,197,94,0.15);
  color: #15803d;
}

.provider-badge.worst {
  background: rgba(239,68,68,0.15);
  color: #b91c1c;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.price-item {
  text-align: center;
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--app-surface-2, #f8fafc);
  border: 1px solid var(--app-border);
}

.price-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-text-muted);
  margin-bottom: 4px;
}

.price-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--app-text);
}

.price-value.cheap { color: var(--app-cheap, #22c55e); }
.price-value.expensive { color: var(--app-expensive, #ef4444); }

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

.provider-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--app-border);
}

.monthly-fee {
  font-size: 13px;
  color: var(--app-text-muted);
}

.monthly-fee strong {
  color: var(--app-text);
}

.view-details {
  font-size: 14px;
  font-weight: 700;
  color: #2563eb;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(37,99,235,0.08);
  transition: background 0.15s;
}

.view-details:active {
  background: rgba(37,99,235,0.15);
}

/* Sort options */
.sort-options {
  display: flex;
  gap: 8px;
}

.sort-option {
  padding: 8px 14px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-2);
  color: var(--app-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.sort-option.active {
  background: var(--app-text);
  color: var(--app-bg);
  border-color: var(--app-text);
}

/* App header for providers page */
.app-header {
  padding: 12px 16px;
  background: var(--app-bg);
}

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

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--app-text);
}

.app-refresh-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-2);
  font-size: 16px;
  cursor: pointer;
}

/* ========== AFFILIATE CTA ========== */
.affiliate-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  margin: 0 16px 16px;
  border-radius: 12px;
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.affiliate-cta:active {
  transform: scale(0.98);
}

.affiliate-cta.best-cta {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
}

.affiliate-cta.best-cta:active {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.affiliate-cta-icon {
  font-size: 16px;
}

.affiliate-cta-text {
  flex: 1;
  text-align: center;
}

/* ========== PROVIDER PAGE FIXES ========== */

/* Hourly table expand arrows: always visible */
button.hour-toggle,
button[data-hour-toggle] {
  border: none !important;
  background: rgba(148,163,184,0.12) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  padding: 0 !important;
}

button.hour-toggle .hour-arrow,
button[data-hour-toggle] .hour-arrow {
  display: inline-block !important;
  color: #64748b !important;
  font-size: 14px !important;
  line-height: 1 !important;
  transition: transform 0.15s !important;
}

/* Force expand column visible on mobile — overrides styles-combined.min.css
   which hides .data-table td.expand-col inside @media (max-width:768px).
   Scoped to .expandable so monthTable (non-expandable) isn't affected. */
@media (max-width: 768px) {
  .data-table.expandable td.expand-col,
  .data-table.expandable th.expand-col {
    display: table-cell !important;
    width: 36px !important;
    padding: 8px 2px !important;
    text-align: right !important;
  }
  .data-table.expandable td:first-child,
  .data-table.expandable th:first-child { width: 30% !important; }
  .data-table.expandable td:nth-child(2),
  .data-table.expandable th:nth-child(2) { width: 20% !important; }
  .data-table.expandable td:nth-child(3),
  .data-table.expandable th:nth-child(3) { width: 16% !important; }
  .data-table.expandable td:nth-child(4),
  .data-table.expandable th:nth-child(4) { width: auto !important; }
  .data-table.expandable button.hour-toggle,
  .data-table.expandable button[data-hour-toggle] {
    width: 24px !important;
    height: 24px !important;
  }
}

/* Quarter rows styling */
.quarter-row td {
  font-size: 12px !important;
  padding: 6px 8px !important;
  color: var(--text-muted, #64748b);
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}

/* ========== HEAT MAP ========== */
.heatmap-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.heatmap-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 360px;
}

.heatmap-row {
  display: flex;
  gap: 2px;
  align-items: center;
}

.heatmap-header {
  margin-bottom: 2px;
}

.heatmap-label {
  width: 32px;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--app-text-muted);
  text-align: right;
  padding-right: 4px;
}

.heatmap-hour {
  flex: 1;
  min-width: 0;
  font-size: 9px;
  color: var(--app-text-muted);
  text-align: center;
}

.heatmap-cell {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 3px;
  min-height: 14px;
  cursor: default;
  transition: transform 0.1s;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 1;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.heatmap-legend-label {
  font-size: 11px;
  color: var(--app-text-muted);
}

.heatmap-legend-bar {
  width: 100px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgb(34,197,94), rgb(245,158,11), rgb(239,68,68));
}

/* ========== ECO BADGE ========== */
.eco-badge-container {
  margin: 6px 0 2px;
  text-align: center;
}

.eco-badge-container[hidden] { display: none; }

.eco-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text-muted);
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
}

.eco-badge.clean {
  color: #15803d;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
}

/* ========== BILL TRACKER ========== */
.bill-card {
  padding: 16px;
}

.bill-card[hidden] { display: none; }

.bill-hero {
  text-align: center;
  padding: 8px 0 12px;
}

.bill-amount {
  font-size: 36px;
  font-weight: 800;
  color: var(--app-text);
  letter-spacing: -0.02em;
}

.bill-sub {
  font-size: 13px;
  color: var(--app-text-muted);
  margin-top: 4px;
}

.bill-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
  overflow: hidden;
  margin: 8px 0;
}

.bill-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--app-cheap), var(--app-amber));
  transition: width 0.5s ease;
}

.bill-projected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--app-text-muted);
}

.bill-projected strong {
  color: var(--app-text);
  font-size: 15px;
}

/* ========== FIX: hide garbled expand arrows from website CSS ========== */
.expand-btn-inline {
  display: none !important;
}
.expand-btn-inline::before {
  content: none !important;
}

/* ========== RUN NOW VS LATER ========== */
.run-now-card {
  padding: 16px;
}

.run-now-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.run-now-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  min-width: 60px;
  flex: 1;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface-2);
  cursor: pointer;
  transition: all 0.15s;
}

.run-now-btn:active,
.run-now-btn.selected {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}

.run-now-icon {
  font-size: 22px;
}

.run-now-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--app-text-muted);
  text-align: center;
  line-height: 1.2;
}

.run-now-result {
  margin-top: 12px;
  animation: contextSlideIn 0.2s ease-out;
}

.run-now-comparison {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.run-now-col {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
}

.run-now-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text-muted);
  margin-bottom: 4px;
}

.run-now-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--app-text);
}

.run-now-price.cheap {
  color: var(--app-cheap);
}

.run-now-arrow {
  font-size: 18px;
  color: var(--app-text-muted);
  flex-shrink: 0;
}

.run-now-savings {
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.savings-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #15803d;
  background: rgba(34, 197, 94, 0.14);
}

.run-now-best {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.1);
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text);
}

.run-now-best-icon {
  font-size: 18px;
}

/* ========== CONTEXT ALERT ========== */
.context-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(245,158,11,0.08));
  border: 1px solid rgba(239,68,68,0.2);
  font-size: 13px;
  line-height: 1.4;
  color: var(--app-text);
  animation: contextSlideIn 0.3s ease-out;
}

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

.context-alert-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.context-alert-text {
  flex: 1;
  min-width: 0;
}

.context-alert-close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--app-text-muted);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.context-alert-close:active {
  background: var(--app-border);
}

@keyframes contextSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== SETTINGS PAGE ========== */
.settings-header {
  padding: 8px 0 4px;
  text-align: center;
}

.settings-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--app-text);
  margin: 0;
  letter-spacing: -0.02em;
}

.settings-section {
  padding: 0;
  overflow: hidden;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-muted);
  padding: 16px 18px 8px;
  margin: 0;
}

.settings-hint {
  font-size: 12px;
  color: var(--app-text-muted);
  padding: 0 18px 10px;
  line-height: 1.4;
  margin: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 6px 18px;
  gap: 12px;
  transition: background 0.1s;
}

.settings-row:active {
  background: rgba(148,163,184,0.04);
}

.settings-row + .settings-row {
  border-top: 1px solid var(--app-border);
  margin-left: 18px;
  padding-left: 0;
}

.settings-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--app-text);
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  gap: 0;
  background: var(--app-surface-2);
  border-radius: 10px;
  padding: 3px;
  margin: 0 18px 14px;
  position: relative;
}

.seg-sm {
  margin: 0;
  width: auto;
}

.seg-btn {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--app-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  position: relative;
  z-index: 1;
}

.seg-btn.active {
  background: var(--app-surface);
  color: var(--app-text);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e2e8f0;
  border-radius: 999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 1px 1px rgba(0,0,0,0.06);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-slider {
  background: #2563eb;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Number Stepper */
.number-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--app-surface-2);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  height: 36px;
}

.step-btn {
  width: 38px;
  height: 36px;
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.step-btn:active {
  background: rgba(37,99,235,0.08);
}

.step-value {
  width: 48px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--app-border);
  border-right: 1px solid var(--app-border);
  background: transparent;
  color: var(--app-text);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  height: 36px;
  -moz-appearance: textfield;
}

.step-value::-webkit-inner-spin-button,
.step-value::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Time Input */
.time-input {
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  height: 36px;
}

/* Widget Radio Cards */
.widget-variants {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 18px 16px;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--app-surface-2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.radio-card:active {
  transform: scale(0.98);
}

.radio-card.active {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.05);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.radio-card input[type="radio"] {
  display: none;
}

.radio-card-content {
  flex: 1;
  min-width: 0;
}

.radio-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--app-text);
  margin-bottom: 2px;
}

.radio-card-desc {
  font-size: 12px;
  color: var(--app-text-muted);
  line-height: 1.3;
}

.radio-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s;
}

.radio-card.active .radio-dot {
  border-color: #2563eb;
  border-width: 2px;
}

.radio-card.active .radio-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #2563eb;
}

/* Action Button */
.settings-action-btn {
  width: calc(100% - 36px);
  margin: 0 18px 16px;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--app-surface-2);
  color: var(--app-expensive);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-action-btn:active {
  background: rgba(239,68,68,0.08);
  transform: scale(0.98);
}

.settings-version {
  padding: 8px 0 20px;
  text-align: center;
  font-size: 12px;
  color: var(--app-text-muted);
  opacity: 0.6;
}

/* ========== GAMIFICATION ========== */
.gamify-card {
  padding: 14px 16px;
}

.gamify-card[hidden] { display: none; }

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

.gamify-streak {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gamify-fire {
  font-size: 20px;
}

.gamify-streak-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--app-text);
  line-height: 1;
}

.gamify-streak-label {
  font-size: 12px;
  color: var(--app-text-muted);
  font-weight: 600;
}

.gamify-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.gamify-stat {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: var(--app-surface-2);
  border-radius: 10px;
}

.gamify-stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--app-cheap);
  line-height: 1.2;
}

.gamify-stat-label {
  font-size: 10px;
  color: var(--app-text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.gamify-progress {
  margin-bottom: 8px;
}

.gamify-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--app-text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.gamify-progress-bar {
  height: 6px;
  background: var(--app-surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.gamify-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--app-cheap), #34d399);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.gamify-share-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}

.gamify-share-btn:active {
  background: rgba(37,99,235,0.08);
}

/* ========== CONTRACT CALCULATOR ========== */
.contract-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contract-form .input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.contract-form label {
  font-size: 14px;
  font-weight: 500;
  color: var(--app-text);
  flex: 1;
}

.contract-form input[type="number"] {
  width: 80px;
  padding: 8px 10px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary:active {
  background: #1d4ed8;
}

.contract-result {
  margin-top: 16px;
}

.contract-result[hidden] { display: none; }

.contract-summary {
  margin-bottom: 16px;
}

.contract-winner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.contract-savings {
  font-size: 18px;
  font-weight: 800;
  color: var(--app-text);
}

.contract-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.contract-total-col {
  padding: 12px;
  border-radius: 12px;
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
  text-align: center;
}

.contract-total-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--app-text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.contract-total-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--app-text);
}

.contract-total-value.highlight {
  color: var(--app-cheap);
}

.contract-total-sub {
  font-size: 11px;
  color: var(--app-text-muted);
  margin-top: 4px;
}

.contract-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contract-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contract-bar-label {
  width: 50px;
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text-muted);
  text-align: right;
  flex-shrink: 0;
}

.contract-bar-pair {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contract-bar {
  height: 8px;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.3s ease;
}

.contract-bar.spot {
  background: var(--app-cheap);
}

.contract-bar.fixed {
  background: var(--app-amber);
}

.contract-data-warning {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  font-size: 12px;
  color: var(--app-text);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* ========== FORECAST ========== */
.forecast-card {
  padding: 16px;
}

.forecast-card[hidden] { display: none; }

.forecast-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.forecast-day {
  display: flex;
  align-items: center;
  gap: 8px;
}

.forecast-label {
  width: 36px;
  font-size: 11px;
  font-weight: 700;
  color: var(--app-text);
  text-align: center;
  flex-shrink: 0;
  line-height: 1.2;
}

.forecast-date {
  font-size: 9px;
  color: var(--app-text-muted);
  font-weight: 600;
}

.forecast-bar-wrap {
  flex: 1;
  height: 16px;
  position: relative;
  background: var(--app-surface-2);
  border-radius: 8px;
  overflow: hidden;
}

.forecast-range {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: linear-gradient(90deg, rgba(34,197,94,0.3), rgba(245,158,11,0.3));
  border-radius: 6px;
}

.forecast-avg {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--app-text);
  border-radius: 2px;
  transform: translateX(-50%);
}

.forecast-price {
  width: 32px;
  font-size: 12px;
  font-weight: 700;
  color: var(--app-text);
  text-align: right;
  flex-shrink: 0;
}

.forecast-conf {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.forecast-conf.high { background: var(--app-cheap); }
.forecast-conf.medium { background: var(--app-amber); }
.forecast-conf.low { background: var(--app-expensive); opacity: 0.6; }

/* ========== WEBHOOK SETTINGS ========== */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 13px;
  font-family: inherit;
}

/* ========== RATE & SHARE ========== */
.rate-share-card {
  border-radius: var(--app-radius, 16px);
  background: linear-gradient(135deg, rgba(37,99,235,0.08), rgba(34,197,94,0.06));
  border: 1px solid rgba(37,99,235,0.15);
  overflow: hidden;
}

.rate-share-card[hidden] { display: none; }

.rate-share-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  position: relative;
}

.rate-share-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text);
  flex: 1;
  min-width: 0;
}

.rate-share-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.rate-share-btn {
  padding: 7px 14px;
  border: none;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.rate-btn {
  background: #2563eb;
  color: #fff;
}

.rate-btn:active {
  background: #1d4ed8;
}

.share-btn {
  background: var(--app-surface-2, #f8fafc);
  color: var(--app-text);
  border: 1px solid var(--app-border);
}

.share-btn:active {
  background: var(--app-border);
}

.rate-share-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--app-text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.rate-share-close:active {
  background: var(--app-border);
}

/* ========== ABOUT & SUPPORT ========== */
.about-app {
  text-align: center;
  padding: 16px 18px 12px;
}

.about-logo {
  margin-bottom: 10px;
}

.about-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--app-text);
  margin-bottom: 4px;
}

.about-desc {
  font-size: 13px;
  color: var(--app-text-muted);
  line-height: 1.4;
}

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

.about-link {
  font-size: 14px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.about-actions {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -18px;
  padding: 0;
}

.about-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: none;
  background: transparent;
  color: var(--app-text);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  width: 100%;
  text-align: left;
}

.about-action-btn:active {
  background: rgba(148,163,184,0.06);
}

.about-action-btn + .about-action-btn {
  border-top: 1px solid var(--app-border);
}

.about-action-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.about-action-text {
  flex: 1;
}

.about-action-arrow {
  color: var(--app-text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* Legal expandable sections */
.legal-expand {
  border-top: 1px solid var(--app-border);
}

.legal-expand summary {
  list-style: none;
}

.legal-expand summary::-webkit-details-marker {
  display: none;
}

.legal-expand[open] .about-action-arrow {
  transform: rotate(180deg);
}

.legal-content {
  padding: 12px 18px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--app-text-muted);
  white-space: pre-line;
  border-top: 1px solid var(--app-border);
}

.about-data-source {
  padding: 10px 18px 16px;
  font-size: 11px;
  color: var(--app-text-muted);
  line-height: 1.4;
  opacity: 0.7;
}

/* ========== AI CHAT ========== */
.ai-chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--app-nav-height, 56px) + env(safe-area-inset-bottom, 0px) + 20px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(37,99,235,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-chat-fab:active {
  transform: scale(0.92);
}

.ai-chat-fab.open {
  display: none !important;
}

.ai-chat-panel {
  position: fixed;
  left: 8px;
  right: 8px;
  top: 140px;
  bottom: 100px;
  border-radius: 20px;
  background: var(--app-surface, #fff);
  border: 1px solid var(--app-border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.25s ease-out;
}

.ai-chat-panel[hidden] { display: none; }

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface-2);
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--app-text);
}

.ai-chat-icon {
  font-size: 18px;
}

.ai-chat-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--app-text-muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-close:active {
  background: var(--app-border);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ai-msg {
  display: flex;
}

.ai-msg.user {
  justify-content: flex-end;
}

.ai-msg.bot {
  justify-content: flex-start;
}

.ai-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-msg.user .ai-msg-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg.bot .ai-msg-bubble {
  background: var(--app-surface-2);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-bottom-left-radius: 4px;
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--app-text-muted);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-chat-chips {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--app-border);
}

.ai-chip {
  padding: 5px 8px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

.ai-chip:active {
  background: rgba(37,99,235,0.1);
  border-color: #2563eb;
}

.ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--app-border);
  background: var(--app-surface);
}

.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface-2);
  color: var(--app-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.ai-chat-input:focus {
  border-color: #2563eb;
}

.ai-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-send:active {
  background: #1d4ed8;
}

.ai-chat-send:disabled {
  opacity: 0.5;
}

@media (max-width: 375px) {
  html.app-mode .app-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .current-price {
    font-size: clamp(48px, 16vw, 64px);
  }

  .best-times-grid {
    gap: 8px;
  }

  .time-card {
    padding: 12px 8px;
  }
}

/* ========== DARK MODE — App Variables ========== */
[data-theme="dark"] {
  --app-bg: #0B0F1A;
  --app-surface: #111827;
  --app-surface-2: #1E293B;
  --app-text: #E2E8F0;
  --app-text-muted: #94A3B8;
  --app-border: rgba(148,163,184,0.12);
  --app-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

[data-theme="dark"] .toggle-slider {
  background: #334155;
}

[data-theme="dark"] .toggle-switch input:checked + .toggle-slider {
  background: #818CF8;
}

[data-theme="dark"] .step-btn {
  color: #818CF8;
}

[data-theme="dark"] .step-btn:active {
  background: rgba(129,140,248,0.12);
}

[data-theme="dark"] .radio-card.active {
  border-color: #818CF8;
  background: rgba(129,140,248,0.08);
  box-shadow: 0 0 0 1px rgba(129,140,248,0.15);
}

[data-theme="dark"] .radio-card.active .radio-dot {
  border-color: #818CF8;
}

[data-theme="dark"] .radio-card.active .radio-dot::after {
  background: #818CF8;
}

[data-theme="dark"] .radio-dot {
  border-color: #475569;
}

[data-theme="dark"] .run-now-btn:active,
[data-theme="dark"] .run-now-btn.selected {
  border-color: #818CF8;
  background: rgba(129,140,248,0.1);
}

[data-theme="dark"] .savings-badge {
  color: #4ADE80;
  background: rgba(34,197,94,0.15);
}

[data-theme="dark"] .context-alert {
  background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(245,158,11,0.1));
  border-color: rgba(239,68,68,0.25);
}

[data-theme="dark"] .rate-share-card {
  background: linear-gradient(135deg, rgba(129,140,248,0.1), rgba(34,197,94,0.08));
  border-color: rgba(129,140,248,0.2);
}

[data-theme="dark"] .rate-btn {
  background: #818CF8;
}

[data-theme="dark"] .rate-btn:active {
  background: #6366F1;
}

[data-theme="dark"] .about-link {
  color: #818CF8;
}

[data-theme="dark"] .btn-primary {
  background: #818CF8;
}

[data-theme="dark"] .btn-primary:active {
  background: #6366F1;
}

[data-theme="dark"] .settings-action-btn:active {
  background: rgba(239,68,68,0.12);
}

[data-theme="dark"] .contract-data-warning {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.25);
}

[data-theme="dark"] .eco-badge.clean {
  color: #4ADE80;
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.25);
}

/* AI Chat dark mode */
[data-theme="dark"] .ai-chat-fab {
  background: linear-gradient(135deg, #818CF8, #6366F1);
  box-shadow: 0 4px 16px rgba(129,140,248,0.4);
}

[data-theme="dark"] .ai-chat-panel {
  background: var(--app-surface);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

[data-theme="dark"] .ai-msg.user .ai-msg-bubble {
  background: #818CF8;
}

[data-theme="dark"] .ai-chat-input:focus {
  border-color: #818CF8;
}

[data-theme="dark"] .ai-chat-send {
  background: #818CF8;
}

[data-theme="dark"] .ai-chat-send:active {
  background: #6366F1;
}

[data-theme="dark"] .ai-chip:active {
  background: rgba(129,140,248,0.15);
  border-color: #818CF8;
}
