:root {
  --bg: #f5f5f7;
  --window: #ffffff;
  --sidebar: rgba(236, 236, 240, 0.78);
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --yellow: #ffd60a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 24px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e;
    --window: #1e1e20;
    --sidebar: rgba(40, 40, 44, 0.72);
    --surface: #2a2a2d;
    --surface-2: #232326;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent-soft: rgba(10, 132, 255, 0.22);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 30px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  --bg: #1c1c1e;
  --window: #1e1e20;
  --sidebar: rgba(40, 40, 44, 0.72);
  --surface: #2a2a2d;
  --surface-2: #232326;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent-soft: rgba(10, 132, 255, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 30px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: conic-gradient(from 200deg, #0a84ff, #bf5af2, #ff375f, #ff9f0a, #30d158, #0a84ff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 2px 8px rgba(10, 132, 255, 0.35);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.brand-name { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-2); }

.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: default;
  color: var(--text);
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.nav-item:hover { background: rgba(127, 127, 127, 0.1); }
.nav-item.active { background: var(--accent); color: white; }
.nav-item.active svg { color: white; }
.nav-item .badge { margin-left: auto; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.nav-item.active .badge { color: rgba(255, 255, 255, 0.85); }

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.08);
  display: flex;
  align-items: center;
  gap: 9px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--window);
}

.toolbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.toolbar h1 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.toolbar .sub { color: var(--text-2); font-size: 12px; }
.toolbar .spacer { flex: 1; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.live.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.2); animation: pulse 2s infinite; }

@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(48, 209, 88, 0); } }

.search {
  width: 220px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
}

.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.content {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.content.flush { padding: 0; overflow: hidden; position: relative; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }

@media (max-width: 1100px) {
  .two { grid-template-columns: 1fr; }
  .access-form { order: -1; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0;
}

.card h2 {
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .muted { font-weight: 400; }

.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .hint { font-size: 11px; color: var(--text-3); }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex: none;
  position: relative;
}

.avatar.lg { width: 38px; height: 38px; font-size: 14px; }
.avatar .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--surface);
}

.avatar .bot {
  position: absolute;
  left: -3px;
  top: -3px;
  font-size: 9px;
  background: var(--surface);
  border-radius: 50%;
  width: 13px;
  height: 13px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 1px var(--border);
}

.row { display: flex; align-items: center; gap: 10px; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: 0; }

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.6s cubic-bezier(.2, .8, .2, 1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}

.chip.done { background: rgba(48, 209, 88, 0.14); color: #1f9d48; border-color: transparent; }
.chip.implementing { background: rgba(10, 132, 255, 0.14); color: var(--accent); border-color: transparent; }
.chip.blocked { background: rgba(255, 69, 58, 0.14); color: var(--red); border-color: transparent; }
.chip.skipped { opacity: 0.6; text-decoration: line-through; }
.chip.breaking { background: rgba(255, 69, 58, 0.14); color: var(--red); border-color: transparent; }
.chip.warning { background: rgba(255, 159, 10, 0.16); color: #c77700; border-color: transparent; }
.chip.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

@media (prefers-color-scheme: dark) {
  .chip.done { color: var(--green); }
  .chip.warning { color: var(--orange); }
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 7px;
  cursor: default;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--accent); color: white; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.small { padding: 2px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(168px, 1fr));
  gap: 12px;
  height: 100%;
  align-items: start;
  overflow-x: auto;
}

.column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.column-head { display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 2px 4px 6px; }
.column-head i { width: 8px; height: 8px; border-radius: 50%; }
.column-head .count { margin-left: auto; color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

.pcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: default;
  transition: transform 0.15s, box-shadow 0.15s;
}

.pcard:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.pcard .title { font-weight: 600; margin-bottom: 6px; }
.pcard .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pcard.flash { animation: flash 1.2s ease-out; }

@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
  animation: fade 0.15s;
}

.sheet {
  width: min(620px, 100vw);
  height: 100%;
  background: var(--window);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.18);
  overflow: auto;
  padding: 22px 24px;
  animation: slide 0.22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.sheet h3 { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.01em; }
.sheet section { margin-top: 18px; }
.sheet section > h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin: 0 0 8px; }

pre.code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font: 12px/1.55 var(--mono);
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.tl-name { color: var(--purple); }
.tl-id { color: var(--text-3); }
.tl-type { color: var(--accent); }
.tl-flag { color: var(--orange); }

textarea.input, input.input, select.input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
}

textarea.input:focus, input.input:focus, select.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.timeline { position: relative; padding-left: 16px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline .t { position: relative; padding: 3px 0; }
.timeline .t::before { content: ""; position: absolute; left: -16px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--window); }

.feed-item { display: flex; gap: 10px; padding: 7px 0; align-items: flex-start; }
.feed-item .when { margin-left: auto; color: var(--text-3); font-size: 11px; white-space: nowrap; }
.feed-item.new { animation: newrow 1.5s ease-out; border-radius: 8px; }

@keyframes newrow { from { background: var(--accent-soft); } to { background: transparent; } }

.idea-card { display: flex; gap: 14px; align-items: flex-start; }
.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 4px 10px;
  min-width: 48px;
  background: var(--surface);
  cursor: default;
}

.vote.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.vote b { font-size: 15px; font-variant-numeric: tabular-nums; }

.toggle { position: relative; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: 0.2s; }
.toggle span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: 0.2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(16px); }

.setting { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.card.issued { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 9px 12px;
  max-width: 360px;
  display: flex;
  gap: 9px;
  align-items: center;
  animation: toast-in 0.3s cubic-bezier(.2, .8, .2, 1);
}

@keyframes toast-in { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 30% 20%, rgba(10, 132, 255, 0.25), transparent), radial-gradient(900px 500px at 80% 90%, rgba(191, 90, 242, 0.25), transparent), var(--bg);
  z-index: 100;
}

.login .card { width: 380px; padding: 24px; }

.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.chart-bars .b { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; }
.chart-bars .b i { display: block; border-radius: 3px 3px 1px 1px; min-height: 2px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-3); margin-top: 4px; }

.waiting-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; padding: 5px 0; }

.schema-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; height: 100%; }
.schema-list { overflow: auto; max-height: calc(100vh - 140px); }
.schema-item { padding: 6px 10px; border-radius: 7px; cursor: default; font-family: var(--mono); font-size: 12px; }
.schema-item:hover { background: var(--surface-2); }
.schema-item.active { background: var(--accent); color: white; }
.schema-item .k { font-size: 10px; opacity: 0.6; margin-left: 6px; font-family: -apple-system, system-ui; }

.empty { color: var(--text-3); text-align: center; padding: 24px; }

.pipeline-wrap { position: absolute; inset: 0; background: #070a14; }
.pipeline-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: absolute; color: #e8ecff; font-size: 12px; pointer-events: none; }
.hud.tl { left: 18px; top: 16px; }
.hud.tr { right: 18px; top: 16px; text-align: right; }
.hud.bl { left: 18px; bottom: 16px; width: min(460px, 60%); }
.hud.br { right: 18px; bottom: 16px; pointer-events: auto; }
.hud .level { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: #8fa3ff; }
.hud .big { font-size: 34px; font-weight: 750; letter-spacing: -0.02em; text-shadow: 0 0 24px rgba(120, 150, 255, 0.6); }
.hud .xp { margin-top: 6px; width: 220px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.hud .xp i { display: block; height: 100%; background: linear-gradient(90deg, #64d2ff, #bf5af2); box-shadow: 0 0 12px #bf5af2; transition: width 0.8s; }
.hud.ticker div { padding: 3px 10px; margin-top: 4px; background: rgba(20, 26, 48, 0.65); border: 1px solid rgba(140, 160, 255, 0.18); border-radius: 8px; backdrop-filter: blur(8px); animation: tick-in 0.35s ease-out; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes tick-in { from { transform: translateX(-12px); } }
.hud.legend span { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; opacity: 0.85; }
.hud.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.hud .btn { background: rgba(30, 36, 64, 0.8); color: #e8ecff; border-color: rgba(140, 160, 255, 0.3); }
.hud-tooltip { position: absolute; pointer-events: none; background: rgba(14, 18, 36, 0.92); color: #e8ecff; border: 1px solid rgba(140, 160, 255, 0.3); border-radius: 10px; padding: 8px 10px; font-size: 12px; max-width: 280px; transform: translate(12px, 12px); backdrop-filter: blur(10px); }

.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.howto .step { padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.howto .step b { display: block; margin-bottom: 4px; }
.howto .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: white; font-size: 11px; font-weight: 700; margin-bottom: 6px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .search { width: 140px; }
  .content { padding: 14px 16px; }
  .schema-layout { grid-template-columns: 1fr; }
}

.hud.br { display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; border-radius: 8px; overflow: hidden; border: 1px solid rgba(140, 160, 255, 0.3); }
.seg .btn { border: 0; border-radius: 0; box-shadow: none; }
.seg .btn.on { background: rgba(120, 140, 255, 0.35); color: white; }

.g3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.g3-label { position: absolute; left: 0; top: 0; color: #e8ecff; font-size: 11px; text-align: center; white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95); will-change: transform; }
.g3-label b { display: block; font-weight: 650; font-size: 12px; letter-spacing: 0.01em; }
.g3-label i { font-style: normal; font-size: 10px; }
.g3-label span { display: block; opacity: 0.55; font-size: 10.5px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; }
.g3-label.on span { opacity: 0.95; color: #b8ffd0; }
.g3-core b { font-size: 20px; font-weight: 750; letter-spacing: 0.02em; text-shadow: 0 0 18px rgba(255, 170, 90, 0.95), 0 1px 6px rgba(0, 0, 0, 0.8); }
.g3-core span { text-transform: uppercase; letter-spacing: 0.16em; font-size: 9px; opacity: 0.75; }
.g3-lane { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(215, 175, 255, 0.75); }

.hud .bright { display: inline-flex; align-items: center; gap: 6px; color: #e8ecff; font-size: 13px; padding: 2px 8px; border-radius: 8px; background: rgba(30, 36, 64, 0.8); border: 1px solid rgba(140, 160, 255, 0.3); }
.hud .bright input { width: 90px; accent-color: #8fa3ff; }
