/* ============================================================
   Base Carbon Meter — Premium Dark UI
   Design system: glassmorphism + gradient accents + micro-animations
   ============================================================ */

:root {
  /* Backgrounds */
  --bg: #060a0d;
  --bg-2: #0a1015;
  --surface: rgba(19, 26, 32, 0.6);
  --surface-2: rgba(28, 37, 45, 0.5);
  --surface-solid: #131a20;
  --border: rgba(38, 51, 61, 0.6);
  --border-bright: rgba(0, 214, 143, 0.25);

  /* Text */
  --text: #e6edf3;
  --muted: #7d8b99;
  --muted-2: #5a6877;

  /* Accents */
  --primary: #00d68f;
  --primary-dark: #00b377;
  --primary-glow: rgba(0, 214, 143, 0.15);
  --secondary: #3b82f6;
  --secondary-glow: rgba(59, 130, 246, 0.12);
  --warning: #f59e0b;
  --danger: #ef4444;
  --cyan: #06b6d4;

  /* Layout */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --max-width: 1140px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================ RESET */

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(10, 16, 21, 0.6);
  color: var(--text);
  width: 100%;
  transition: var(--transition);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
input::placeholder { color: var(--muted-2); }

.mono { font-family: "JetBrains Mono", "SF Mono", Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.link { color: var(--primary); }
.hidden { display: none !important; }

/* ============================================================ BG ORBS */

.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.15; animation: float 20s ease-in-out infinite; }
.orb-1 { width: 500px; height: 500px; background: var(--primary); top: -100px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: var(--secondary); bottom: -50px; right: -50px; animation-delay: -7s; }
.orb-3 { width: 300px; height: 300px; background: var(--cyan); top: 40%; left: 50%; animation-delay: -14s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ============================================================ GLASS */

.glass {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================================ HEADER */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 1rem auto;
  padding: 0.85rem 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0.5rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.logo {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #00a3ff);
  border-radius: 12px;
  flex-shrink: 0;
}

.brand h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { display: block; color: var(--muted); font-size: 0.72rem; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

.network-badge {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}

.status-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ============================================================ BUTTONS */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 0 20px var(--primary-glow); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-bright); background: rgba(28, 37, 45, 0.8); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--muted);
  transition: var(--transition);
  margin-left: auto;
}
.btn-icon:hover { color: var(--primary); background: var(--surface-2); }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 0.5rem;
}

/* ============================================================ HERO */

.hero { max-width: var(--max-width); margin: 2.5rem auto 1rem; padding: 0 1.5rem; position: relative; z-index: 1; }

.hero-content { text-align: center; margin-bottom: 2.5rem; }

.hero-badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: var(--primary-glow);
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.25rem;
}

.hero h2 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p { color: var(--muted); max-width: 580px; margin: 0 auto; font-size: 1.05rem; }

/* ============================================================ STAT CARDS */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-bright); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: var(--transition);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ic) 12%, transparent);
  color: var(--ic);
  flex-shrink: 0;
}

.stat-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; word-break: break-word; }
.stat-sub { color: var(--muted-2); font-size: 0.75rem; }

/* ============================================================ IMPACT */

.impact-section { max-width: var(--max-width); margin: 1.5rem auto; padding: 0 1.5rem; position: relative; z-index: 1; }

.section-header { text-align: center; margin-bottom: 1.25rem; }
.section-header h3 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.section-header p { color: var(--muted); font-size: 0.9rem; }

.impact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.impact-card {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}
.impact-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }

.impact-emoji { font-size: 2rem; flex-shrink: 0; }
.impact-data { display: flex; flex-direction: column; gap: 0.1rem; }
.impact-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.impact-label { color: var(--muted); font-size: 0.78rem; }

/* ============================================================ ENERGY BAR */

.energy-section { max-width: var(--max-width); margin: 1.5rem auto; padding: 0 1.5rem; position: relative; z-index: 1; }

.energy-card { padding: 1.5rem; }

.energy-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.energy-header h3 { font-size: 1.1rem; font-weight: 700; }
.energy-header p { font-size: 0.82rem; }

.energy-threshold { display: flex; align-items: baseline; gap: 0.3rem; }
.energy-current { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.energy-divider { color: var(--muted-2); font-size: 1.2rem; }
.energy-target { color: var(--muted); font-size: 0.9rem; }

.energy-bar-container {
  height: 14px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.energy-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 2;
}

.energy-bar-glow {
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--primary-glow));
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: absolute;
  top: 0; left: 0;
  filter: blur(4px);
}

.energy-footer { display: flex; justify-content: space-between; margin-top: 0.75rem; font-size: 0.82rem; }

/* ============================================================ TABS */

.tabs {
  display: flex;
  gap: 0.25rem;
  max-width: var(--max-width);
  margin: 1.5rem auto 0;
  padding: 0.4rem;
  position: relative;
  z-index: 1;
  overflow-x: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary); background: var(--primary-glow); }

/* ============================================================ PANELS */

.panel { max-width: var(--max-width); margin: 1rem auto 2rem; padding: 0 1.5rem; display: none; position: relative; z-index: 1; }
.panel.active { display: block; animation: fadeIn 0.3s ease; }

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

.panel-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.two-col { grid-template-columns: 1fr; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* ============================================================ CARDS */

.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}
.card-title svg { color: var(--primary); }

/* ============================================================ WALLET INFO */

.wallet-info { display: flex; flex-direction: column; gap: 0.75rem; }
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-label { color: var(--muted); font-size: 0.85rem; flex-shrink: 0; }
.info-value { font-weight: 600; text-align: right; word-break: break-all; font-size: 0.88rem; }

/* ============================================================ FORMS */

.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.form button { margin-top: 0.3rem; }
.form-hint { font-size: 0.8rem; color: var(--primary); min-height: 1.2em; }

/* ============================================================ ACTIVITY FEED */

.activity-card { margin-top: 1rem; }
.activity-feed { display: flex; flex-direction: column; gap: 0.5rem; max-height: 400px; overflow-y: auto; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.activity-item:hover { border-color: var(--border-bright); }

.activity-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 1rem;
}

.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; font-size: 0.88rem; }
.activity-detail { color: var(--muted); font-size: 0.78rem; word-break: break-all; }
.activity-time { color: var(--muted-2); font-size: 0.72rem; flex-shrink: 0; }

/* ============================================================ LISTINGS */

.listings-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 620px) { .listings-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }

.listing-card {
  padding: 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.listing-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }

.listing-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.listing-id { font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.listing-seller { color: var(--muted); font-size: 0.78rem; }

.listing-amount { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.25rem; }
.listing-amount span { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.listing-unit { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.75rem; }

.listing-price-row { display: flex; justify-content: space-between; align-items: center; }
.listing-price { color: var(--primary); font-weight: 700; font-size: 1.1rem; }

/* ============================================================ DEVICES */

.device-list { display: flex; flex-direction: column; gap: 0.5rem; }

.device-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.device-item:hover { border-color: var(--border-bright); }

.device-status {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.device-status.active { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.device-status.inactive { background: var(--danger); }

.device-info { flex: 1; min-width: 0; }
.device-id { font-weight: 600; font-size: 0.85rem; word-break: break-all; }
.device-stats { color: var(--muted); font-size: 0.78rem; display: flex; gap: 1rem; flex-wrap: wrap; }

/* ============================================================ CONTRACTS */

.contract-list { display: flex; flex-direction: column; gap: 0.75rem; }

.contract-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.contract-name { font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
.contract-addr { color: var(--muted); font-size: 0.82rem; word-break: break-all; }

.params-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }
.param-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.param-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.param-value { font-weight: 700; font-size: 1rem; }

/* ============================================================ TOAST */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: 380px;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  font-size: 0.88rem;
  font-weight: 500;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
.toast.success { border-color: var(--primary); border-left: 3px solid var(--primary); }
.toast.error { border-color: var(--danger); border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--secondary); }

/* ============================================================ MODAL */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal {
  max-width: 420px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.75rem; }
.modal p { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.92rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ============================================================ FOOTER */

.footer {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 1.25rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
  font-size: 0.88rem;
  color: var(--muted);
}
.footer-top { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
@media (min-width: 640px) {
  .footer-top { flex-direction: row; justify-content: space-between; gap: 1rem; }
}
.footer-brand { font-weight: 700; color: var(--text); }
.footer-built { text-align: center; }
.footer-net {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.75rem;
  font-size: 0.75rem;
}
.footer-divider { border-top: 1px solid var(--border); margin: 0.75rem 0; }
.footer-partner p {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.footer-partner-name { font-weight: 600; color: var(--text); }
.botchain-logo { height: 20px; width: auto; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1rem; margin-top: 0.3rem; }
.footer-links a { font-size: 0.88rem; color: var(--muted); text-decoration: underline; }
.footer-links a:hover { color: var(--text); }

/* ============================================================ SCROLLBAR */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ============================================================ RESPONSIVE */

@media (max-width: 640px) {
  .hero h2 { font-size: 1.75rem; }
  .header { flex-wrap: wrap; }
  .stat-value { font-size: 1.25rem; }
  .energy-current { font-size: 1.3rem; }
}
