@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

:root {
  /* Premium Light Theme Palette (default) */
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #e2e8f0;

  --surface-glass: rgba(255, 255, 255, 0.75);
  --surface-glass-hover: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --border-glass: rgba(15, 23, 42, 0.08);
  --border-glass-focus: rgba(99, 102, 241, 0.3);

  --primary: #818cf8;
  /* Vivid Indigo */
  --primary-hover: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.08);
  --secondary: #a855f7;
  /* alias for accent-purple */

  --accent-purple: #a855f7;
  /* Violet */
  --accent-purple-glow: rgba(168, 85, 247, 0.15);

  --success: #10b981;
  /* Neon Emerald */
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.2);
  --success-glow: rgba(16, 185, 129, 0.15);

  --warning: #f59e0b;
  /* Amber */
  --warning-bg: rgba(245, 158, 11, 0.08);
  --warning-border: rgba(245, 158, 11, 0.2);
  --warning-glow: rgba(245, 158, 11, 0.12);

  --error: #f43f5e;
  /* Coral/Rose */
  --error-bg: rgba(244, 63, 94, 0.08);
  --error-border: rgba(244, 63, 94, 0.2);
  --error-glow: rgba(244, 63, 94, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-tertiary: #94a3b8;

  --chip-bg: rgba(15, 23, 42, 0.05);
  --chip-border: rgba(15, 23, 42, 0.12);
  --chip-bg-hover: rgba(15, 23, 42, 0.08);

  /* "Ink" = the neutral tint colour laid over surfaces (borders, hovers,
     subtle fills). Dark ink on light surfaces in light mode; flips to a
     white ink on dark surfaces in dark mode via [data-theme="dark"]. */
  --ink-rgb: 15, 23, 42;
  --header-bg: rgba(255, 255, 255, 0.82);

  --toolbar-input-height: 58px;
  --toolbar-btn-height: 58px;
  --toolbar-chip-height: 38px;
  --toolbar-home-inset-top: 2.5cm;

  --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "Fira Code", "ui-monospace", monospace;

  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.08);
  --shadow-lg: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

/* The palette above is light by default. Dark mode is opt-in via a
   data-theme="dark" attribute on <html>, toggled by the header switch
   (persisted in localStorage). Everything variable-driven flips here. */
:root[data-theme="dark"] {
  --bg-gradient-start: #040810;
  --bg-gradient-end: #090e1a;

  --surface-glass: rgba(12, 18, 30, 0.55);
  --surface-glass-hover: rgba(20, 28, 45, 0.70);
  --surface-solid: #0c1019;
  --border-glass: rgba(255, 255, 255, 0.05);
  --border-glass-focus: rgba(99, 102, 241, 0.5);

  --primary-glow: rgba(129, 140, 248, 0.25);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-tertiary: #64748b;

  --chip-bg: rgba(255, 255, 255, 0.06);
  --chip-border: rgba(255, 255, 255, 0.1);
  --chip-bg-hover: rgba(255, 255, 255, 0.1);

  --ink-rgb: 255, 255, 255;
  --header-bg: rgba(8, 10, 20, 0.78);

  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  background-attachment: fixed;
  color: var(--text-secondary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(var(--ink-rgb), 0.06);
}

::-webkit-scrollbar-thumb {
  background: rgba(var(--ink-rgb), 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.app-shell {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 20px 24px 96px;
}

.hidden {
  display: none !important;
}

/* ─── PAGE LOADER — slim top progress bar only ─────────────────────────── */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  background: transparent;
  transition: opacity 0.4s ease;
}

#page-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Animated indeterminate sliding bar */
#page-loader .loader-bar-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--primary), var(--accent-purple));
  border-radius: 0 99px 99px 0;
  animation: loaderSlide 1.4s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.7);
}

@keyframes loaderSlide {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(400%);
  }
}

/* ─── SKELETON LOADERS ─────────────────────────────────────────────────────
   Shimmer animation applied to .skeleton elements while data is loading.
   Works by sliding a light gradient across a dark base shape.           */

@keyframes shimmer {
  0% {
    background-position: -600px 0;
  }

  100% {
    background-position: 600px 0;
  }
}

.skeleton {
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.04) 25%,
      rgba(255, 255, 255, 0.10) 50%,
      rgba(255, 255, 255, 0.04) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
}

/* Skeleton shape helpers */
.sk-heading {
  height: 28px;
  width: 55%;
  margin-bottom: 10px;
}

.sk-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.sk-text.w-80 {
  width: 80%;
}

.sk-text.w-60 {
  width: 60%;
}

.sk-text.w-40 {
  width: 40%;
}

.sk-badge {
  height: 22px;
  width: 80px;
  border-radius: 99px;
  display: inline-block;
}

.sk-metric {
  height: 80px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.sk-chart {
  height: 120px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.sk-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  padding: 20px;
  margin-bottom: 16px;
  background: var(--surface-glass);
}

.sk-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.sk-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sk-table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.sk-table-row .sk-text {
  margin: 0;
  height: 16px;
}

/* ─── SKELETON COMPOUND COMPONENTS ────────────────────────────────────────*/

/* Company header skeleton */
#sk-company-header {
  padding: 24px 0 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

#sk-company-header .sk-avatar {
  width: 52px;
  height: 52px;
}

/* Verdict card skeleton */
#sk-verdict {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  padding: 24px;
  margin-bottom: 24px;
  background: var(--surface-glass);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* Metric grid skeleton */
#sk-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* Floating Radial Glows */
body::before,
body::after {
  content: "";
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  filter: blur(120px);
  opacity: 0.12;
}

body::before {
  top: -100px;
  right: -50px;
  background: var(--primary);
}

body::after {
  bottom: -150px;
  left: -100px;
  background: var(--accent-purple);
}

/* Glassmorphism Generic Card */
.glass-card {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* AUTHENTICATION SCREEN */
.auth-wrap {
  min-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Auth card entrance animation */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card {
  width: 100%;
  max-width: 440px;
  /* Always visible — never let GSAP hide auth card or its children */
  animation: cardFadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Protect ALL children inside auth-card from GSAP opacity manipulation */
.auth-card,
.auth-card * {
  opacity: 1 !important;
  visibility: visible !important;
}

.brand-lockup {
  text-align: center;
  margin-bottom: 28px;
}

.brand-lockup--auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.brand-name-auth {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.brand-lockup .brand-mark {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.brand-lockup p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.036);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid var(--border-glass);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.auth-tab.is-active {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

.auth-form {
  display: grid;
  gap: 16px;
}

/* INPUTS */
.input-group {
  position: relative;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  height: 50px;
  background: rgba(15, 23, 42, 0.045);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.072);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

input::placeholder {
  color: var(--text-muted);
}

/* BUTTONS */
.primary-btn {
  height: 48px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  filter: brightness(1.1);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.danger-btn {
  height: 48px;
  background: var(--error, #ef4444);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.danger-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  filter: brightness(1.1);
}

.danger-btn:active:not(:disabled) {
  transform: translateY(0);
}

.danger-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ghost-btn {
  height: 48px;
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost-btn:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Heading actions (Analyse result header) ───────────────────────────── */
.heading-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.heading-actions .primary-btn,
.heading-actions .ghost-btn {
  height: 42px;
  font-size: 0.88rem;
  padding: 0 16px;
}

/* ── Compare tab count badge ───────────────────────────────────────────── */
.tab-label-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.35);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35);
}

.top-tab.is-active .tab-badge {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* ── Analyse toolbar — sits directly under header (Analyse tab only) ───── */
.analyse-toolbar-wrap {
  max-width: 820px;
  margin: 0 auto 18px;
  padding: 0 4px;
  /* Keep search autocomplete above result/chart layers that follow in the DOM */
  position: relative;
  z-index: 40;
}

.analyse-toolbar-wrap:not(.hidden):not(.is-home) {
  margin-top: 24px;
}

.analyse-toolbar-wrap.is-home {
  max-width: 680px;
  margin-top: calc(132px + var(--toolbar-home-inset-top));
}

.analyse-toolbar-wrap.hidden {
  display: none !important;
}

.analyse-toolbar-wrap.is-home .search-card {
  padding: 12px 16px;
  border-radius: 999px;
}

.analyse-toolbar-wrap.is-home .search-card input {
  height: var(--toolbar-input-height);
  min-height: var(--toolbar-input-height);
  font-size: 1.08rem;
  padding-left: 46px;
}

.analyse-toolbar-wrap.is-home .search-input-wrapper .search-icon {
  left: 14px;
  width: 21px;
  height: 21px;
}

.analyse-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.analyse-toolbar-wrap.is-home .search-card .primary-btn {
  min-width: 132px;
  height: var(--toolbar-btn-height);
  min-height: var(--toolbar-btn-height);
  font-size: 0.98rem;
  border-radius: 999px;
  padding: 0 22px;
}

.analyse-toolbar-wrap.is-home .period-strip {
  justify-content: center;
  gap: 8px;
}

.analyse-toolbar-wrap.is-home .period-btn,
.analyse-toolbar-wrap.is-home .year-picker-label {
  min-height: var(--toolbar-chip-height);
  padding: 0 16px;
  font-size: 0.88rem;
}

.analyse-toolbar:not(.is-compact) .period-strip {
  justify-content: center;
}

.analyse-toolbar-wrap #analyze-message {
  text-align: center;
}

.analyse-toolbar.is-compact .search-card {
  padding: 8px;
}

.analyse-toolbar.is-compact .search-card input,
.analyse-toolbar.is-compact .search-card .primary-btn {
  height: var(--toolbar-input-height);
  min-height: var(--toolbar-input-height);
}

.period-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
  width: 100%;
}

.period-strip .time-explorer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.period-active-pill,
.period-strip-label {
  display: none !important;
}

#analyse-panel.is-home {
  min-height: auto;
}

.period-btn,
.year-picker-label {
  min-height: var(--toolbar-chip-height);
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-secondary);
  font: 600 0.84rem var(--font-body);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.period-btn:hover:not(.is-active) {
  background: var(--chip-bg-hover);
  color: var(--text-primary);
}

.period-btn {
  padding: 0 14px;
  cursor: pointer;
}

.period-btn.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

/* ── Workspace strip (sticky header row when companies queued) ─────────── */
.dashboard-header .workspace-strip {
  margin: 0;
  max-width: none;
  border-radius: 0;
  border: none;
  border-top: 1px solid rgba(99, 102, 241, 0.22);
  padding: 10px 16px 12px;
  background: rgba(99, 102, 241, 0.08);
}

.workspace-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  max-width: 100%;
  margin: 0 auto 24px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.06);
}

.workspace-strip--pulse {
  animation: workspacePulse 0.85s ease;
}

@keyframes workspacePulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.workspace-compare-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace-strip .workspace-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

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

.workspace-strip-actions .primary-btn,
.workspace-strip-actions .ghost-btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}

/* ── Compare view (replaces single-company report) ───────────────────── */
.compare-view {
  margin-top: 8px;
  animation: panelFade 0.35s ease-out;
}

.compare-view:not(.hidden) {
  display: block;
}

#analyse-panel.is-compare-mode #result-shell {
  display: none !important;
}

#analyse-panel.is-compare-mode .workspace-strip {
  margin-bottom: 16px;
}

.compare-view .cmp-section,
.compare-view .glass-card {
  margin-bottom: 20px;
}

.compare-view .compare-columns {
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Comparison Workspace tray (legacy — kept for reference) ───────────── */
.workspace-tray {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px 16px;
  padding: 12px 16px 14px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.03));
  border-top: 1px solid rgba(99, 102, 241, 0.18);
  animation: workspaceTrayIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.workspace-tray-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workspace-tray-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(129, 140, 248, 0.25);
  font-size: 1rem;
  flex-shrink: 0;
}

.workspace-tray-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.workspace-tray-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.workspace-tray-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.workspace-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.workspace-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 280px);
  padding: 6px 8px 6px 14px;
  background: var(--surface-solid);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(var(--ink-rgb), 0.10);
  transition: all 0.2s ease;
}

.workspace-chip:hover {
  background: var(--surface-glass-hover);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.workspace-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-chip .chip-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
  color: #ffffff;
  box-shadow: 0 0 10px var(--primary-glow);
  flex-shrink: 0;
}

.workspace-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(var(--ink-rgb), 0.08);
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.workspace-chip button:hover {
  background: var(--error, #ef4444);
  color: #ffffff;
}

.workspace-tray-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.workspace-tray-actions .primary-btn,
.workspace-tray-actions .ghost-btn {
  height: 36px;
  font-size: 0.82rem;
  padding: 0 14px;
  white-space: nowrap;
}

.workspace-compare-btn {
  min-width: 112px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.25s ease;
  letter-spacing: 0.01em;
}

.google-btn:hover {
  background: rgba(15, 23, 42, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.15);
  transform: translateY(-1px);
}

.google-btn:active {
  transform: translateY(0);
}

.google-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}


.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 8px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glass);
}

.divider:not(:empty)::before {
  margin-right: .75em;
}

.divider:not(:empty)::after {
  margin-left: .75em;
}

/* DASHBOARD HEADER — unified topbar + primary tabs + workspace tray */
.dashboard-header {
  position: sticky;
  top: 12px;
  z-index: 90;
  margin-bottom: 28px;
  background: var(--header-bg);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: visible;   /* let the account dropdown escape the header instead of being clipped */
  box-shadow: 0 8px 32px rgba(var(--ink-rgb), 0.10);
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  position: static;
  top: auto;
  z-index: auto;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.08);
}

.topbar-brand, .mobile-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
}
.topbar-brand:hover, .mobile-nav-brand:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.brand-logo-round {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #a78bfa 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  font-family: Georgia, "Times New Roman", serif;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.brand-logo-round--lg {
  width: 56px;
  height: 56px;
  font-size: 1.85rem;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.22);
  font-size: 1rem;
  flex-shrink: 0;
}

.topbar .brand-mark {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 20%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-email-pill {
  max-width: min(34vw, 240px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.04);
  border: 1px solid rgba(var(--ink-rgb), 0.10);
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar-action-btn {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb), 0.10);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.topbar-action-btn:hover {
  background: rgba(var(--ink-rgb), 0.07);
  color: var(--text-primary);
  border-color: rgba(var(--ink-rgb), 0.16);
}

.topbar-action-btn--danger {
  color: #e11d48;
  border-color: rgba(244, 63, 94, 0.30);
}

.topbar-action-btn--danger:hover {
  background: rgba(244, 63, 94, 0.10);
  color: #be123c;
  border-color: rgba(244, 63, 94, 0.45);
}

/* THEME TOGGLE SWITCH (light <-> dark) */
.theme-toggle {
  --tt-w: 54px;
  --tt-h: 28px;
  position: relative;
  width: var(--tt-w);
  height: var(--tt-h);
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 999px;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.06);
  border: 1px solid var(--border-glass);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.theme-toggle-ic {
  font-size: 0.72rem;
  line-height: 1;
  z-index: 1;
  transition: opacity 0.25s ease;
}

.theme-toggle-ic--sun {
  color: #f59e0b;
}

.theme-toggle-ic--moon {
  color: #a5b4fc;
}

.theme-toggle-thumb {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.28);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), background 0.25s ease;
}

.theme-toggle[aria-checked="true"] .theme-toggle-thumb {
  transform: translateY(-50%) translateX(calc(var(--tt-w) - 28px));
  background: #cbd5e1;
}

.theme-toggle[aria-checked="true"] .theme-toggle-ic--sun {
  opacity: 0.3;
}

.theme-toggle[aria-checked="false"] .theme-toggle-ic--moon {
  opacity: 0.3;
}

.text-btn {
  background: none;
  border: none;
  color: var(--error);
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  font-size: 0.9rem;
  transition: filter 0.2s ease;
}

.text-btn:hover {
  filter: brightness(1.2);
  text-decoration: underline;
}

/* TOP TABS NAVIGATION */
.top-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 0;
  background: rgba(var(--ink-rgb), 0.03);
  padding: 6px 8px 8px;
  border: none;
  border-radius: 0;
  position: static;
  top: auto;
  z-index: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.top-tab {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 6px 10px 8px;
  border: 1px solid transparent;
  background: transparent;
  box-sizing: border-box;
  color: var(--text-secondary, #94a3b8);
  opacity: 1 !important;
  visibility: visible !important;
  font-family: var(--font-display), "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  border-radius: 10px;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  transition: color 0.2s ease, background 0.25s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.2s ease, box-shadow 0.25s ease;
}

.top-tab .tab-label {
  font-size: 0.92rem;
  line-height: 1.1;
}

.top-tab .tab-desc {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.75;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-tab:hover {
  color: var(--text-primary);
  background: rgba(var(--ink-rgb), 0.04);
  border-color: rgba(var(--ink-rgb), 0.06);
}

.top-tab.is-active {
  outline: none;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.top-tab.is-active .tab-desc {
  opacity: 0.88;
  color: #c7d2fe;
}

.top-tab.is-active::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.95), transparent);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.45);
  animation: topTabUnderline 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes topTabUnderline {
  from { transform: scaleX(0); opacity: 0; }
  to { transform: scaleX(1); opacity: 1; }
}

.time-explorer-panel {
  max-width: 920px;
  margin: 0 auto 18px;
  padding: 12px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.025);
}

/* legacy time explorer — replaced by period-strip in toolbar */

.time-explorer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 750;
}

.time-explorer-head strong {
  color: var(--text-primary);
  text-transform: none;
}

.time-explorer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.period-btn,
.year-picker-label {
  min-height: var(--toolbar-chip-height);
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-secondary);
  font: 600 0.84rem var(--font-body);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.period-btn:hover:not(.is-active) {
  background: var(--chip-bg-hover);
  color: var(--text-primary);
}

.period-btn {
  padding: 0 14px;
  cursor: pointer;
}

.period-btn.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.year-picker-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
}

.year-picker-label span {
  color: var(--text-muted);
}

.year-picker-label select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 800;
  outline: none;
}

/* The year-period picker's option popup is OS-rendered; give it a solid surface
   that follows the app's OWN light/dark theme (the [data-theme] toggle), not the
   OS `prefers-color-scheme`. Keying it to the OS made the popup render dark — with
   dark, invisible text — whenever the OS was dark but the page shown in light. */
.year-picker-label select { color-scheme: light; }
.year-picker-label select option {
  background-color: #ffffff;
  color: #0f172a;
}

:root[data-theme="dark"] .year-picker-label select { color-scheme: dark; }
:root[data-theme="dark"] .year-picker-label select option {
  background-color: #0f172a;   /* slate-900 — solid so the popup isn't translucent */
  color: #f8fafc;
}

/* Mobile: keep the native year dropdown from collapsing into a thin tall strip.
   A wider select + 16px font makes the OS popup render at a readable width and
   avoids iOS auto-zoom on focus. */
@media (max-width: 600px) {
  .year-picker-label { flex-shrink: 0; }
  .year-picker-label select {
    min-width: 88px;
    font-size: 16px;
    padding: 4px 6px;
  }
  .year-picker-label select option { font-size: 16px; padding: 8px; }
}

/* DYNAMIC PANEL TRANSITION */
.panel {
  display: none;
  animation: panelFade 0.4s ease-out;
}

.panel.is-active {
  display: block;
}

@keyframes panelFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* HERO SECTION */
.hero-block {
  text-align: center;
  padding: 4px 0 10px;
}

.hero-block h1 {
  font-size: 1.7rem;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-block p {
  display: none;
}

/* SEARCH & INPUT CARD */
.search-card {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  position: relative;
  z-index: 1;
}

#analyse-panel:not(.is-home) .analyse-toolbar-wrap,
.analyse-toolbar-wrap:not(.is-home) {
  max-width: 920px;
}

.analyse-toolbar-wrap:not(.is-home) .search-card input {
  height: var(--toolbar-input-height);
  min-height: var(--toolbar-input-height);
  font-size: 1.08rem;
}

.analyse-toolbar-wrap:not(.is-home) .search-card .primary-btn {
  min-width: 132px;
  height: var(--toolbar-btn-height);
  min-height: var(--toolbar-btn-height);
  font-size: 0.98rem;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  overflow: visible;
  z-index: 2;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 14px;
  width: 21px;
  height: 21px;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 1;
}

.search-card input {
  flex: 1;
  height: var(--toolbar-input-height);
  min-height: var(--toolbar-input-height);
  background: transparent;
  border: none;
  font-size: 1.08rem;
  padding-left: 46px;
  color: var(--text-primary);
}

.search-card .primary-btn {
  min-width: 132px;
  height: var(--toolbar-btn-height);
  min-height: var(--toolbar-btn-height);
  font-size: 0.98rem;
  padding: 0 22px;
}

.search-card input:focus {
  background: transparent;
  box-shadow: none;
  outline: none;
}

@media (prefers-color-scheme: light) {
  .ghost-btn:hover {
    background: var(--chip-bg-hover);
    border-color: var(--chip-border);
  }
}

/* AUTOCOMPLETE DROPDOWN — must sit above chart/company layers, never see-through */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: -10px;
  right: -142px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(99, 102, 241, 0.1);
  z-index: 1000;
  isolation: isolate;
  padding: 6px;
  animation: dropdownSlideIn 0.2s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-dropdown .ac-loading,
.autocomplete-dropdown .ac-empty {
  padding: 16px 18px;
  color: var(--text-tertiary);
  font-size: 0.88rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.autocomplete-dropdown .ac-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: rgb(99, 102, 241);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  border: 1px solid transparent;
}

.ac-item:hover,
.ac-item.ac-active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}

.ac-item:active {
  transform: scale(0.99);
}

.ac-item+.ac-item {
  margin-top: 2px;
}

.ac-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: rgb(165, 180, 252);
  flex-shrink: 0;
  overflow: hidden;
}

.ac-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ac-info {
  flex: 1;
  min-width: 0;
}

.ac-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-meta {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ac-ticker-badge {
  background: rgba(99, 102, 241, 0.15);
  color: rgb(165, 180, 252);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  font-family: 'JetBrains Mono', monospace;
}

.ac-exchange-badge {
  background: rgba(52, 211, 153, 0.12);
  color: rgb(110, 231, 183);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.72rem;
}

.ac-country {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  white-space: nowrap;
}

.ac-source-tag {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  opacity: 0.5;
  margin-left: auto;
  flex-shrink: 0;
}

/* FLASH MESSAGES */
.flash {
  width: 100%;
  max-width: 680px;
  margin: 12px auto 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.flash.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
  box-shadow: 0 4px 15px var(--error-glow);
}

.flash.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  box-shadow: 0 4px 15px var(--success-glow);
}

/* RESULT SHELL — below search autocomplete stacking context */
.result-shell {
  margin-top: 12px;
  position: relative;
  z-index: 1;
  animation: panelFade 0.5s ease-out;
}

.company-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding-top: 8px;
}

.company-heading h2 {
  font-size: 2rem;
  line-height: 1.15;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.company-heading p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* PREMIUM VERDICT CARD */
.verdict-card {
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.verdict-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
}

.verdict-card .brand-mark {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.verdict-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

.company-kicker {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.verdict-card h2 {
  color: var(--text-primary);
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.1;
  margin: 0 0 12px;
}

.recommendation-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-weight: 800;
  letter-spacing: 0;
}

.hero-score-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px;
  min-width: 250px;
}

.hero-score {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.032);
}

.hero-score span,
.hero-score small {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
}

.hero-score strong {
  color: var(--text-primary);
  font-size: 1.8rem;
  line-height: 1;
  font-family: var(--font-display);
}

.hero-metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-metric-strip span {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.04);
}

.hero-metric-strip strong,
.pos-text {
  color: var(--success);
}

.neg-text {
  color: var(--error);
}

.driver-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.driver-grid h4,
.compact-evidence h5 {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.driver-grid ul,
.compact-evidence ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.driver-grid ul {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.driver-grid li,
.compact-evidence li {
  display: grid;
  gap: 3px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.driver-grid li strong,
.compact-evidence li strong {
  color: var(--text-primary);
}

.driver-grid li small,
.compact-evidence li span {
  color: var(--text-muted);
  line-height: 1.35;
}

.driver-grid li.positive span,
.compact-evidence li.positive strong {
  color: var(--success);
}

.driver-grid li.negative span,
.compact-evidence li.negative strong {
  color: var(--error);
}

.verdict-card p.score-highlight {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.verdict-card p.reason {
  font-size: 1.05rem;
  line-height: 1.6;
}

.verdict-card.buy,
.verdict-card.strong_buy,
.verdict-card.speculative_buy,
.verdict-card.accumulate {
  background: linear-gradient(135deg, var(--success-bg) 0%, rgba(16, 185, 129, 0.02) 100%);
  border-color: var(--success-border);
  color: #a7f3d0;
  box-shadow: 0 4px 20px var(--success-glow);
}

.verdict-card.buy::before,
.verdict-card.strong_buy::before,
.verdict-card.speculative_buy::before,
.verdict-card.accumulate::before {
  background: var(--success);
}

.verdict-card.buy .brand-mark,
.verdict-card.strong_buy .brand-mark,
.verdict-card.speculative_buy .brand-mark,
.verdict-card.accumulate .brand-mark {
  color: var(--success);
}

.verdict-card.sell,
.verdict-card.strong_sell,
.verdict-card.reduce {
  background: linear-gradient(135deg, var(--error-bg) 0%, rgba(244, 63, 94, 0.02) 100%);
  border-color: var(--error-border);
  color: #fecdd3;
  box-shadow: 0 4px 20px var(--error-glow);
}

.verdict-card.sell::before,
.verdict-card.strong_sell::before,
.verdict-card.reduce::before {
  background: var(--error);
}

.verdict-card.sell .brand-mark,
.verdict-card.strong_sell .brand-mark,
.verdict-card.reduce .brand-mark {
  color: var(--error);
}

.verdict-card.hold,
.verdict-card.insufficient_data {
  background: linear-gradient(135deg, var(--warning-bg) 0%, rgba(245, 158, 11, 0.02) 100%);
  border-color: var(--warning-border);
  color: #fde68a;
  box-shadow: 0 4px 20px var(--warning-glow);
}

.verdict-card.hold::before,
.verdict-card.insufficient_data::before {
  background: var(--warning);
}

.verdict-card.hold .brand-mark,
.verdict-card.insufficient_data .brand-mark {
  color: var(--warning);
}

/* METRICS GRID */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.metric-card h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.metric-card strong {
  font-size: 1.12rem;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.score-explanation-shell {
  margin-bottom: 18px;
}

.score-explanation-shell h3 {
  margin-bottom: 6px;
  color: var(--text-primary);
}

.score-domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.score-domain-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.015);
}

.score-domain-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
  font-weight: 750;
}

.score-domain-card header strong {
  color: var(--primary);
  font-size: 1.2rem;
}

.score-track {
  height: 6px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: inherit;
}

.score-math {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.036);
  padding: 8px;
  border-radius: 6px;
}

/* PRICE BANNER PULSE */
.price-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  margin: 0 0 24px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.036);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.price-banner strong {
  font-size: 1.3rem;
  color: var(--text-primary);
}

.price-banner.is-pulsing {
  animation: pulseBorder 1.2s ease-in-out;
}

@keyframes pulseBorder {
  0% {
    border-color: var(--border-glass);
    box-shadow: none;
  }

  50% {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
  }

  100% {
    border-color: var(--border-glass);
    box-shadow: none;
  }
}

/* SUBTABS NAVIGATION — segmented pill */
.analysis-nav-sticky {
  display: flex;
  justify-content: center;
  position: sticky;
  top: calc(10px + var(--dashboard-header-height, 132px) + 8px);
  z-index: 88;
  margin: 0 0 24px;
  padding: 0;
  background: transparent;
  border: none;
  backdrop-filter: none;
}

.analysis-nav-shell {
  width: 100%;
  max-width: 440px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.subtabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border-glass);
}

.subtabs-segmented {
  display: flex;
  width: 100%;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.068);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.subtab {
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}

.subtabs-segmented .subtab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.subtab-icon {
  font-size: 0.72rem;
  opacity: 0.75;
  line-height: 1;
}

.subtab:hover {
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.04);
}

.subtab.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.subtabs-segmented .subtab.is-active .subtab-icon {
  opacity: 1;
}

.ai-summary-panel {
  background: rgba(15, 23, 42, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 16px;
}

.ai-summary-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
}

.ai-summary-panel-head h5 {
  margin: 0;
  color: var(--primary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.ai-summary-spinner {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-summary-spinner-icon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

.ai-summary-content .ai-exec-summary {
  margin: 0;
  line-height: 1.55;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.result-chart-card {
  margin: 20px 0 24px;
}

.analysis-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.collapsible-summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--text-primary);
  outline: none;
  list-style: none;
}

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

.collapsible-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--primary);
  transition: transform 0.2s ease;
}

details[open] > .collapsible-summary::before {
  transform: rotate(90deg);
}

.audit-panel-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 14px;
  padding-top: 4px;
}

.audit-block-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.audit-block + .audit-block {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#hovered-event-details {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 14px;
  margin-top: 14px;
  min-height: 44px;
}

#hovered-event-details.is-pinned {
  background: rgba(15, 23, 42, 0.03);
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
}

.chart-event-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px 0;
}

.chart-event-panel,
.chart-event-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-event-date {
  margin: 0;
  color: var(--primary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-event-price-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.036);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-event-price-bar.is-compact {
  padding: 8px 10px;
  font-size: 0.76rem;
}

.chart-event-price-bar strong {
  color: var(--text-primary);
}

.chart-event-hint,
.chart-event-preview-cta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chart-event-expand {
  border-left: 3px solid var(--event-accent, #94a3b8);
  background: rgba(15, 23, 42, 0.02);
  border-radius: 8px;
  overflow: hidden;
}

.chart-event-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.chart-event-summary::-webkit-details-marker {
  display: none;
}

.chart-event-chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.chart-event-expand[open] .chart-event-chevron {
  transform: rotate(45deg);
  margin-top: 4px;
}

.chart-event-summary-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chart-event-title {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.35;
}

.chart-event-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--event-accent, var(--text-secondary));
}

.chart-event-score-teaser,
.chart-event-price-teaser {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.chart-event-teaser {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.chart-event-body {
  padding: 0 14px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chart-event-section-title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.chart-event-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.chart-event-metric {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-event-metric-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.chart-event-metric-value {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.chart-event-score-line,
.chart-event-tech-line {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-domain-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chart-domain-chip {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
}

.chart-domain-chip.is-pos {
  color: #22c55e;
}

.chart-domain-chip.is-neg {
  color: #ef4444;
}

.chart-event-llm-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.chart-event-llm-content p {
  margin: 0 0 8px;
}

.chart-event-llm-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.chart-event-llm-loading.hidden,
.llm-why.hidden,
.llm-takeaway.hidden {
  display: none;
}

.chart-event-preview-card {
  border-left: 3px solid var(--event-accent, #94a3b8);
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.02);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chart-event-preview-card strong {
  font-size: 0.84rem;
  color: var(--text-primary);
}

.chart-event-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

#chart-metrics-strip.hidden {
  display: none !important;
}

.chart-events-intelligence {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 16px;
  padding-top: 16px;
}

.chart-events-intelligence.is-visible {
  display: block;
}

.chart-events-intelligence.is-pinned {
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
  border-radius: 10px;
  padding: 14px;
}

.chart-event-zone {
  position: relative;
}

.chart-events-intelligence-header {
  margin-bottom: 14px;
}

.chart-events-intelligence-header h4 {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.chart-events-hover-date {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary);
  margin-left: 6px;
}

.chart-events-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#important-events-timeline-container .timeline-card-v2 {
  margin-bottom: 12px;
}

.verdict-context-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.verdict-context-strip span strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* SUBPANEL ACTIONS */
.subpanel {
  display: none;
  animation: panelFade 0.4s ease-out;
}

.subpanel.is-active {
  display: block;
}

/* Technical snapshot minimum dataset (#9) */
.tech-snap-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
}

.tech-snap-status.is-warn {
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(234, 179, 8, 0.06);
}

.tech-snap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.tech-snap-cell {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.015);
}

.tech-snap-cell.is-missing {
  border-color: rgba(148, 163, 184, 0.15);
  background: rgba(148, 163, 184, 0.04);
}

.tech-snap-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tech-snap-value {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tech-snap-reason {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* SUMMARY TAB DESIGN */
.summary-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.section-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 24px;
}

.section-card h4 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.section-card p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.section-card ul {
  list-style: none;
}

.section-card ul li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.section-card ul li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--primary);
}

/* PILLS */
.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-secondary);
}

.pill.pos {
  background: var(--success-bg);
  color: #34d399;
  border: 1px solid var(--success-border);
}

.pill.neg {
  background: var(--error-bg);
  color: #fb7185;
  border: 1px solid var(--error-border);
}

.pill.neu {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}

/* SCORES TAB DESIGN */
.score-row {
  margin-bottom: 20px;
}

.score-row header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.score-row header span:first-child {
  color: var(--text-primary);
  text-transform: capitalize;
}

.score-row header span:last-child {
  color: var(--primary);
  font-family: var(--font-mono);
}

.score-track {
  height: 10px;
  background: rgba(15, 23, 42, 0.054);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.score-fill {
  height: 100%;
  border-radius: 99px;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Event intelligence panel — no left timeline rail */
#important-events-timeline-container,
.intelligence-events-panel {
  position: relative;
  padding: 0;
}

#important-events-timeline-container::before,
.intelligence-events-panel::before {
  content: none !important;
  display: none !important;
}

/* Event cards — reliable expand/collapse */
.timeline-card-v2 > summary {
  cursor: pointer;
  list-style: none;
}

.timeline-card-v2 > summary::-webkit-details-marker {
  display: none;
}

.timeline-card-v2[open] > .timeline-card-body {
  display: flex;
}

.timeline-card-v2 > .timeline-card-body {
  display: flex;
}

/* Digital Twin lists inside intelligence — no decorative rail bullets */
.intelligence-events-panel .event-description-block,
.intelligence-events-panel .timeline-card-v2 {
  border-left: none;
}

.intelligence-events-panel ul {
  list-style: disc;
  padding-left: 18px;
}

.intelligence-events-panel ul li::before {
  content: none;
  display: none;
}

/* INTERACTIVE VERTICAL TIMELINE FOR EVENTS (legacy timeline rail) */
.timeline-wrap {
  position: relative;
  padding: 20px 0;
}

.timeline-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 2px;
  background: rgba(15, 23, 42, 0.08);
}

.timeline-event {
  position: relative;
  padding-left: 54px;
  margin-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: 11px;
  top: 18px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-gradient-end);
  border: 4px solid var(--text-muted);
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.02);
  transition: all 0.25s ease;
}

.timeline-event.positive .timeline-dot {
  border-color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}

.timeline-event.negative .timeline-dot {
  border-color: var(--error);
  box-shadow: 0 0 8px var(--error-glow);
}

.timeline-event.neutral .timeline-dot {
  border-color: var(--warning);
  box-shadow: 0 0 8px var(--warning-glow);
}

.timeline-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.timeline-card:hover {
  transform: translateX(4px);
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--surface-glass-hover);
}

.timeline-card h3 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.timeline-card .meta-row {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.timeline-card .evidence {
  font-size: 0.95rem;
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.timeline-card.is-expanded .evidence {
  max-height: 500px;
  opacity: 1;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline-card .expand-trigger {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
  display: block;
  margin-top: 10px;
}

/* COMPARISON LAYOUT */
.compare-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.compare-actions {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  margin-bottom: 30px;
}

.compare-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.compare-col {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s ease;
}

.compare-col:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.compare-col h3 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.compare-col p {
  margin-bottom: 12px;
  line-height: 1.5;
}

.chart-wrap {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

#vip-chart-card .chart-wrap {
  border: 1px solid rgba(99, 102, 241, 0.45);
  box-shadow: 0 10px 34px rgba(99, 102, 241, 0.2);
}

#chart-metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.chart-metric {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.02);
}

.chart-metric .k {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.chart-metric .v {
  display: block;
  margin-top: 3px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.96rem;
}

/* ════════ INSTITUTIONAL COMPARISON WORKSPACE (Bloomberg-style density) ════ */
.cmp-section {
  margin-bottom: 16px;
  padding: 16px 18px;
}
.cmp-price-wrap {
  min-height: 280px;
}

.cmp-price-tf-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.05);
  padding: 4px;
  border-radius: 6px;
}

.cmp-price-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cmp-section > h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--text-primary);
}
.cmp-sub {
  font-size: 0.78rem;
  margin: 0 0 12px;
  color: var(--text-muted);
}
.cmp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.cmp-section-head h3 { margin: 0; }
.cmp-sort-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cmp-sort-label select {
  background: rgba(15, 23, 42, 0.045);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 5px 8px;
  cursor: pointer;
}

/* Compact company cards */
.compare-col { padding: 14px 16px; }
.compare-col h3 { font-size: 1.05rem; margin-bottom: 2px; }
.compare-col p { margin-bottom: 6px; line-height: 1.35; font-size: 0.85rem; }
.compare-col:hover { transform: translateY(-2px); }

/* Ranking leaderboard */
.rank-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rank-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}
.rank-card.is-top {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}
.rank-pos {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-secondary);
}
.rank-card.is-top .rank-pos { color: var(--success); }
.rank-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.rank-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

/* Chart ↔ Timeline sync (#5) */
.chart-sync-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.timeline-card-v2.is-chart-selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 10px var(--primary-glow) !important;
}

.timeline-card-v2.out-of-chart-window {
  opacity: 0.45;
}

.timeline-card-v2.out-of-chart-window:not([open]) summary {
  filter: grayscale(0.3);
}

/* Compare timeline overlay (#10) */
.cmp-timeline-overlay {
  margin-top: 12px;
  padding: 8px 0 4px;
}

.cmp-tl-axis {
  position: relative;
  height: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.cmp-tl-axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.cmp-tl-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cmp-tl-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-left: 8px;
  line-height: 1.3;
}

.cmp-tl-label span {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.cmp-tl-track {
  position: relative;
  height: 28px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.cmp-tl-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cmp-tl-dot:hover {
  transform: scale(1.35);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.45);
  z-index: 2;
}

.cmp-window-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--border-glass-focus);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}

/* Not-Available marker */
.cmp-na {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.78rem;
  opacity: 0.7;
}

/* Dense matrix */
.cmp-table { margin-bottom: 0; box-shadow: none; }
.cmp-table table { font-variant-numeric: tabular-nums; width: 100%; table-layout: fixed; }
.data-table.cmp-table th,
.data-table.cmp-table td {
  padding: 4px 4px;
  font-size: 0.7rem;
  white-space: normal;
  word-wrap: break-word;
}
.cmp-matrix { overflow-x: auto; }
.cmp-row-label {
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface-glass);
}
.cmp-table tr:hover td { background: rgba(15, 23, 42, 0.03); }

/* Recommendation explanation cards */
.rec-grid,
.evt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.rec-card,
.evt-card {
  background: rgba(15, 23, 42, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
}
.rec-head,
.evt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.rec-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 999px;
}
.rec-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.rec-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
}
.rec-list li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
  line-height: 1.35;
}

/* Event intelligence cards */
.evt-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
}
.evt-label { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; white-space: nowrap; }
.evt-title { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evt-val { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }

/* Radar sizing — keep proportionate, not dominating */
.cmp-radar-wrap { padding: 12px; max-height: 420px; }
.cmp-radar-wrap canvas { max-height: 380px; }

/* PREMIUM TABLES */
.data-table {
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 32px;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 16px 20px;
  font-size: 0.95rem;
}

.data-table th {
  background: rgba(15, 23, 42, 0.036);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: rgba(15, 23, 42, 0.02);
  color: var(--text-primary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.table-group-header td {
  background: rgba(99, 102, 241, 0.08) !important;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  padding-top: 12px;
  padding-bottom: 12px;
}

/* RANKINGS PANEL */
.rankings-leaderboard {
  margin-top: 24px;
  animation: panelFade 0.5s ease-out;
}

.rankings-leaderboard table {
  width: 100%;
}

.rankings-leaderboard td.rank {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  width: 60px;
}

.rankings-leaderboard .badge-rec {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.rankings-leaderboard .badge-rec.buy {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.rankings-leaderboard .badge-rec.sell {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.rankings-leaderboard .badge-rec.hold {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.rankings-action-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.rankings-action-btn:hover {
  background: var(--primary);
  color: white;
}

/* Portfolio/watchlist action cells: keep Edit / Analyse / Remove inside the
   frame on wide tables — let them wrap and shrink instead of overflowing. */
.pf-cell-actions, .wl-cell-actions { white-space: normal !important; text-align: right; }
.pf-cell-actions .rankings-action-btn,
.wl-cell-actions .rankings-action-btn {
  padding: 5px 9px;
  font-size: 0.76rem;
  margin: 2px 0 2px 4px;
  display: inline-block;
}

/* RESPONSIVENESS */
@media (max-width: 768px) {
  .app-shell {
    padding: 12px 14px 60px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .user-email-pill {
    max-width: 55vw;
  }

  .topbar-actions {
    flex-shrink: 0;
  }

  .topbar-action-btn {
    padding: 6px 9px;
    font-size: 0.72rem;
  }

  .dashboard-header {
    top: 6px;
  }

  .top-tabs {
    gap: 4px;
    padding: 6px;
  }

  .top-tab {
    min-height: 50px;
    padding: 7px 6px 10px;
  }

  .top-tab .tab-desc {
    display: none;
  }

  .workspace-strip {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }

  .workspace-strip-actions {
    width: 100%;
  }

  .workspace-strip-actions .primary-btn,
  .workspace-strip-actions .ghost-btn {
    flex: 1;
  }

  .period-active-pill {
    margin-left: 0;
  }

  .analyse-toolbar-wrap.is-home {
    margin-top: 100px;
  }

  .workspace-tray {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px 12px;
  }

  .workspace-tray-head {
    width: 100%;
  }

  .workspace-tray-sub {
    display: none;
  }

  .workspace-chips {
    width: 100%;
  }

  .workspace-tray-actions {
    width: 100%;
  }

  .workspace-tray-actions .primary-btn,
  .workspace-tray-actions .ghost-btn {
    flex: 1;
  }

  .analysis-nav-sticky {
    top: calc(6px + var(--dashboard-header-height, 118px) + 6px);
    padding: 0 8px;
  }

  .analysis-nav-shell {
    max-width: 100%;
  }

  .company-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .timeline-wrap::before {
    left: 12px;
  }

  .timeline-event {
    padding-left: 36px;
  }

  .timeline-dot {
    left: 3px;
    width: 16px;
    height: 16px;
  }

  .verdict-hero-grid,
  .driver-grid {
    grid-template-columns: 1fr;
  }

  .hero-score-stack {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-score strong {
    font-size: 1.45rem;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Keep autocomplete dropdowns inside the viewport on small screens. The
     desktop base rule extends them 142px past the right edge for a roomier
     list, which overflows / clips off the side of a phone. */
  .autocomplete-dropdown {
    left: 0;
    right: 0;
  }
}

.time-pill {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 16px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.time-pill:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-primary);
}

.time-pill.is-active {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
}

/* ── BetaIdeaz v3 Chart & Search ───────────────────────────────────── */
.gf-company-header {
  align-items: flex-start;
  gap: 16px;
}

.gf-company-identity {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.gf-company-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(56, 189, 248, 0.2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--primary);
  flex-shrink: 0;
  overflow: hidden;
}

.gf-company-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gf-quote-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-top: 8px;
}

.gf-current-price {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.gf-day-change.positive { color: #22c55e; }
.gf-day-change.negative { color: #ef4444; }

.gf-chart-card {
  padding: 0;
  overflow: hidden;
}

.gf-chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gf-chart-modes,
.gf-chart-toggles,
.gf-period-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.gf-chart-mode,
.gf-chart-toggle,
.gf-period-btn {
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gf-chart-mode:hover,
.gf-chart-toggle:hover,
.gf-period-btn:hover {
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.08);
}

.gf-chart-mode.is-active,
.gf-period-btn.is-active {
  background: var(--primary);
  color: var(--bg);
}

.gf-chart-toggle.is-on {
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--primary);
}

.gf-period-strip {
  padding: 8px 16px 12px;
}

.gf-chart-wrap {
  min-height: 380px;
  position: relative;
}

.lw-chart-host {
  width: 100%;
  min-height: 380px;
}

.hidden-fallback-chart {
  display: none;
}

.gf-crosshair-tooltip {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.78rem;
  pointer-events: none;
  max-width: 280px;
}

.gf-crosshair-tooltip.hidden {
  display: none;
}

.ac-quote {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.cmp-price-wrap .lw-chart-host {
  min-height: 320px;
}

.cmp-compare-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.cmp-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--text-primary);
}

.cmp-legend-item.is-hidden {
  opacity: 0.45;
}

.cmp-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cmp-normalize-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ── Compare Workspace (compact bar on Analyse) ───────────────────── */
.compare-workspace {
  position: relative;
  z-index: 100;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(8px);
}

.compare-workspace.hidden {
  display: none;
}

.cw-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--chip-bg);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: 16px;
}

.cw-bar-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.cw-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 120px;
}

.cw-add-dropdown {
  position: relative;
}

.cw-add-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 20px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cw-add-toggle.is-open,
.cw-add-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
  box-shadow: var(--shadow-glow);
}

.cw-caret {
  font-size: 0.65rem;
  opacity: 0.7;
}

.cw-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 999999;
  width: min(280px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-solid, #0b0e17);
  border: 1px solid var(--border-glass);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-glass);
}

.cw-add-menu input {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--text-primary);
  font-size: 0.82rem;
  box-sizing: border-box;
}

.cw-ac-in-menu {
  position: static;
  margin-top: 4px;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: none;
  border: 1px solid var(--border-glass);
}

.compare-workspace .workspace-compare-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.compare-workspace .ghost-btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.workspace-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 8px;
  vertical-align: middle;
  border-radius: 999px;
  background: var(--primary);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 800;
}

.chip-status {
  font-size: 0.65rem;
  opacity: 0.7;
  margin-right: 2px;
}

.gf-chart-toggle--soon {
  opacity: 0.5;
}


/* ── Catalyst Engine + busy-button spinner (Catalyst feature) ──────────── */
button.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: progress;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}
.btn-busy-label { display: inline-block; line-height: 1; }

.catalyst-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.catalyst-skew {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 150px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.02);
}
.catalyst-skew-score { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.catalyst-skew-label { font-size: 0.78rem; font-weight: 700; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.catalyst-skew-net { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.catalyst-summary {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 3px solid var(--primary);
  padding-left: 12px;
}
.catalyst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.catalyst-card {
  border: 1px solid var(--border-glass);
  border-left: 3px solid var(--text-muted);
  border-radius: 10px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.catalyst-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }
.catalyst-card.cat-bullish { border-left-color: var(--success); }
.catalyst-card.cat-bearish { border-left-color: var(--error); }
.catalyst-card.cat-neutral { border-left-color: var(--text-muted); }
.catalyst-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.catalyst-icon { font-size: 1.2rem; flex-shrink: 0; }
.catalyst-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.catalyst-title strong { color: var(--text-primary); font-size: 0.92rem; }
.catalyst-basis { color: var(--text-muted); font-size: 0.7rem; margin-top: 1px; }
.catalyst-dir {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.catalyst-dir.cat-bullish { color: var(--success); background: var(--success-bg); }
.catalyst-dir.cat-bearish { color: var(--error); background: rgba(244, 63, 94, 0.1); }
.catalyst-dir.cat-neutral { color: var(--text-secondary); background: rgba(148, 163, 184, 0.1); }
.catalyst-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.catalyst-metric { display: flex; flex-direction: column; }
.cm-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.cm-value { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.cm-value.cat-bullish { color: var(--success); }
.cm-value.cat-bearish { color: var(--error); }
.cm-sub { font-size: 0.6rem; color: var(--text-muted); margin-top: 1px; }
.catalyst-prob-bar {
  height: 5px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.catalyst-prob-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.catalyst-rationale { margin: 0; color: var(--text-secondary); font-size: 0.78rem; line-height: 1.45; }
.catalyst-disclaimer { margin: 16px 0 0; color: var(--text-muted); font-size: 0.72rem; font-style: italic; }
.catalyst-skew.cat-bullish .catalyst-skew-score, .catalyst-skew.cat-bullish .catalyst-skew-label { color: var(--success); }
.catalyst-skew.cat-bearish .catalyst-skew-score, .catalyst-skew.cat-bearish .catalyst-skew-label { color: var(--error); }
.catalyst-skew.cat-neutral .catalyst-skew-score, .catalyst-skew.cat-neutral .catalyst-skew-label { color: var(--text-secondary); }
.catalyst-foot { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.catalyst-strength {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-glass);
}
.catalyst-strength.es-strong { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.catalyst-strength.es-moderate { color: #38bdf8; background: rgba(56, 189, 248, 0.1); }
.catalyst-strength.es-emerging { color: var(--warning); background: var(--warning-bg); }
.catalyst-strength.es-baseline { color: var(--text-muted); background: rgba(148, 163, 184, 0.08); }
.catalyst-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.catalyst-next-sched {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--border-glass);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.catalyst-next-sched .cns-days { color: var(--text-muted); font-size: 0.76rem; }
.catalyst-sched-chip {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 2px 7px;
}

/* Catalyst Engine — minimal dropdown UI */
.catalyst-disclosure { width: 100%; }
.catalyst-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  outline: none;
  padding: 2px 0;
}
.catalyst-summary-bar::-webkit-details-marker { display: none; }
.catalyst-summary-bar::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.catalyst-disclosure[open] .catalyst-summary-bar::after { transform: rotate(180deg); }
.catalyst-summary-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.catalyst-skew-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.02);
}
.csi-score { font-size: 1.1rem; font-weight: 800; }
.csi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.catalyst-skew-inline.cat-bullish .csi-score, .catalyst-skew-inline.cat-bullish .csi-label { color: var(--success); }
.catalyst-skew-inline.cat-bearish .csi-score, .catalyst-skew-inline.cat-bearish .csi-label { color: var(--error); }
.catalyst-skew-inline.cat-neutral .csi-score, .catalyst-skew-inline.cat-neutral .csi-label { color: var(--text-secondary); }
.catalyst-body { margin-top: 16px; }
.catalyst-select-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.catalyst-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.03);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.catalyst-select:focus { border-color: var(--primary); }
/* Native option popup: force a dark background + light text so the list is
   readable (otherwise the select's light text renders on the OS-white popup). */
.catalyst-select option {
  background-color: #ffffff;
  color: #0f172a;
  padding: 6px;
}
:root[data-theme="dark"] .catalyst-select option {
  background-color: #0f172a;
  color: #f8fafc;
}
.catalyst-foot-chips { margin-top: 14px; }

/* Catalyst Engine — geopolitical sub-section */
.catalyst-geo {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-glass);
}
.catalyst-geo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.catalyst-geo-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }

/* ── Rankings tab (Sensex 30 daily ranking) ───────────────────────────── */
.rankings-wrap { margin-top: 20px; }
.rankings-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.rankings-title { margin: 0; color: var(--text-primary); font-weight: 800; }
.rankings-sub { margin: 4px 0 0; color: var(--text-secondary); font-size: 0.85rem; }
.rankings-universe {
  margin: 0 0 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.rankings-universe.is-error {
  color: var(--error);
}
.rankings-provenance {
  margin: 0 0 16px 0;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.rankings-provenance.hidden {
  display: none;
}
.rk-prov-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.rk-prov-item strong {
  color: var(--text-primary);
  font-weight: 600;
}
.rk-prov-sep {
  color: var(--text-muted);
  opacity: 0.5;
}
.rankings-date-select[type="date"] {
  color-scheme: dark;
  min-width: 150px;
}
.rankings-table-scroll { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-glass); }
.rankings-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 720px; }
.rankings-table thead th {
  text-align: left; padding: 12px 14px; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700;
  background: rgba(15, 23, 42,0.03); position: sticky; top: 0;
}
.rankings-table td { padding: 11px 14px; border-top: 1px solid var(--border-glass); }
.rk-row { cursor: pointer; transition: background 0.12s ease; }
.rk-row:hover { background: rgba(99,102,241,0.06); }
.rk-num { font-weight: 800; color: var(--text-primary); font-family: var(--font-mono, monospace); width: 46px; }
.rk-delta { width: 52px; }
.rk-stock { display: flex; flex-direction: column; }
.rk-stock strong { color: var(--text-primary); }
.rk-ticker-sub { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono, monospace); }
.rk-ticker { color: var(--text-primary); font-family: var(--font-mono, monospace); }
.rk-composite { font-size: 1.02rem; font-family: var(--font-mono, monospace); }
.rk-up { color: var(--success); font-weight: 700; }
.rk-down { color: var(--error); font-weight: 700; }
.rk-flat { color: var(--text-muted); }
/* Yahoo-style day change ("−4.90 (−2.26%)") in the custom-ranking table */
.rk-change { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; font-family: var(--font-mono, monospace); font-size: 0.9rem; }
.rk-change.rk-muted { color: var(--text-muted); font-weight: 500; }

/* Custom-ranking mode: show only the user's basket, hide the daily Sensex board. */
.rankings-wrap.custom-mode .rankings-header,
.rankings-wrap.custom-mode #rankings-universe-label,
.rankings-wrap.custom-mode #rankings-provenance,
.rankings-wrap.custom-mode #rankings-main-board,
.rankings-wrap.custom-mode #rankings-drilldown { display: none; }
.rk-new { color: var(--primary); font-weight: 800; font-size: 0.66rem; }
/* Sector column: sector name + realised return since the ranking date */
.rk-sector-name { display: block; }
.rk-since {
  display: block; margin-top: 3px;
  font-size: 0.76rem; font-weight: 700; color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}
.rk-rec {
  font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.02em;
}
.rk-rec.rec-strong-buy { color: var(--success); background: var(--success-bg); }
.rk-rec.rec-buy { color: var(--success); background: rgba(16,185,129,0.08); }
.rk-rec.rec-hold { color: var(--text-secondary); background: rgba(148,163,184,0.1); }
.rk-rec.rec-sell { color: var(--error); background: rgba(244,63,94,0.08); }
.rk-rec.rec-strong-sell { color: var(--error); background: rgba(244,63,94,0.15); }
@media (max-width: 720px) { .rk-hide-sm { display: none; } .rankings-table { min-width: 0; } }

/* Drill-down */
.rankings-drilldown {
  margin-top: 18px; padding: 18px; border: 1px solid var(--border-glass);
  border-radius: 12px; background: rgba(15, 23, 42,0.02);
}
/* Inline drilldown: the company insight expands as a row right below the clicked
   company (accordion), instead of at the bottom of the board. */
.rk-dd-cell { padding: 0 4px 10px; background: transparent; }
.rk-dd-cell .rankings-drilldown { margin-top: 6px; }
.rk-row-active > td { background: rgba(99, 102, 241, 0.06); }
.rk-row-active > td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.rk-dd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.rk-dd-head h3 { margin: 0; color: var(--text-primary); }
.rk-dd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.rk-dd-col h4 { margin: 0 0 10px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.rk-dom-grid { display: flex; flex-direction: column; gap: 6px; }
.rk-dom { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.rk-dom span { color: var(--text-secondary); }
.rk-dom strong { color: var(--text-primary); font-family: var(--font-mono, monospace); }
.rk-list { margin: 0; padding-left: 4px; list-style: none; }
.rk-list li { font-size: 0.8rem; color: var(--text-secondary); padding: 5px 0; line-height: 1.4; border-bottom: 1px solid rgba(255,255,255,0.04); }
.rk-ev-cat { font-size: 0.64rem; text-transform: uppercase; color: var(--primary); font-weight: 700; margin-right: 4px; }

/* Full Analysis Button inside Drilldown */
.btn-full-analysis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  margin-top: 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0 16px;
  border: none;
  background: var(--primary);
  color: white;
}
.btn-full-analysis:hover, .btn-full-analysis:focus {
  background: var(--primary-hover);
  transform: translateY(-1px);
  outline: none;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-full-analysis:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

@media (max-width: 720px) {
  .btn-full-analysis {
    width: 100%;
  }
}
/* Rankings — date picker + per-share tags */
.rankings-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rankings-date-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
}
.rankings-date-select { width: auto; min-width: 130px; padding: 7px 10px; font-size: 0.82rem; }
.rk-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.rk-tag {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border-glass);
}
.rk-tag.tone-gold { color: #f5b301; background: rgba(245, 179, 1, 0.12); border-color: rgba(245,179,1,0.3); }
.rk-tag.tone-up   { color: var(--success); background: var(--success-bg); }
.rk-tag.tone-down { color: var(--error); background: rgba(244, 63, 94, 0.1); }
.rk-tag.tone-warn { color: var(--warning); background: var(--warning-bg); }
.rk-tag.tone-info { color: #38bdf8; background: rgba(56, 189, 248, 0.1); }

/* Rankings — relative rating pill (Call) */
.rk-rating {
  font-size: 0.7rem; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.02em;
}
.rk-rate-strong-buy  { color: var(--success); background: var(--success-bg); border: 1px solid var(--success-border); }
.rk-rate-buy         { color: var(--success); background: rgba(16,185,129,0.1); }
.rk-rate-hold        { color: var(--text-secondary); background: rgba(148,163,184,0.12); }
.rk-rate-sell        { color: var(--warning); background: var(--warning-bg); }
.rk-rate-strong-sell { color: var(--error); background: rgba(244,63,94,0.14); }
.rk-rate-neutral     { color: var(--text-muted); background: rgba(148,163,184,0.08); }

/* Rankings — classification (sector + cap) tags: descriptive, muted */
.rk-tag.tone-sector { color: #a78bfa; background: rgba(167, 139, 250, 0.1); border-color: rgba(167,139,250,0.25); }
.rk-tag.tone-cap    { color: var(--text-secondary); background: rgba(148, 163, 184, 0.12); }

/* ── Custom ranking (rank any user-chosen basket) ─────────────────────────── */
.rankings-custom {
  margin: 16px 0 4px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.04);
  padding: 4px 16px;
}
.rankings-custom[open] { padding-bottom: 16px; }
.rankings-custom-body { margin-top: 12px; }
.custom-rank-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.custom-rank-input-wrap { position: relative; flex: 1 1 320px; min-width: 200px; }
.custom-rank-input {
  flex: 1 1 320px; min-width: 200px;
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border-glass);
  background: var(--surface-2, rgba(255,255,255,0.03));
  color: var(--text-primary); font-size: 0.9rem;
}
.custom-rank-input-wrap .custom-rank-input { flex: none; width: 100%; min-width: 0; }
.custom-rank-dropdown { top: calc(100% + 4px); left: 0; right: 0; }
.custom-rank-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.custom-rank-count {
  font-family: var(--font-mono, monospace); font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted); min-width: 46px; text-align: center;
}
.custom-rank-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.custom-rank-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono, monospace); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.03em; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: rgba(99,102,241,0.14); color: var(--primary);
  border: 1px solid rgba(99,102,241,0.28);
}
.custom-rank-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; border: none; border-radius: 50%;
  font-size: 0.9rem; line-height: 1; cursor: pointer;
  background: rgba(99,102,241,0.18); color: var(--primary);
  transition: background 0.15s, color 0.15s;
}
.custom-rank-chip-x:hover { background: var(--error, #ef4444); color: #fff; }
.custom-rank-controls .primary-btn:disabled,
.custom-rank-controls .ghost-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.custom-rank-status { margin-top: 10px; min-height: 1.1em; }
.custom-rank-results { margin-top: 14px; }

/* Watchlist — star toggle + panel */
.wl-star {
  background: none; border: none; cursor: pointer; font-size: 1.15rem; line-height: 1;
  color: var(--text-muted); padding: 2px 4px; transition: color 0.15s ease, transform 0.1s ease;
}
.wl-star:hover { transform: scale(1.2); color: #f5b301; }
.wl-star.is-on { color: #f5b301; }
.rk-call-cell { white-space: nowrap; }
.wl-call-cell { white-space: nowrap; }
.wl-nocall { color: var(--text-muted); font-size: 0.82rem; font-style: italic; }
#analysis-watch-btn.is-watching { color: #f5b301; border-color: rgba(245,179,1,0.4); }
.wl-analyse { margin-left: 8px; }

/* Watchlist — named-list selector bar */
.wl-lists-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 4px 0 14px;
}
.wl-list-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.wl-list-tab {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--surface-2, rgba(255,255,255,0.04)); color: var(--text-muted);
  border: 1px solid var(--border, rgba(255,255,255,0.12)); border-radius: 999px;
  padding: 6px 10px 6px 14px; font-size: 0.86rem; font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.wl-list-tab:hover { color: var(--text); border-color: rgba(245,179,1,0.4); }
.wl-list-tab.is-active {
  color: #f5b301; border-color: rgba(245,179,1,0.55); background: rgba(245,179,1,0.1);
}
.wl-list-count {
  font-size: 0.72rem; font-weight: 700; min-width: 18px; text-align: center;
  padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.08);
}
.wl-list-tab.is-active .wl-list-count { background: rgba(245,179,1,0.2); }
.wl-list-del {
  cursor: pointer; background: rgba(239,83,80,0.12); border: none; color: #ef5350;
  font-size: 0.8rem; line-height: 1; width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.85; transition: color 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.wl-list-del:hover { opacity: 1; color: #fff; background: #ef5350; }
.wl-lists-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.wl-list-action {
  cursor: pointer; background: none; color: var(--text-muted);
  border: 1px solid var(--border, rgba(255,255,255,0.12)); border-radius: 8px;
  padding: 5px 11px; font-size: 0.8rem; font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.wl-list-action:hover { color: var(--text); border-color: rgba(245,179,1,0.4); }

/* Inline new/rename-list form */
.wl-new-form { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; flex-wrap: wrap; }
.wl-new-input {
  flex: 1 1 220px; min-width: 180px; padding: 8px 12px; font-size: 0.88rem;
  color: var(--text); background: var(--surface-2, rgba(255,255,255,0.05));
  border: 1px solid var(--border, rgba(255,255,255,0.14)); border-radius: 9px; outline: none;
}
.wl-new-input:focus { border-color: rgba(245,179,1,0.55); }
.wl-new-create {
  cursor: pointer; padding: 8px 16px; font-size: 0.84rem; font-weight: 700;
  color: #1a1400; background: #f5b301; border: none; border-radius: 9px;
}
.wl-new-create:hover { background: #ffc21f; }
.wl-new-cancel {
  cursor: pointer; padding: 8px 14px; font-size: 0.84rem; font-weight: 600;
  color: var(--text-muted); background: none;
  border: 1px solid var(--border, rgba(255,255,255,0.14)); border-radius: 9px;
}
.wl-new-cancel:hover { color: var(--text); }

/* Add-a-stock search box */
.wl-add-stock { margin: 0 0 16px; }
.wl-add-input-wrap { position: relative; max-width: 460px; }
.wl-add-input {
  width: 100%; padding: 10px 14px; font-size: 0.9rem; color: var(--text);
  background: var(--surface-2, rgba(255,255,255,0.05));
  border: 1px solid var(--border, rgba(255,255,255,0.14)); border-radius: 10px; outline: none;
}
.wl-add-input:focus { border-color: rgba(245,179,1,0.55); }
.wl-add-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40; }

/* Google Identity Services button mount — centre the rendered button */
.google-btn-mount { display: flex; justify-content: center; margin: 8px 0; min-height: 44px; }

/* Filter-by-call chip bar */
.wl-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 14px; }
.wl-filter-chip {
  cursor: pointer; background: var(--surface-2, rgba(255,255,255,0.04)); color: var(--text-muted);
  border: 1px solid var(--border, rgba(255,255,255,0.12)); border-radius: 999px;
  padding: 5px 13px; font-size: 0.8rem; font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.wl-filter-chip:hover { color: var(--text); border-color: rgba(245,179,1,0.4); }
.wl-filter-chip.is-active {
  color: #1a1400; background: #f5b301; border-color: #f5b301;
}

/* "Analysing…" placeholder while a composite is being fetched */
.wl-analysing { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.82rem; font-style: italic; }
.wl-mini-spinner {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  border: 2px solid rgba(245,179,1,0.25); border-top-color: #f5b301;
  animation: spin 0.7s linear infinite;
}

/* Watchlist topbar button */
.topbar-action-btn--watch { font-weight: 700; }
.topbar-action-btn--watch:hover { color: #f5b301; border-color: rgba(245,179,1,0.4); }
.topbar-action-btn--watch.is-active {
  color: #f5b301; border-color: rgba(245,179,1,0.5); background: rgba(245,179,1,0.1);
}

/* ── Portfolio ─────────────────────────────────────────────────────────────── */
.topbar-action-btn--portfolio { font-weight: 700; }
.topbar-action-btn--portfolio:hover { color: var(--primary-hover); border-color: rgba(99,102,241,0.4); }
.topbar-action-btn--portfolio.is-active {
  color: var(--primary-hover); border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.10);
}

.pf-pos { color: var(--success); }
.pf-neg { color: var(--error); }
.pf-plpct { font-size: 0.82em; opacity: 0.85; }

/* Portfolio picker (multiple named portfolios) */
.pf-head-left { display: flex; flex-direction: column; gap: 6px; }
.pf-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pf-select {
  min-width: 200px; max-width: 320px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass); background: var(--surface-glass);
  color: var(--text-primary); font-size: 0.9rem; font-weight: 700;
  cursor: pointer;
}
.pf-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--radius-sm); border: 1px solid var(--border-glass);
  background: var(--surface-glass); color: var(--text-secondary);
  font-size: 0.9rem; cursor: pointer; line-height: 1;
}
.pf-icon-btn:hover { color: var(--text-primary); border-color: rgba(99,102,241,0.4); }
.pf-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pf-danger-btn { background: var(--error); border-color: var(--error); }
.pf-danger-btn:hover { filter: brightness(0.92); }

/* Hero: live value + today's move + stat tiles */
.pf-hero {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; justify-content: space-between;
  margin: 16px 0 18px; padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(99,102,241,0.02));
  border: 1px solid var(--border-glass);
}
.pf-hero:empty { display: none; }
.pf-hero-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 4px;
}
.pf-hero-value { font-size: 2.1rem; font-weight: 800; line-height: 1.05; color: var(--text-primary); }
.pf-hero-day { display: inline-block; margin-top: 6px; font-size: 0.9rem; font-weight: 700; }
.pf-tiles { display: flex; flex-wrap: wrap; gap: 22px; }
.pf-tile-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin-bottom: 4px;
}
.pf-tile-value { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); white-space: nowrap; }

/* Performance chart */
.pf-perf {
  margin-bottom: 18px; padding: 16px 18px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-glass); border: 1px solid var(--border-glass);
}
.pf-perf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pf-perf-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.pf-perf-sub { font-size: 1rem; font-weight: 700; margin-top: 2px; }
.pf-perf-range-lbl { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.pf-perf-canvas { position: relative; height: 240px; margin-top: 10px; }
.pf-perf-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 8px; }
.pf-range, .pf-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(var(--ink-rgb), 0.06); }
.pf-range button, .pf-seg button {
  border: none; background: none; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
}
.pf-range button.is-active, .pf-seg button.is-active {
  background: var(--surface-solid); color: var(--primary-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Insights chips */
.pf-insights { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.pf-insights:empty { display: none; }
.pf-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  background: var(--surface-glass); border: 1px solid var(--border-glass);
}
.pf-chip-warn { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.08); }
.pf-chip-k { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.pf-chip-v { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

/* Layout: allocation donut + main column */
.pf-body { display: flex; gap: 18px; align-items: flex-start; }
.pf-alloc {
  flex: 0 0 300px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
}
.pf-alloc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pf-alloc-title {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.pf-alloc-head .pf-seg button { padding: 4px 9px; font-size: 0.72rem; }
.pf-alloc-canvas { position: relative; height: 220px; }
.pf-main { flex: 1 1 auto; min-width: 0; }

/* Pro table: numeric alignment, sortable headers, day pill */
.pf-table th.pf-th-num, .pf-table td.pf-td-num { text-align: right; }
.pf-table th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.pf-table th[data-sort]:hover { color: var(--text-primary); }
.pf-table th.pf-sorted { color: var(--primary-hover); }
.pf-table th.pf-sorted[data-dir="asc"]::after { content: " ▲"; font-size: 0.7em; }
.pf-table th.pf-sorted[data-dir="desc"]::after { content: " ▼"; font-size: 0.7em; }
.pf-daypill { display: inline-block; margin-left: 6px; font-size: 0.72rem; font-weight: 600; }

/* Add-holding form */
.pf-add-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px;
}
.pf-add-search { position: relative; flex: 1 1 260px; min-width: 200px; }
.pf-add-search input, .pf-num {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-primary);
  font-size: 0.9rem;
}
.pf-num { flex: 0 0 110px; width: 110px; }
.pf-date { flex: 0 0 150px; width: 150px; color-scheme: light dark; }
.pf-add-form .primary-btn { padding: 9px 18px; }
.pf-ac { top: calc(100% + 4px); left: 0; right: 0; }
.pf-add-msg { flex-basis: 100%; font-size: 0.82rem; color: var(--error); }

/* Quick-add modal */
.pf-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 20px;
}
.pf-modal.hidden { display: none; }
.pf-modal-card {
  position: relative;
  width: min(400px, 100%);
  padding: 22px 22px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-lg);
}
.pf-modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--text-muted); line-height: 1;
}
.pf-modal-title { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); margin-bottom: 4px; }
.pf-modal-company { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 16px; }
.pf-modal-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 12px;
}
.pf-modal-field input {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-primary);
  font-size: 0.95rem; font-weight: 500;
  color-scheme: light dark;
}
.pf-modal-optional { font-weight: 500; color: var(--text-muted); }
.pf-modal-msg { font-size: 0.82rem; color: var(--error); min-height: 1em; margin-bottom: 10px; }
.pf-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 760px) {
  .pf-body { flex-direction: column; }
  .pf-alloc { flex-basis: auto; width: 100%; }
  .pf-num { flex: 1 1 100px; width: auto; }
  .pf-hero { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px; }
  .pf-hero-value { font-size: 1.7rem; }
  .pf-tiles { gap: 16px; justify-content: space-between; }
  .pf-perf-canvas { height: 200px; }
}

/* ============================================================================
   ADMIN PANEL STYLES
   ============================================================================ */

/* ============================================================================
   ADMIN PORTAL – PREMIUM REDESIGN
   ============================================================================ */

.admin-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 32px;
}

.admin-header {
  margin-bottom: 4px;
  position: relative;
  padding-bottom: 16px;
}

.admin-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent-purple));
  border-radius: 3px;
}

.admin-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  letter-spacing: -0.03em;
}

.admin-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
  letter-spacing: 0.01em;
}

/* --- Admin Tabs --- */
.admin-tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 0;
  margin-bottom: 20px;
  overflow-x: auto;
}

.admin-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
  position: relative;
  text-align: center;
}

.admin-tab-btn:hover {
  color: var(--text-primary);
}

.admin-tab-btn.is-active {
  color: var(--primary-hover);
  border-bottom-color: var(--primary-hover);
}

.admin-subtab {
  display: none;
}

.admin-subtab.is-active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: adminFadeIn 0.3s ease;
}

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

/* --- Search / Filter Controls --- */
.admin-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-search-wrapper, .admin-filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.admin-input {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.02);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.admin-select {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: var(--surface-solid);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.admin-select:focus {
  border-color: var(--primary);
}

/* --- Users Table --- */
.table-scroll-wrapper {
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.admin-table th {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(var(--ink-rgb), 0.025);
  border-bottom: 1px solid var(--border-glass);
}

.admin-table td {
  padding: 14px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.04);
  vertical-align: middle;
}

.admin-table tbody tr {
  transition: background 0.15s ease;
}

.admin-table tbody tr:hover {
  background: rgba(var(--ink-rgb), 0.03);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Badges --- */
.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-badge--admin {
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-purple);
}

.admin-badge--user {
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--text-secondary);
}

.admin-badge--free {
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--text-secondary);
}

.admin-badge--pro {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-hover);
}

.admin-badge--gold {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.admin-badge--restricted {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.admin-badge--active {
  background: var(--success-bg);
  color: var(--success);
}

/* --- Action Buttons --- */
.admin-action-btn {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--primary-hover);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.admin-action-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
}

.admin-action-btn--danger {
  color: var(--error);
  border-color: rgba(244, 63, 94, 0.2);
}

.admin-action-btn--danger:hover {
  background: var(--error-bg);
  border-color: var(--error);
}

/* --- Pagination --- */
.admin-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.admin-pagination-btn {
  background: var(--surface-solid);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
}

.admin-pagination-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.admin-pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.admin-pagination-info {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* --- Stats Cards --- */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.admin-stats-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.01);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.admin-stats-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-stats-value {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.admin-stats-subtext {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Subscription Plan Cards --- */
.admin-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.admin-plan-card {
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--border-glass);
  background: rgba(var(--ink-rgb), 0.015);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-plan-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.admin-plan-card-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-glass);
  position: relative;
}

.admin-plan-card-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-glass);
}

.admin-plan-card--free .admin-plan-card-header::before {
  background: linear-gradient(90deg, #64748b, #94a3b8);
}

.admin-plan-card--pro .admin-plan-card-header::before {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

.admin-plan-card--gold .admin-plan-card-header::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.admin-plan-card-body {
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-plan-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-plan-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
  text-transform: capitalize;
}

.admin-plan-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-plan-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-plan-field .admin-input {
  max-width: 100%;
}

/* Feature checklist (checkboxes + custom merits) */
.admin-plan-features {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid rgba(var(--ink-rgb), 0.05);
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.05);
}

.admin-plan-features-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.admin-plan-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.admin-plan-checkbox-label:hover {
  background: rgba(var(--ink-rgb), 0.03);
}

.admin-plan-checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Custom merit item in the checklist */
.admin-merit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.admin-merit-item:hover {
  background: rgba(var(--ink-rgb), 0.03);
}

/* Toggle switch for enabling/disabling merits */
.merit-toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.merit-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.merit-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(var(--ink-rgb), 0.18);
  border-radius: 18px;
  transition: background 0.25s ease;
}
.merit-toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.merit-toggle-switch input:checked + .merit-toggle-slider {
  background: var(--primary);
}
.merit-toggle-switch input:checked + .merit-toggle-slider::before {
  transform: translateX(14px);
}

/* Disabled merit row */
.admin-merit-item.merit-disabled {
  opacity: 0.45;
}
.admin-merit-item.merit-disabled .merit-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Feature binding select dropdown */
.merit-feature-select {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-secondary);
  cursor: pointer;
  max-width: 130px;
  transition: border-color 0.15s ease;
}
.merit-feature-select:focus {
  border-color: var(--primary);
  outline: none;
}

.admin-merit-item .merit-text {
  flex: 1;
}

.admin-merit-item .merit-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.admin-merit-item:hover .merit-delete-btn {
  opacity: 1;
}

.admin-merit-item .merit-delete-btn:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Add Merit inline form */
.admin-add-merit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

.admin-add-merit-btn {
  background: transparent;
  color: var(--primary);
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  width: 100%;
}

.admin-add-merit-btn:hover {
  background: rgba(99, 102, 241, 0.06);
}

.admin-add-merit-btn .plus-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px dashed var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.admin-add-merit-input-row {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

.admin-add-merit-input-row.is-visible {
  display: flex;
}

.admin-add-merit-input-row .admin-input {
  min-width: 0;
  flex: 1;
  max-width: none;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.admin-add-merit-input-row .merit-submit-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: filter 0.15s;
  flex-shrink: 0;
}

.admin-add-merit-input-row .merit-submit-btn:hover {
  filter: brightness(1.1);
}

/* --- Save Button --- */
.admin-plan-save-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  color: white;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s;
  margin-top: 4px;
}

.admin-plan-save-btn:hover {
  filter: brightness(1.08);
}

.admin-plan-save-btn:active {
  transform: scale(0.98);
}

.admin-plan-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- User Detail Modal --- */
.admin-modal-card {
  width: min(580px, 100%) !important;
}

.admin-detail-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  background: rgba(var(--ink-rgb), 0.025);
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  border: 1px solid var(--border-glass);
}

.admin-detail-summary div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-modal-sec-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

.admin-modal-logs-scroll {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: rgba(var(--ink-rgb), 0.01);
}

.admin-modal-table {
  font-size: 0.8rem;
}

.admin-modal-table th, .admin-modal-table td {
  padding: 8px 12px;
}

.admin-action-select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-glass);
  background: var(--surface-solid);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.admin-action-select:focus {
  border-color: var(--primary);
}

.admin-restricted-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(244, 63, 94, 0.05);
  border: 1px dashed rgba(244, 63, 94, 0.2);
}

.admin-reason-input {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-glass);
  background: var(--surface-solid);
  color: var(--text-primary);
  font-size: 0.75rem;
}

/* ============================================================================
   PROGRESS LOADER SPINNER & MESSAGE STYLES
   ============================================================================ */

.progress-loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(var(--primary-rgb), 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinner 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}


/* ==========================================================================
   UPGRADE MODAL & SUBSCRIPTION CARDS (THEME AWARE)
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
}

:root[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.75);
}

.modal-content {
  position: relative;
  background: var(--surface-solid, #ffffff);
  border: 1px solid var(--border-glass, rgba(15, 23, 42, 0.1));
  border-radius: var(--radius-lg, 16px);
  padding: 32px;
  width: 92%;
  max-width: 900px;
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.25);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-primary, #0f172a);
}

:root[data-theme="dark"] .modal-content {
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

.modal:not(.hidden) .modal-content {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(var(--ink-rgb), 0.05);
  border: 1px solid var(--border-glass);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: rgba(var(--ink-rgb), 0.12);
  color: var(--text-primary);
}

.upgrade-modal-header {
  text-align: center;
  margin-bottom: 28px;
}

.upgrade-modal-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.upgrade-modal-subtitle {
  color: var(--primary-hover, #6366f1);
  font-size: 0.98rem;
  font-weight: 600;
}

.upgrade-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.plan-card {
  background: rgba(var(--ink-rgb), 0.03);
  border: 1px solid var(--border-glass, rgba(15, 23, 42, 0.1));
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  border-color: var(--primary, #6366f1);
}

.plan-name {
  font-size: 1.4rem;
  font-weight: 800;
  text-transform: capitalize;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.plan-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 20px;
  flex-grow: 1;
  min-height: 38px;
}

.plan-merits {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.plan-merits li {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.plan-merits li::before {
  content: '✓';
  color: var(--primary, #6366f1);
  font-weight: 800;
  font-size: 0.9rem;
}

.plan-btn {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

.plan-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
  filter: brightness(1.08);
}

.plan-btn:active {
  transform: translateY(0);
}

/* Gold Plan Styling */
.plan-card.plan-gold {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(var(--ink-rgb), 0.02) 100%);
}

.plan-card.plan-gold:hover {
  border-color: #f59e0b;
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.2);
}

.plan-card.plan-gold .plan-merits li::before {
  color: #d97706;
}

.plan-card.plan-gold .plan-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.plan-card.plan-gold .plan-btn:hover {
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
  filter: brightness(1.08);
}

/* BLOCKED MODAL */
.blocked-modal-content {
  background: var(--surface-solid, #ffffff);
  border-radius: var(--radius-lg, 16px);
  padding: 2.5rem 2rem;
  box-shadow: 0 24px 48px rgba(239, 68, 68, 0.25);
  animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  color: var(--text-primary);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   GLOBAL & ADMIN BUTTON ENHANCEMENTS — SPACIOUS & WELL-FORMATTED
   ========================================================================== */

/* Cache Controls Card */
.admin-cache-card {
  margin-top: 24px;
  width: 100%;
  padding: 24px 28px;
  border-radius: 16px;
  background: rgba(var(--ink-rgb), 0.02);
  border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-cache-card-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-cache-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.admin-cache-controls-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.admin-cache-input-wrap {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.admin-cache-input-wrap .admin-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.admin-cache-input-wrap .autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1200;
  max-height: 240px;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Cache Buttons */
.admin-cache-btn {
  height: 44px;
  padding: 0 22px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-cache-btn .btn-icon {
  font-size: 1rem;
}

.admin-cache-btn--single {
  background: rgba(244, 63, 94, 0.08);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.admin-cache-btn--single:hover {
  background: rgba(244, 63, 94, 0.18);
  border-color: #f43f5e;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(244, 63, 94, 0.25);
}

.admin-cache-btn--single:active {
  transform: translateY(0);
}

.admin-cache-btn--all {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.35);
}

.admin-cache-btn--all:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(244, 63, 94, 0.5);
  filter: brightness(1.1);
}

.admin-cache-btn--all:active {
  transform: translateY(0);
}

/* Spacious Filter & Search Buttons */
.admin-controls-row .admin-input,
.admin-controls-row .admin-select {
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.admin-controls-row button,
.admin-filter-group button {
  height: 44px;
  padding: 0 22px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Action Buttons inside User Table */
.admin-action-btn {
  padding: 8px 14px !important;
  border-radius: 8px !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  letter-spacing: 0.01em;
}

.admin-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.admin-action-btn--danger:hover {
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}

/* Upgrade & Save Buttons formatting */
.admin-plan-save-btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 10px;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.admin-plan-save-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.45);
}

/* ==========================================================================
   ANALYSIS PROGRESS STATUS PILL & ANIMATION
   ========================================================================== */
/* ==========================================================================
   ANALYSIS PROGRESS STATUS PILL & ANIMATION (CENTERED GLASS BADGE)
   ========================================================================== */
#analyze-message {
  margin: 22px auto 0 auto;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.analysis-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 28px;
  border-radius: 9999px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  animation: statusPillFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards, pillGlowPulse 3s ease-in-out infinite alternate;
}

:root[data-theme="light"] .analysis-status-pill {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.09), rgba(168, 85, 247, 0.06));
  border-color: rgba(139, 92, 246, 0.28);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-pulse-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(168, 85, 247, 0.25);
  border-top-color: #a855f7;
  border-right-color: #6366f1;
  border-radius: 50%;
  animation: spinner 0.75s linear infinite;
  flex-shrink: 0;
}

.status-text-content {
  font-family: var(--font-display);
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.015em;
}

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

@keyframes pillGlowPulse {
  0% { box-shadow: 0 8px 24px rgba(99, 102, 241, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
  100% { box-shadow: 0 12px 36px rgba(168, 85, 247, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
}

/* --- Toast Notifications --- */
#notification-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast-notification {
  pointer-events: auto;
  min-width: 250px;
  padding: 12px 18px;
  border-radius: var(--radius-md, 8px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
  color: var(--text-primary, #fff);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.3));
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-notification.toast-success {
  border-left: 3px solid var(--success, #10b981);
}

.toast-notification.toast-error {
  border-left: 3px solid var(--error, #ef4444);
}

.toast-icon {
  font-size: 1.1rem;
}

.toast-success .toast-icon {
  color: var(--success, #10b981);
}

.toast-error .toast-icon {
  color: var(--error, #ef4444);
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =====================================================================
   RESPONSIVE / MOBILE PASS — adapt to any device
   Tiers:  1024 tablet · 768 phone-landscape · 600 phone · 400 small phone
   Plus:   coarse-pointer touch sizing, reduced-motion, safe-area, dvh.
   Everything here is inside a media/feature query, so desktop is untouched.
   ===================================================================== */

/* Use dynamic viewport height so the mobile URL bar doesn't cause a jump. */
@supports (min-height: 100dvh) {
  body { min-height: 100dvh; }
  .auth-wrap { min-height: calc(100dvh - 100px); }
}

/* ── Tablet: roomier gutters, cap chart heights ───────────────────────── */
@media (max-width: 1024px) {
  .page { max-width: 100%; }
  .pf-perf-canvas { height: 240px; }
}

/* ── Phone (portrait + small landscape) ───────────────────────────────── */
@media (max-width: 600px) {
  /* Topbar: let actions wrap into a tidy second row, shrink the email pill. */
  .topbar { row-gap: 8px; padding: 10px 12px; }
  .topbar-right { flex-wrap: wrap; row-gap: 8px; }
  .user-email-pill { max-width: 46vw; font-size: 0.72rem; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .topbar-action-btn { padding: 8px 10px; font-size: 0.74rem; }

  /* Primary tabs full-width and comfortable. */
  .top-tab { flex: 1; }

  /* Home hero search: keep input + button on one line but never overflow. */
  .analyse-toolbar-wrap.is-home { margin-top: 84px; }
  .search-card { flex-wrap: wrap; }
  .search-input-wrapper { flex: 1 1 100%; }
  .analyse-toolbar-wrap.is-home .search-card .primary-btn { flex: 1 1 100%; }

  /* Period strip (Lifetime / 10Y / … / year) wraps and stays tappable. */
  .period-strip .time-explorer-controls { flex-wrap: wrap; gap: 6px; }

  /* 16px inputs prevent iOS auto-zoom on focus. */
  .search-card input, #company-input,
  .pf-add-search input, .pf-num,
  .pf-modal-field input, .wl-add-input-wrap input { font-size: 16px; }

  /* Portfolio header/picker stacks cleanly. */
  .rankings-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .pf-picker { flex-wrap: wrap; }
  .pf-select { flex: 1 1 160px; min-width: 0; }
  .pf-refresh-btn, #pf-refresh-btn { align-self: flex-start; }

  /* Add-holding form: search full width, qty/price side by side, date + Add full width. */
  .pf-add-form { gap: 8px; }
  .pf-add-search { flex: 1 1 100%; min-width: 0; }
  .pf-num { flex: 1 1 calc(50% - 4px); width: auto; }
  .pf-date { flex: 1 1 100%; }
  .pf-add-form .primary-btn { flex: 1 1 100%; }

  /* Charts reflow to full width; heads wrap. */
  .pf-perf-head, .pf-alloc-head { flex-wrap: wrap; gap: 10px; }
  .pf-range, .pf-seg { flex-wrap: wrap; }
  .pf-perf-canvas { height: 190px; }
  .pf-alloc-canvas { height: 220px; }

  /* Modals become bottom sheets: full-width, slide up, safe-area padded. */
  .pf-modal { align-items: flex-end; padding: 0; }
  .pf-modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: pfSheetUp 0.28s ease;
  }
  .pf-modal-actions { gap: 10px; }
  .pf-modal-actions .primary-btn, .pf-modal-actions .ghost-btn, .pf-modal-actions .danger-btn { flex: 1; }
}

@keyframes pfSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Portfolio holdings: table → card-per-holding on phones ────────────── */
@media (max-width: 680px) {
  #portfolio-panel .rankings-table-scroll { overflow: visible; }
  #pf-table { display: block; width: 100%; min-width: 0; }
  #pf-table tbody { display: block; width: 100%; }
  /* Keep the header row for screen readers, off-screen visually. */
  #pf-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  #pf-table tr.rk-row {
    display: block;
    background: rgba(var(--ink-rgb), 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  /* Every cell (incl. the normally-hidden ones) becomes a label:value line. */
  #pf-table td, #pf-table td.rk-hide-sm {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    border: none;
    text-align: right;
    font-size: 0.9rem;
    white-space: normal;
  }
  #pf-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-align: left;
    white-space: nowrap;
  }

  /* Stock name = card header (full width, no label). */
  #pf-table td.pf-cell-stock {
    display: block;
    text-align: left;
    padding: 0 0 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-glass);
  }
  #pf-table td.pf-cell-stock::before { content: none; }

  /* Value + Net P&L read as the headline numbers. */
  #pf-table td[data-label="Value"], #pf-table td[data-label="Net P&L"] { font-size: 1rem; }

  /* Actions = a button row pinned to the card footer. */
  #pf-table td.pf-cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 0 0;
    margin-top: 6px;
    border-top: 1px solid var(--border-glass);
  }
  #pf-table td.pf-cell-actions::before { content: none; }
  #pf-table td.pf-cell-actions .rankings-action-btn { min-height: 40px; padding: 8px 14px; }
}

/* ── Small phones ─────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .app-shell { padding: 10px 10px 60px; }
  .pf-hero-value { font-size: 1.5rem; }
  .rankings-title { font-size: 1.05rem; }
  .pf-num { flex: 1 1 100%; }        /* qty / price each on their own line */
  .brand-mark { font-size: 1rem; }
}

/* ── Touch devices: guarantee 44px targets & kill the 300ms tap delay ──── */
@media (hover: none) and (pointer: coarse) {
  button, a, input, select, textarea, [role="button"] { touch-action: manipulation; }
  .pf-icon-btn, .pf-range button, .pf-seg button, .wl-filter-chip,
  .rankings-action-btn, .period-btn, .gf-period-btn,
  .topbar-action-btn, .top-tab { min-height: 44px; }
  .pf-icon-btn { min-width: 44px; }
  .pf-add-form .primary-btn, .pf-modal-actions .primary-btn,
  .pf-modal-actions .ghost-btn, .pf-modal-actions .danger-btn { min-height: 46px; }
}

/* ── Accessibility: visible keyboard focus + honour reduced-motion ─────── */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   WATCHLIST — mobile pass (match the portfolio's polish)
   ══════════════════════════════════════════════════════════════════════════ */

/* Phone: list selector + filters become single scrollable rows, forms stack. */
@media (max-width: 600px) {
  .wl-lists-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .wl-list-tabs,
  .wl-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .wl-list-tabs::-webkit-scrollbar,
  .wl-filter-bar::-webkit-scrollbar { display: none; }
  .wl-list-tab,
  .wl-filter-chip { flex: 0 0 auto; }
  .wl-lists-actions { justify-content: stretch; }
  .wl-lists-actions .wl-list-action { flex: 1; text-align: center; min-height: 40px; }

  .wl-new-form { flex-wrap: wrap; }
  .wl-new-input { flex: 1 1 100%; }
  .wl-new-create, .wl-new-cancel { flex: 1; min-height: 44px; }

  .wl-add-input-wrap { max-width: 100%; }
  .google-btn-mount { width: 100%; }
}

/* Phone: watchlist table → one card per stock (mirrors #pf-table). */
@media (max-width: 680px) {
  #watchlist-panel .rankings-table-scroll { overflow: visible; }
  #watchlist-table { display: block; width: 100%; min-width: 0; }
  #watchlist-table tbody { display: block; width: 100%; }
  /* Keep the header for screen readers, hidden visually. */
  #watchlist-table thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }

  #watchlist-table tr.rk-row {
    display: block;
    background: rgba(var(--ink-rgb), 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  /* Every cell (incl. the normally-hidden Composite) → label:value line. */
  #watchlist-table td,
  #watchlist-table td.rk-hide-sm {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    border: none;
    text-align: right;
    font-size: 0.9rem;
    white-space: normal;
  }
  #watchlist-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-align: left;
    white-space: nowrap;
  }

  /* Stock name = card header. */
  #watchlist-table td.wl-cell-stock {
    display: block;
    text-align: left;
    padding: 0 0 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-glass);
  }
  #watchlist-table td.wl-cell-stock::before { content: none; }

  /* The Call is the headline read. */
  #watchlist-table td.wl-call-cell { font-size: 1rem; }

  /* Actions pinned to a card footer row. */
  #watchlist-table td.wl-cell-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0 0;
    margin-top: 6px;
    border-top: 1px solid var(--border-glass);
  }
  #watchlist-table td.wl-cell-actions::before { content: none; }
  #watchlist-table td.wl-cell-actions .rankings-action-btn { min-height: 40px; padding: 8px 12px; }
  #watchlist-table td.wl-cell-actions .wl-star { font-size: 1.4rem; padding: 4px 8px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   TOPBAR RESTRUCTURE — inline Analyse/Rankings + account (email) dropdown
   ══════════════════════════════════════════════════════════════════════════ */
.topbar-inline-tabs {
  display: flex; gap: 8px; background: none; border: none; padding: 0; box-shadow: none;
}
/* Match the other topbar buttons (Clear Cache etc.): bordered pill buttons. */
.topbar-inline-tabs .top-tab {
  min-height: 0; flex: 0 0 auto; cursor: pointer;
  padding: 6px 13px; border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb), 0.10);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-secondary);
  font-family: var(--font-display);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.topbar-inline-tabs .top-tab .tab-label { font-size: 0.78rem; font-weight: 600; }
.topbar-inline-tabs .top-tab:hover { border-color: rgba(99,102,241,0.35); color: var(--text-primary); }
.topbar-inline-tabs .top-tab.is-active {
  background: rgba(99,102,241,0.14); border-color: rgba(99,102,241,0.45); color: var(--primary);
}

/* Account dropdown (email trigger + menu) */
.account-menu { position: relative; }
.account-trigger {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: rgba(127,127,127,0.08); color: var(--text-primary);
  border: 1px solid var(--border-glass, rgba(127,127,127,0.2)); border-radius: 999px;
  padding: 5px 10px 5px 12px; font-size: 0.82rem; transition: border-color 0.15s ease;
}
.account-trigger:hover, .account-trigger.is-active { border-color: rgba(99,102,241,0.5); }
.account-trigger .account-email {
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; padding: 0; border: none;
}
.account-caret { font-size: 0.7rem; color: var(--text-muted); }
.account-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 210px;
  background: #ffffff; border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,0.18); padding: 6px;
}
:root[data-theme="dark"] .account-dropdown { background: #1e293b; border-color: rgba(255,255,255,0.14); }
.account-item {
  display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer;
  background: none; border: none; border-radius: 8px; padding: 10px 12px;
  font-size: 0.88rem; font-weight: 600; color: var(--text-primary); text-align: left;
  transition: background 0.15s ease;
}
.account-item:hover { background: rgba(99,102,241,0.1); }
.account-item.is-active { background: rgba(99,102,241,0.14); color: var(--primary); }
.account-item--danger { color: var(--error, #ef5350); }
.account-item--danger:hover { background: rgba(239,83,80,0.12); }
.account-sep { height: 1px; background: rgba(127,127,127,0.2); margin: 5px 4px; }

/* Mobile: keep the relocated nav + account tidy */
@media (max-width: 600px) {
  .topbar-inline-tabs .top-tab { padding: 8px 12px; }
  .account-trigger .account-email { max-width: 34vw; }
  .account-dropdown { min-width: 190px; }
}

/* =====================================================================
   MOBILE NAV — Hamburger button + slide-down drawer
   The desktop topbar-right is hidden on small screens and replaced
   by a compact controls strip (theme toggle + hamburger) and a
   collapsible drawer containing all nav actions.
   ===================================================================== */

/* Hide mobile-only controls on desktop */
.topbar-mobile-controls { display: none; }
.mobile-nav-drawer { display: none; }

/* ── Mobile breakpoint: ≤ 700px ─────────────────────────────────────── */
@media (max-width: 700px) {
  /* Hide the desktop right section, show mobile controls */
  .topbar-right { display: none !important; }
  .topbar-mobile-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  /* Hamburger button */
  .mobile-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(var(--ink-rgb), 0.12);
    background: rgba(var(--ink-rgb), 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    padding: 0;
  }
  .mobile-menu-btn:hover,
  .mobile-menu-btn.is-open {
    background: rgba(var(--ink-rgb), 0.08);
    border-color: rgba(99, 102, 241, 0.3);
  }
  .hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-secondary);
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .mobile-menu-btn.is-open .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .mobile-menu-btn.is-open .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .mobile-menu-btn.is-open .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Fullscreen Mobile Navigation Drawer Overlay */
  .mobile-nav-drawer {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 99999 !important;
    background: var(--surface-solid, #0B0E17) !important;
    background-image: radial-gradient(circle at 50% 0%, rgba(99,102,241,0.15) 0%, transparent 75%) !important;
    flex-direction: column !important;
    padding: 20px 18px !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }
  .mobile-nav-drawer.is-open {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  .mobile-nav-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-bottom: 16px !important;
    border-bottom: 1px solid rgba(var(--ink-rgb), 0.1) !important;
    margin-bottom: 12px !important;
  }
  .mobile-nav-brand {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .mobile-drawer-close-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: 1px solid var(--chip-border) !important;
    background: var(--chip-bg) !important;
    color: var(--text-primary) !important;
    font-size: 1.1rem !important;
    cursor: pointer !important;
  }
  .mobile-nav-user {
    padding: 10px 14px !important;
    background: rgba(var(--ink-rgb), 0.04) !important;
    border-radius: 10px !important;
    margin-bottom: 16px !important;
  }
  .mobile-nav-email {
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
    font-weight: 600 !important;
    word-break: break-all !important;
  }
  .mobile-nav-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  .mobile-nav-btn {
    width: 100% !important;
    padding: 14px 18px !important;
    border-radius: 12px !important;
    border: 1px solid rgba(var(--ink-rgb), 0.12) !important;
    background: rgba(var(--ink-rgb), 0.04) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-display) !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: left !important;
    min-height: 48px !important;
  }
  .mobile-nav-btn:hover, .mobile-nav-btn:active {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
  }
  .mobile-nav-btn--danger {
    color: #f43f5e !important;
    border-color: rgba(244, 63, 94, 0.3) !important;
    margin-top: 12px !important;
  }
  .mobile-nav-btn--danger:hover {
    background: rgba(244, 63, 94, 0.2) !important;
    color: #ffffff !important;
  }
  .mobile-nav-btn--admin:not(.hidden) {
    grid-column: 1 / -1;
  }

  /* Topbar itself: brand + mobile controls on one line */
  .topbar {
    padding: 10px 14px;
    gap: 0;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  /* Compact app shell */
  .app-shell { padding: 10px 12px 70px; }

  /* Dashboard header: remove sticky top gap so it sits flush */
  .dashboard-header { top: 4px; margin-bottom: 16px; }

  /* Tabs: full-width and tall enough to tap */
  .top-tab { flex: 1; min-height: 46px; }

  /* Compare workspace: stack vertically on mobile */
  /* Ultra-Compact Compare Workspace on Mobile */
  .compare-workspace {
    margin: 0 0 8px !important;
    padding: 6px 10px !important;
    border-radius: 10px !important;
  }
  .cw-bar {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 6px 8px !important;
    margin-bottom: 0 !important;
    border-radius: 8px !important;
  }
  .cw-bar-label {
    width: auto !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    margin-right: 4px !important;
    order: 1 !important;
  }
  .workspace-chips {
    order: 2 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    flex: 1 1 auto !important;
    width: auto !important;
    margin: 0 !important;
  }
  .workspace-chip {
    display: inline-flex !important;
    align-items: center !important;
    padding: 2px 6px !important;
    gap: 4px !important;
    font-size: 0.74rem !important;
    height: 26px !important;
    min-height: 26px !important;
    border-radius: 99px !important;
    box-sizing: border-box !important;
    max-width: 160px !important;
  }
  .workspace-chip .chip-name {
    max-width: 95px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .workspace-chip .chip-score {
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 4px !important;
    font-size: 0.65rem !important;
  }
  .cw-add-dropdown { order: 3 !important; position: relative !important; }
  .cw-add-toggle {
    padding: 2px 8px !important;
    font-size: 0.72rem !important;
    height: 26px !important;
    min-height: 26px !important;
    border-radius: 99px !important;
  }
  .cw-add-menu {
    position: absolute !important;
    top: calc(100% + 4px) !important;
    right: 0 !important;
    left: auto !important;
    width: min(260px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    z-index: 999999 !important;
    background: var(--surface-solid, #0b0e17) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6) !important;
    padding: 6px !important;
  }
  .cw-ac-in-menu {
    max-height: 140px !important;
    overflow-y: auto !important;
  }
  .workspace-compare-btn {
    order: 4 !important;
    flex: 0 0 auto !important;
    min-height: 26px !important;
    height: 26px !important;
    padding: 2px 10px !important;
    font-size: 0.74rem !important;
    border-radius: 8px !important;
  }
  #cw-clear-workspace-btn {
    order: 5 !important;
    min-height: 26px !important;
    height: 26px !important;
    padding: 2px 8px !important;
    font-size: 0.72rem !important;
    border-radius: 8px !important;
  }

  /* Search card: stacks on mobile */
  .search-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .search-input-wrapper { width: 100%; }
  .search-card .primary-btn {
    width: 100%;
    min-width: 0;
    height: 50px;
    min-height: 50px;
    font-size: 1rem;
    border-radius: 12px;
  }
  .search-card input {
    height: 50px;
    min-height: 50px;
    font-size: 16px; /* prevent iOS zoom */
  }

  /* Period strip: scroll horizontally */
  .time-explorer-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
    gap: 6px;
  }
  .time-explorer-controls::-webkit-scrollbar { display: none; }
  .period-btn { flex-shrink: 0; }

  /* Company heading stacks */
  .company-heading { flex-direction: column; gap: 14px; }
  .company-actions-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .action-bar-btn {
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 6px !important;
    font-size: 0.72rem !important;
  }

  /* Rankings header stacks */
  .rankings-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .rankings-controls { flex-wrap: wrap; gap: 8px; }
  .rankings-date-label { flex: 1 1 calc(50% - 4px); }

  /* Chart toolbar wraps */
  .gf-chart-toolbar { padding: 10px 12px 0; }
  .gf-chart-modes { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .gf-chart-toggles { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .gf-chart-modes::-webkit-scrollbar,
  .gf-chart-toggles::-webkit-scrollbar { display: none; }
  .gf-chart-mode, .gf-chart-toggle, .gf-period-btn { flex-shrink: 0; }
  .gf-period-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .gf-period-strip::-webkit-scrollbar { display: none; }
  .gf-chart-wrap { min-height: 260px; }

  /* Score grid: 2 cols on phone */
  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Admin panel tabs: scrollable row */
  .admin-tabs-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }
  .admin-tabs-nav::-webkit-scrollbar { display: none; }
  .admin-tab-btn { flex-shrink: 0; }

  /* Toast: full-width on mobile */
  .toast-notification { max-width: calc(100vw - 32px); left: 16px; right: 16px; bottom: 16px; }

  /* Home hero search spacing */
  .analyse-toolbar-wrap.is-home { margin-top: 60px; }
}

/* ── Very small phones (≤ 400px) ─────────────────────────────────────── */
@media (max-width: 400px) {
  .topbar { padding: 8px 10px; }
  .brand-mark { font-size: 0.95rem; }
  .mobile-nav-actions { grid-template-columns: 1fr; }
  .mobile-nav-btn--danger { grid-column: auto; }
  .metric-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   UI POLISH — Sleek Icon Action Bar, Fixed Technical Snapshot & High Surface Area Chart
   ===================================================================== */

/* 1. Global Search card: rectangle with soft corners */
.search-card { border-radius: 14px !important; }
.search-card input, #company-input { border-radius: 8px !important; }
.search-card .primary-btn { border-radius: 10px !important; }

/* 2. Sleek Company Icon Action Bar */
.company-actions-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.action-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.action-bar-btn .action-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.action-bar-btn:hover {
  background: rgba(var(--ink-rgb), 0.08);
  color: var(--text-primary);
  border-color: rgba(var(--ink-rgb), 0.2);
  transform: translateY(-1px);
}

.action-bar-btn--watch.is-watching {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.action-bar-btn--portfolio:hover {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.action-bar-btn--compare:hover {
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.08);
}

.action-bar-btn--new:hover {
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
}

/* 3. Technical Snapshot: Fixed clean full-width layout */
#technical-snapshot-details {
  display: block !important;
  margin-top: 16px !important;
  padding-top: 14px !important;
  border-top: 1px solid rgba(var(--ink-rgb), 0.08) !important;
}

.tech-snap-status {
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 8px 12px !important;
  margin-bottom: 12px !important;
  border-radius: 8px !important;
  background: rgba(15, 23, 42, 0.03) !important;
  border: 1px solid rgba(var(--ink-rgb), 0.08) !important;
  font-size: 0.78rem !important;
}

.tech-snap-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  gap: 8px !important;
}

.tech-snap-cell {
  padding: 10px 12px !important;
  border-radius: 8px !important;
  background: rgba(var(--ink-rgb), 0.02) !important;
  border: 1px solid rgba(var(--ink-rgb), 0.06) !important;
}

.tech-snap-label {
  font-size: 0.68rem !important;
  color: var(--text-muted) !important;
  font-weight: 600 !important;
  letter-spacing: 0.03em !important;
}

.tech-snap-value {
  margin-top: 2px !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
}

/* 4. High-Surface Area Chart Card */
.gf-chart-card {
  padding: 0 !important;
  border-radius: 14px !important;
  overflow: hidden !important;
}

.gf-chart-wrap {
  min-height: 350px !important;
}

.lw-chart-host {
  min-height: 350px !important;
}

/* ── Mobile-only targeted fixes (≤ 700px) ─────────────────────────── */
@media (max-width: 700px) {
  /* 1. Global Search card */
  .search-card {
    border-radius: 12px !important;
    padding: 10px 12px;
    gap: 8px;
  }
  .search-card input, #company-input {
    height: 46px;
    min-height: 46px;
    font-size: 15px;
    border-radius: 8px !important;
  }
  .search-card .primary-btn {
    height: 46px;
    min-height: 46px;
    border-radius: 8px !important;
    font-size: 0.95rem;
  }

  /* 2. Company heading & action bar */
  .company-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }
  .company-heading h2 { font-size: 1.3rem; margin-bottom: 2px; }
  .company-heading p  { font-size: 0.78rem; }
  .gf-company-logo { width: 38px; height: 38px; border-radius: 8px; }

  /* Company Action Bar: Sleek 2x2 equal-dimension grid on mobile */
  .company-actions-bar {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
    padding-bottom: 2px;
  }

  .action-bar-btn {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 6px !important;
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    gap: 4px !important;
    justify-content: center !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 3. Technical snapshot: 2-col grid */
  .tech-snap-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* 4. Chart height: high surface area */
  .gf-chart-wrap { min-height: 320px !important; }
  .lw-chart-host { min-height: 320px !important; }

  /* 5. Chart Toolbar & Period strip */
  .gf-chart-toolbar { padding: 8px 10px 0; gap: 6px; }
  .gf-chart-modes, .gf-chart-toggles { gap: 4px; padding-bottom: 8px; }
  .gf-chart-mode, .gf-chart-toggle, .gf-period-btn { padding: 4px 8px; font-size: 0.72rem; min-height: 30px; }
  .gf-period-strip { padding: 6px 10px 8px; gap: 4px; }

  /* 6. Metric grid — mobile tight responsive 2-column layout */
  .metric-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .metric-card, .metric-item {
    padding: 6px 8px !important;
    min-width: 0 !important;
    overflow: hidden !important;
    word-break: break-word !important;
    box-sizing: border-box !important;
  }
  .metric-label {
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .metric-value {
    font-size: 0.84rem !important;
    font-weight: 800 !important;
    word-break: break-all !important;
  }

  /* 7. Section cards & shell */
  .section-card { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  .result-shell { padding-top: 2px; }

  /* Compare Columns -> 2 per row on mobile */
  .compare-columns {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .compare-col {
    padding: 10px 10px !important;
  }
  .compare-col h3 {
    font-size: 0.95rem !important;
    margin-bottom: 4px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .compare-col p {
    font-size: 0.72rem !important;
    margin-bottom: 8px !important;
  }

  /* Why these recommendations -> 2 per row on mobile */
  .rec-grid, .evt-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .rec-card, .evt-card {
    padding: 8px !important;
  }
  .rec-pill {
    font-size: 0.62rem !important;
    padding: 1px 4px !important;
  }
  .rec-meta {
    font-size: 0.65rem !important;
    margin-bottom: 4px !important;
  }
  .rec-list li {
    font-size: 0.68rem !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
  }

  /* 8. ADMIN CONSOLE — Mobile Polish (Screenshots 3 & 4) */
  .admin-container {
    padding: 12px 10px !important;
    gap: 14px !important;
  }
  .admin-title { font-size: 1.25rem !important; margin-bottom: 0 !important; }

  /* Admin Nav Tabs: 4 equal 25% columns so no tab text cut off */
  .admin-tabs-nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 2px !important;
    width: 100% !important;
    margin-bottom: 14px !important;
    overflow-x: visible !important;
  }
  .admin-tab-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 6px 2px !important;
    font-size: 0.74rem !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Admin Search Bar: Input + Search + Reset ALL INLINE NEXT TO TEXT BOX */
  .admin-search-wrapper {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
  }
  .admin-search-wrapper .admin-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 36px !important;
    font-size: 13px !important;
    padding: 0 8px !important;
  }
  .admin-search-wrapper .primary-btn,
  .admin-search-wrapper .ghost-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.76rem !important;
    white-space: nowrap !important;
  }

  /* Admin Log Filter Bar: All Actions + Filter Input + Filter + Reset ALL INLINE NEXT TO TEXT BOX */
  .admin-filter-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
  }
  .admin-filter-group .admin-select {
    flex: 0 0 95px !important;
    width: 95px !important;
    min-width: 0 !important;
    height: 36px !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
  }
  .admin-filter-group .admin-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 36px !important;
    font-size: 13px !important;
    padding: 0 8px !important;
  }
  .admin-filter-group .primary-btn,
  .admin-filter-group .ghost-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 8px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  /* Admin Stats Cards: 2-column compact grid */
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .admin-stats-card {
    padding: 12px 14px !important;
    gap: 4px !important;
    border-radius: 10px !important;
  }
  .admin-stats-value {
    font-size: 1.5rem !important;
  }
  .admin-stats-label {
    font-size: 0.65rem !important;
  }
  .admin-stats-subtext {
    font-size: 0.72rem !important;
  }

  /* Admin Table & Compact Logs (Fits on screen side without horizontal scrolling) */
  .table-scroll-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .admin-table {
    min-width: 0 !important;
    width: 100% !important;
  }
  .admin-table th,
  .admin-table td {
    padding: 6px 6px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
    max-width: none !important;
  }
  .admin-table td .admin-badge {
    white-space: nowrap !important;
    padding: 2px 6px !important;
    font-size: 0.68rem !important;
  }

  /* Cache control card in Admin */
  .admin-cache-controls-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .admin-cache-btn {
    width: 100% !important;
  }

  /* 9. RANKINGS VIEW — Sleek 1-Row Mobile Strip (Guaranteed 0px overflow) */
  .rankings-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }
  .rankings-controls {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .rankings-controls .rk-label-txt {
    display: none !important;
  }
  .rankings-date-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    margin: 0 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }
  .rankings-date-select[type="date"] {
    width: 95px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 4px !important;
    font-size: 0.7rem !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
  }
  select.rankings-date-select {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #rankings-refresh-btn {
    flex: 0 0 auto !important;
    width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Rankings Table Polish */
  .rankings-table-scroll {
    overflow-x: auto !important;
    border-radius: 8px !important;
    border: 1px solid var(--border-glass) !important;
    background: rgba(var(--ink-rgb), 0.02) !important;
  }
  .rankings-table {
    min-width: 0 !important;
    width: 100% !important;
  }
  .rankings-table th {
    padding: 6px 4px !important;
    font-size: 0.66rem !important;
  }
  .rankings-table td {
    padding: 6px 4px !important;
    font-size: 0.72rem !important;
  }
  .rk-stock strong {
    font-size: 0.78rem !important;
  }
  .rk-ticker-sub {
    font-size: 0.68rem !important;
    opacity: 0.75 !important;
  }
}
