:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-2: #f1f4ef;
  --line: #d9dfd3;
  --line-strong: #b7c2af;
  --text: #1d2525;
  --muted: #66736b;
  --accent: #146c5c;
  --accent-2: #2563a6;
  --amber: #a26315;
  --red: #b42318;
  --green-soft: #e4f2ed;
  --blue-soft: #e8f0f8;
  --amber-soft: #fff1d7;
  --red-soft: #fde8e5;
  --shadow: 0 14px 35px rgba(33, 44, 38, 0.08);
  --radius: 8px;
  --sidebar: 268px;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #fbfcf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

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

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 14px 0;
  overflow-y: auto;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav button:hover {
  background: var(--surface-2);
}

.nav button.active {
  border-color: #bdd7cc;
  background: var(--green-soft);
  color: #0b5144;
  font-weight: 700;
}

[data-icon] {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: currentColor;
}

[data-icon] svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.main {
  min-width: 0;
  padding: 20px 24px 38px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 330px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 100%);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.ghost-button {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.danger-button {
  border-color: #efc0bb;
  background: var(--red-soft);
  color: var(--red);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.danger-button:hover {
  filter: brightness(0.98);
}

.alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  background: #fffaf0;
  color: #51350c;
}

.view {
  display: grid;
  gap: 16px;
}

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

.section {
  padding: 16px;
}

.section-header,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-header h2,
.panel-header h2,
.section-header h3,
.panel-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

.section-header p,
.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.auto {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 116px;
  padding: 14px;
}

.metric-card .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.metric-card.accent {
  border-color: #b7d7cd;
  background: var(--green-soft);
}

.metric-card.blue {
  border-color: #bfd1e4;
  background: var(--blue-soft);
}

.metric-card.amber {
  border-color: #edcf9d;
  background: var(--amber-soft);
}

.metric-card.red {
  border-color: #f0b8b1;
  background: var(--red-soft);
}

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

.pipeline-step {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.pipeline-step span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-step strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: var(--surface-2);
  color: #3e4a43;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.strong {
  font-weight: 700;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #3d4b43;
  font-size: 12px;
  font-weight: 700;
}

.chip.green {
  background: var(--green-soft);
  color: #0d5d4e;
}

.chip.blue {
  background: var(--blue-soft);
  color: #174e86;
}

.chip.amber {
  background: var(--amber-soft);
  color: #7a4707;
}

.chip.red {
  background: var(--red-soft);
  color: #8e1d14;
}

.toolbar,
.filters,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

.tab-button.active {
  border-color: #bdd7cc;
  background: var(--green-soft);
  color: #0b5144;
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 5px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 92, 0.14);
}

.field.compact {
  gap: 4px;
}

.field.compact select,
.field.compact input {
  min-height: 34px;
}

.full-span {
  grid-column: 1 / -1;
}

.chart-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 210px) minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.answer-box {
  display: grid;
  gap: 10px;
  min-height: 140px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcf8;
}

.compact-answer {
  min-height: 110px;
}

.boss-ai-panel {
  border-color: #c9d9e8;
  background: linear-gradient(180deg, #fbfdff 0%, var(--surface) 100%);
}

.ask-form {
  gap: 10px;
}

.ask-suggestions {
  align-items: flex-start;
}

.ai-answer-head {
  display: grid;
  gap: 4px;
  line-height: 1.55;
}

.ai-answer-head span {
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid #b7d7cd;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: #0b5144;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.cloud-badge {
  min-width: 118px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 37, 37, 0.42);
  backdrop-filter: blur(3px);
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin: 3px 0 0;
  font-size: 24px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fbfcf8;
}

.small-empty {
  min-height: 92px;
}

.smart-entry {
  display: grid;
  gap: 14px;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.draft-list {
  display: grid;
  gap: 10px;
}

.draft-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.draft-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.draft-head div {
  display: grid;
  gap: 3px;
}

.draft-head span,
.draft-source,
.draft-attach,
.draft-warning {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.draft-source {
  color: var(--text);
}

.draft-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.draft-fields span {
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
}

.draft-fields b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.draft-warning {
  color: #7a4707;
}

@media (max-width: 1160px) {
  .metrics,
  .grid.four,
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding-bottom: 10px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    min-width: 0;
  }

  .metrics,
  .grid.two,
  .grid.three,
  .grid.four,
  .pipeline,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .draft-head {
    flex-direction: column;
  }

  .draft-fields {
    grid-template-columns: 1fr;
  }
}
