:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #1769aa;
  --brand-dark: #0f4f83;
  --warn: #b54708;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #eef4fb 0, var(--bg) 360px);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.upload-panel,
.summary-grid {
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.account-chip {
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.upload-panel {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 20px;
  border: 2px dashed #9bb9d6;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.upload-panel.is-dragging {
  border-color: var(--brand);
  background: #edf7ff;
  transform: translateY(-1px);
}

.upload-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  background: #dcecff;
  color: var(--brand-dark);
  font-weight: 800;
}

.upload-panel p {
  margin-top: 6px;
  color: var(--muted);
}

.primary-button {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.ghost-button:hover {
  color: var(--danger);
  border-color: #f3b7b2;
  background: #fff7f6;
}

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

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

.risk-strip span,
.panel-header span {
  color: var(--muted);
  font-size: 13px;
}

.metric-body {
  padding: 16px 18px;
}

.metric-body strong {
  display: block;
  font-size: clamp(20px, 3vw, 30px);
}

.mini-chart {
  margin-top: 16px;
}

.mini-pie-wrap {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 18px;
}

.mini-pie {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(23, 32, 51, 0.12);
}

.mini-pie-label {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 38px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #172033;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 1px 5px rgba(23, 32, 51, 0.16);
}

.mini-legend {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.mini-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(48px, auto) 1fr 48px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.mini-legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.mini-legend-row b {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-legend-row span {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-legend-row em {
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.mini-empty {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.risk-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-left: 6px solid var(--brand);
}

.risk-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.risk-strip p {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.55;
}

.risk-strip.warning {
  border-left-color: var(--warn);
}

.risk-strip.danger {
  border-left-color: var(--danger);
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

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

.compact table {
  min-width: 900px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f6;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

th:first-child .sort-button {
  justify-content: flex-start;
}

.sort-button::after {
  content: "-";
  color: #98a2b3;
  font-size: 11px;
}

.sort-button.active {
  color: var(--brand-dark);
}

.sort-button.active[data-direction="asc"]::after {
  content: "^";
  color: var(--brand-dark);
}

.sort-button.active[data-direction="desc"]::after {
  content: "v";
  color: var(--brand-dark);
}

td.negative {
  color: var(--danger);
  font-weight: 700;
}

td.positive {
  color: var(--ok);
  font-weight: 700;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  background: #fff4e5;
  color: var(--warn);
}

.tag.danger {
  background: #fee4e2;
  color: var(--danger);
}

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

.assignment-card strong {
  font-size: clamp(18px, 2.4vw, 26px);
}

.assignment-list {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.total-row td {
  position: sticky;
  bottom: 0;
  border-top: 2px solid var(--line);
  background: #f8fafc;
  font-weight: 800;
}

@media (max-width: 900px) {
  .topbar,
  .risk-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-panel,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    text-align: center;
  }

  .upload-actions {
    justify-content: center;
  }

  .upload-icon {
    margin: 0 auto;
  }
}
