:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --text: #17201b;
  --muted: #66736d;
  --line: #d9e1dd;
  --primary: #00798c;
  --primary-dark: #005a68;
  --accent: #d1495b;
  --gold: #edae49;
  --green: #3b7a57;
  --blue: #30638e;
  --shadow: 0 12px 30px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 28px;
}

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

.brand-name {
  font-size: 15px;
  font-weight: 800;
}

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

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-2);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
}

.dot.ok {
  background: var(--green);
}

.dot.fail {
  background: var(--accent);
}

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
  line-height: 1.35;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions,
.button-row,
.panel-head,
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 16px;
}

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

.span-2 {
  grid-column: span 2;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.input-panel,
.result-panel {
  min-height: 620px;
}

.field-label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.text-input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfc;
  outline: none;
}

.text-input {
  height: 42px;
  padding: 0 12px;
}

.textarea {
  min-height: 286px;
  padding: 12px;
  line-height: 1.55;
  resize: vertical;
}

.text-input:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 121, 140, 0.12);
}

.form-row {
  align-items: flex-start;
}

.form-row > div {
  flex: 1;
  min-width: 0;
}

.primary-button,
.secondary-button,
.link-button,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.primary-button.muted {
  background: var(--blue);
}

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

.secondary-button:hover,
.link-button:hover {
  background: var(--surface-2);
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
}

.segment.active {
  color: #fff;
  background: var(--primary);
}

.status-pill,
.tag,
.metric-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 0 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f8faf9;
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 510px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfc;
}

.analysis-layout {
  display: grid;
  gap: 14px;
}

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

.metric {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-value {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.confidence-bar {
  height: 9px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe7e3;
}

.confidence-fill {
  height: 100%;
  background: var(--green);
}

.section-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.section-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.6;
}

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

.score-card,
.company-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.score-card h3,
.company-card h3 {
  margin-bottom: 10px;
}

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

.metric-pill {
  justify-content: center;
  min-width: 0;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.forecast-chart {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe7e3;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  background: #fff;
}

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

th {
  color: var(--muted);
  background: #f8faf9;
  font-weight: 850;
}

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

.report-preview {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
  line-height: 1.6;
}

.report-preview h3 {
  margin: 14px 0 6px;
}

.report-preview ul {
  margin: 6px 0 12px;
  padding-left: 18px;
}

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

.company-card {
  display: grid;
  gap: 10px;
}

.company-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.score-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

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

.export-panel {
  display: grid;
  gap: 14px;
}

.export-panel p {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 20;
}

.toast.error {
  border-color: rgba(209, 73, 91, 0.45);
}

@media (max-width: 1180px) {
  .workbench-grid,
  .dashboard-grid,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

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

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

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .sidebar-foot {
    margin-top: 16px;
  }

  .main {
    padding: 16px;
  }

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

  .topbar-actions,
  .form-row,
  .button-row {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .mainline-grid,
  .company-grid,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .result-panel {
    min-height: 0;
  }
}
