/* ═══════════════════════════════════════════════════════════════
   AFFINCO FINANCE — Light Theme Design System
   Clean SaaS dashboard inspired by Linear, Notion, Stripe
   ═══════════════════════════════════════════════════════════════ */


/* ─── Auth Gate (Password Protection) ──────────────── */
.auth-gate {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f1f5f9 100%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.auth-card {
  width: 100%; max-width: 420px; margin: 20px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 20px 50px -12px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 40px 36px; animation: authSlideIn 0.4s ease;
}
@keyframes authSlideIn { from { opacity:0; transform: translateY(12px) scale(0.98); } to { opacity:1; transform: translateY(0) scale(1); } }
.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand { font-size: 20px; font-weight: 800; color: #1e293b; letter-spacing: -0.3px; }
.auth-brand-sub { font-size: 12px; color: #94a3b8; font-weight: 500; letter-spacing: 0.5px; }
.auth-shield {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: #f1f5f9; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: #64748b;
  margin-bottom: 28px; border: 1px solid #e2e8f0;
}
.auth-shield svg { color: #4f46e5; flex-shrink: 0; }
.auth-field { margin-bottom: 18px; }
.auth-field label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px; letter-spacing: 0.3px; text-transform: uppercase; }
.auth-field input {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  background: #f8fafc; color: #1e293b; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit; box-sizing: border-box;
}
.auth-field input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); background: #fff; }
.auth-field input::placeholder { color: #94a3b8; }
.auth-pw-wrap { position: relative; }
.auth-pw-wrap input { padding-right: 44px; }
.auth-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: #94a3b8; padding: 6px;
  border-radius: 6px; transition: color 0.2s;
}
.auth-eye:hover { color: #4f46e5; }
.auth-error {
  padding: 10px 14px; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; font-size: 13px; color: #dc2626;
  margin-bottom: 16px; font-weight: 500;
}
.auth-submit {
  width: 100%; padding: 13px; font-size: 14px; font-weight: 600;
  background: #4f46e5; color: #fff; border: none; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-submit:hover { background: #4338ca; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.25); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.auth-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 24px; font-size: 11px; color: #94a3b8; font-weight: 500;
}
@media (max-width: 480px) {
  .auth-card { padding: 28px 24px; margin: 16px; }
  .auth-brand { font-size: 17px; }
}


/* ── Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-primary:     #ffffff;
  --bg-secondary:   #f8fafc;
  --bg-tertiary:    #f1f5f9;
  --bg-hover:       #f0f4ff;

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-tertiary:  #94a3b8;
  --text-inverse:   #ffffff;

  /* Borders */
  --border:         #e2e8f0;
  --border-hover:   #cbd5e1;
  --border-focus:   #4f46e5;

  /* Accent — Indigo */
  --accent:         #4f46e5;
  --accent-hover:   #4338ca;
  --accent-active:  #3730a3;
  --accent-light:   #eef2ff;
  --accent-muted:   #e0e7ff;

  /* Semantic */
  --success:        #16a34a;
  --success-bg:     #f0fdf4;
  --success-border: #bbf7d0;
  --danger:         #dc2626;
  --danger-bg:      #fef2f2;
  --danger-border:  #fecaca;
  --warning:        #d97706;
  --warning-bg:     #fffbeb;
  --warning-border: #fde68a;
  --info:           #0284c7;
  --info-bg:        #f0f9ff;
  --info-border:    #bae6fd;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius:     12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  /* Transitions */
  --transition-fast: 100ms ease;
  --transition:      150ms ease;
  --transition-slow: 250ms ease;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  min-height: 100vh;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

img, svg { display: block; }

/* ── App Shell ────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow), width var(--transition-slow);
  z-index: 50;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-height);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.sidebar-logo-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ── Header ───────────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-clock {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.header-badge.demo {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition);
}

.hamburger-btn:hover { background: var(--bg-tertiary); }

/* ── View Container ───────────────────────────────────────────── */
.view-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-secondary);
  padding-bottom: 24px;
}

.view {
  display: none;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100%;
}

.view.active { display: block; }

/* ── Section Titles ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 16px 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* ── KPI Cards ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-change {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }
.kpi-change.neutral  { color: var(--text-tertiary); }

/* ── Grid Layouts ─────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.4;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-danger:hover {
  background: #fecaca;
  border-color: var(--danger);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
}

/* ── Form Controls ────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

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

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-primary); }

tbody tr {
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 10px 14px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-accent  { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-muted); }

/* ── Signal Badges ────────────────────────────────────────────── */
.signal-buy        { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.signal-strong-buy { background: #dcfce7; color: #166534; border: 1px solid #86efac; font-weight: 700; }
.signal-sell       { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.signal-strong-sell{ background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; font-weight: 700; }
.signal-hold       { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Upload / Drop Zone ───────────────────────────────────────── */
.broker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.broker-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
}

.broker-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.broker-card.has-data {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.broker-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.broker-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.broker-icon.groww    { background: #00b386; }
.broker-icon.indmoney { background: #1a73e8; }
.broker-icon.dhan     { background: #2563eb; }
.broker-icon.univest  { background: #7c3aed; }
.broker-icon.upstox   { background: #5b21b6; }

.broker-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.broker-status {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.broker-status.active { color: var(--success); }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  margin-bottom: 12px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon {
  font-size: 24px;
  margin-bottom: 6px;
  color: var(--text-tertiary);
}

.drop-zone-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.drop-zone-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.broker-card-actions {
  display: flex;
  gap: 6px;
}

.broker-upload-time {
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: right;
  margin-top: 8px;
}

/* ── Portfolio Summary (Upload view) ──────────────────────────── */
.upload-summary {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.upload-summary-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.upload-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.upload-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.upload-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.danger  { background: var(--danger); }
.progress-fill.warning { background: var(--warning); }

/* ── Score Circle ─────────────────────────────────────────────── */
.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 3px solid currentColor;
}

.score-circle.excellent { color: var(--success); border-color: var(--success); background: var(--success-bg); }
.score-circle.good      { color: var(--info);    border-color: var(--info);    background: var(--info-bg); }
.score-circle.average   { color: var(--warning); border-color: var(--warning); background: var(--warning-bg); }
.score-circle.poor      { color: var(--danger);  border-color: var(--danger);  background: var(--danger-bg); }

/* ── Bulk Analysis Table ──────────────────────────────────────── */
.bulk-table-wrap {
  overflow-x: auto;
}

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bulk-table th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.bulk-table th:hover { color: var(--text-primary); }

.bulk-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.bulk-table tbody tr:hover { background: var(--bg-hover); }

.bulk-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.reasoning-cell {
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Loading States ───────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner.sm { width: 12px; height: 12px; }
.loading-spinner.lg { width: 24px; height: 24px; border-width: 3px; }

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

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

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

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.2s ease;
  font-size: 13px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

.toast-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1px;
}

.toast-msg { color: var(--text-secondary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Charts ───────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-wrap canvas {
  max-width: 100%;
}

/* ── Stock Detail ─────────────────────────────────────────────── */
.stock-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.stock-symbol {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stock-name {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stock-price {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  text-align: right;
}

.price-change {
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.price-change.up   { color: var(--success); }
.price-change.down { color: var(--danger); }

/* ── Sector Bars ──────────────────────────────────────────────── */
.sector-item {
  margin-bottom: 12px;
}

.sector-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.sector-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Screener Filters ─────────────────────────────────────────── */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* ── News Cards ───────────────────────────────────────────────── */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: box-shadow var(--transition);
}

.news-card:hover { box-shadow: var(--shadow-md); }

.news-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.news-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  gap: 8px;
  align-items: center;
}

.news-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

/* ── News Feed (Multi-Source) ────────────────────────────────── */
.news-filter-pills {
  display: flex;
  gap: 4px;
}

.news-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.news-pill:hover {
  border-color: var(--text-tertiary);
}

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

.news-feed-list {
  display: flex;
  flex-direction: column;
}

.news-feed-card {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.news-feed-card:last-child {
  border-bottom: none;
}

.news-feed-card:hover {
  background: var(--bg-secondary);
}

.news-feed-img {
  width: 80px;
  min-width: 80px;
  height: 60px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-secondary);
  flex-shrink: 0;
}

.news-feed-content {
  flex: 1;
  min-width: 0;
}

.news-feed-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.news-provider-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.news-provider-badge.provider-global {
  background: #dbeafe;
  color: #1d4ed8;
}

.news-provider-badge.provider-india {
  background: #fef3c7;
  color: #92400e;
}

.news-feed-source {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.news-feed-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.news-feed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-feed-summary {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-feed-footer {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.news-cat-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-weight: 500;
}

.news-related-ticker {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: #ede9fe;
  color: #6d28d9;
}

/* ── News Feed Items (Market Intel page) ───────────────────── */
.news-feed-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.news-feed-item:last-child {
  border-bottom: none;
}

.news-feed-item .news-feed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.news-feed-item .news-feed-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.news-source-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.news-source-badge.finnhub {
  background: #dbeafe;
  color: #1d4ed8;
}

.news-source-badge.newsdata {
  background: #fef3c7;
  color: #92400e;
}

/* ── Deep News Analysis ────────────────────────────────────── */
.deep-news-container {
  display: flex;
  flex-direction: column;
}

.dn-sentiment-badge,
.dn-action-badge {
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dn-news-list {
  display: flex;
  flex-direction: column;
}

.dn-news-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.dn-news-item:last-child {
  border-bottom: none;
}

.dn-news-item.dn-impact-positive {
  border-left-color: #16a34a;
}

.dn-news-item.dn-impact-negative {
  border-left-color: #dc2626;
}

.dn-news-item.dn-impact-neutral {
  border-left-color: #6b7280;
}

.dn-news-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.dn-news-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
  min-width: 200px;
}

.dn-news-item-title a:hover {
  text-decoration: underline;
}

.dn-news-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.dn-impact-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.dn-impact-badge.dn-impact-positive {
  background: #dcfce7;
  color: #15803d;
}

.dn-impact-badge.dn-impact-negative {
  background: #fee2e2;
  color: #b91c1c;
}

.dn-impact-badge.dn-impact-neutral {
  background: #f3f4f6;
  color: #6b7280;
}

.dn-level-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.dn-level-badge.dn-level-high {
  background: #fef2f2;
  color: #991b1b;
}

.dn-level-badge.dn-level-medium {
  background: #fefce8;
  color: #854d0e;
}

.dn-level-badge.dn-level-low {
  background: #f0fdf4;
  color: #166534;
}

.dn-cat-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 500;
}

.dn-news-item-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.dn-price-impact {
  font-weight: 600;
  font-size: 11px;
}

.dn-news-item-analysis {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
}

/* ── Deep News Events ──────────────────────────────────────── */
.dn-events-list {
  display: flex;
  flex-direction: column;
}

.dn-event-item {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.dn-event-item:last-child {
  border-bottom: none;
}

.dn-event-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 80px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  text-align: center;
}

.dn-event-details {
  flex: 1;
}

.dn-event-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.dn-event-impact {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── Trading Form ─────────────────────────────────────────────── */
.trade-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

/* ── Watchlist ────────────────────────────────────────────────── */
.watchlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.watchlist-item:last-child { border-bottom: none; }
.watchlist-item:hover { background: var(--bg-hover); }

/* ── Alert Items ──────────────────────────────────────────────── */
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.alert-item:last-child { border-bottom: none; }

.alert-item.triggered {
  background: var(--success-bg);
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13px;
  max-width: 320px;
  line-height: 1.6;
}

/* ── Demo Banner ──────────────────────────────────────────────── */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--warning);
  margin-bottom: 20px;
}

/* ── Accordion / Expandable ───────────────────────────────────── */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  overflow: hidden;
}

.accordion-header {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-primary);
  transition: background var(--transition);
  font-size: 13px;
  font-weight: 500;
}

.accordion-header:hover { background: var(--bg-tertiary); }

.accordion-body {
  display: none;
  padding: 14px 16px;
  background: var(--bg-secondary);
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.accordion-body.open { display: block; }

/* ── Recommendation Cards ─────────────────────────────────────── */
.rec-card {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rec-card.buy     { background: var(--success-bg); border-color: var(--success-border); }
.rec-card.sell    { background: var(--danger-bg);  border-color: var(--danger-border); }
.rec-card.hold    { background: var(--warning-bg); border-color: var(--warning-border); }
.rec-card.neutral { background: var(--bg-tertiary); border-color: var(--border); }

.rec-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.rec-detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Header Period Buttons ────────────────────────────────────── */
.period-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 2px;
  border-radius: var(--radius-xs);
}

.period-tab {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

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

.period-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ── Footer ───────────────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0 0;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

.app-footer a {
  color: var(--text-tertiary);
  transition: color var(--transition);
}

.app-footer a:hover { color: var(--accent); text-decoration: none; }

.footer-sep { color: var(--border); }

/* ── Divider ──────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Inline Status Dot ────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active  { background: var(--success); box-shadow: 0 0 0 2px var(--success-border); }
.status-dot.inactive{ background: var(--text-tertiary); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-border); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Search / Command Palette ─────────────────────────────────── */
.command-bar {
  position: fixed;
  bottom: 16px;
  left: calc(var(--sidebar-width) + 50% - 280px);
  z-index: 60;
  width: 560px;
  max-width: calc(100vw - var(--sidebar-width) - 48px);
}

@media (max-width: 768px) {
  .command-bar {
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 32px);
    max-width: 100%;
  }
}

.command-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xl);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.command-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12), var(--shadow-xl);
}

.command-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.command-input::placeholder { color: var(--text-tertiary); }

.command-shortcut {
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
    display: none;
  }

  .sidebar-overlay.visible { display: block; }

  .hamburger-btn { display: flex; }

  .main-content { width: 100%; }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

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

  .view { padding: 16px; }
  .app-header { padding: 0 16px; }

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

  .stock-header {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .command-bar {
    bottom: 12px;
  }
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-tertiary); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.ticker { font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }

.flex    { display: flex; }
.flex-col{ display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.mt-4    { margin-top: 16px; }
.mt-6    { margin-top: 24px; }
.mb-4    { margin-bottom: 16px; }
.mb-6    { margin-bottom: 24px; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden { display: none !important; }
.visible { display: block !important; }

/* ═══════════════════════════════════════════════════════════════
   Deep Research Button
   ═══════════════════════════════════════════════════════════════ */
.deep-research-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border: 1px solid #6366f1; border-radius: 6px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color: #4338ca; font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all 0.15s ease;
  letter-spacing: 0.02em;
}
.deep-research-btn:hover {
  background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
  color: #3730a3; border-color: #4f46e5;
  box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}
.deep-research-btn.sm { padding: 3px 8px; font-size: 10px; }

/* ═══════════════════════════════════════════════════════════════
   Deep Research Modal
   ═══════════════════════════════════════════════════════════════ */
.dr-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dr-modal {
  background: var(--bg-primary, #fff); border-radius: 16px;
  max-width: 960px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  overflow: hidden;
}
.dr-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}
.dr-modal-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text-primary, #111);
}
.dr-icon { font-size: 22px; }
.dr-close-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--bg-tertiary, #e5e7eb); color: var(--text-secondary, #6b7280);
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.dr-close-btn:hover { background: #dc2626; color: #fff; }
.dr-modal-body {
  overflow-y: auto; padding: 24px;
  flex: 1; min-height: 300px;
}

/* ── Header ─────────────────────────────────────────── */
.dr-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-wrap: wrap;
}
.dr-header-left { flex: 1; min-width: 200px; }
.dr-header-right { text-align: right; }
.dr-company-name { font-size: 22px; font-weight: 800; color: var(--text-primary, #111); line-height: 1.2; }
.dr-meta { font-size: 12px; color: var(--text-tertiary, #9ca3af); margin-top: 4px; }
.dr-meta-date { font-size: 11px; color: var(--text-tertiary, #9ca3af); margin-top: 2px; }
.dr-price { font-size: 26px; font-weight: 800; line-height: 1.2; }
.dr-verdict {
  display: inline-block; padding: 4px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 800; letter-spacing: 0.05em; margin-top: 6px;
}
.dr-verdict-buy { background: #dcfce7; color: #15803d; }
.dr-verdict-sell { background: #fee2e2; color: #b91c1c; }
.dr-verdict-hold { background: #fef9c3; color: #854d0e; }
.dr-sentiment-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; justify-content: flex-end; }
.dr-sentiment {
  font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 4px;
}
.dr-sentiment-bull { background: #dcfce7; color: #15803d; }
.dr-sentiment-bear { background: #fee2e2; color: #b91c1c; }
.dr-sentiment-neutral { background: #f3f4f6; color: #6b7280; }
.dr-confidence { font-size: 11px; color: var(--text-tertiary, #9ca3af); }

/* ── Summary ────────────────────────────────────────── */
.dr-summary {
  font-size: 14px; line-height: 1.7; color: var(--text-secondary, #374151);
  padding: 16px; background: var(--bg-secondary, #f9fafb);
  border-radius: 10px; margin-bottom: 20px; border-left: 4px solid #6366f1;
}

/* ── Sections ───────────────────────────────────────── */
.dr-section { margin-bottom: 24px; }
.dr-section-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary, #111);
  margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--border, #e5e7eb);
}

/* ── Timeframe Grid ─────────────────────────────────── */
.dr-tf-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.dr-tf-card {
  background: var(--bg-secondary, #f9fafb); border-radius: 10px;
  padding: 14px; border: 1px solid var(--border, #e5e7eb);
  transition: box-shadow 0.15s;
}
.dr-tf-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.dr-tf-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.dr-tf-period { font-size: 12px; font-weight: 700; color: var(--text-primary, #111); }
.dr-tf-verdict {
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.05em;
}
.dr-tf-buy { background: #dcfce7; color: #15803d; }
.dr-tf-sell { background: #fee2e2; color: #b91c1c; }
.dr-tf-hold { background: #fef9c3; color: #854d0e; }
.dr-tf-outlook { font-size: 11px; font-weight: 600; margin-bottom: 8px; }
.dr-outlook-bull { color: #16a34a; }
.dr-outlook-bear { color: #dc2626; }
.dr-outlook-neutral { color: #6b7280; }
.dr-tf-prices {
  display: flex; gap: 16px; margin-bottom: 8px;
}
.dr-tf-prices > div { display: flex; flex-direction: column; }
.dr-label { font-size: 10px; color: var(--text-tertiary, #9ca3af); text-transform: uppercase; letter-spacing: 0.05em; }
.dr-value { font-size: 13px; font-weight: 700; color: var(--text-primary, #111); }
.dr-tf-reasoning { font-size: 12px; line-height: 1.6; color: var(--text-secondary, #374151); }
.dr-triggers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.dr-trigger {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  background: #eef2ff; color: #4338ca; font-weight: 500;
}

/* ── Bull vs Bear ───────────────────────────────────── */
.dr-cases-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .dr-cases-grid { grid-template-columns: 1fr; } }
.dr-cases-col { display: flex; flex-direction: column; gap: 8px; }
.dr-cases-header {
  font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 8px;
}
.dr-cases-header.dr-bull { background: #dcfce7; color: #15803d; }
.dr-cases-header.dr-bear { background: #fee2e2; color: #b91c1c; }
.dr-case-item {
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
}
.dr-case-item.dr-bull { border-left: 3px solid #16a34a; }
.dr-case-item.dr-bear { border-left: 3px solid #dc2626; }
.dr-case-point { font-size: 13px; font-weight: 600; color: var(--text-primary, #111); line-height: 1.4; }
.dr-case-evidence {
  font-size: 12px; color: var(--text-tertiary, #6b7280);
  margin-top: 4px; font-style: italic; line-height: 1.5;
}

/* ── Expert Opinions ────────────────────────────────── */
.dr-experts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.dr-expert-card {
  padding: 12px; border-radius: 10px;
  background: var(--bg-secondary, #f9fafb); border: 1px solid var(--border, #e5e7eb);
}
.dr-expert-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dr-expert-source { font-size: 13px; font-weight: 700; color: var(--text-primary, #111); }
.dr-expert-rating {
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.03em;
}
.dr-expert-buy { background: #dcfce7; color: #15803d; }
.dr-expert-sell { background: #fee2e2; color: #b91c1c; }
.dr-expert-hold { background: #fef9c3; color: #854d0e; }
.dr-expert-target { font-size: 12px; font-weight: 600; color: var(--text-primary, #111); margin-bottom: 4px; }
.dr-expert-comment { font-size: 12px; color: var(--text-secondary, #374151); line-height: 1.5; }
.dr-expert-date { font-size: 10px; color: var(--text-tertiary, #9ca3af); margin-top: 6px; }

/* ── Metrics Grid ───────────────────────────────────── */
.dr-metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.dr-metric {
  padding: 10px; background: var(--bg-secondary, #f9fafb);
  border-radius: 8px; border: 1px solid var(--border, #e5e7eb);
  display: flex; flex-direction: column; gap: 2px;
}
.dr-metric-label { font-size: 10px; color: var(--text-tertiary, #9ca3af); text-transform: uppercase; letter-spacing: 0.05em; }
.dr-metric-value { font-size: 14px; font-weight: 700; color: var(--text-primary, #111); }
.dr-highlight {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: #fffbeb; border: 1px solid #fde68a;
  font-size: 12px; line-height: 1.6; color: #92400e;
}

/* ── Tech Summary ───────────────────────────────────── */
.dr-tech-summary { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.dr-tech-trend {
  font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 6px;
  background: #f3f4f6; color: #374151;
}
.dr-tech-trend.dr-bull { background: #dcfce7; color: #15803d; }
.dr-tech-trend.dr-bear { background: #fee2e2; color: #b91c1c; }
.dr-tech-vol { font-size: 12px; color: var(--text-secondary, #6b7280); }

/* ── News ───────────────────────────────────────────── */
.dr-news-item {
  padding: 10px 12px; border-radius: 8px; margin-bottom: 6px;
  border: 1px solid var(--border, #e5e7eb); background: var(--bg-secondary, #f9fafb);
}
.dr-news-item.dr-news-positive { border-left: 3px solid #16a34a; }
.dr-news-item.dr-news-negative { border-left: 3px solid #dc2626; }
.dr-news-item.dr-news-neutral { border-left: 3px solid #6b7280; }
.dr-news-headline { font-size: 13px; font-weight: 600; color: var(--text-primary, #111); line-height: 1.4; }
.dr-news-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.dr-news-source { font-size: 11px; color: var(--text-tertiary, #9ca3af); }
.dr-news-impact {
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px;
}
.dr-news-impact.dr-news-positive { background: #dcfce7; color: #15803d; }
.dr-news-impact.dr-news-negative { background: #fee2e2; color: #b91c1c; }
.dr-news-impact.dr-news-neutral { background: #f3f4f6; color: #6b7280; }
.dr-news-summary { font-size: 12px; color: var(--text-secondary, #374151); margin-top: 4px; line-height: 1.5; }

/* ── Peers Table ─────────────────────────────────────── */
.dr-peers-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.dr-peers-table th {
  text-align: left; padding: 8px 10px; font-size: 11px;
  color: var(--text-tertiary, #9ca3af); text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 2px solid var(--border, #e5e7eb);
}
.dr-peers-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb);
  color: var(--text-primary, #111);
}

/* ── Risk Factors ───────────────────────────────────── */
.dr-risk-item {
  padding: 10px 12px; border-radius: 8px; margin-bottom: 6px;
  border: 1px solid var(--border, #e5e7eb); background: var(--bg-secondary, #f9fafb);
}
.dr-risk-header { display: flex; gap: 8px; align-items: center; }
.dr-risk-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.03em; flex-shrink: 0;
}
.dr-risk-high { background: #fee2e2; color: #b91c1c; }
.dr-risk-med { background: #fef9c3; color: #854d0e; }
.dr-risk-low { background: #dcfce7; color: #15803d; }
.dr-risk-text { font-size: 13px; font-weight: 600; color: var(--text-primary, #111); }
.dr-risk-mitigation { font-size: 12px; color: var(--text-tertiary, #6b7280); margin-top: 4px; font-style: italic; }

/* ── Citations ──────────────────────────────────────── */
.dr-citations { border-top: 2px solid var(--border, #e5e7eb); padding-top: 16px; }
.dr-citations-list { display: flex; flex-direction: column; gap: 6px; }
.dr-cite-item {
  display: flex; gap: 8px; font-size: 12px; line-height: 1.5;
  padding: 6px 8px; border-radius: 6px;
  background: var(--bg-secondary, #f9fafb);
}
.dr-cite-num {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: #6366f1; color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.dr-cite-claim { font-weight: 600; color: var(--text-primary, #111); }
.dr-cite-source { color: var(--text-tertiary, #6b7280); }
.dr-cite-item a {
  color: #4f46e5; text-decoration: none; word-break: break-all;
}
.dr-cite-item a:hover { text-decoration: underline; }

.dr-no-data { font-size: 12px; color: var(--text-tertiary, #9ca3af); padding: 12px; text-align: center; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  .dr-modal { max-height: 95vh; border-radius: 12px; }
  .dr-modal-body { padding: 16px; }
  .dr-header { flex-direction: column; }
  .dr-header-right { text-align: left; }
  .dr-tf-grid { grid-template-columns: 1fr; }
  .dr-experts-grid { grid-template-columns: 1fr; }
  .dr-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Institutional Holdings ─────────────────────────────────── */
.inst-container { background: var(--bg-primary); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.inst-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.inst-header-left h2 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; }
.inst-header-left .inst-subtitle { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.inst-signal { display: flex; align-items: center; gap: 10px; }
.inst-signal-badge { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.inst-signal-badge.bullish { background: #dcfce7; color: #15803d; }
.inst-signal-badge.bearish { background: #fee2e2; color: #dc2626; }
.inst-signal-badge.neutral { background: #fef3c7; color: #d97706; }

.inst-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-secondary); overflow-x: auto; }
.inst-tab { padding: 12px 20px; font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; transition: all 0.2s; }
.inst-tab:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.inst-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.inst-tab-content { display: none; padding: 20px 24px; }
.inst-tab-content.active { display: block; }

.inst-table { width: 100%; border-collapse: collapse; }
.inst-table thead th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.inst-table tbody td { padding: 10px 12px; font-size: 13px; color: var(--text-primary); border-bottom: 1px solid var(--border); vertical-align: middle; }
.inst-table tbody tr:last-child td { border-bottom: none; }
.inst-table tbody tr:hover { background: var(--bg-secondary); }
.inst-table .change-up { color: #16a34a; font-weight: 600; }
.inst-table .change-down { color: #dc2626; font-weight: 600; }
.inst-table .change-new { color: var(--accent); font-weight: 600; }
.inst-table .change-exit { color: #dc2626; font-weight: 600; text-decoration: line-through; }

.inst-pie-row { display: flex; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.inst-pie-card { flex: 1; min-width: 200px; }
.inst-pie-card .pie-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.inst-pie-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 8px; }
.inst-pie-bar .segment { transition: width 0.4s ease; }
.inst-pie-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.inst-pie-legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.inst-pie-legend-item .dot { width: 8px; height: 8px; border-radius: 50%; }

.inst-trend-table { width: 100%; border-collapse: collapse; }
.inst-trend-table th, .inst-trend-table td { padding: 8px 12px; font-size: 12px; text-align: center; border-bottom: 1px solid var(--border); }
.inst-trend-table th { font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.3px; background: var(--bg-secondary); font-size: 11px; }
.inst-trend-table td:first-child { text-align: left; font-weight: 500; }

.inst-obs-list { display: flex; flex-direction: column; gap: 8px; }
.inst-obs-item { display: flex; gap: 10px; padding: 10px 14px; background: var(--bg-secondary); border-radius: 8px; font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.inst-obs-item .obs-icon { font-size: 16px; flex-shrink: 0; }

.inst-pledge-card { display: flex; gap: 20px; flex-wrap: wrap; }
.inst-pledge-metric { flex: 1; min-width: 140px; padding: 14px; background: var(--bg-secondary); border-radius: 10px; text-align: center; }
.inst-pledge-metric .metric-value { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.inst-pledge-metric .metric-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.inst-deal-card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.inst-deal-left { display: flex; flex-direction: column; gap: 2px; }
.inst-deal-entity { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.inst-deal-meta { font-size: 12px; color: var(--text-secondary); }
.inst-deal-right { text-align: right; }
.inst-deal-shares { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.inst-deal-value { font-size: 12px; color: var(--text-secondary); }

.inst-sources { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.inst-sources-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.inst-sources-list { display: flex; flex-wrap: wrap; gap: 8px; }
.inst-sources-list a { font-size: 12px; color: var(--accent); text-decoration: none; }
.inst-sources-list a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .inst-tabs { gap: 0; }
  .inst-tab { padding: 10px 14px; font-size: 12px; }
  .inst-tab-content { padding: 14px; }
  .inst-table { font-size: 12px; }
  .inst-pie-row { flex-direction: column; }
  .inst-deal-card { flex-direction: column; gap: 8px; }
}
