@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:wght@300;400;500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── DESIGN TOKENS ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0f0f0f;
  --bg2:       #141414;
  --bg3:       #1a1a1a;
  --bg4:       #1e1e1e;
  --border:    #222;
  --border2:   #2a2a2a;
  --red:       #E50914;
  --red-dim:   rgba(229,9,20,0.12);
  --green:     #46D369;
  --blue:      #54A0FF;
  --gold:      #F5A623;
  --purple:    #A29BFE;
  --text:      #e5e5e5;
  --text2:     #aaa;
  --text3:     #666;
  --text4:     #3a3a3a;
  --font-head: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:    8px;
  --radius-sm: 5px;
  --radius-lg: 12px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --transition: 0.14s ease;
}

/* ── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-body); }
input, textarea, select { font-family: var(--font-body); }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d2d2d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3d3d3d; }

/* ── ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes ticker  { 0%{transform:translateX(0)} 100%{transform:translateX(-50%)} }
@keyframes fadeUp  { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn  { from{opacity:0} to{opacity:1} }
@keyframes slideIn { from{transform:translateX(-8px);opacity:0} to{transform:translateX(0);opacity:1} }
@keyframes glow    { 0%,100%{box-shadow:0 0 6px rgba(229,9,20,.3)} 50%{box-shadow:0 0 18px rgba(229,9,20,.7)} }

/* ── APP SHELL ──────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 210px; min-width: 210px;
  background: #0a0a0a;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 10;
}
.logo-area {
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.logo-n {
  width: 30px; height: 30px; background: var(--red); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 17px; color: #fff; flex-shrink: 0;
  animation: glow 3s ease-in-out infinite;
}
.logo-txt { font-family: var(--font-head); font-size: 24px; letter-spacing: 3px; color: #fff; line-height: 1; }
.logo-txt em { color: var(--red); font-style: normal; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 6px 0; }
.nav-section { padding: 14px 14px 4px; font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #2a2a2a; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; color: #484848; font-size: 12.5px; font-weight: 500;
  border-left: 3px solid transparent; transition: all var(--transition); user-select: none;
  position: relative;
}
.nav-item:hover { background: #161616; color: #888; }
.nav-item.active { background: rgba(229,9,20,.08); color: #fff; border-left-color: var(--red); }
.nav-item.active .nav-ic { color: var(--red); }
.nav-ic { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}
.nav-badge.gold { background: var(--gold); color: #000; }
.user-foot {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px; cursor: pointer; flex-shrink: 0;
  transition: background var(--transition);
}
.user-foot:hover { background: #141414; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 600; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10px; color: var(--text4); }

/* ── MAIN CONTENT AREA ──────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.ticker-wrap { overflow: hidden; background: #0d0d0d; border-bottom: 1px solid rgba(229,9,20,.25); height: 36px; display: flex; align-items: center; flex-shrink: 0; }
.ticker-inner { display: flex; animation: ticker 80s linear infinite; white-space: nowrap; align-items: center; height: 36px; }
.ticker-inner:hover { animation-play-state: paused; }
.tick-item { padding: 0 20px; font-size: 12.5px; font-weight: 500; color: #aaa; border-right: 1px solid rgba(255,255,255,.08); flex-shrink: 0; line-height: 36px; letter-spacing: 0.01em; }
.tick-item b { font-weight: 600; }
.tick-item.tick-up b { color: #22c97a; }
.tick-item.tick-dn b { color: #ff4455; }
.tick-item.tick-news b { color: #c8c8c8; font-weight: 500; }
.tick-item.tick-news .tick-src { color: #E50914; font-weight: 700; margin-right: 4px; }
.sarvatra-link:hover { background: rgba(229,9,20,.07) !important; border-left-color: #E50914 !important; color: #fff !important; }
.topbar {
  height: 50px; background: #0d0d0d; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 18px; gap: 12px; flex-shrink: 0;
}
.topbar-title { font-family: var(--font-head); font-size: 19px; letter-spacing: 2px; color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page-content { flex: 1; overflow-y: auto; padding: 18px 20px; animation: fadeIn .2s ease; }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-red {
  background: var(--red); border: none; border-radius: var(--radius-sm);
  color: #fff; font-family: var(--font-body); font-size: 12px; font-weight: 600;
  padding: 7px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: background var(--transition), transform .1s;
}
.btn-red:hover { background: #c0070f; }
.btn-red:active { transform: scale(.98); }
.btn-ghost {
  background: transparent; border: 1px solid #272727; border-radius: var(--radius-sm);
  color: #555; font-family: var(--font-body); font-size: 11.5px;
  padding: 5px 10px; cursor: pointer; transition: all var(--transition);
}
.btn-ghost:hover { color: #ccc; background: #1c1c1c; border-color: #333; }
.btn-ghost.danger:hover { color: var(--red); border-color: rgba(229,9,20,.3); }

/* ── INPUTS ─────────────────────────────────────────────────────────────── */
.inp {
  width: 100%; background: var(--bg4); border: 1px solid #2a2a2a; border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-body); font-size: 12.5px;
  padding: 8px 10px; outline: none; transition: border-color var(--transition);
}
.inp:focus { border-color: var(--red); }
select.inp { cursor: pointer; }
.inp-label { font-size: 10.5px; font-weight: 600; color: var(--text3); margin-bottom: 5px; display: block; }
.frow { margin-bottom: 12px; }
.bool-editor {
  width: 100%; background: #111; border: 2px solid #2a2a2a; border-radius: 7px;
  padding: 12px 14px; font-family: var(--font-mono); font-size: 13px; color: var(--text);
  min-height: 74px; resize: vertical; outline: none; line-height: 1.7; transition: border-color .2s;
}
.bool-editor:focus { border-color: var(--red); }
.bool-valid   { border-color: var(--green) !important; }
.bool-invalid { border-color: var(--red) !important; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; }
.card-label { font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: #383838; margin-bottom: 8px; }
.stat-num { font-family: var(--font-head); font-size: 34px; color: #fff; line-height: 1; }
.stat-change { font-size: 11px; font-weight: 500; margin-top: 5px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 14px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2,1fr); } }

/* ── PROGRESS & SPARKLINE ───────────────────────────────────────────────── */
.prog-bar { height: 4px; background: #1c1c1c; border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* ── TABS ───────────────────────────────────────────────────────────────── */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; gap: 2px; }
.tab {
  padding: 9px 16px; font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--transition); user-select: none; white-space: nowrap; border-radius: 4px 4px 0 0;
}
.tab:hover { color: #aaa; background: rgba(255,255,255,.03); }
.tab.active { color: #fff; border-bottom-color: var(--red); }

/* ── CHIPS ──────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 14px; font-size: 10.5px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg4);
  color: var(--text3); transition: all var(--transition); user-select: none; margin: 2px;
}
.chip:hover { color: #ccc; border-color: #333; }
.chip.active  { background: rgba(229,9,20,.1); border-color: var(--red); color: var(--red); }
.chip.active-b { background: rgba(84,160,255,.1); border-color: var(--blue); color: var(--blue); }

/* ── SECTION HEADER ─────────────────────────────────────────────────────── */
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sec-title { font-family: var(--font-head); font-size: 20px; letter-spacing: 1.5px; color: #fff; }

/* ── RESULT ITEMS ───────────────────────────────────────────────────────── */
.result-item {
  background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid transparent;
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: all var(--transition); animation: fadeUp .18s ease;
}
.result-item:hover { border-color: #333; transform: translateX(2px); box-shadow: var(--shadow); }
.result-item.pos { border-left-color: var(--green); }
.result-item.neg { border-left-color: var(--red); }
.result-item.neu { border-left-color: #555; }
.rel-bar { height: 3px; background: #1c1c1c; border-radius: 2px; overflow: hidden; margin-top: 9px; }
.rel-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--red), var(--gold)); }

/* ── OVERLAYS & MODALS ──────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  z-index: 9999; display: flex; align-items: flex-start; justify-content: center;
  padding: 24px; overflow-y: auto;
}
.modal {
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 12px;
  width: 100%; animation: fadeUp .2s ease; margin: auto;
}
.modal-sm { max-width: 520px; }
.modal-md { max-width: 780px; }
.modal-lg { max-width: 960px; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; color: #fff; }
.modal-body { padding: 16px 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── TOGGLE ─────────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 34px; height: 18px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.tslider { position: absolute; cursor: pointer; inset: 0; background: #2a2a2a; border-radius: 18px; transition: .2s; }
.tslider::before { position: absolute; content: ""; height: 12px; width: 12px; left: 3px; bottom: 3px; background: #555; border-radius: 50%; transition: .2s; }
.toggle input:checked + .tslider { background: var(--red); }
.toggle input:checked + .tslider::before { transform: translateX(16px); background: #fff; }

/* ── TABLE ──────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 7px 10px; text-align: left; font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #383838; border-bottom: 1px solid var(--border); }
.data-table td { padding: 9px 10px; font-size: 12px; border-bottom: 1px solid var(--bg4); color: var(--text2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── BOOLEAN OPS ────────────────────────────────────────────────────────── */
.op-btn {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 700; cursor: pointer; border: 1px solid; margin: 2px;
  user-select: none; font-family: var(--font-mono); transition: opacity var(--transition);
}
.op-btn:hover { opacity: .8; }
.op-AND   { background: rgba(70,211,105,.1); border-color: rgba(70,211,105,.4); color: var(--green); }
.op-OR    { background: rgba(84,160,255,.1); border-color: rgba(84,160,255,.4); color: var(--blue); }
.op-NOT   { background: rgba(229,9,20,.1);   border-color: rgba(229,9,20,.4);   color: var(--red); }
.op-NEAR  { background: rgba(162,155,254,.1);border-color: rgba(162,155,254,.4);color: var(--purple); }
.op-WILD  { background: rgba(245,166,35,.1); border-color: rgba(245,166,35,.4); color: var(--gold); }
.op-phrase{ background: rgba(255,159,67,.1); border-color: rgba(255,159,67,.4); color: #ff9f43; }

/* ── SOURCE ITEMS ───────────────────────────────────────────────────────── */
.src-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all var(--transition); user-select: none; margin-bottom: 5px;
}
.src-item:hover { border-color: #333; }
.src-item.active { border-color: var(--red); background: rgba(229,9,20,.05); }
.src-item.src-paid { opacity: 0.55; }
.src-item.src-paid:hover { opacity: 0.8; }
.src-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.btn-ghost.danger { color: #666; }
.btn-ghost.danger:hover { color: var(--red); border-color: rgba(229,9,20,.3); background: rgba(229,9,20,.05); }

/* ── SNIP CARDS ─────────────────────────────────────────────────────────── */
.snip-card {
  display: flex; align-items: stretch; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: #141414; transition: all var(--transition);
  min-width: 190px; max-width: 260px;
}
.snip-card:hover { border-color: #333; }
.snip-card.snip-on { border-color: var(--snip-color, var(--blue)); }

/* ── DIGEST CARDS ───────────────────────────────────────────────────────── */
.digest-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; margin-bottom: 12px; transition: border-color var(--transition); }
.digest-card:hover { border-color: #333; }

/* ── HERO ───────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg,#120606,#0e0e0e 55%,#060610);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px;
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 0% 50%, rgba(229,9,20,.07), transparent 60%);
  pointer-events: none;
}

/* ── SPINNER & LOADER ───────────────────────────────────────────────────── */
.spinner { width: 13px; height: 13px; border: 2px solid #444; border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); display: inline-block; animation: pulse 1.5s infinite; vertical-align: middle; }

/* ── TAGS ───────────────────────────────────────────────────────────────── */
.tag-active  { padding: 2px 8px; border-radius: 3px; font-size: 10.5px; font-weight: 600; background: rgba(70,211,105,.1); color: var(--green); }
.tag-paused  { padding: 2px 8px; border-radius: 3px; font-size: 10.5px; font-weight: 600; background: rgba(85,85,85,.2); color: #666; }

/* ── AI CHAT ────────────────────────────────────────────────────────────── */
.ai-layout { display: grid; grid-template-columns: 1fr 290px; gap: 14px; height: calc(100vh - 160px); }
.ai-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-width: 88%; animation: fadeUp .15s ease; }
.bubble-user { background: var(--red); color: #fff; align-self: flex-end; border-bottom-right-radius: 2px; }
.bubble-ai { background: var(--bg4); color: var(--text); border: 1px solid var(--border2); align-self: flex-start; border-bottom-left-radius: 2px; }
.ai-input-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ai-input-row input { flex: 1; background: var(--bg4); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); font-family: var(--font-body); font-size: 13px; padding: 9px 12px; outline: none; transition: border-color var(--transition); }
.ai-input-row input:focus { border-color: var(--red); }

/* ── LOGIN PAGE ─────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; background: var(--bg); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 20% 50%, rgba(229,9,20,.08), transparent 55%), radial-gradient(ellipse at 80% 80%, rgba(84,160,255,.04), transparent 50%); pointer-events: none; }
.login-card { width: 400px; background: var(--bg3); border: 1px solid var(--border2); border-radius: 14px; padding: 32px 28px; box-shadow: 0 12px 48px rgba(0,0,0,.7); position: relative; z-index: 1; }
.demo-row { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 4px; cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: background var(--transition); }
.demo-row:hover { background: #252525; }

/* ── GUIDE ROW ──────────────────────────────────────────────────────────── */
.guide-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--bg4); }
.guide-row:last-child { border-bottom: none; }

/* ── NO RESULTS ─────────────────────────────────────────────────────────── */
.no-results { text-align: center; padding: 50px 20px; color: var(--text3); }
.no-results .icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.no-results h3 { font-size: 15px; color: #777; margin-bottom: 6px; }
.no-results p { font-size: 12px; }
