:root {
  --bg-app: #080d16;
  --bg-sidebar: #0c1322;
  --bg-card: #111a2c;
  --bg-card-hover: #162238;
  --bg-elevated: #192640;
  --bg-input: #0b1220;
  --border: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --emerald-bright: #34d399;
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --sky: #0ea5e9;
  --sky-soft: rgba(14, 165, 233, 0.15);
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, 0.15);

  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-elevated: #e2e8f0;
  --bg-input: #f8fafc;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --shadow: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ================= CONTINUOUS SCROLLING LIVE TOP TICKER ================= */
.top-sticky-header {
  position: sticky;
  top: 0;
  z-index: 60;
  padding-top: env(safe-area-inset-top, 0px);
  background: #061c17;
}

.ticker-bar {
  height: 36px;
  background: linear-gradient(90deg, #06281e 0%, #0b172a 50%, #06281e 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
  overflow: hidden;
  color: #e2e8f0;
  font-size: 12px;
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  mask-image: linear-gradient(to right, transparent 0%, black 3%, black 96%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 96%, transparent 100%);
}

.ticker-track {
  display: flex;
  width: max-content;
  align-items: center;
  will-change: transform;
  animation: tickerMarquee var(--ticker-duration, 165s) linear infinite;
}

.ticker-viewport:hover .ticker-track,
.ticker-viewport:active .ticker-track {
  animation-play-state: paused;
}

@keyframes tickerMarquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.ticker-group {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-right: 24px;
  white-space: nowrap;
}

.ticker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.ticker-chip .lbl {
  color: #94a3b8;
  font-weight: 600;
}
.ticker-chip .val {
  font-weight: 700;
  color: #f8fafc;
}
.ticker-sep {
  color: rgba(148, 163, 184, 0.35);
  font-size: 10px;
}

.up { color: #34d399 !important; }
.down { color: #fb7185 !important; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  margin-left: 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.38);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.live-pill.offline {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* Mobile Compact Header (Visible on Phone/Tablet) */
.mobile-app-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}
.mob-brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.mob-brand-logo {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 8px;
  flex-shrink: 0;
}
.mob-brand-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mob-brand-title {
  font-weight: 800;
  font-size: 13.5px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mob-brand-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.mob-cash-txt {
  font-size: 10.5px;
  color: var(--emerald-bright);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mob-hdr-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.mob-hdr-actions .mob-ico-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 7px;
  font-size: 12px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
  gap: 3px;
}
.mob-hdr-actions .bell-count {
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  font-size: 9.5px;
}
.mob-logout-btn {
  white-space: nowrap;
  font-weight: 700;
  height: 30px;
  padding: 0 9px !important;
  font-size: 11px !important;
  border-radius: 8px;
  flex-shrink: 0;
}
@media (max-width: 520px) {
  .mob-cash-txt {
    display: none;
  }
  .mob-logout-ico {
    display: none;
  }
}
@media (max-width: 345px) {
  .mob-logout-ico {
    display: inline;
  }
  .mob-logout-lbl {
    display: none;
  }
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: calc(100vh - 36px);
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 36px;
  height: calc(100vh - 36px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}
.brand-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.nav-btn.active {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  border-color: rgba(16, 185, 129, 0.3);
  font-weight: 700;
}
[data-theme="light"] .nav-btn.active { color: #047857; }
.nav-btn-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.sidebar-summary-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.06));
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.sidebar-summary-box .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.sidebar-summary-box .big-cash {
  font-size: 19px;
  font-weight: 800;
  color: var(--emerald-bright);
  margin: 4px 0;
}
[data-theme="light"] .sidebar-summary-box .big-cash { color: #047857; }
.sidebar-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Main Content */
.main-area {
  padding: 22px 26px 48px;
  overflow-x: hidden;
  max-width: 1480px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--bg-card-hover);
}
.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-success-soft {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  border-color: rgba(16, 185, 129, 0.35);
}
[data-theme="light"] .btn-success-soft { color: #047857; }
.btn-danger-soft {
  background: var(--rose-soft);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.3);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--emerald));
}
.kpi-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-value {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}
.kpi-foot {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Panels & Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.grid-4-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 15px;
  font-weight: 800;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* PSX Buy-Plan Cards */
.psx-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.psx-plan-card {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.rate-band-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-card);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.rate-cell-lbl {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 700;
}
.rate-cell-val {
  font-size: 13px;
  font-weight: 800;
  margin-top: 2px;
}

/* Insights */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insight-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--emerald);
  background: var(--bg-input);
}
.insight-item.warning { border-left-color: var(--amber); }
.insight-item.info { border-left-color: var(--sky); }
.insight-item.tip { border-left-color: var(--violet); }
.insight-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
}
.insight-detail {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-received { background: var(--emerald-soft); color: var(--emerald-bright); }
.badge-paid { background: var(--rose-soft); color: var(--rose); }
.badge-pending_pay { background: var(--amber-soft); color: var(--amber); }
.badge-pending_receive { background: var(--sky-soft); color: var(--sky); }
.badge-shariah { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
[data-theme="light"] .badge-received,
[data-theme="light"] .badge-shariah { color: #047857; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 11px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  font-weight: 700;
}
tr:hover td { background: var(--bg-card-hover); }
.text-right { text-align: right; }

/* Filter Pills & Inputs */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.pill-group {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  gap: 2px;
}
.pill-group::-webkit-scrollbar { display: none; }
.pill-btn {
  padding: 6px 11px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.pill-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--emerald);
}

/* Ledger Board Columns */
.board-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.board-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.board-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.board-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  gap: 8px;
}
.board-item-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

/* Stock Cards */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 12px;
}
.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.stock-card:hover {
  transform: translateY(-2px);
  border-color: var(--emerald);
}
.stock-card.selected {
  border-color: var(--emerald-bright);
  box-shadow: 0 0 0 1px var(--emerald-bright);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(5px);
  display: none;
  place-items: center;
  z-index: 200;
  padding: 14px;
}
.modal-backdrop.open { display: grid; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Advisor Chat */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.chat-msg {
  padding: 10px 13px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
  max-width: 92%;
}
.chat-msg.bot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.chat-msg.user {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.35);
  align-self: flex-end;
}

/* ================= iPHONE / MOBILE NATIVE BOTTOM TAB BAR ================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: rgba(12, 19, 34, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-strong);
  padding-top: 6px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
}
[data-theme="light"] .mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.96);
}
.mob-tab-btn {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 1px;
}
.mob-tab-btn .ico {
  font-size: 17px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mob-alert-dot {
  position: absolute;
  top: -4px;
  right: -9px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #f59e0b;
  color: #080d16;
  font-size: 9px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mob-tab-btn.active {
  color: var(--emerald-bright);
  font-weight: 800;
}
[data-theme="light"] .mob-tab-btn.active { color: #059669; }

.toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  left: 16px;
  max-width: 360px;
  margin: 0 auto;
  background: #064e3b;
  color: #ecfdf5;
  border: 1px solid #10b981;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 250;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .grid-2, .grid-equal { grid-template-columns: 1fr; }
  .grid-4-cols { grid-template-columns: repeat(2, 1fr); }
}

/* ================= PSX v3: FUNDAMENTAL 4-RATIOS, SEARCH, FILTERS & TECHNICAL SUITE ================= */
.psx-toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.psx-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.psx-search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.psx-search-box input {
  width: 100%;
  padding-left: 34px;
  padding-right: 30px;
  font-size: 13.5px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
}

.psx-search-ico {
  position: absolute;
  left: 11px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0.75;
}

.psx-search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
}

.universe-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.universe-tabs::-webkit-scrollbar { display: none; }

.uni-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.uni-btn:hover {
  color: var(--text-primary);
  border-color: var(--emerald);
}
.uni-btn.active {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  border-color: var(--emerald);
}
.uni-btn.dip.active {
  background: var(--rose-soft);
  color: #fb7185;
  border-color: var(--rose);
}
.uni-btn.penny.active {
  background: var(--violet-soft);
  color: #c4b5fd;
  border-color: var(--violet);
}
.uni-btn.signal.active {
  background: var(--amber-soft);
  color: #fbbf24;
  border-color: var(--amber);
}
[data-theme="light"] .uni-btn.active { color: #047857; }
[data-theme="light"] .uni-btn.dip.active { color: #be123c; }
[data-theme="light"] .uni-btn.penny.active { color: #6d28d9; }
[data-theme="light"] .uni-btn.signal.active { color: #b45309; }

.uni-count {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  font-size: 11px;
  font-weight: 800;
}

/* 4-Ratio Fundamental Grid (P/E, P/B, Equity/Debt, Current Ratio) */
.ratio-4-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 12px;
}
.ratio-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ratio-box .r-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.ratio-box .r-val {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-primary);
}
.ratio-box .r-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Compact 4-Ratio Strip inside Stock Cards */
.card-ratio-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  margin: 8px 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.card-ratio-4 .cr-lbl {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card-ratio-4 .cr-val {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 1px;
}

/* Technical Stock Analysis Suite */
.tech-verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tech-verdict-badge.strong-buy { background: rgba(16, 185, 129, 0.22); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.tech-verdict-badge.buy { background: rgba(14, 165, 233, 0.2); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.35); }
.tech-verdict-badge.neutral { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.tech-verdict-badge.sell, .tech-verdict-badge.strong-sell { background: rgba(244, 63, 94, 0.18); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.35); }
[data-theme="light"] .tech-verdict-badge.strong-buy { color: #047857; }
[data-theme="light"] .tech-verdict-badge.buy { color: #0369a1; }
[data-theme="light"] .tech-verdict-badge.neutral { color: #b45309; }
[data-theme="light"] .tech-verdict-badge.sell, [data-theme="light"] .tech-verdict-badge.strong-sell { color: #be123c; }

.tech-meter-track {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f43f5e 0%, #f59e0b 38%, #0ea5e9 68%, #10b981 100%);
  position: relative;
  margin: 8px 0 4px;
}
.tech-meter-thumb {
  position: absolute;
  top: -4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}

.tech-osc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.ma-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 11.5px;
  margin-bottom: 10px;
}
.ma-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.pivot-ladder {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
  text-align: center;
}
.pivot-cell {
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 11px;
}
.pivot-cell .p-lbl {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--text-secondary);
}
.pivot-cell .p-val {
  font-weight: 800;
  margin-top: 1px;
}

.rank-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.rank-tag.penny {
  background: var(--violet-soft);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}
.rank-tag.signal {
  background: var(--amber-soft);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.38);
}
[data-theme="light"] .rank-tag.penny { color: #6d28d9; }
[data-theme="light"] .rank-tag.signal { color: #b45309; }

/* ================= v4: SIGNAL PILLS, BUSINESS NEWS ANALYZER & MY PORTFOLIO MANAGER ================= */
.signal-banner-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.38);
}
[data-theme="light"] .signal-banner-pill { color: #b45309; }

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 14px;
  width: 100%;
  max-width: 100%;
}

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.news-card.verdict-GOOD { border-top: 3px solid var(--emerald); }
.news-card.verdict-BAD { border-top: 3px solid var(--rose); }
.news-card.verdict-MIXED { border-top: 3px solid var(--amber); }

.news-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.news-card-head .rank-tag {
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
}
.news-card-title {
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.42;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.news-card-summary {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.48;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.news-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.news-analyzer-form {
  display: flex;
  gap: 8px;
  width: 100%;
}
.news-analyzer-form input {
  flex: 1;
  min-width: 0;
  width: 100%;
}
.news-analyzer-form button {
  flex-shrink: 0;
}

.news-sample-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
  margin-top: 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.news-sample-strip::-webkit-scrollbar { display: none; }
.news-sample-strip .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.news-toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.news-toolbar-stack .pill-group {
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.news-toolbar-stack .pill-group::-webkit-scrollbar { display: none; }

.news-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}
.news-search-row input {
  flex: 1;
  min-width: 0;
}
.news-search-row button {
  flex-shrink: 0;
}

.news-verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  max-width: 100%;
}
.news-verdict-pill.GOOD { background: var(--emerald-soft); color: var(--emerald-bright); border: 1px solid rgba(16, 185, 129, 0.35); }
.news-verdict-pill.BAD { background: var(--rose-soft); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.35); }
.news-verdict-pill.MIXED { background: var(--amber-soft); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
[data-theme="light"] .news-verdict-pill.GOOD { color: #047857; }
[data-theme="light"] .news-verdict-pill.BAD { color: #be123c; }
[data-theme="light"] .news-verdict-pill.MIXED { color: #b45309; }

.impact-box {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.impact-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.impact-stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease;
}
.impact-stock-chip:hover { transform: translateY(-1px); }
.impact-stock-chip.good {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.38);
}
.impact-stock-chip.bad {
  background: rgba(244, 63, 94, 0.16);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.38);
}
[data-theme="light"] .impact-stock-chip.good { color: #047857; }
[data-theme="light"] .impact-stock-chip.bad { color: #be123c; }

.portfolio-holding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 13px;
}
.holding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

@media (max-width: 860px) {
  html, body { max-width: 100%; overflow-x: clip; }
  .app-shell { display: block; max-width: 100vw; overflow-x: hidden; }
  .sidebar { display: none; }
  .mobile-app-bar { display: flex; }
  .mobile-bottom-nav { display: flex; }
  .main-area {
    padding: 12px 12px calc(92px + env(safe-area-inset-bottom, 0px));
    max-width: 100vw;
    overflow-x: hidden;
  }
  .topbar {
    margin-bottom: 10px;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
  }
  /* Hide duplicate Admin & Alerts buttons in page topbar since they live in the sticky mobile header */
  #topAdminBtn,
  #topBellBtn {
    display: none !important;
  }
  .topbar-actions {
    gap: 6px;
    width: auto;
    flex-shrink: 0;
    justify-content: flex-end;
  }
  .page-title { font-size: 16.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-subtitle { display: none; }
  .card, .psx-toolbar-card { padding: 13px; min-width: 0; max-width: 100%; overflow: hidden; }
  .card svg { max-width: 100%; height: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .kpi-card {
    min-width: 0;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .kpi-label { font-size: 10px; line-height: 1.25; gap: 4px; }
  .kpi-value { font-size: 15.5px; margin: 5px 0 3px; word-break: break-word; }
  .kpi-foot { font-size: 10.5px; line-height: 1.3; }
  .grid-2,
  .grid-equal,
  .grid-4-cols,
  .psx-plan-grid,
  .news-grid,
  .portfolio-holding-grid,
  .stock-grid,
  .admin-receipt-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .news-analyzer-form {
    flex-direction: column;
  }
  .news-analyzer-form button {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }
  .news-card {
    padding: 13px 14px;
  }
  .news-card-title {
    font-size: 14px;
  }
  input, select, textarea {
    font-size: 16px;
  }
  .ratio-4-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-band-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ma-list { grid-template-columns: minmax(0, 1fr); }
  .form-2col { grid-template-columns: minmax(0, 1fr); }
  .alerts-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .ledger-period-strip { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .auth-lock-overlay,
  .sub-gate-overlay {
    align-items: flex-start;
    padding: 16px 12px calc(32px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  .auth-card {
    padding: 18px 15px;
    border-radius: 15px;
  }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 16px 15px calc(22px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 375px) {
  .kpi-value { font-size: 14.5px; }
}

/* Gemini AI Advisor UI & Rich Markdown Chat Formatting */
.advisor-quick-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 3px;
  max-width: 100%;
}
.advisor-quick-strip::-webkit-scrollbar { display: none; }
.advisor-quick-strip .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.advisor-chat-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}
.advisor-chat-form input {
  flex: 1;
  min-width: 0;
}
.advisor-chat-form button {
  flex-shrink: 0;
  white-space: nowrap;
}
.gemini-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(14, 165, 233, 0.2));
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.42);
}
.gemini-live-pill.missing {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.chat-box {
  max-height: 440px;
}
.chat-msg {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-msg p { margin: 0 0 7px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol {
  margin: 5px 0 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg h3, .chat-msg h4 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--emerald-bright);
  margin: 8px 0 4px;
}
.chat-msg code {
  background: rgba(148, 163, 184, 0.16);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.chat-msg.loading-msg {
  color: var(--text-secondary);
  font-style: italic;
  border-color: rgba(14, 165, 233, 0.35);
}

/* ================= v6.0 + v7.5: PUBLIC SALES LANDING PAGE, AUTH MODAL & SUBSCRIPTION GATE ================= */
body.auth-locked .top-sticky-header,
body.auth-locked .app-shell,
body.auth-locked .mobile-bottom-nav,
body.auth-locked .sub-gate-overlay,
body.auth-locked .modal-backdrop {
  display: none !important;
}
body:not(.auth-locked) .public-landing-wrap,
body:not(.auth-locked) .auth-lock-overlay {
  display: none !important;
}
body.auth-checking .public-landing-wrap {
  opacity: 0;
  pointer-events: none;
}
body.auth-locked .auth-lock-overlay:not(.modal-open) {
  display: none !important;
}
body.auth-locked .auth-lock-overlay.modal-open {
  position: fixed;
  inset: 0;
  z-index: 500;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 14px)) 12px calc(36px + env(safe-area-inset-bottom, 0px));
  background: rgba(3, 7, 18, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.sub-gated .top-sticky-header,
body.sub-gated .app-shell,
body.sub-gated .mobile-bottom-nav,
body.sub-gated .public-landing-wrap,
body.sub-gated .auth-lock-overlay {
  display: none !important;
}
body:not(.sub-gated) .sub-gate-overlay {
  display: none !important;
}

.sub-gate-overlay {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  background:
    radial-gradient(circle at 18% 15%, rgba(16, 185, 129, 0.16), transparent 45%),
    radial-gradient(circle at 82% 80%, rgba(14, 165, 233, 0.14), transparent 45%),
    var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.auth-card.wide-register {
  max-width: 540px;
}

.bank-transfer-banner {
  background: linear-gradient(155deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 12px;
}

.role-mini-chip {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: var(--emerald-bright);
  border: 1px solid rgba(16, 185, 129, 0.35);
  letter-spacing: 0.04em;
}
.role-mini-chip.admin {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}
[data-theme="light"] .role-mini-chip { color: #047857; }
[data-theme="light"] .role-mini-chip.admin { color: #b45309; }

.admin-nav-item {
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.06);
}
.admin-nav-item.active {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fbbf24 !important;
  border-color: rgba(245, 158, 11, 0.45) !important;
}
[data-theme="light"] .admin-nav-item.active { color: #b45309 !important; }

.admin-receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.auth-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 9px 10px;
  min-height: 38px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
}
.auth-close-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 6px 10px;
  flex-shrink: 0;
  touch-action: manipulation;
}
.auth-mode-btn.active {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}
[data-theme="light"] .auth-mode-btn.active { color: #047857; }

.auth-error-msg {
  padding: 9px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fb7185;
  font-size: 12.5px;
  font-weight: 700;
}
[data-theme="light"] .auth-error-msg { color: #be123c; }

/* Bell & Alert Badges */
.bell-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.bell-count, .alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  font-size: 10.5px;
  font-weight: 800;
}
.bell-count.urgent, .alert-badge.urgent {
  background: #10b981;
  color: #052e16;
  border-color: #34d399;
}
[data-theme="light"] .bell-count, [data-theme="light"] .alert-badge { color: #b45309; }

/* Timeline Pill & 4-Column Rate + Timeline Grid */
.timeline-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.35);
  white-space: nowrap;
}
[data-theme="light"] .timeline-pill { color: #0369a1; }

.rate-band-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Notifications Tab Cards */
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 14px;
}

.alert-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.alert-card.sell-alert {
  border-top: 3px solid #10b981;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-card) 42%);
}
.alert-card.buy-alert {
  border-top: 3px solid #0ea5e9;
}
.alert-card.watch-alert {
  border-top: 3px solid #f59e0b;
}
.alert-card.stop-alert {
  border-top: 3px solid #f43f5e;
}

/* Smart Ledger Period Summary Strip & Overview Item Quick Actions */
.ledger-period-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.board-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn-xs {
  padding: 2px 7px !important;
  font-size: 11px !important;
  line-height: 1.3;
}

/* ================= v7.0: PSX RADAR 5-PILLAR NAVIGATION, QUICK-ACTION SHEET, GLOBAL JUMP, AI DRAWER, ANNOUNCEMENTS & LESSONS ================= */
.nav-section-lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 4px;
}
.nav-section-lbl:first-child {
  padding-top: 2px;
}

/* Pillar Sub-Navigation Strip (Inside Market, Wealth, Learn/AI, Menu/Admin) */
.pillar-subnav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pillar-subnav::-webkit-scrollbar { display: none; }

.pillar-sub-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.pillar-sub-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.pillar-sub-btn.active {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  border-color: rgba(16, 185, 129, 0.36);
}
[data-theme="light"] .pillar-sub-btn.active { color: #047857; }

/* Global Search & Jump Bar */
.global-jump-wrap {
  position: relative;
  width: 265px;
  display: flex;
  align-items: center;
}
.global-jump-ico {
  position: absolute;
  left: 10px;
  font-size: 12.5px;
  pointer-events: none;
  opacity: 0.75;
}
.global-jump-wrap input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
}
.global-jump-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  z-index: 160;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.jump-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-size: 12.5px;
}
.jump-item:hover {
  background: var(--bg-card-hover);
}

.btn-ai-glow {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(139, 92, 246, 0.2));
  border-color: rgba(139, 92, 246, 0.45);
  color: #e2e8f0;
}
[data-theme="light"] .btn-ai-glow { color: #4c1d95; }

/* Slide-Over Gemini AI Drawer (Desktop Side Panel / Mobile Safe-Area Bottom Sheet) */
.ai-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  justify-content: flex-end;
  align-items: stretch;
  z-index: 240;
}
.ai-drawer-backdrop.open {
  display: flex;
}
.ai-drawer-panel {
  width: 100%;
  max-width: 450px;
  height: 100dvh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-strong);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.ai-sheet-grabber {
  display: none;
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  margin: 0 auto 10px;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .ai-drawer-backdrop {
    justify-content: center;
    align-items: flex-end;
    padding-top: calc(56px + env(safe-area-inset-top, 0px));
  }
  .ai-drawer-panel {
    max-width: 100%;
    height: 80dvh;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 56px);
    border-left: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 20px 20px 0 0;
    padding: 10px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.65);
  }
  .ai-sheet-grabber {
    display: block;
  }
}

/* 6-Item Mobile Bottom Bar */
.mob-pillar-btn {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  padding: 4px 1px;
  position: relative;
}
.mob-pillar-btn .ico {
  font-size: 16.5px;
  line-height: 1.1;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mob-pillar-btn.active {
  color: var(--emerald-bright);
  font-weight: 800;
}
.mob-pillar-btn.active::before {
  content: "";
  position: absolute;
  top: -6px;
  width: 24px;
  height: 2.5px;
  border-radius: 0 0 4px 4px;
  background: var(--emerald-bright);
}
[data-theme="light"] .mob-pillar-btn.active { color: #059669; }

.mob-center-fab {
  width: 46px;
  height: 46px;
  margin-top: -16px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 23px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
  cursor: pointer;
  flex-shrink: 0;
}

/* Quick-Action Sheet Tiles */
.quick-action-sheet-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 8px;
}
.quick-action-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.quick-action-tile:hover {
  border-color: var(--emerald);
  transform: translateY(-1px);
}
.qa-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 19px;
  flex-shrink: 0;
}
.qa-title {
  font-size: 13.5px;
  font-weight: 800;
}
.qa-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Progressive Disclosure Technical Accordion */
.tech-disclosure {
  margin-top: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.tech-disclosure summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--emerald-bright);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tech-disclosure summary::-webkit-details-marker { display: none; }
.tech-disclosure[open] summary {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* PSX Announcements & Daily Lessons Cards */
.annc-grid,
.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 13px;
}
.annc-card,
.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.lesson-hero {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.14), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
}

@media (max-width: 860px) {
  .global-jump-wrap,
  .desktop-only-btn {
    display: none !important;
  }
  .topbar-actions {
    width: auto;
  }
  .annc-grid,
  .lessons-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .lesson-hero {
    padding: 15px;
  }
}

/* v7.2 — Signal Verdict Filters, Daily PSX Analysis & Investment Planner */
.verdict-filter-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.verdict-filter-lbl {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 2px;
}
.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.verdict-pill:hover {
  transform: translateY(-1px);
  color: var(--text-primary);
}
.verdict-pill .v-cnt {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  background: rgba(148, 163, 184, 0.16);
}
.verdict-pill.active {
  background: rgba(14, 165, 233, 0.18);
  border-color: #38bdf8;
  color: #e0f2fe;
}
[data-theme="light"] .verdict-pill.active { color: #0369a1; }
.verdict-pill.strong-buy.active {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  color: #6ee7b7;
}
[data-theme="light"] .verdict-pill.strong-buy.active { color: #047857; }
.verdict-pill.buy.active {
  background: rgba(52, 211, 153, 0.16);
  border-color: #34d399;
  color: #a7f3d0;
}
[data-theme="light"] .verdict-pill.buy.active { color: #059669; }
.verdict-pill.neutral.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: #f59e0b;
  color: #fde68a;
}
[data-theme="light"] .verdict-pill.neutral.active { color: #b45309; }
.verdict-pill.sell.active {
  background: rgba(244, 63, 94, 0.2);
  border-color: #f43f5e;
  color: #fda4af;
}
[data-theme="light"] .verdict-pill.sell.active { color: #be123c; }

/* Daily PSX Analysis & Coming-Days Direction */
.direction-hero {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(16, 185, 129, 0.42);
  background: linear-gradient(140deg, rgba(16, 185, 129, 0.14), rgba(14, 165, 233, 0.09));
  box-shadow: var(--shadow);
}
.direction-hero.cautious {
  border-color: rgba(244, 63, 94, 0.45);
  background: linear-gradient(140deg, rgba(244, 63, 94, 0.14), rgba(245, 158, 11, 0.08));
}
.direction-hero.neutral {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(140deg, rgba(245, 158, 11, 0.14), rgba(14, 165, 233, 0.08));
}
.breadth-bar-track {
  display: flex;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.18);
  margin: 8px 0 6px;
}
.breadth-seg.adv { background: linear-gradient(90deg, #10b981, #34d399); }
.breadth-seg.flat { background: #64748b; }
.breadth-seg.dec { background: linear-gradient(90deg, #fb7185, #f43f5e); }

.sector-heat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 10px;
}
.sector-heat-card {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Investment Guide & Wealth Divider Calculator */
.planner-hero-card {
  background: linear-gradient(145deg, rgba(14, 165, 233, 0.13), rgba(16, 185, 129, 0.11));
  border: 1px solid rgba(14, 165, 233, 0.38);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.planner-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.planner-top-btns {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.planner-controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.planner-chips-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.capital-chip-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
@media (max-width: 1040px) {
  .planner-controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .planner-controls-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .planner-top-btns {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .planner-top-btns button:last-child {
    grid-column: 1 / -1;
    justify-content: center;
  }
  .planner-top-btns button {
    justify-content: center;
  }
  .capital-chip-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .capital-chip-strip::-webkit-scrollbar {
    display: none;
  }
  .capital-chip-strip .btn {
    flex-shrink: 0;
  }
}
.plan-alloc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 13px;
  margin-top: 14px;
}
.plan-stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.alloc-weight-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}
.alloc-weight-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #0ea5e9);
}

@media (max-width: 860px) {
  .direction-hero,
  .planner-hero-card {
    padding: 14px;
  }
  .plan-alloc-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* v7.3 — 3-Tier Membership Cards, PSX Treemap Heatmap, Ex-Date Calendar, Net-Profit Calc & Referrals */
.tier-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.tier-select-card {
  position: relative;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  padding: 10px 9px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tier-select-card:hover {
  border-color: var(--emerald);
}
.tier-select-card.active {
  border-color: #10b981;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.18), rgba(14, 165, 233, 0.08));
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.35);
}
.tier-select-card.elite.active {
  border-color: #f59e0b;
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.20), rgba(139, 92, 246, 0.12));
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.4);
}
.tier-pop-ribbon {
  position: absolute;
  top: -8px;
  right: 8px;
  background: linear-gradient(90deg, #10b981, #059669);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.tier-chip.starter {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.tier-chip.pro {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.tier-chip.elite {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(139, 92, 246, 0.22));
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.5);
}
[data-theme="light"] .tier-chip.starter { color: #334155; }
[data-theme="light"] .tier-chip.pro { color: #047857; }
[data-theme="light"] .tier-chip.elite { color: #b45309; }

/* Interactive PSX Sector Treemap Heatmap */
.treemap-sector-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}
.treemap-sector-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.treemap-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 128px;
}
.treemap-tile {
  border-radius: 8px;
  padding: 8px 7px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-width: 72px;
  min-height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  overflow: hidden;
}
.treemap-tile:hover {
  transform: scale(1.03);
  z-index: 2;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.treemap-tile .tm-sym {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.treemap-tile .tm-chg {
  font-weight: 800;
  font-size: 11.5px;
  margin-top: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.treemap-tile .tm-prc {
  font-size: 10px;
  opacity: 0.9;
  margin-top: 1px;
}

/* Net-Profit Receipt Ledger & Referral Hero */
.fee-receipt-box {
  background: var(--bg-input);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.fee-receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  gap: 10px;
}
.fee-receipt-row.total {
  border-top: 1px solid var(--border-strong);
  padding-top: 9px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 800;
}
.referral-code-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(16, 185, 129, 0.42);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .tier-selector-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* v7.3 — 3-Tier Membership Cards, Sector Treemap Heatmap, Ex-Date Calendar, Broker CGT Calc & Referrals */
.tier-mini-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.tier-mini-btn {
  position: relative;
  padding: 10px 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.tier-mini-btn:hover {
  border-color: var(--emerald);
}
.tier-mini-btn.active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.14);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.35);
}
.tier-mini-btn .tm-pop {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #10b981, #0ea5e9);
  color: #fff;
  font-size: 8.5px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.tier-mini-btn .tm-name {
  font-size: 12px;
  font-weight: 800;
}
.tier-mini-btn .tm-price {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--emerald-bright);
  margin-top: 2px;
}
.tier-mini-btn .tm-sub {
  font-size: 9.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tier-cards-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
  gap: 16px;
}
.tier-plan-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tier-plan-card.popular {
  border-color: #10b981;
  background: linear-gradient(160deg, rgba(16, 185, 129, 0.11), var(--bg-card) 45%);
  box-shadow: 0 14px 36px rgba(16, 185, 129, 0.16);
}
.tier-plan-card.elite {
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(160deg, rgba(245, 158, 11, 0.11), var(--bg-card) 45%);
}
.tier-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
}
.tier-badge-pill.starter { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.tier-badge-pill.pro { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }
.tier-badge-pill.elite { background: rgba(245, 158, 11, 0.22); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.45); }
[data-theme="light"] .tier-badge-pill.starter { color: #334155; }
[data-theme="light"] .tier-badge-pill.pro { color: #047857; }
[data-theme="light"] .tier-badge-pill.elite { color: #b45309; }

/* Interactive PSX Sector Treemap Heatmap */
.heatmap-sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 12px;
}
.heatmap-sector-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.heatmap-tiles-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 112px;
}
.hm-tile {
  border-radius: 8px;
  padding: 7px 8px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.12s ease, filter 0.12s ease;
  min-height: 58px;
  overflow: hidden;
}
.hm-tile:hover {
  transform: scale(1.03);
  filter: brightness(1.1);
  z-index: 2;
}
.hm-up-3 { background: #047857; }
.hm-up-2 { background: #059669; }
.hm-up-1 { background: #0d9488; }
.hm-flat { background: #334155; }
.hm-dn-1 { background: #be123c; }
.hm-dn-2 { background: #e11d48; }
.hm-dn-3 { background: #9f1239; }

/* Broker + CGT + CDC Receipt & Referral Banner */
.fee-receipt-box {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fee-receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.fee-receipt-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.referral-code-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(139, 92, 246, 0.14));
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .tier-mini-selector {
    grid-template-columns: 1fr;
  }
}

/* v7.5 — Public Marketing & Sales Landing Page */
.public-landing-wrap {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, rgba(16, 185, 129, 0.15), transparent 38%),
    radial-gradient(circle at 86% 18%, rgba(14, 165, 233, 0.14), transparent 40%),
    var(--bg-base);
  color: var(--text-primary);
}
.lp-container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}
.lp-top-ticker {
  padding-top: env(safe-area-inset-top, 0px);
  background: #061c17;
  width: 100%;
  overflow: hidden;
}
.lp-ticker-bar {
  height: 38px;
  padding-left: 8px;
  padding-right: 10px;
}
.lp-ticker-track {
  animation: tickerMarquee var(--lp-ticker-duration, 52s) linear infinite !important;
}
@media (hover: hover) {
  .lp-ticker-viewport:hover .lp-ticker-track {
    animation-play-state: paused !important;
  }
}
@media (hover: none) {
  .lp-ticker-viewport:hover .lp-ticker-track,
  .lp-ticker-viewport:active .lp-ticker-track {
    animation-play-state: running !important;
  }
}
.lp-navbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(8, 13, 22, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.lp-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.lp-brand-logo {
  width: 40px;
  height: 40px;
  font-size: 15px;
  flex-shrink: 0;
}
.lp-brand-txt {
  min-width: 0;
}
.lp-brand-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
}
.lp-brand-sub {
  font-size: 10.5px;
  color: var(--emerald-bright);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}
.lp-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  transition: color 0.15s ease;
}
.lp-nav-links a:hover {
  color: var(--emerald-bright);
}
.lp-nav-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.lp-auth-btn {
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 36px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 700;
  touch-action: manipulation;
}
.lp-ref-toast-bar {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.22), rgba(14, 165, 233, 0.22));
  border-bottom: 1px solid rgba(16, 185, 129, 0.45);
  text-align: center;
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 800;
  color: #6ee7b7;
}
.lp-hero-section {
  padding: 54px 0 46px;
}
.lp-hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 34px;
  align-items: center;
}
.lp-eyebrow-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.13);
  border: 1px solid rgba(16, 185, 129, 0.36);
  color: var(--emerald-bright);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}
.lp-hero-title {
  font-size: clamp(28px, 4.2vw, 46px);
  font-weight: 900;
  line-height: 1.13;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}
.lp-hero-title span {
  background: linear-gradient(90deg, #34d399, #38bdf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lp-hero-sub {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.62;
  margin-bottom: 24px;
  max-width: 600px;
}
.lp-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.lp-btn-lg {
  padding: 12px 20px;
  font-size: 14.5px;
  font-weight: 800;
  border-radius: 11px;
  text-decoration: none;
}
.lp-trust-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lp-trust-pills span {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
}

/* Hero Terminal Mockup Card */
.lp-terminal-preview {
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.96), rgba(8, 13, 22, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 26px 65px rgba(0, 0, 0, 0.55), 0 0 40px rgba(16, 185, 129, 0.1);
}
.lp-term-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.lp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.lp-dot.red { background: #f43f5e; }
.lp-dot.amber { background: #f59e0b; }
.lp-dot.green { background: #10b981; }
.lp-term-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.lp-mini-kpi {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
.lp-mini-kpi .lbl {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
}
.lp-mini-kpi .val {
  font-size: 14px;
  font-weight: 900;
  margin-top: 2px;
}
.lp-signal-preview-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.lp-sig-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lp-section {
  padding: 52px 0;
}
.lp-section-alt {
  background: rgba(15, 23, 42, 0.42);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.lp-sec-head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 30px;
}
.lp-sec-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--emerald-bright);
  margin-bottom: 8px;
}
.lp-sec-head h2 {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  line-height: 1.22;
  margin-bottom: 8px;
}
.lp-sec-head p {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.lp-demo-card {
  background: var(--bg-card);
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.lp-locked-blur-card {
  position: relative;
  background: rgba(15, 23, 42, 0.75);
  border: 1px dashed rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.lp-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 255px), 1fr));
  gap: 16px;
}
.lp-feat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  padding: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.lp-feat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.5);
}
.lp-feat-ico {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 12px;
}
.lp-feat-card h3 {
  font-size: 15.5px;
  font-weight: 800;
  margin-bottom: 6px;
  line-height: 1.3;
}
.lp-feat-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.52;
}
.lp-roi-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(14, 165, 233, 0.14));
  border: 1px solid rgba(16, 185, 129, 0.42);
  border-radius: 20px;
  padding: 28px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.lp-single-price-box {
  max-width: 580px;
  margin: 0 auto;
  background: linear-gradient(165deg, rgba(16, 185, 129, 0.13), var(--bg-card) 48%);
  border: 2px solid #10b981;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 22px 55px rgba(16, 185, 129, 0.16);
}
.lp-footer {
  border-top: 1px solid var(--border);
  padding: 26px 0 40px;
  background: rgba(5, 9, 17, 0.85);
}
.lp-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.lp-footer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .lp-hero-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .lp-nav-links {
    display: none;
  }
  .lp-hero-section {
    padding: 28px 0 30px;
  }
  .lp-section {
    padding: 36px 0;
  }
  .lp-roi-banner,
  .lp-demo-card,
  .lp-single-price-box {
    padding: 20px 16px;
  }
}

@media (max-width: 640px) {
  .lp-container {
    padding: 0 12px;
  }
  .lp-navbar {
    padding: 9px 0;
  }
  .lp-nav-row {
    gap: 8px;
  }
  .lp-brand {
    gap: 7px;
  }
  .lp-brand-logo {
    width: 33px;
    height: 33px;
    font-size: 12.5px;
    border-radius: 9px;
  }
  .lp-brand-title {
    font-size: 15.5px;
  }
  .lp-brand-sub {
    display: none;
  }
  .lp-nav-cta {
    gap: 6px;
  }
  .lp-auth-btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 34px;
  }
  .lp-hero-actions {
    flex-direction: column;
    gap: 10px;
  }
  .lp-hero-actions .btn,
  .lp-roi-banner .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .lp-btn-lg {
    padding: 12px 14px;
    font-size: 13.5px;
  }
  #lpDemoCapBtns {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  #lpDemoCapBtns .btn {
    width: 100%;
    justify-content: center;
    font-size: 11.5px;
    padding: 7px 8px;
  }
  .lp-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .lp-footer-actions .btn {
    width: 100%;
    justify-content: center;
  }
  body.auth-locked .auth-lock-overlay.modal-open {
    padding: max(12px, env(safe-area-inset-top, 10px)) 10px calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .auth-card {
    padding: 16px 14px;
    border-radius: 15px;
  }
}

/* ================= v8.0: SIMPLIFIED 4-BLOCK HOME & GEMINI-STYLE PSX AI CHAT ================= */
.home-ai-hero-card {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.08), var(--bg-card));
  border: 1px solid rgba(16, 185, 129, 0.36);
  border-radius: 18px;
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.home-ai-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px 6px 6px 14px;
  margin-top: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.home-ai-form:focus-within {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.home-ai-form input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  padding: 8px 4px !important;
  font-size: 14px;
  color: var(--text-primary);
  outline: none !important;
  box-shadow: none !important;
}
.home-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}
.home-ai-chip {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.home-ai-chip:hover {
  border-color: var(--emerald);
  color: var(--emerald-bright);
  background: rgba(16, 185, 129, 0.1);
}
[data-theme="light"] .home-ai-chip {
  background: var(--bg-input);
}

.home-pulse-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.home-pulse-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.home-clean-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* Full-Page Gemini-Style PSX AI Chat Workspace */
body[data-active-tab="advisor"] #openAiDrawerBtn {
  display: none !important;
}
.psx-ai-shell {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 165px);
}
.psx-ai-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.psx-ai-empty-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 28px 12px 24px;
}
.psx-ai-greeting {
  font-size: clamp(23px, 3.2vw, 32px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.2;
  background: linear-gradient(90deg, #34d399, #38bdf8, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}
.psx-ai-sub {
  font-size: 14.5px;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.55;
  margin-bottom: 24px;
}
.psx-ai-starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  width: 100%;
  max-width: 720px;
}
.psx-ai-starter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.psx-ai-starter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.55);
  background: var(--bg-card-hover);
}
.psx-ai-starter-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}
.psx-ai-starter-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.42;
}

.psx-ai-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px 0 22px;
}
.psx-msg-row {
  display: flex;
  gap: 12px;
  width: 100%;
}
.psx-msg-row.user {
  justify-content: flex-end;
}
.psx-user-bubble {
  max-width: min(82%, 580px);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(14, 165, 233, 0.18));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--text-primary);
  padding: 11px 16px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.psx-ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  color: #fff;
  font-weight: 900;
  font-size: 11.5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.28);
}
.psx-ai-body {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 15px 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}
.psx-ai-body h4 {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--emerald-bright);
  margin: 12px 0 6px;
}
.psx-ai-body h4:first-child {
  margin-top: 0;
}
.psx-ai-body ul,
.psx-ai-body ol {
  padding-left: 20px;
  margin: 6px 0 10px;
}
.psx-ai-body li {
  margin-bottom: 5px;
}
.psx-ai-body p {
  margin-bottom: 8px;
}
.psx-ai-body p:last-child {
  margin-bottom: 0;
}
.psx-thinking-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-style: normal;
  font-weight: 600;
}
.psx-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.psx-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald-bright);
  animation: psxDotPulse 1.2s infinite ease-in-out;
}
.psx-thinking-dots span:nth-child(2) {
  animation-delay: 0.18s;
}
.psx-thinking-dots span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes psxDotPulse {
  0%, 80%, 100% { opacity: 0.28; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.15); }
}
.psx-ai-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-input);
}
.psx-ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.psx-ai-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--emerald-bright);
  background: rgba(16, 185, 129, 0.09);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.psx-ai-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.psx-ai-table tbody tr:last-child td {
  border-bottom: none;
}
.psx-ai-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.05);
}
.psx-dps-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.psx-dps-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
  max-width: 100%;
  transition: border-color 0.14s ease;
}
.psx-dps-source-pill:hover {
  border-color: var(--emerald);
}
.psx-ai-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.psx-ai-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* ================= v8.5: SIGNAL EXPLANATION HOVER TOOLTIP & VERIFIED TRACK RECORD ================= */
.sig-has-tooltip {
  cursor: help;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sig-has-tooltip::after {
  content: "ⓘ";
  font-size: 10px;
  opacity: 0.78;
}
.sig-hover-tooltip {
  position: fixed;
  z-index: 9999;
  width: min(355px, calc(100vw - 24px));
  background: rgba(9, 15, 28, 0.98);
  border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.72), 0 0 24px rgba(16, 185, 129, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #f1f5f9;
  font-size: 12px;
  line-height: 1.48;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.sig-tip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}
.sig-tip-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.sig-tip-list li {
  color: #cbd5e1;
  font-size: 11.5px;
  line-height: 1.42;
}
.signal-track-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.1), var(--bg-card));
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.psx-ai-composer-wrap {
  position: sticky;
  bottom: 12px;
  z-index: 25;
  margin-top: auto;
  padding-top: 8px;
}
.psx-ai-composer {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 10px 12px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.45);
  transition: border-color 0.15s ease;
}
.psx-ai-composer:focus-within {
  border-color: var(--emerald);
}
.psx-attached-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.42);
  color: var(--emerald-bright);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  max-width: 100%;
}
.psx-composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.psx-dps-attach-btn {
  border-radius: 999px;
  padding: 7px 11px;
  flex-shrink: 0;
}
.dps-lbl-mob {
  display: none;
}
.psx-composer-row textarea {
  flex: 1;
  min-width: 0;
  border: none !important;
  background: transparent !important;
  resize: none;
  min-height: 36px;
  height: 36px;
  max-height: 140px;
  padding: 8px 4px !important;
  font-size: 15px;
  line-height: 20px;
  color: var(--text-primary);
  outline: none !important;
  box-shadow: none !important;
  overflow-y: hidden;
}
.psx-composer-row textarea:placeholder-shown,
.psx-composer-row textarea::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.psx-send-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.psx-send-circle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.psx-dps-picker-popover {
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}
.psx-dps-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
}
.psx-dps-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  transition: border-color 0.12s ease;
}
.psx-dps-picker-item:hover {
  border-color: var(--emerald);
}

@media (max-width: 860px) {
  body[data-active-tab="advisor"] .topbar {
    display: none;
  }
  body[data-active-tab="advisor"] .main-area {
    padding: 10px 12px calc(144px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .home-pulse-strip {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .home-clean-grid {
    grid-template-columns: 1fr;
  }
  .psx-ai-shell {
    min-height: auto;
  }
  .psx-ai-topbar {
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  .psx-ai-empty-hero {
    justify-content: flex-start;
    padding: 8px 2px 12px;
  }
  .psx-ai-greeting {
    font-size: 20px;
    margin-bottom: 5px;
  }
  .psx-ai-sub {
    font-size: 12.5px;
    line-height: 1.45;
    margin-bottom: 14px;
  }
  .psx-ai-starter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .psx-ai-starter-card {
    padding: 11px 11px;
    border-radius: 12px;
    gap: 4px;
  }
  .psx-ai-starter-title {
    font-size: 12px;
    line-height: 1.28;
  }
  .psx-ai-starter-desc {
    font-size: 11px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .psx-ai-composer-wrap {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 85;
    padding: 0;
    margin: 0;
  }
  .psx-ai-composer {
    padding: 6px 8px;
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  }
  .psx-ai-composer:has(.psx-attached-chip) {
    border-radius: 18px;
    padding: 8px 10px;
  }
  .psx-composer-row {
    gap: 8px;
    align-items: center;
  }
  .psx-dps-attach-btn {
    height: 34px;
    padding: 0 10px !important;
    font-size: 11.5px !important;
    display: inline-flex;
    align-items: center;
  }
  .dps-lbl-full {
    display: none;
  }
  .dps-lbl-mob {
    display: inline;
  }
  .psx-composer-row textarea {
    font-size: 16px !important;
    line-height: 20px !important;
    min-height: 34px !important;
    height: 34px;
    padding: 7px 2px !important;
  }
  .psx-send-circle {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }
  .psx-user-bubble {
    max-width: 90%;
  }
  .psx-ai-body {
    padding: 13px 14px;
    font-size: 13.5px;
  }
}

@media print {
  .auth-lock-overlay, .top-sticky-header, .sidebar, .mobile-bottom-nav, .topbar-actions, .pillar-subnav { display: none !important; }
  .app-shell { display: block; }
  body { background: #fff; color: #000; }
}
