:root {
  --bg: #090b10;
  --surface: #11141b;
  --surface-2: #171b24;
  --surface-3: #1d222d;
  --line: #252b37;
  --line-soft: #1c212b;
  --text: #f2f4f8;
  --muted: #8d95a5;
  --dim: #606979;
  --lime: #c9f43d;
  --lime-soft: rgba(201, 244, 61, .1);
  --blue: #68a7ff;
  --orange: #ff9a62;
  --red: #ff6978;
  --green: #55d68b;
  --purple: #a994ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 72% 8%, rgba(104, 167, 255, .07), transparent 30%),
    radial-gradient(circle at 20% 20%, rgba(201, 244, 61, .04), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(9, 11, 16, .86);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; font-weight: 760; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--lime);
  color: #10130a;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 0 22px rgba(201, 244, 61, .18);
}

.primary-nav { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.025); }
.primary-nav a { padding: 8px 13px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.primary-nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.primary-nav a.active { color: var(--text); background: var(--surface-3); box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }

.system-pill {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.system-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.system-pill.ready span { background: var(--green); box-shadow: 0 0 9px var(--green); }
.system-pill.partial span { background: var(--orange); box-shadow: 0 0 9px var(--orange); }

.hero { padding-top: 64px; padding-bottom: 50px; }
.eyebrow, .step-label { color: var(--lime); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 14px var(--lime); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 64px; align-items: end; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 22px; font-size: clamp(48px, 6.8vw, 92px); line-height: .93; letter-spacing: -.065em; font-weight: 790; }
h1 em { color: var(--lime); font-style: normal; }
.hero-copy { max-width: 710px; margin-bottom: 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.ingest-card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(23,27,36,.98), rgba(14,17,23,.98));
  box-shadow: var(--shadow);
}
.ingest-card { padding: 24px; }
.ingest-head, .panel-head, .section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.ingest-head { margin-bottom: 22px; }
.ingest-head h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.025em; }
.automation-badge { padding: 6px 8px; border-radius: 7px; background: var(--lime-soft); color: var(--lime); font-size: 10px; font-weight: 760; }
.ingest-card label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: rgba(6,8,12,.75);
  color: var(--text);
  padding: 0 12px;
}
input:focus, select:focus { border-color: rgba(201,244,61,.55); box-shadow: 0 0 0 3px rgba(201,244,61,.06); }
input::placeholder { color: #4f5766; }
.form-footer { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; margin-top: 12px; }
.form-footer label { margin: 0; }
.form-footer select { justify-self: end; max-width: 200px; min-height: 34px; font-size: 12px; }
.form-message { min-height: 18px; margin: 11px 0 -7px; color: var(--muted); font-size: 11px; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 740;
  transition: .18s ease;
}
.button:hover { transform: translateY(-1px); border-color: #3a4353; background: #252b37; }
.button:disabled { opacity: .45; cursor: wait; transform: none; }
.button-primary { border-color: var(--lime); background: var(--lime); color: #0b0d08; }
.button-primary:hover { background: #dbff62; border-color: #dbff62; }
.button-quiet { min-height: 32px; padding: 0 10px; font-size: 11px; }
.button-danger { color: var(--red); }

.workspace { padding-bottom: 80px; }
.workspace-tabs {
  position: sticky;
  top: 64px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9,11,16,.9);
  backdrop-filter: blur(15px);
}
.workspace-tab, .scope-switch button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.workspace-tab { padding: 9px 12px; }
.workspace-tab.active { background: var(--surface-2); color: var(--text); }
.scope-switch { display: flex; gap: 3px; margin-left: auto; padding: 3px; border: 1px solid var(--line-soft); border-radius: 9px; }
.scope-switch button { padding: 6px 9px; font-size: 10px; }
.scope-switch button.active { background: var(--lime-soft); color: var(--lime); }

.view { display: none; padding-top: 28px; }
.view.active { display: block; animation: viewIn .24s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi-card { min-height: 118px; padding: 17px; border: 1px solid var(--line-soft); border-radius: 13px; background: rgba(17,20,27,.78); }
.kpi-card .kpi-label { color: var(--muted); font-size: 10px; font-weight: 720; text-transform: uppercase; letter-spacing: .08em; }
.kpi-card strong { display: block; margin-top: 18px; font-size: 28px; line-height: 1; letter-spacing: -.04em; }
.kpi-card small { display: block; margin-top: 7px; color: var(--dim); font-size: 10px; }
.kpi-card.highlight { border-color: rgba(201,244,61,.22); background: linear-gradient(145deg, rgba(201,244,61,.08), rgba(17,20,27,.72)); }
.kpi-card.highlight strong { color: var(--lime); }

.command-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .7fr); gap: 16px; margin-bottom: 16px; }
.panel { padding: 22px; }
.panel-head { align-items: center; margin-bottom: 20px; }
.panel-head.compact { margin-bottom: 14px; }
.panel-head h2, .section-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.03em; }
.panel-note, .section-heading p { margin: 0; color: var(--dim); font-size: 11px; }

.decision-list { display: grid; gap: 7px; }
.decision-item {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 13px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: rgba(255,255,255,.018);
}
.decision-item:hover { border-color: var(--line); background: rgba(255,255,255,.03); }
.priority-score { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(201,244,61,.32); color: var(--lime); font-size: 12px; font-weight: 800; }
.decision-item h3 { margin: 0 0 4px; font-size: 13px; }
.decision-item p { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.decision-actions { display: flex; gap: 6px; }

.pulse-panel { display: flex; flex-direction: column; }
.automation-list { display: grid; gap: 9px; }
.automation-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.automation-row span { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.automation-row i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.automation-row i.ok { background: var(--green); box-shadow: 0 0 8px rgba(85,214,139,.5); }
.automation-row b { font-size: 10px; }
.flow-line { display: flex; align-items: center; justify-content: space-between; margin: 22px 0; color: var(--dim); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.flow-line i { flex: 1; height: 1px; margin: 0 7px; background: var(--line); }
.telegram-link { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; margin-top: auto; padding: 13px; border: 1px solid rgba(104,167,255,.18); border-radius: 12px; background: rgba(104,167,255,.06); }
.telegram-link:hover { border-color: rgba(104,167,255,.4); }
.telegram-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--blue); color: #07101e; font-weight: 900; }
.telegram-link strong, .telegram-link small { display: block; }
.telegram-link strong { font-size: 11px; }
.telegram-link small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.telegram-link b { color: var(--blue); }

.radar-panel { box-shadow: none; }
.radar-table { display: grid; gap: 3px; }
.radar-row { display: grid; grid-template-columns: minmax(170px, 1.4fr) 100px 1fr 62px 62px 62px; gap: 14px; align-items: center; min-height: 48px; padding: 0 10px; border-radius: 9px; font-size: 11px; }
.radar-row.header { min-height: 30px; color: var(--dim); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.radar-row:not(.header):hover { background: rgba(255,255,255,.025); }
.radar-row strong { font-size: 11px; }
.maturity { width: fit-content; padding: 4px 6px; border-radius: 6px; color: var(--muted); background: var(--surface-3); font-size: 9px; font-weight: 740; }
.maturity.strong { color: var(--lime); background: var(--lime-soft); }
.maturity.promising { color: var(--blue); background: rgba(104,167,255,.1); }
.bar { position: relative; height: 5px; border-radius: 9px; background: #222733; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #829d2e, var(--lime)); }
.metric-number { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.section-heading { margin-bottom: 22px; align-items: end; }
.section-heading p { margin-top: 6px; max-width: 650px; }
.video-grid, .knowledge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.video-card, .knowledge-card, .experiment-card, .empty-state { border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(17,20,27,.76); }
.video-card { display: grid; grid-template-columns: 170px minmax(0,1fr); overflow: hidden; }
.video-thumb { position: relative; min-height: 180px; background: #080a0e; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .76; }
.video-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 55%, rgba(17,20,27,.55)); pointer-events: none; }
.video-focus { position: absolute; left: 10px; bottom: 10px; z-index: 1; padding: 5px 7px; border-radius: 6px; background: rgba(7,9,13,.78); color: var(--text); font-size: 9px; font-weight: 760; backdrop-filter: blur(8px); }
.video-body { padding: 17px; min-width: 0; }
.video-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; color: var(--dim); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.scope-chip { padding: 3px 6px; border-radius: 5px; color: var(--blue); background: rgba(104,167,255,.08); font-weight: 800; }
.video-card h3 { margin: 0 0 8px; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-summary { min-height: 34px; margin: 0 0 13px; color: var(--muted); font-size: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pipeline { display: flex; align-items: center; gap: 5px; margin-bottom: 13px; }
.pipeline span { width: 7px; height: 7px; border-radius: 50%; background: #303643; }
.pipeline span.done { background: var(--green); }
.pipeline span.running { background: var(--lime); box-shadow: 0 0 10px rgba(201,244,61,.7); animation: pulse 1.3s infinite; }
.pipeline i { width: 15px; height: 1px; background: var(--line); }
@keyframes pulse { 50% { opacity: .35; } }
.video-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.job-status { margin-top: 10px; color: var(--lime); font-size: 10px; }
.job-status.failed { color: var(--red); }

.knowledge-head { align-items: end; }
.filter-row { display: flex; gap: 8px; min-width: min(100%, 420px); }
.filter-row input { flex: 1; }
.filter-row select { width: 150px; }
.knowledge-card { padding: 18px; }
.knowledge-top { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 13px; }
.knowledge-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 4px 6px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 9px; font-weight: 740; }
.tag.lime { color: var(--lime); background: var(--lime-soft); }
.tag.blue { color: var(--blue); background: rgba(104,167,255,.08); }
.score-stack { flex: 0 0 auto; text-align: right; }
.score-stack strong { display: block; color: var(--lime); font-size: 19px; line-height: 1; }
.score-stack small { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.knowledge-card h3 { margin: 0 0 8px; font-size: 15px; }
.knowledge-claim { margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.evidence-box { margin-bottom: 12px; padding: 10px 11px; border-left: 2px solid var(--purple); border-radius: 0 8px 8px 0; background: rgba(169,148,255,.045); color: #b5bac6; font-size: 10px; }
.evidence-box a { color: var(--purple); font-weight: 740; }
.ai-role { margin-bottom: 13px; padding: 9px 10px; border-radius: 8px; background: rgba(201,244,61,.045); color: #bac68c; font-size: 10px; }
.ai-role strong { color: var(--lime); }
.score-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.mini-score { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.mini-score b { display: block; margin-top: 3px; color: var(--text); font-size: 11px; }
.knowledge-actions { display: flex; gap: 6px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
.knowledge-source { margin-left: auto; align-self: center; color: var(--dim); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.experiment-board { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.experiment-card { padding: 17px; }
.experiment-card.running { border-color: rgba(201,244,61,.22); }
.experiment-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.experiment-status span { padding: 4px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 9px; font-weight: 760; }
.experiment-card.running .experiment-status span { color: var(--lime); background: var(--lime-soft); }
.experiment-card h3 { margin: 0 0 8px; font-size: 14px; }
.experiment-card p { margin-bottom: 14px; color: var(--muted); font-size: 10px; }
.experiment-metric { margin-bottom: 13px; padding: 10px; border-radius: 9px; background: rgba(255,255,255,.022); }
.experiment-metric small, .experiment-metric strong { display: block; }
.experiment-metric small { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.experiment-metric strong { margin-top: 4px; font-size: 11px; }
.experiment-controls { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.experiment-controls select { min-height: 36px; font-size: 10px; }

.empty-state { grid-column: 1 / -1; padding: 42px 24px; text-align: center; }
.empty-state strong { display: block; font-size: 14px; }
.empty-state p { max-width: 440px; margin: 8px auto 0; color: var(--dim); font-size: 11px; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 360px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: #1b202a; color: var(--text); box-shadow: var(--shadow); font-size: 11px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,105,120,.35); color: #ffc0c7; }

@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; gap: 34px; }
  .ingest-card { max-width: 760px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .command-grid { grid-template-columns: 1fr; }
  .radar-row { grid-template-columns: minmax(160px,1.4fr) 95px 1fr 55px 55px; }
  .radar-row > :last-child { display: none; }
  .experiment-board { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 1320px); }
  .app-header { grid-template-columns: 1fr auto; min-height: 56px; padding: 0 12px; }
  .primary-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; justify-content: space-around; border-top: 1px solid var(--line); border-radius: 0; background: rgba(12,14,19,.97); padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
  .primary-nav a { flex: 1; text-align: center; font-size: 11px; }
  .system-pill { font-size: 0; }
  .system-pill::after { content: ""; }
  .hero { padding-top: 42px; padding-bottom: 32px; }
  h1 { font-size: clamp(42px, 15vw, 68px); }
  .hero-copy { font-size: 14px; }
  .ingest-card { padding: 17px; }
  .url-row { grid-template-columns: 1fr; }
  .form-footer { grid-template-columns: 1fr; }
  .form-footer select { justify-self: stretch; max-width: none; }
  .workspace { padding-bottom: 100px; }
  .workspace-tabs { top: 56px; overflow-x: auto; }
  .workspace-tab { white-space: nowrap; }
  .scope-switch { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card { min-height: 100px; }
  .kpi-card:last-child { grid-column: span 2; }
  .decision-item { grid-template-columns: 38px minmax(0,1fr); }
  .decision-actions { grid-column: 2; }
  .radar-panel { overflow: hidden; }
  .radar-table { overflow-x: auto; }
  .radar-row { min-width: 660px; }
  .video-grid, .knowledge-grid, .experiment-board { grid-template-columns: 1fr; }
  .video-card { grid-template-columns: 120px minmax(0,1fr); }
  .video-thumb { min-height: 210px; }
  .section-heading, .knowledge-head { align-items: stretch; flex-direction: column; }
  .filter-row { min-width: 0; width: 100%; }
  .knowledge-actions { flex-wrap: wrap; }
  .knowledge-source { width: 100%; max-width: none; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
