/* ============ DemandLens — design system (Databox-inspired) ============ */
:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F1F4F8;
  --ink: #0F1B2D;
  --muted: #5B6B82;
  --faint: #93A1B5;
  --teal: #0D9488;
  --teal-dark: #0B7C72;
  --teal-soft: #E6F5F1;
  --navy: #0F172A;
  --navy-2: #1B2537;
  --border: #E6EAF0;
  --go: #0D9488;
  --watch: #C9820A;
  --avoid: #D1453B;
  --shadow-sm: 0 1px 2px rgba(15,27,45,.05);
  --shadow: 0 1px 3px rgba(15,27,45,.06), 0 10px 30px rgba(15,27,45,.06);
  --r: 14px; --r-sm: 10px;
  --sb: 258px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1,h2,h3 { margin: 0; font-family: "Sora", sans-serif; }
a { color: inherit; text-decoration: none; }
em { font-style: normal; color: var(--teal); }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sb); flex: none; background: var(--navy); color: #AEB9CC;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; }
.brand-name { font-family: "Sora"; font-size: 19px; font-weight: 700; color: #fff; }
.brand-name b { color: #5EEAD4; }
.workspace { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08); border-radius: 11px; padding: 9px 11px; margin-bottom: 14px; cursor: pointer; }
.ws-ic { width: 30px; height: 30px; border-radius: 8px; background: var(--teal); color: #fff; font-size: 12px;
  font-weight: 700; display: grid; place-items: center; flex: none; }
.ws-meta { flex: 1; min-width: 0; }
.ws-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-sub { font-size: 11px; color: #64748B; }
.ws-caret { color: #64748B; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #556079; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; font-size: 14px;
  font-weight: 500; color: #AEB9CC; transition: .15s; }
.nav-item .ic { width: 18px; text-align: center; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; box-shadow: 0 6px 16px rgba(13,148,136,.3); }
.soon { margin-left: auto; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em;
  background: rgba(255,255,255,.08); color: #8696AD; padding: 2px 7px; border-radius: 999px; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user { display: flex; align-items: center; gap: 10px; padding: 4px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#0D9488,#0B7C72);
  color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; font-size: 14px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.u-name { font-size: 13px; font-weight: 600; color: #fff; }
.u-sub { font-size: 11px; color: #64748B; }

/* ---------- Topbar ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 28px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); }
.crumb { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.crumb .sep { color: var(--faint); }
.crumb b { color: var(--ink); font-weight: 600; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.tb-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted);
  background: var(--surface-2); padding: 6px 12px; border-radius: 999px; }
.tb-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.tb-status.ok .dot { background: var(--go); box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
.tb-status.down .dot { background: var(--avoid); }

.content { padding: 26px 28px 40px; max-width: 1160px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 23px; font-weight: 800; }
.page-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Search ---------- */
.search-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px 4px 4px 14px; }
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); background: #fff; }
.search-ic { color: var(--faint); font-size: 18px; }
.search input { flex: 1; border: none; background: none; outline: none; font-size: 15px; color: var(--ink); padding: 11px 0; }
.search button { border: none; background: var(--teal); color: #fff; font-weight: 600; font-size: 14.5px;
  padding: 11px 22px; border-radius: 9px; cursor: pointer; transition: .15s; white-space: nowrap; }
.search button:hover { background: var(--teal-dark); }
.search button:disabled { opacity: .6; cursor: default; }
.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 13px; font-size: 13px; color: var(--muted); }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; cursor: pointer; transition: .15s; }
.chip:hover { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-dark); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-badge { width: 60px; height: 60px; border-radius: 16px; background: var(--teal-soft); color: var(--teal);
  font-size: 28px; display: grid; place-items: center; margin: 0 auto 14px; }
.empty h2 { font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 420px; margin: 0 auto; }

/* ---------- Grid & widgets ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 20px; }
.hidden { display: none !important; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: 18px 20px; min-width: 0; }
.w-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.w-head h3 { font-family: "Inter"; font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); }
.w-dots { color: var(--faint); letter-spacing: 2px; }

.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }

/* verdict hero */
.hero { grid-column: span 12; display: flex; align-items: center; gap: 24px; color: #fff;
  border-radius: var(--r); padding: 24px 26px; box-shadow: var(--shadow); }
.hero.GO { background: linear-gradient(120deg,#0D9488,#0B6F67); }
.hero.WATCH { background: linear-gradient(120deg,#C9820A,#9C6608); }
.hero.AVOID { background: linear-gradient(120deg,#D1453B,#A6332B); }
.ring { --val: 0; width: 104px; height: 104px; border-radius: 50%; flex: none;
  background: conic-gradient(#fff calc(var(--val)*1%), rgba(255,255,255,.22) 0); display: grid; place-items: center; }
.ring::after { content: ""; grid-area: 1/1; width: 80px; height: 80px; border-radius: 50%; background: rgba(0,0,0,.14); }
.ring .rv { grid-area: 1/1; z-index: 1; text-align: center; }
.ring .rv b { font-size: 30px; font-weight: 800; display: block; line-height: 1; }
.ring .rv small { font-size: 10px; opacity: .8; }
.hero-body { flex: 1; min-width: 0; }
.hero-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-q { font-family: "Sora"; font-size: 22px; font-weight: 700; }
.v-pill { font-size: 12px; font-weight: 800; letter-spacing: .06em; background: rgba(255,255,255,.22); padding: 6px 14px; border-radius: 999px; }
.delta { font-size: 12.5px; font-weight: 700; background: rgba(255,255,255,.16); padding: 5px 11px; border-radius: 999px; }
.hero-r { font-size: 13.5px; opacity: .94; margin-top: 8px; max-width: 70ch; }

/* KPI tiles */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi .k .ki { width: 22px; height: 22px; border-radius: 6px; background: var(--teal-soft); color: var(--teal-dark);
  display: grid; place-items: center; font-size: 12px; }
.kpi .v { font-size: 25px; font-weight: 800; margin-top: 10px; font-family: "Sora"; }
.kpi .v small { font-size: 13px; color: var(--faint); font-weight: 600; }
.kpi .v.pos { color: var(--go); } .kpi .v.neg { color: var(--avoid); }
.kpi .sub { font-size: 12px; color: var(--faint); margin-top: 3px; }

.chart-wrap { height: 250px; position: relative; }

/* signal bars */
.bars { display: flex; flex-direction: column; gap: 16px; }
.bar-row .bl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bar-row .bl b { font-weight: 700; }
.track { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg,#0D9488,#14B8A6); }

/* lifecycle */
.life { display: flex; gap: 8px; }
.life .stage { flex: 1; text-align: center; font-size: 11.5px; color: var(--faint); }
.life .bar { height: 8px; border-radius: 999px; background: var(--surface-2); margin-bottom: 8px; }
.life .stage.on .bar { background: var(--teal); } .life .stage.on .lbl { color: var(--teal-dark); font-weight: 700; }
.life .stage.done .bar { background: var(--teal-soft); }

/* confidence */
.conf-big { display: flex; align-items: center; gap: 12px; }
.conf-badge { font-weight: 800; padding: 6px 14px; border-radius: 999px; font-size: 13px; text-transform: capitalize; }
.conf-badge.high { background: #E6F5F1; color: var(--teal-dark); }
.conf-badge.medium { background: #FBF0D9; color: var(--watch); }
.conf-badge.low { background: #FBE4E2; color: var(--avoid); }
.conf-note { font-size: 12.5px; color: var(--muted); margin-top: 12px; }

/* evidence */
.ev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.ev { display: flex; gap: 12px; align-items: center; border: 1px solid var(--border); border-radius: 11px; padding: 13px 14px; transition: .15s; }
.ev:hover { border-color: var(--teal); background: var(--teal-soft); transform: translateY(-1px); }
.ev .ev-ic { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--teal-dark); flex: none; }
.ev .ev-s { font-size: 13.5px; font-weight: 600; } .ev .ev-l { font-size: 12px; color: var(--muted); }
.ev .ev-go { margin-left: auto; color: var(--faint); }

/* skeleton */
.sk { background: linear-gradient(90deg,#EDF0F4 25%,#E2E6EC 37%,#EDF0F4 63%); background-size: 400% 100%;
  animation: sh 1.3s ease infinite; border-radius: var(--r); }
@keyframes sh { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

.error { background: #FBE4E2; color: #9B2820; border: 1px solid #F3C9C5; border-radius: 11px; padding: 14px 16px; font-size: 14px; margin-top: 18px; }
.error code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 5px; }
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 22px; border-top: 1px solid var(--border); }

/* responsive */
@media (max-width: 1000px) {
  .col-3,.col-4,.col-5,.col-7,.col-8 { grid-column: span 6; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .hamburger { display: block; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .col-3 { grid-column: span 1; } .col-4,.col-5,.col-7,.col-8,.hero { grid-column: span 2; }
  .hero { flex-direction: column; text-align: center; } .content { padding: 18px; }
}
