:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f3f5fa;
  --text: #202433;
  --muted: #747b8e;
  --line: #e3e6ee;
  --primary: #bd1749;
  --primary-dark: #99113b;
  --blue-soft: #e8efff;
  --blue: #4f73ce;
  --shadow: 0 14px 40px rgba(31, 37, 55, 0.06);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 264px;
  flex: 0 0 264px;
  display: flex;
  flex-direction: column;
  padding: 30px 18px 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: var(--primary);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: .95rem;
  letter-spacing: 0;
}
.product-nav { margin-top: 54px; }
.nav-label, .eyebrow, .metric-label {
  margin: 0;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.nav-label { padding: 0 12px 11px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: .91rem;
  font-weight: 700;
}
.nav-item.active { color: #36599d; background: var(--blue-soft); }
.nav-item.disabled { margin-top: 6px; color: #a5aab7; cursor: default; }
.nav-icon { width: 20px; color: currentColor; font-size: 1.25rem; line-height: 1; text-align: center; }
.nav-badge, .soon-badge, .panel-chip {
  margin-left: auto;
  border-radius: 999px;
  padding: 4px 8px;
  color: #6379b5;
  background: #dce7ff;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.soon-badge { color: #8b91a0; background: #eef0f4; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 5px; padding: 18px 12px 0; border-top: 1px solid var(--line); }
.sidebar-caption { color: var(--text); font-size: .76rem; font-weight: 700; }
.sidebar-version { color: var(--muted); font-size: .72rem; }

.main-shell { min-width: 0; flex: 1; }
.main-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(24px, 5vw, 76px);
  background: rgba(255, 255, 255, .74);
  border-bottom: 1px solid var(--line);
}
.header-context { color: var(--muted); font-size: .83rem; font-weight: 700; }
.header-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #47ae75; box-shadow: 0 0 0 4px #e2f4ea; }
.container { width: min(1120px, 100%); margin: 0 auto; padding: 62px clamp(24px, 5vw, 76px) 80px; }

.hero { max-width: 820px; }
.hero h1 {
  margin: 14px 0 18px;
  color: #242838;
  font-size: clamp(2.1rem, 4.2vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.hero h1 span { color: var(--primary); }
.hero-copy { max-width: 650px; margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.representative-search { margin-top: 39px; }
.representative-search label { display: block; margin-bottom: 10px; color: #495064; font-size: .79rem; font-weight: 800; }
.search-control { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 18px; color: var(--muted); font-size: 1.35rem; line-height: 1; pointer-events: none; }
.search-control input {
  width: 100%;
  height: 60px;
  padding: 0 155px 0 48px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #d8dce6;
  border-radius: 12px;
  outline: none;
  box-shadow: 0 5px 15px rgba(44, 51, 70, .04);
}
.search-control input:focus { border-color: #99abe0; box-shadow: 0 0 0 4px #e8edfc; }
.search-control input::placeholder { color: #a5abb9; }
.search-control button {
  position: absolute;
  right: 7px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 0 17px;
  color: white;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 800;
}
.search-control button:hover { background: var(--primary-dark); }
.search-control button:disabled { cursor: wait; opacity: .68; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 13px; color: var(--muted); font-size: .75rem; }
.examples button { padding: 0; color: #6275a9; background: none; border: 0; font-size: .75rem; }
.examples button:hover { color: var(--primary); text-decoration: underline; }

.search-status, .inline-error {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 820px;
  margin-top: 27px;
  padding: 15px 17px;
  border-radius: 10px;
  color: #596173;
  background: #eef2fd;
  font-size: .83rem;
}
.inline-error { color: #9d2046; background: #fff0f3; }
.spinner { width: 17px; height: 17px; flex: 0 0 17px; border: 2px solid #c4d0f1; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { margin-top: 76px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.results-heading h2 { margin: 9px 0 0; font-size: clamp(1.35rem, 2.5vw, 1.9rem); letter-spacing: -.025em; }
.results-heading h2 span { color: var(--primary); }
.secondary-button { padding: 9px 13px; color: #52607a; background: transparent; border: 1px solid #d8dce6; border-radius: 8px; font-size: .78rem; font-weight: 750; }
.secondary-button:hover { color: var(--primary); border-color: #d6a2b2; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.metric-card, .result-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.metric-card { min-height: 128px; padding: 19px 20px; }
.metric-card strong { display: block; margin-top: 13px; color: #272c3c; font-size: 1.85rem; letter-spacing: -.04em; }
.metric-card .metric-note { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.accent-card { border-top: 3px solid var(--primary); }
.accent-card strong { color: var(--primary); font-size: 1.45rem; }
.results-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .85fr); gap: 13px; margin-top: 13px; }
.result-panel { min-width: 0; padding: 24px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.panel-heading h3, .cpc-panel h3 { margin: 7px 0 0; font-size: 1.08rem; }
.panel-chip { margin: 0; color: #61729f; background: var(--blue-soft); }
.ranking-list { display: grid; }
.ranking-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 53px; border-bottom: 1px solid #eff0f4; }
.ranking-row:last-child { border-bottom: 0; }
.ranking-position { color: #9aa1af; font-size: .78rem; font-weight: 800; }
.ranking-name { overflow: hidden; color: #343a4c; font-size: .82rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.ranking-country { margin-left: 5px; color: var(--muted); font-size: .73rem; font-weight: 500; }
.ranking-count { min-width: 28px; padding: 5px 7px; color: #4262a5; background: var(--blue-soft); border-radius: 6px; font-size: .74rem; font-weight: 800; text-align: center; }
.cpc-panel { background: #fbfbfd; }
.cpc-code { margin-top: 28px; color: var(--primary); font-size: 1.62rem; font-weight: 850; letter-spacing: -.03em; }
.cpc-panel > p { margin: 8px 0 0; color: #555d70; font-size: .87rem; line-height: 1.55; }
.method-note { display: flex; gap: 10px; margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
.method-note p { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.55; }
.method-icon { display: grid; width: 18px; height: 18px; flex: 0 0 18px; place-items: center; color: #637bb8; background: var(--blue-soft); border-radius: 50%; font-size: .68rem; font-weight: 800; }
.results-footnote { margin: 17px 2px 0; color: #9197a5; font-size: .7rem; }
.raw-result { margin-top: 25px; color: var(--muted); font-size: .75rem; }
.raw-result summary { cursor: pointer; }
.raw-result pre { overflow: auto; max-height: 300px; padding: 14px; color: #586174; background: var(--surface-soft); border-radius: 8px; white-space: pre-wrap; }

/* Existing Company-Scope views remain usable while Company Lens is being built. */
.topbar { display: none; }
.card, .hero:not(.search-hero) { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; box-shadow: var(--shadow); }
.container h1, .container h2 { color: var(--text); }
.search { display: flex; gap: .75rem; margin-top: 1rem; }
.search input { width: 100%; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 8px; }
.search button, .button { padding: .85rem 1rem; color: white; background: var(--primary); border: 0; border-radius: 8px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.candidate-list { display: grid; gap: 1rem; }
.candidate { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; }
.muted, .meta { color: var(--muted); }
.list { padding-left: 1.1rem; }
.list li { margin: .55rem 0; }
.scroll-list { max-height: 360px; overflow: auto; }
.actions { display: flex; min-width: 130px; flex-direction: column; gap: .75rem; align-items: flex-end; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; }
code { padding: .1rem .3rem; background: #edf0f7; border-radius: 5px; }
.back { display: inline-block; margin-bottom: 1rem; }
.error { border-color: #fecaca; }
.error h1, .error-text { color: #b42318; }

@media (max-width: 820px) {
  .sidebar { width: 220px; flex-basis: 220px; }
  .container { padding-right: 30px; padding-left: 30px; }
  .main-header { padding: 0 30px; }
  .results-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; height: auto; padding: 17px 16px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .product-nav { display: flex; align-items: center; gap: 5px; margin-top: 18px; }
  .nav-label, .sidebar-bottom, .nav-item.disabled { display: none; }
  .nav-item { min-height: 38px; padding: 0 10px; font-size: .78rem; }
  .nav-icon { display: none; }
  .main-header { height: 52px; padding: 0 18px; }
  .container { padding: 40px 18px 55px; }
  .hero h1 { font-size: 2.15rem; }
  .search-control input { height: 55px; padding-right: 116px; font-size: .82rem; }
  .search-control button { height: 43px; padding: 0 11px; font-size: .75rem; }
  .search-control button span:last-child { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 105px; }
  .results { margin-top: 55px; }
  .results-heading { align-items: start; flex-direction: column; }
  .candidate, .search { flex-direction: column; align-items: stretch; }
  .actions { align-items: stretch; }
  .grid { grid-template-columns: 1fr; }
}
