:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #edf5f8;
  --surface-3: #f8fbfd;
  --text: #183342;
  --muted: #6c7f8c;
  --line: #d9e6ec;
  --primary: #0878a8;
  --primary-2: #0ea5c6;
  --primary-dark: #064f76;
  --accent: #c88942;
  --danger: #b42318;
  --warning: #b7791f;
  --success: #087f5b;
  --shadow: 0 18px 48px rgba(24, 51, 66, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 292px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top left, rgba(14, 165, 198, 0.14), transparent 34rem), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  background: linear-gradient(180deg, #082f49 0%, #0b4664 55%, #07324c 100%);
  color: #e4f5fb;
  box-shadow: 12px 0 30px rgba(6, 42, 65, 0.16);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 20px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2dd4bf, #0ea5c6 58%, #3b82f6);
  color: #fff; font-weight: 900; letter-spacing: .08em;
  box-shadow: 0 12px 24px rgba(14, 165, 198, .28);
}
.brand-title { font-weight: 800; letter-spacing: .02em; }
.brand-subtitle { color: #9bd7e8; font-size: 12px; margin-top: 2px; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent; border-radius: 14px;
  padding: 11px 12px; color: #d7eff7; background: transparent; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
  color: white;
  box-shadow: inset 4px 0 0 #2dd4bf;
}
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; opacity: .98; }
.nav-label { flex: 1; }
.nav-badge { font-size: 11px; color: #b7e5ef; }
.sidebar-card {
  margin-top: 18px; padding: 14px; border-radius: 18px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: #d9f4fb; font-size: 13px; line-height: 1.6;
}
.mini-title { font-weight: 800; font-size: 13px; margin-bottom: 8px; color: white; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 4px 9px;
  font-size: 12px; background: rgba(8,120,168,.1); color: var(--primary-dark);
  border: 1px solid rgba(8,120,168,.16);
}
.sidebar .pill { background: rgba(255,255,255,.12); color: #e8fbff; border-color: rgba(255,255,255,.16); }
.pill.success { background: rgba(8,127,91,.12); color: var(--success); border-color: rgba(8,127,91,.18); }
.sidebar .pill.success { background: rgba(45,212,191,.18); color: #bffaf0; }
.pill.warn { background: rgba(183,121,31,.12); color: var(--warning); border-color: rgba(183,121,31,.20); }
.pill.danger { background: rgba(180,35,24,.10); color: var(--danger); border-color: rgba(180,35,24,.18); }

.workspace { min-width: 0; padding: 24px 28px 48px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin: 0 0 16px;
}
.eyebrow { font-size: 12px; color: var(--primary); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; letter-spacing: -.025em; }
h1 { font-size: clamp(26px, 3vw, 36px); }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { line-height: 1.75; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; padding: 4px; background: #e4eef3; border-radius: 999px; border: 1px solid var(--line); }
.segmented button {
  border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 10px;
}
.segmented button.active { background: white; color: var(--primary-dark); box-shadow: 0 4px 12px rgba(24,51,66,.08); }
.primary-button, .ghost-button, .soft-button, .danger-button, .icon-button {
  border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 700;
}
.primary-button { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; box-shadow: 0 12px 22px rgba(8,120,168,.22); }
.ghost-button { background: white; border: 1px solid var(--line); color: var(--primary-dark); }
.soft-button { background: #e8f4f8; color: var(--primary-dark); }
.danger-button { background: #fff1f0; color: var(--danger); border: 1px solid #ffd0cc; }
.icon-button {
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  background: white; border: 1px solid var(--line); color: var(--text); font-size: 22px;
}
.notice {
  border: 1px solid #f2d5aa; background: #fff8ec; color: #6b4a18;
  padding: 12px 14px; border-radius: 14px; margin-bottom: 18px;
}
.content { display: grid; gap: 18px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card, .panel, .metric-card, .flow-card {
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(24,51,66,.06);
}
.card { padding: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-subtitle { color: var(--muted); font-size: 13px; margin-top: 5px; line-height: 1.6; }
.metric-card { padding: 16px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; inset: auto -20px -26px auto; width: 90px; height: 90px; border-radius: 50%; background: rgba(14,165,198,.11); }
.metric-value { font-size: 30px; font-weight: 900; color: var(--primary-dark); }
.metric-label { color: var(--muted); margin-top: 4px; }
.panel { padding: 18px; }
.panel.dark { background: linear-gradient(135deg, #082f49, #0b5d78); color: #eefcff; border-color: rgba(255,255,255,.16); }
.panel.dark .card-subtitle, .panel.dark .muted { color: #bae6f3; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.hero {
  min-height: 240px; padding: 24px; border-radius: 24px;
  background:
    radial-gradient(circle at 80% 25%, rgba(45,212,191,.26), transparent 18rem),
    linear-gradient(135deg, #092f49 0%, #0a5b78 55%, #0e7490 100%);
  color: white;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -70px; top: -70px; width: 240px; height: 240px;
  border: 1px solid rgba(255,255,255,.12); transform: rotate(35deg); border-radius: 34px;
}
.hero h2 { font-size: clamp(26px, 4vw, 42px); line-height: 1.2; max-width: 760px; }
.hero p { max-width: 760px; color: #d8f7ff; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero .ghost-button { background: rgba(255,255,255,.1); color: white; border-color: rgba(255,255,255,.24); }

.layer-stack { display: grid; gap: 12px; }
.layer {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 14px; align-items: center;
  padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-3);
}
.layer-index { font-size: 20px; font-weight: 900; color: var(--accent); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 10px; border-radius: 999px; background: #edf6f8; color: #245466; font-size: 12px; border: 1px solid #d7edf3; }
.tag.active { background: #e3f9f6; color: var(--success); border-color: #b7f0e6; }
.tag.clickable:hover { border-color: var(--primary-2); color: var(--primary-dark); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 800; font-size: 13px; color: #28495a; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: white; border-radius: 12px;
  padding: 11px 12px; color: var(--text); outline: none;
}
textarea { min-height: 126px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(14,165,198,.10); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.timeline { display: grid; gap: 12px; }
.timeline-item { display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: start; }
.timeline-dot {
  width: 32px; height: 32px; border-radius: 12px; background: #e3f7fb; color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 900; border: 1px solid #c4edf7;
}
.timeline-body { background: var(--surface-3); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.progress { height: 8px; border-radius: 999px; background: #e6eef2; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.confidence { display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: white; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f2f8fb; color: #2c5364; font-size: 13px; }
tr:last-child td { border-bottom: 0; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 10px 12px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 800; white-space: nowrap;
}
.tab.active { color: var(--primary-dark); border-color: var(--primary-2); }

.phone-mock {
  width: min(100%, 355px); margin: 0 auto; border: 12px solid #183342; border-radius: 34px;
  background: #f8fbfd; box-shadow: var(--shadow); overflow: hidden;
}
.phone-top { background: #183342; color: white; text-align: center; padding: 8px; font-size: 12px; }
.phone-content { padding: 14px; display: grid; gap: 10px; }
.mobile-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 12px; }

.kg-canvas {
  min-height: 360px; border-radius: 18px; background:
    linear-gradient(90deg, rgba(8,120,168,.05) 1px, transparent 1px),
    linear-gradient(rgba(8,120,168,.05) 1px, transparent 1px), #fbfdfe;
  background-size: 28px 28px; border: 1px solid var(--line); position: relative; overflow: hidden;
}
.kg-node {
  position: absolute; min-width: 86px; padding: 10px 12px; border-radius: 999px;
  background: white; border: 1px solid #bfe7f0; box-shadow: 0 12px 24px rgba(24,51,66,.10); text-align: center; font-weight: 800;
}
.kg-line { position: absolute; height: 2px; background: rgba(8,120,168,.28); transform-origin: 0 50%; }

.mock-upload {
  border: 1px dashed #9ccbd8; background: #f5fbfd; border-radius: 16px; padding: 18px; text-align: center;
}
.waveform { height: 86px; display: flex; gap: 6px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.waveform span { flex: 1; background: linear-gradient(180deg, #3cc6d9, #0878a8); border-radius: 999px 999px 4px 4px; opacity: .8; }

.alert { padding: 12px 14px; border-radius: 14px; border: 1px solid; line-height: 1.6; }
.alert.info { background: #edf8fb; border-color: #cbeef6; color: #155d74; }
.alert.warning { background: #fff8eb; border-color: #f3d39d; color: #78520c; }
.alert.danger { background: #fff1f0; border-color: #ffd0cc; color: #7b2119; }
.alert.success { background: #effcf7; border-color: #bfead9; color: #0d5e45; }

.modal { width: min(860px, calc(100vw - 28px)); border: 0; border-radius: 22px; padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(8, 28, 42, .45); backdrop-filter: blur(4px); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; }
.drawer-backdrop { display: none; }
.mobile-only { display: none; }

@media (max-width: 1160px) {
  .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; transform: translateX(-105%); transition: transform .24s ease; width: min(86vw, 320px);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(4, 24, 38, .42); z-index: 20; }
  .mobile-only { display: grid; }
  .workspace { padding: 18px 14px 36px; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5, .form-grid { grid-template-columns: 1fr; }
  .layer { grid-template-columns: 44px 1fr; }
  .layer .tag-list { grid-column: 1 / -1; }
}
@media (max-width: 580px) {
  .topbar { display: grid; grid-template-columns: auto 1fr; }
  .top-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .hero { padding: 18px; }
  .actions { display: grid; }
  .actions > button { width: 100%; }
}
