:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #667085;
  --line: #d7dee8;
  --nav: #17324d;
  --nav-active: #2463eb;
  --accent: #0f766e;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --info: #2563eb;
  --soft-info: #eff6ff;
  --soft-success: #ecfdf5;
  --soft-warning: #fffbeb;
  --soft-danger: #fef2f2;
  --shadow: 0 10px 28px rgba(23, 33, 43, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button { cursor: pointer; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 18px 14px;
  background: var(--nav);
  color: #fff;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--nav);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--nav-active);
  color: #fff;
}

.muted-nav::after {
  content: "Phase 2/3";
  float: right;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.app-shell {
  min-height: 100vh;
  margin-left: 248px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 12px 24px;
  background: rgba(245, 247, 250, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.search-wrap {
  position: relative;
  max-width: 720px;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.search-results {
  position: absolute;
  inset: 48px 0 auto 0;
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.search-result:hover { background: #f1f5f9; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  color: var(--muted);
  white-space: nowrap;
}

.user-pill strong { color: var(--ink); }

.view-root {
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.15;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.phase-note {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card.pad { padding: 18px; }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title h2,
.card-title h3 {
  margin: 0;
}

.card-title h2 { font-size: 17px; }
.card-title h3 { font-size: 15px; }

.metric {
  min-height: 118px;
  padding: 16px;
}

.metric-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
}

.metric span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.tag,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag { background: #f1f5f9; color: #475569; }
.badge.high,
.badge.danger { background: var(--soft-danger); color: var(--danger); }
.badge.medium,
.badge.warning { background: var(--soft-warning); color: var(--warning); }
.badge.low,
.badge.success { background: var(--soft-success); color: var(--success); }
.badge.info { background: var(--soft-info); color: var(--info); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}

.tab.active {
  border-color: var(--nav-active);
  background: var(--soft-info);
  color: var(--nav-active);
  font-weight: 700;
}

.todo-list,
.plain-list,
.risk-list,
.timeline {
  display: grid;
  gap: 10px;
}

.todo-item,
.list-row,
.risk-item,
.timeline-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.todo-item strong,
.list-row strong,
.risk-item strong {
  display: block;
}

.btn,
.text-btn {
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.btn {
  min-height: 38px;
  padding: 0 14px;
  background: var(--nav-active);
  color: #fff;
}

.btn.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.btn.danger {
  background: var(--danger);
}

.text-btn {
  background: transparent;
  color: var(--nav-active);
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filters select,
.filters input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.step {
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.step.done {
  border-color: #a7f3d0;
  background: var(--soft-success);
  color: var(--success);
}

.step.current {
  border-color: #bfdbfe;
  background: var(--soft-info);
  color: var(--info);
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.draft-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.contract-preview {
  min-height: 520px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.contract-preview h2 {
  margin: 0 0 18px;
  text-align: center;
}

.contract-preview p {
  margin: 10px 0;
}

.upload-box {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.roadmap-card {
  min-height: 170px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout,
  .draft-layout { grid-template-columns: 1fr; }
  .roadmap-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .app-shell {
    margin-left: 0;
  }

  .menu-btn {
    display: inline-grid;
    place-items: center;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    padding: 10px 14px;
  }

  .user-pill {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .view-root { padding: 14px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .field-grid,
  .stepper,
  .roadmap-grid { grid-template-columns: 1fr; }

  .todo-item,
  .list-row,
  .risk-item {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
