:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #14201f;
  --muted: #6a7775;
  --line: #dfe7e5;
  --soft: #f8fbfa;
  --accent: #008b84;
  --accent-dark: #05726d;
  --accent-soft: #e7f6f4;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --danger: #c2410c;
  --green: #059669;
  --shadow: 0 14px 36px rgba(15, 35, 32, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 750;
}

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

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

button.ghost:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 750;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(500px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #10201e;
  color: #f4c56a;
  font-weight: 850;
  margin-bottom: 18px;
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
}

.login-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.login-panel form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.notice {
  border-radius: 8px;
  padding: 12px;
  margin: 14px 0;
  line-height: 1.5;
}

.warn { background: #fff8e6; color: #6e4f00; }
.danger { background: #fff0ee; color: #b42318; }

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

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

.side-brand {
  padding: 0 10px 8px;
}

.side-brand strong {
  display: block;
  font-size: 18px;
}

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

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

.side-nav a {
  display: block;
  color: var(--ink);
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 750;
}

.side-nav a.active,
.side-nav a:hover {
  color: #fff;
  background: linear-gradient(135deg, #00988f, #05726d);
}

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

.side-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.side-action {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: left;
}

.data-card {
  margin-top: auto;
  background: linear-gradient(180deg, #fff, #eef8fb);
}

.data-card p {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.data-card strong {
  display: block;
  font-size: 15px;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

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

.top-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.app-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.65fr 1.2fr;
  gap: 16px;
  padding: 18px;
}

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

.panel h2 {
  margin: 0;
  font-size: 17px;
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
  margin: 8px 0 14px;
}

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

.help-dot,
.alert-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.alert-badge {
  background: #fff3df;
  color: #c26a00;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 212px;
  border: 1px dashed #b9c6c3;
  border-radius: 8px;
  background: #fbfdfc;
  padding: 20px;
  text-align: center;
}

.dropzone input[type="file"] {
  max-width: 320px;
}

.upload-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #edf5f3;
  color: var(--accent);
  font-size: 25px;
}

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

.summary-panel {
  grid-column: span 1;
}

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

.hero-metrics div {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdfc);
  padding: 16px;
}

.hero-metrics small {
  color: var(--muted);
  font-weight: 750;
}

.hero-metrics span {
  display: block;
  margin-top: 14px;
  font-size: 26px;
  font-weight: 850;
}

.hero-metrics em {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-style: normal;
  font-weight: 750;
}

.hero-metrics .negative {
  color: #dc2626;
}

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

.risk-item {
  position: relative;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff9f0;
  padding: 12px 60px 12px 14px;
}

.risk-item.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.risk-item.info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.risk-item strong {
  display: block;
  font-size: 14px;
}

.risk-item p {
  margin: 4px 0 0;
  font-size: 13px;
}

.risk-item button {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 4px 6px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}

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

.charts-panel {
  grid-column: span 1;
}

.analysis-panel,
.prompt-panel,
.settings-panel {
  grid-column: span 1;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #fbfdfc;
}

td input, td select {
  min-width: 88px;
  padding: 7px 8px;
  font-size: 13px;
}

.remove-row {
  width: 30px;
  height: 30px;
  padding: 0;
  background: #fff0ee;
  color: #dc2626;
}

.computed-cell {
  display: inline-block;
  min-width: 78px;
  font-weight: 800;
  color: var(--ink);
}

.computed-cell.positive {
  color: var(--green);
}

.computed-cell.negative {
  color: #dc2626;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.chart-actions label {
  min-width: 140px;
}

.chart-focus {
  display: grid;
  grid-template-columns: 220px 1fr 1.1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.chart-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 230px;
}

.donut-main {
  border: 0;
  padding: 0;
}

.chart-box h3,
.bar-list h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}

.chart-box canvas {
  width: 100% !important;
  height: 210px !important;
}

.donut-main canvas {
  height: 220px !important;
}

.compact-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.chart-box.wide {
  grid-column: span 2;
}

.chart-box.wide canvas {
  height: 250px !important;
}

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

.allocation-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.allocation-row span {
  color: var(--ink);
  font-weight: 750;
}

.allocation-row i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 7px;
}

.allocation-row em {
  grid-column: 1 / -1;
  font-style: normal;
}

.bar-list {
  display: grid;
  gap: 12px;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px 1fr 46px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row div {
  height: 8px;
  background: #e9eeee;
  border-radius: 999px;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

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

.analysis-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
}

.score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdfc;
}

.score-card span {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 7px solid #84d6be;
  color: var(--accent);
  font-size: 24px;
  font-weight: 850;
}

.score-card strong {
  display: block;
  margin-top: 12px;
  color: var(--green);
}

.score-card p {
  font-size: 13px;
}

.analysis {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  line-height: 1.75;
  white-space: pre-wrap;
  background: #fbfdfc;
}

.analysis.empty,
.muted {
  color: var(--muted);
}

.status {
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.6;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #e8f5f2;
  color: var(--accent);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.warn-pill {
  background: #fff8e6;
  color: #8a5d00;
}

.disclaimer {
  color: var(--muted);
  padding: 0 18px 26px;
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 1200px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    display: block;
  }
  .side-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .side-card {
    display: none;
  }
  .app-grid {
    grid-template-columns: 1fr 1fr;
  }
  .summary-panel,
  .alert-panel,
  .table-panel,
  .charts-panel,
  .analysis-panel,
  .prompt-panel,
  .settings-panel {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .topbar,
  .top-status {
    align-items: flex-start;
    flex-direction: column;
  }
  .app-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .summary-panel,
  .alert-panel,
  .table-panel,
  .charts-panel,
  .analysis-panel,
  .prompt-panel,
  .settings-panel {
    grid-column: span 1;
  }
  .hero-metrics,
  .chart-focus,
  .compact-charts,
  .form-grid,
  .settings-form,
  .analysis-layout {
    grid-template-columns: 1fr;
  }
  .chart-box.wide {
    grid-column: span 1;
  }
  .bar-list {
    border-left: 0;
    padding-left: 0;
  }
  .side-nav {
    grid-template-columns: 1fr 1fr;
  }
}
