/* ─────────────────────────────────────────────────────────────
 * ZephFlow APY Calculator — shared explorer theme + calc-specific
 * ───────────────────────────────────────────────────────────── */

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

:root {
  --bg:           #0E0E21;
  --bg-card:      #12102a;
  --bg-card-alt:  rgba(14,14,33,0.85);
  --bg-deep:      #0a0a18;
  --bg-row:       #1a1540;
  --border:       #282554;
  --border-light: rgba(99,72,255,0.15);
  --border-soft:  rgba(99,72,255,0.10);
  --text:         #F5F5FA;
  --text-muted:   #9490b0;
  --text-dim:     #5a5678;
  --text-faint:   #3d3960;
  --accent:       #6348FF;
  --accent-soft:  #b4a0ff;
  --accent-deep:  #4931AF;
  --green:        #3fb950;
  --green-soft:   #7dffb3;
  --red:          #FF616D;
  --amber:        #d29922;
  --shadow-card:  0 0 20px rgba(99,72,255,0.05), 0 0 40px rgba(99,72,255,0.02);
}

body.light-mode {
  --bg:           #F0EFF5;
  --bg-card:      #FFFFFF;
  --bg-card-alt:  rgba(255,255,255,0.9);
  --bg-deep:      #e8e6f2;
  --bg-row:       #f5f4fa;
  --border:       #d4d0e8;
  --border-light: rgba(99,72,255,0.12);
  --border-soft:  rgba(99,72,255,0.08);
  --text:         #161430;
  --text-muted:   #5a5678;
  --text-dim:     #827FAE;
  --text-faint:   #a09cc4;
  --accent:       #4931AF;
  --accent-soft:  #6348FF;
  --accent-deep:  #2e1d8a;
  --green:        #1a8a3e;
  --green-soft:   #1a8a3e;
  --red:          #d4404d;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-soft); text-decoration: underline; }
body.light-mode a:hover { color: var(--accent-deep); }

code, .mono { font-family: 'SF Mono', 'Fira Code', Consolas, ui-monospace, monospace; }

/* ───── Theme toggle ───── */
.theme-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 999;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
body.light-mode .theme-toggle { box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
.theme-toggle:hover { border-color: var(--accent); box-shadow: 0 0 12px rgba(99,72,255,0.2); }
.theme-toggle svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ───── Top header bar ───── */
.top-bar {
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border-light);
  padding: 18px 24px;
}
.top-bar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, #e8d5ff 0%, #b4a0ff 55%, #6348FF 100%);
  color: #0E0E21;
  box-shadow: 0 2px 14px rgba(180,160,255,0.40), inset 0 -1px 2px rgba(73,49,175,0.25);
  border: 1px solid rgba(73,49,175,0.40);
}
body.light-mode .brand-mark {
  background: radial-gradient(circle at 35% 30%, #8870ff 0%, #6348FF 55%, #4931AF 100%);
  color: #F5F5FA;
  box-shadow: 0 2px 12px rgba(99,72,255,0.40);
  border-color: rgba(46,29,138,0.40);
}
.brand-mark svg { width: 60%; height: 60%; display: block; }

.brand-name {
  font-weight: 800;
  background: linear-gradient(120deg, #b4a0ff 0%, #6348FF 60%, #b4a0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}
body.light-mode .brand-name {
  background: linear-gradient(120deg, #4931AF 0%, #6348FF 60%, #4931AF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--accent);
  padding: 2px 8px; border: 1px solid rgba(99,72,255,0.35);
  border-radius: 20px; margin-left: 4px;
}
.nav-links {
  display: flex; align-items: center; gap: 18px;
  font-size: 13px; font-weight: 600;
}
.nav-links a {
  color: var(--text-muted); padding: 6px 0;
  border-bottom: 1px solid transparent;
}
.nav-links a:hover { color: var(--text); border-bottom-color: var(--accent); text-decoration: none; }
.nav-links a.ext::after { content: '↗'; margin-left: 3px; font-size: 11px; opacity: 0.7; }

/* ───── Hero ───── */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-row) 40%, var(--bg) 100%);
  padding: 44px 24px 36px; text-align: center;
  border-bottom: 1px solid rgba(99,72,255,0.15);
}
body.light-mode .hero { background: linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%); }
.hero::before {
  content: ''; position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%; pointer-events: none;
  background: radial-gradient(ellipse at 30% 50%, rgba(73,49,175,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(99,72,255,0.04) 0%, transparent 60%);
  animation: shimmer 20s ease-in-out infinite alternate;
}
@keyframes shimmer { 0% { transform: translate(0,0); } 100% { transform: translate(-5%, 3%); } }
.hero-inner { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; }
.hero-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(99,72,255,0.35);
  padding: 4px 14px; border-radius: 20px; margin-bottom: 16px;
}
.hero h1 {
  font-size: 32px; font-weight: 800; letter-spacing: -0.8px;
  line-height: 1.15; margin-bottom: 8px;
  background: linear-gradient(160deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 22px; }

/* ───── Content ───── */
.content { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--accent);
  margin: 28px 0 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.section-title .live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px rgba(63,185,80,0.6);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ───── Stat cards ───── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: rgba(99,72,255,0.4); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}
.stat-card.highlight::before {
  background: linear-gradient(90deg, var(--green), transparent);
  opacity: 0.85;
}
.stat-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.stat-value {
  font-size: 24px; font-weight: 700; color: var(--text);
  font-family: 'SF Mono', Consolas, monospace;
  letter-spacing: -0.5px;
}
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-value.accent { color: var(--accent); }
.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-card.highlight .stat-value { color: var(--green); }

/* ───── Panels ───── */
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  margin-bottom: 18px;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.panel-title { font-size: 14px; font-weight: 700; color: var(--text); }
.panel-meta { font-size: 11px; color: var(--text-dim); }
.panel-body { padding: 16px 20px; }

/* ───── Pills ───── */
.pill {
  display: inline-block; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; padding: 2px 8px; border-radius: 20px;
  background: rgba(99,72,255,0.12); color: var(--accent);
  border: 1px solid rgba(99,72,255,0.25);
}
.pill.green { background: rgba(63,185,80,0.10);  color: var(--green); border-color: rgba(63,185,80,0.25); }
.pill.amber { background: rgba(210,153,34,0.10); color: var(--amber); border-color: rgba(210,153,34,0.25); }
.pill.red   { background: rgba(255,97,109,0.10); color: var(--red);   border-color: rgba(255,97,109,0.25); }

/* ───── Footer ───── */
.footer {
  text-align: center; padding: 32px 24px;
  color: var(--text-faint); font-size: 11px;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}
.footer a { color: var(--accent-deep); }

/* ════════════════════════════════════════════════════════════
 * Calc-specific UI
 * ════════════════════════════════════════════════════════════ */

/* View toggle (Simple / Advanced) */
.view-toggle {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.view-toggle button {
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-muted); padding: 6px 14px; font-size: 12px; font-weight: 600;
  font-family: inherit; transition: all 0.15s;
}
.view-toggle button.active {
  background: rgba(99,72,255,0.15); color: var(--accent);
}
.view-toggle button:hover:not(.active) { color: var(--text); }

/* Inputs */
.field-group { margin-bottom: 14px; }
.field-label {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px;
}
.zinput, .zselect {
  width: 100%; max-width: 360px;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px;
  font-family: 'SF Mono', Consolas, monospace;
  outline: none; transition: all 0.15s;
}
.zinput:focus, .zselect:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,72,255,0.15);
}
.zselect { font-family: 'Inter', sans-serif; }
.field-hint {
  font-size: 11px; color: var(--text-dim); margin-top: 6px; line-height: 1.5;
}
.live-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 6px; border-radius: 10px;
  background: rgba(63,185,80,0.12); color: var(--green);
  border: 1px solid rgba(63,185,80,0.30);
  text-transform: uppercase;
}
.live-tag::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 4px rgba(63,185,80,0.6);
}

/* Buttons */
.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 20px; border-radius: 10px; font-weight: 600;
  font-size: 13px; cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--accent-deep); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); background: rgba(99,72,255,0.08); }
.btn.big { padding: 13px 28px; font-size: 15px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* KPI grid (advanced view) */
.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 6px;
}
@media (max-width: 600px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi {
  background: var(--bg-deep); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 10px 12px;
}
.kpi.highlight { border-color: rgba(63,185,80,0.30); background: rgba(63,185,80,0.04); }
.kpi-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: 'SF Mono', Consolas, monospace; font-size: 14px; color: var(--text); font-weight: 600; }
.kpi.highlight .kpi-value { color: var(--green); font-weight: 800; font-size: 15px; }

/* Tooltip icon (carry-over from original calc) */
.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 10px; font-weight: 700; cursor: help;
  background: rgba(99,72,255,0.10); color: var(--text-muted);
  border: 1px solid rgba(99,72,255,0.25);
  position: relative; user-select: none;
}
.info:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); min-width: 200px; max-width: 320px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-deep); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; font-weight: 500; line-height: 1.5;
  text-transform: none; letter-spacing: normal;
  white-space: normal; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100;
}
@media (max-width: 520px) {
  .info:hover::after { left: 0; transform: none; max-width: 86vw; }
}

/* Layout grids */
.calc-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 860px) { .calc-cols { grid-template-columns: 1fr; } }

/* Status line */
.calc-status {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.calc-status .status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim);
}
.calc-status.ok .status-dot { background: var(--green); }
.calc-status.err .status-dot { background: var(--red); }
.calc-err { color: var(--red); font-size: 12px; margin-left: 8px; }

/* Loading overlay */
.calc-overlay {
  position: fixed; top: 70px; right: 24px; z-index: 999;
  display: none; align-items: center; gap: 10px;
  background: rgba(14,14,33,0.95); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; backdrop-filter: blur(8px);
  font-size: 12px; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.calc-overlay.on { display: flex; }
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.18);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 640px) {
  .top-bar { padding: 14px 16px; }
  .nav-links { gap: 12px; font-size: 12px; }
  .hero { padding: 32px 16px 28px; }
  .hero h1 { font-size: 24px; }
  .content { padding: 22px 14px 40px; }
  .stat-value { font-size: 20px; }
  .panel-header { padding: 12px 14px; }
  .panel-body { padding: 14px; }
}
