:root {
  --ink: #102631;
  --ink-2: #28424c;
  --muted: #708087;
  --line: #dfe5e4;
  --paper: #f4f3ee;
  --card: #fffefa;
  --accent: #ec6b2d;
  --accent-dark: #c64f18;
  --teal: #0d6b63;
  --teal-light: #dfece9;
  --warning: #9a6b18;
  --shadow: 0 18px 55px rgba(16, 38, 49, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 20px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(236, 107, 45, 0.12), transparent 35%),
    #102631;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--accent); font-weight: 900; font-size: 22px; }
.brand strong { display: block; font-size: 14px; letter-spacing: .12em; }
.brand small { display: block; margin-top: 3px; color: #9db0b7; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.nav { display: grid; gap: 7px; margin-top: 30px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #aebdc2; padding: 13px 14px; display: flex; gap: 14px; align-items: center; text-align: left; border-radius: 3px; transition: .2s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(236,107,45,.16); box-shadow: inset 3px 0 var(--accent); }
.nav-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 20px 10px 0; border-top: 1px solid rgba(255,255,255,.1); color: #8fa4ab; font-size: 11px; }
.system-status { color: #d4e0e2; font-size: 12px; }
.system-status i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: #54c49c; border-radius: 50%; box-shadow: 0 0 0 4px rgba(84,196,156,.12); }

.main { min-width: 0; }
.topbar { min-height: 94px; padding: 22px 42px; display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); background: rgba(244,243,238,.9); backdrop-filter: blur(12px); }
.topbar h1 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.03em; }
.eyebrow, .section-label { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: .16em; color: var(--accent); font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.pilot-badge { background: #e7ecea; color: var(--teal); padding: 7px 10px; font-size: 11px; font-weight: 700; }
.pilot-badge.offline { color: var(--warning); background: #f5edd8; }
.current-user { font-size: 11px; color: var(--muted); font-weight: 700; }
.account-button { border: 0; background: transparent; color: var(--ink-2); padding: 6px 0; font-size: 11px; font-weight: 700; }
.account-button:hover { color: var(--accent); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; border-radius: 50%; }
.menu-button { display: none; border: 1px solid var(--line); background: var(--card); padding: 8px 10px; }

.view { display: none; padding: 38px 42px 56px; }
.view.active { display: block; animation: viewIn .25s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }

.hero-grid { display: grid; grid-template-columns: minmax(0,1fr) 270px; gap: 22px; margin-bottom: 24px; }
.hero-copy { position: relative; overflow: hidden; background: var(--ink); color: white; min-height: 300px; padding: 40px; box-shadow: var(--shadow); }
.hero-copy::after { content: ""; position: absolute; width: 260px; height: 260px; right: -80px; bottom: -130px; border: 46px solid rgba(236,107,45,.15); border-radius: 50%; }
.hero-copy h2 { position: relative; z-index: 1; margin: 16px 0; max-width: 680px; font-size: clamp(32px, 4vw, 52px); line-height: 1.13; letter-spacing: -.055em; }
.hero-copy p { position: relative; z-index: 1; max-width: 720px; color: #c7d1d4; line-height: 1.8; margin: 0; font-size: 14px; }
.hero-points { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.hero-points span { border: 1px solid rgba(255,255,255,.18); padding: 8px 10px; font-size: 11px; color: #eaf0f1; }
.hero-metric { background: var(--accent); color: #fff; padding: 32px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: var(--shadow); }
.hero-metric span { font-size: 12px; letter-spacing: .12em; }
.hero-metric strong { display: block; font-size: 84px; line-height: .95; margin: 28px 0 4px; letter-spacing: -.08em; }
.hero-metric p { margin: 0 0 24px; font-size: 13px; line-height: 1.5; }
.hero-metric small { margin-top: 9px; opacity: .8; }
.progress { height: 5px; background: rgba(255,255,255,.28); }
.progress i { display: block; height: 100%; background: #fff; }

.content-grid { display: grid; gap: 22px; }
.discovery-grid { grid-template-columns: minmax(0, 1.6fr) minmax(280px, .6fr); }
.dashboard-grid { grid-template-columns: 1.25fr .75fr; }
.panel { background: var(--card); border: 1px solid var(--line); box-shadow: 0 12px 34px rgba(16,38,49,.04); }
.panel-head { min-height: 78px; padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 5px 0 0; font-size: 18px; letter-spacing: -.02em; }
.step-tag { color: var(--accent); font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.api-state { color: var(--warning); background: #f5edd8; padding: 7px 9px; font-size: 11px; font-weight: 700; }

.search-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; padding: 24px; }
.search-form label { display: grid; gap: 8px; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.search-form input, .search-form select { width: 100%; border: 1px solid #cfd7d6; background: #fff; color: var(--ink); min-height: 45px; padding: 0 12px; border-radius: 0; outline: none; transition: .2s; }
.search-form input:focus, .search-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(236,107,45,.1); }
.wide { grid-column: 1 / -1; }
.query-preview { background: #edf0ed; padding: 13px 15px; display: grid; gap: 6px; }
.query-preview span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.query-preview code { color: var(--teal); white-space: normal; overflow-wrap: anywhere; line-height: 1.6; font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.button { border: 0; min-height: 43px; padding: 0 17px; font-weight: 800; font-size: 12px; transition: .2s; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.button.secondary { background: var(--ink); color: white; }
.button.secondary:hover { background: #1b3b49; }
.text-button { border: 0; background: none; color: var(--teal); font-size: 11px; font-weight: 700; }

.playbook-list { list-style: none; margin: 0; padding: 10px 24px; }
.playbook-list li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.playbook-list b { color: var(--accent); font: 800 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.playbook-list span { color: var(--muted); font-size: 12px; line-height: 1.55; }
.playbook-list strong { display: block; color: var(--ink); margin-bottom: 3px; font-size: 13px; }
.rule-note { margin: 14px 24px 24px; padding: 18px; background: var(--teal-light); color: var(--teal); }
.rule-note strong { font-size: 12px; }
.rule-note p { margin: 8px 0 0; font-size: 12px; line-height: 1.6; }
.recent-panel { margin-top: 22px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
th { color: var(--muted); background: #f8f8f4; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
td strong { display: block; margin-bottom: 4px; font-size: 13px; }
td small { color: var(--muted); }
.status { display: inline-flex; padding: 6px 8px; font-size: 10px; font-weight: 800; letter-spacing: .05em; }
.status.pending { color: var(--warning); background: #f5edd8; }
.status.verified { color: var(--teal); background: var(--teal-light); }
.status.rejected { color: #9a4242; background: #f4e2e2; }
.inline-action { border: 0; background: none; color: var(--accent-dark); padding: 0; font-weight: 800; font-size: 11px; }
.empty-row { text-align: center; color: var(--muted); padding: 30px; }

.page-intro { margin-bottom: 28px; display: flex; justify-content: space-between; gap: 28px; align-items: flex-end; }
.page-intro h2 { margin: 9px 0 8px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.05em; line-height: 1.12; }
.page-intro p { margin: 0; color: var(--muted); line-height: 1.65; }
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 22px; }
.metric-grid article { padding: 23px; background: var(--card); border-top: 3px solid var(--ink); box-shadow: 0 8px 30px rgba(16,38,49,.05); }
.metric-grid span, .metric-grid small { display: block; color: var(--muted); font-size: 11px; }
.metric-grid strong { display: block; margin: 13px 0 5px; font-size: 36px; letter-spacing: -.05em; }
.task-list { padding: 8px 24px 20px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.task-check { width: 19px; height: 19px; border: 1px solid #bcc7c7; background: white; }
.task.done .task-check { background: var(--teal); border-color: var(--teal); }
.task.done .task-copy { text-decoration: line-through; opacity: .52; }
.task-copy strong { display: block; font-size: 13px; }
.task-copy small { display: block; margin-top: 3px; color: var(--muted); }
.task b { font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); }
.funnel-panel { padding-bottom: 20px; }
.funnel-row { display: grid; grid-template-columns: 92px 1fr 30px; gap: 12px; align-items: center; padding: 11px 24px; font-size: 11px; }
.funnel-row i { height: 13px; background: linear-gradient(90deg, var(--teal), #4c9d91); }
.funnel-row b { text-align: right; }
.demo-note { display: block; margin: 18px 24px 0; color: var(--muted); line-height: 1.6; }

.taxonomy-layout { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.taxonomy-root { background: var(--ink); color: white; padding: 34px; min-height: 260px; position: relative; overflow: hidden; }
.taxonomy-root::after { content: "L1"; position: absolute; right: 10px; bottom: -25px; font-size: 110px; font-weight: 900; color: rgba(255,255,255,.04); }
.taxonomy-root span { color: var(--accent); font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.taxonomy-root h3 { margin: 24px 0 12px; font-size: 33px; letter-spacing: -.05em; }
.taxonomy-root p { color: #c3d0d3; line-height: 1.75; font-size: 13px; }
.taxonomy-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.taxonomy-card { background: var(--card); border: 1px solid var(--line); padding: 22px; transition: .2s; }
.taxonomy-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.taxonomy-card .tax-top { display: flex; justify-content: space-between; gap: 12px; }
.taxonomy-card h3 { margin: 7px 0; font-size: 18px; }
.taxonomy-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.taxonomy-card .tax-count { color: var(--accent); font: 800 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.keyword-list span { padding: 6px 8px; background: #eef0ed; color: var(--ink-2); font-size: 10px; }

.filter-row { display: flex; gap: 8px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.filter { border: 1px solid var(--line); background: white; padding: 8px 11px; font-size: 11px; color: var(--muted); }
.filter.active { background: var(--ink); color: white; border-color: var(--ink); }

.toast { position: fixed; right: 24px; bottom: 24px; min-width: 260px; max-width: 360px; padding: 14px 16px; background: var(--ink); color: white; font-size: 12px; line-height: 1.55; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; z-index: 100; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }

.auth-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 76% 18%, rgba(236,107,45,.2), transparent 28%), #102631; }
.auth-screen[hidden] { display: none; }
.login-card { width: min(440px, 100%); background: var(--card); padding: 36px; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; color: var(--ink); font-size: 12px; letter-spacing: .1em; }
.login-card h2 { margin: 10px 0 10px; font-size: 30px; letter-spacing: -.045em; }
.login-card > p:not(.form-error) { color: var(--muted); margin: 0 0 25px; line-height: 1.7; font-size: 13px; }
.login-card label, .modal label { display: grid; gap: 8px; margin: 16px 0; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.login-card input, .modal input { min-height: 46px; border: 1px solid #cfd7d6; background: white; padding: 0 12px; outline: none; }
.login-card input:focus, .modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(236,107,45,.1); }
.login-card .button { width: 100%; margin-top: 5px; }
.login-card small { display: block; margin-top: 18px; text-align: center; color: var(--muted); }
.form-error { min-height: 18px; margin: 8px 0; color: #a33f3f; font-size: 12px; }

.modal { width: min(470px, calc(100% - 32px)); border: 0; padding: 0; background: var(--card); color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(16,38,49,.68); backdrop-filter: blur(3px); }
.modal form { padding: 26px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 6px 0 0; font-size: 20px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; }
.password-hint { color: var(--muted); font-size: 11px; line-height: 1.6; }
.modal .button { width: 100%; }

@media (max-width: 1100px) {
  .discovery-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-metric { min-height: 210px; }
  .hero-metric strong { font-size: 62px; margin-top: 18px; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: .25s; }
  .sidebar.open { left: 0; box-shadow: 20px 0 60px rgba(0,0,0,.28); }
  .menu-button { display: block; }
  .topbar { padding: 18px 20px; }
  .topbar .eyebrow, .pilot-badge { display: none; }
  .current-user, #changePassword { display: none; }
  .view { padding: 25px 18px 45px; }
  .hero-copy { padding: 28px 24px; min-height: auto; }
  .hero-copy h2 { font-size: 34px; }
  .search-form { grid-template-columns: 1fr; padding: 20px; }
  .wide { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .taxonomy-layout { grid-template-columns: 1fr; }
  .taxonomy-grid { grid-template-columns: 1fr; }
  .page-intro { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .top-actions { gap: 8px; }
  .topbar h1 { font-size: 19px; }
  .hero-points { display: none; }
}
