:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde5;
  --text: #17202c;
  --muted: #657084;
  --blue: #2458a6;
  --blue-dark: #1d4785;
  --red: #c4372f;
  --green: #17864b;
  --amber: #a66a00;
  --shadow: 0 10px 28px rgba(27, 39, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #101821;
  color: #fff;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

h3 {
  font-size: 15px;
}

.subline {
  margin-top: 6px;
  color: #b9c3d2;
  font-size: 13px;
}

.mode-pill {
  border: 1px solid #425167;
  padding: 7px 10px;
  border-radius: 6px;
  color: #dce7f6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-button {
  min-height: 34px;
  border-color: #425167;
  background: transparent;
  color: #dce7f6;
}

.logout-button:hover {
  border-color: #8fa2bc;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 650;
}

main {
  padding: 18px 24px 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

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

.import-grid,
.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 240px;
  flex: 1;
}

.compact-field {
  display: grid;
  gap: 6px;
  min-width: 118px;
}

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

input[type="text"],
input[type="number"],
input[type="date"],
input[type="file"],
input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 11px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
}

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

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

button.secondary:hover,
button.tiny:hover {
  border-color: #9ba8ba;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button.tiny {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

button.danger {
  color: var(--red);
  border-color: #e6b6b3;
}

.preview-box {
  margin-top: 14px;
}

.round-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
}

.round-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 360px;
  box-shadow: var(--shadow);
}

.round-title {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.round-title span {
  color: var(--muted);
}

.round-list {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.stock-row {
  border: 1px solid #e3e7ee;
  border-radius: 6px;
  padding: 9px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.stock-main {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.stock-code {
  color: var(--muted);
  font-family: Consolas, monospace;
}

.stock-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.action-qty {
  width: 76px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 12px;
}

.risk-line {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 82px;
}

.risk-line small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.custom-risk-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 6px 8px;
  min-width: 230px;
}

.custom-risk-controls label {
  display: grid;
  grid-template-columns: auto minmax(60px, 1fr);
  align-items: center;
  gap: 4px 6px;
  color: var(--muted);
  font-size: 11px;
}

.custom-risk-controls input {
  width: 76px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 12px;
}

.custom-risk-controls small {
  grid-column: 2;
  min-height: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.risk-buttons {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
}

.login-page {
  min-height: 100vh;
  background: #eef1f5;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 24px;
  padding: 24px;
}

.login-panel {
  align-self: center;
  width: min(100%, 380px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  margin-bottom: 24px;
  color: var(--text);
  font-size: 22px;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 6px;
}

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

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.login-submit {
  width: 100%;
}

.login-filing {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-filing a {
  color: inherit;
  text-decoration: none;
}

.login-filing a:hover,
.login-filing a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

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

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e8ebf0;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f1f4f8;
  color: #3b4655;
  font-size: 12px;
  white-space: nowrap;
}

td {
  max-width: 260px;
}

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

.up {
  color: var(--red);
  font-weight: 650;
}

.down {
  color: var(--green);
  font-weight: 650;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef2f7;
  color: #344255;
  white-space: nowrap;
}

.badge.hot {
  background: #fdeceb;
  color: var(--red);
}

.badge.green {
  background: #e7f5ee;
  color: var(--green);
}

.badge.amber {
  background: #fff2d9;
  color: var(--amber);
}

.empty,
.notice {
  border: 1px dashed #c6ceda;
  border-radius: 8px;
  color: var(--muted);
  padding: 16px;
  background: #fafbfc;
}

.error-list {
  display: grid;
  gap: 6px;
  color: var(--red);
  margin: 10px 0 0;
}

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

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

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric strong {
  font-size: 20px;
}

.report-curve {
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  margin: 16px 0 0;
  padding: 18px 4px 4px;
}

.curve-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  margin: 0 8px 8px;
}

.curve-head strong {
  font-size: 18px;
}

.curve-svg {
  display: block;
  width: 100%;
  height: 330px;
}

.curve-grid {
  stroke: #edf0f5;
  stroke-width: 1;
  stroke-dasharray: 8 8;
}

.curve-baseline {
  stroke: #e2e6ed;
  stroke-width: 1;
}

.curve-line {
  fill: none;
  stroke: #2f7de1;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.curve-label {
  fill: #b7beca;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.y-label {
  text-anchor: end;
}

.x-label {
  fill: #bdc3cd;
}

@media (max-width: 1100px) {
  .round-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: 14px;
  }

  .tabs {
    padding-left: 14px;
  }

  .round-grid {
    grid-template-columns: 1fr;
  }
}
