:root {
  --bg: #070b14;
  --bg2: #0d1424;
  --surface: rgba(18, 26, 48, 0.85);
  --surface2: #151e36;
  --border: rgba(100, 130, 200, 0.18);
  --text: #eef3ff;
  --muted: #8fa3c8;
  --accent: #5b8cff;
  --accent2: #7c5cff;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(91, 140, 255, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(124, 92, 255, 0.12), transparent),
    radial-gradient(ellipse 50% 30% at 0% 100%, rgba(52, 211, 153, 0.08), transparent);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 16px);
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(91, 140, 255, 0.35);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.brand-mark-video {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
}

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

.brand p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-ok, .pill.on { color: var(--green); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.08); }
.pill-busy { color: var(--amber); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.08); }
.pill-error, .pill.off { color: var(--red); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.08); }
.pill-muted { color: var(--muted); }

/* Hero */
.hero { margin-bottom: 24px; }

.hero-compact h2 { font-size: 1.5rem; }

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

.hero h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

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

/* Feature cards */
.feature-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.feature-card {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.feature-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.feature-trading::before { background: linear-gradient(135deg, rgba(91, 140, 255, 0.12), transparent); }
.feature-licensehub::before { background: linear-gradient(135deg, rgba(13, 115, 119, 0.18), transparent); }
.feature-growaxis::before { background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), transparent); }
.feature-nabh::before { background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), transparent); }
.feature-video::before { background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), transparent); }
.feature-studio::before { background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), transparent); }

.feature-card:hover, .feature-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(91, 140, 255, 0.35);
  box-shadow: var(--shadow);
}

.feature-card:hover::before, .feature-card:focus-visible::before { opacity: 1; }

.feature-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  position: relative;
}

.feature-body { flex: 1; min-width: 0; position: relative; }

.feature-body h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.feature-body p {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.feature-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.feature-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

/* Quick stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-card span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-card strong {
  font-size: 0.95rem;
  font-weight: 700;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  z-index: 100;
}

.bottom-nav {
  max-width: 960px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 8px 4px;
  transition: color 0.15s;
}

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

.nav-icon { font-size: 1.25rem; line-height: 1; }

/* Panels */
.panel {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.panel-head h2 { margin: 0; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid-wide label.span-2 { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

select, input, textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 96px; }

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  padding-top: 8px;
}

.checkbox-label input { width: auto; accent-color: var(--accent); }

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  background: linear-gradient(135deg, #3b6fd9, var(--accent));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 44px;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, #3b6fd9, var(--accent)); }
.btn-accent { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }
.btn-youtube { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }
.btn-youtube:disabled { opacity: 0.45; }
.btn-zerodha { background: linear-gradient(135deg, #387ed1, #2962ff); }
.btn-danger { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-sm { padding: 8px 14px; min-height: 36px; font-size: 0.82rem; }

.job-progress {
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}
.job-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.youtube-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}
.youtube-panel label { margin-bottom: 0; }
.youtube-panel h3 { margin: 0 0 4px; font-size: 1rem; }

/* Cards grid */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card span { color: var(--muted); font-size: 0.75rem; }
.card strong { font-size: 1.15rem; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 400px;
}

th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 500; font-size: 0.78rem; }

.side-buy { color: var(--green); }
.side-sell { color: var(--red); }

/* Badge */
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge.on { color: var(--green); border-color: rgba(52, 211, 153, 0.35); }
.badge.off { color: var(--muted); }
.badge.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); }

.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }

/* Charts */
.chart-panel .chart-wrap {
  position: relative;
  height: 260px;
}

.chart-panel canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Auto trader */
.auto-status {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 12px 0;
}

.auto-status strong { color: var(--text); }

.log-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.log-line { padding: 4px 0; border-bottom: 1px solid rgba(100, 130, 200, 0.1); }
.log-line span { color: var(--muted); margin-right: 8px; }

h3 { font-size: 0.9rem; color: var(--muted); margin: 14px 0 8px; }

/* Video studio */
.template-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.template-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-width: 160px;
  max-width: 200px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}

.template-chip:hover, .template-chip.active {
  border-color: rgba(168, 85, 247, 0.5);
  background: rgba(168, 85, 247, 0.1);
}

.template-chip strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.template-chip span {
  font-size: 0.75rem;
  color: var(--muted);
}

.prompt-output {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
  margin: 0;
}

.scene-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-item {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 12px;
  background: var(--bg2);
  border-radius: 8px;
  border-left: 3px solid var(--accent2);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  transition: border-color 0.15s;
}

.history-item:hover { border-color: rgba(168, 85, 247, 0.4); }

.history-item strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.history-item span {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Desktop */
@media (min-width: 640px) {
  .app-shell { padding: 24px 24px calc(var(--nav-h) + var(--safe-b) + 24px); }

  .feature-grid { grid-template-columns: 1fr 1fr; }

  .cards { grid-template-columns: repeat(4, 1fr); }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 960px;
    border-radius: 16px 16px 0 0;
  }
}

@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .app-shell { padding-bottom: 32px; }

  .page-hub .main-content::after,
  .page-trading .main-content::after,
  .page-video .main-content::after {
    content: "";
    display: block;
    height: 0;
  }
}

/* Desktop top links when bottom nav hidden */
@media (min-width: 768px) {
  .topbar::after {
    content: none;
  }
}

/* Auth */
.page-auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-brand { margin-bottom: 24px; }

.auth-card { padding: 24px; }

.auth-gate {
  max-width: 480px;
  margin: 0 auto;
}

.auth-gate-intro {
  margin-bottom: 20px;
}

.auth-gate-intro h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.auth-gate .auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.auth-tab.active {
  background: rgba(91, 140, 255, 0.15);
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.4);
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; }

.auth-error {
  color: var(--red);
  font-size: 0.9rem;
  margin-top: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-chip {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cards-compact {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.form-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-inline select { flex: 1; min-width: 140px; }

h3 {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 16px 0 8px;
}
