:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --ink: #1c2320;
  --ink-soft: #3f4a45;
  --muted: #6b7670;
  --line: #e2e6e0;
  --line-strong: #cdd4cd;
  --accent: #0f766e;
  --accent-deep: #0b5e58;
  --accent-soft: #e4f2ef;
  --warn: #b45309;
  --warn-soft: #fdf2e2;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e6f4ea;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(28, 35, 32, 0.06), 0 4px 14px rgba(28, 35, 32, 0.05);
  --sidebar-w: 236px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
svg.lucide { width: 18px; height: 18px; flex: none; }

.app-shell { min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #101814;
  color: #d7ded9;
  padding: 16px 12px 24px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: grid;
  place-items: center;
  color: #fff;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 11px; color: #8fa39a; }

.nav-group-label {
  font-size: 11px;
  color: #7f9389;
  padding: 14px 10px 6px;
  letter-spacing: 0.05em;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: #c4cdc7;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(20, 184, 166, 0.16); color: #5eead4; font-weight: 600; }
.nav-link .lucide { width: 17px; height: 17px; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 11px; color: #7f9389; }

/* Main */
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-sub { font-size: 12px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.project-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  max-width: 320px;
}
.project-pill .lucide { width: 15px; height: 15px; }
.project-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* Bottom nav */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner { display: grid; grid-template-columns: repeat(5, 1fr); }
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 7px;
  color: var(--muted);
  border: 0;
  background: none;
  font-size: 11px;
  cursor: pointer;
}
.bn-item.active { color: var(--accent); font-weight: 600; }
.bn-item svg { width: 21px; height: 21px; }

/* Cards & layout */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px 18px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card-title .lucide { width: 17px; height: 17px; color: var(--accent); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-desc { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: 0; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #b8c2b9; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { background: var(--danger-soft); border-color: #f0c4c4; color: var(--danger); }
.btn-danger:hover { background: #fadada; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(0,0,0,0.05); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn .lucide { width: 15px; height: 15px; }
.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 15px; height: 15px; }

/* Chips & status */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-neutral { background: #eef0ed; color: var(--ink-soft); }
.chip-accent { background: var(--accent-soft); color: var(--accent-deep); }

/* Progress */
.progress { height: 7px; border-radius: 999px; background: #e8ece7; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.2s; }
.progress.warn > span { background: var(--warn); }
.progress.ok > span { background: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.tbl th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid #edf0ec; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fafcf9; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--muted); }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* Filters */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filter-bar input[type="text"], .filter-bar select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  min-width: 120px;
}
.filter-bar input[type="text"] { flex: 1; min-width: 180px; max-width: 340px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13.5px;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--accent); }
.field .help { font-size: 11.5px; color: var(--muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 20, 0.45);
  display: grid; place-items: center;
  z-index: 100;
  padding: 18px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--line); }

/* Toast */
#toastRoot { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1c2320; color: #fff;
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex; align-items: center; gap: 8px;
  animation: slide-in 0.18s ease;
  max-width: 340px;
}
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.toast.err { background: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 9px 14px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Task tree */
.task-tree { display: flex; flex-direction: column; }
.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid #edf0ec;
}
.task-row:last-child { border-bottom: 0; }
.task-row.group { background: var(--surface-2); font-weight: 600; }
.task-row.stage { background: #eef4f1; font-weight: 700; }
.task-check { margin-top: 1px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.task-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.task-actions { display: flex; gap: 5px; }
.task-row.lv1 .task-title { font-size: 13px; }
.task-row.lv2 { padding-left: 34px; }
.task-row.lv3 { padding-left: 58px; }
.task-row.lv2 .task-title, .task-row.lv3 .task-title { font-weight: 400; }
.task-row.overdue .task-title { color: var(--danger); }
.task-row.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-count { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* Gantt */
.gantt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.gantt { min-width: 860px; position: relative; }
.gantt-header { display: flex; border-bottom: 1px solid var(--line); }
.gantt-label-col { flex: none; width: 210px; border-right: 1px solid var(--line); background: var(--surface-2); }
.gantt-label-head { height: 54px; display: flex; align-items: center; padding: 0 12px; font-weight: 600; font-size: 12px; }
.gantt-time { flex: 1; position: relative; }
.gantt-months { display: flex; height: 28px; }
.gantt-month { border-left: 1px solid #eef0ed; display: flex; align-items: center; padding-left: 8px; font-size: 11.5px; color: var(--muted); }
.gantt-days { display: flex; height: 26px; }
.gantt-day { flex: 1; border-left: 1px solid #f2f4f0; font-size: 9px; color: #b0b8b1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 2px; }
.gantt-row { display: flex; border-bottom: 1px solid #eef0ec; min-height: 44px; }
.gantt-label { width: 210px; flex: none; padding: 8px 12px; font-size: 12.5px; border-right: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-label .gantt-sub { display: block; font-size: 11px; color: var(--muted); }
.gantt-track { flex: 1; position: relative; }
.gantt-bar {
  position: absolute;
  top: 8px; height: 26px;
  border-radius: 5px;
  cursor: grab;
  min-width: 14px;
  display: flex; align-items: center;
  overflow: hidden;
  color: #fff;
}
.gantt-bar .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,0.32); }
.gantt-bar .bar-label { position: relative; padding: 0 8px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.gantt-handle.left { left: 0; }
.gantt-handle.right { right: 0; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); opacity: 0.65; }
.gantt-empty { padding: 40px; text-align: center; color: var(--muted); }

/* Compare */
.compare-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.compare-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; }
.compare-card.best { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.compare-card.worst { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.compare-card .name { font-weight: 600; font-size: 13.5px; }
.compare-card .price { font-size: 18px; font-weight: 700; margin: 6px 0; }
.compare-row { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 0; }
.compare-row .k { color: var(--muted); }
.compare-row.missing { color: var(--danger); }

/* Compliance */
.check-card {
  display: flex; gap: 12px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow);
}
.check-card.done { background: var(--ok-soft); border-color: #c4e5cd; }
.check-main { flex: 1; min-width: 0; }
.check-title { font-weight: 600; font-size: 13.5px; }
.check-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.check-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }

/* Partners */
.partner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.partner-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 14px; box-shadow: var(--shadow); }
.partner-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.partner-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.partner-lines { margin-top: 9px; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.partner-lines a { word-break: break-all; }
.stars { color: #d97706; letter-spacing: 1px; }

/* Docs */
.doc-row { display: flex; align-items: center; gap: 12px; }
.doc-icon { width: 34px; height: 34px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.doc-icon svg { width: 17px; height: 17px; }
.doc-name { font-weight: 500; font-size: 13.5px; }
.doc-meta { font-size: 12px; color: var(--muted); }

/* AI */
.ai-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 16px; box-shadow: var(--shadow); }
.ai-result {
  margin-top: 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-2); padding: 12px; white-space: pre-wrap;
  font-size: 12.5px; max-height: 420px; overflow-y: auto;
}
.ai-result pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: inherit; }
.token-note { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* Alerts */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { color: var(--warn); margin-top: 1px; }
.alert-item.danger .alert-icon { color: var(--danger); }
.alert-item .alert-text { flex: 1; font-size: 13px; }
.alert-item .alert-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* Empty */
.empty {
  padding: 42px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2);
}
.empty svg { width: 30px; height: 30px; color: #aab4ad; margin-bottom: 8px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.empty-desc { font-size: 12.5px; margin-top: 4px; max-width: 460px; margin-inline: auto; }
.empty .btn { margin-top: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.section-title { font-size: 15px; font-weight: 600; margin: 22px 0 10px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-4, .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .bottom-nav { display: block; }
  .view { padding: 16px 14px calc(76px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-sub { display: none; }
  .project-pill { max-width: 180px; }
}
@media (max-width: 560px) {
  .page-title { font-size: 18px; }
  .stat-value { font-size: 19px; }
  .modal-overlay { padding: 8px; }
  .modal { max-height: 96vh; }
  .page-actions .btn { flex: 1; }
  .filter-bar input[type="text"] { max-width: none; }
}
