:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --line: #d9e0e7;
  --text: #16202a;
  --muted: #667382;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --buy: #b42318;
  --core: #0f766e;
  --quality: #7c3aed;
  --near: #b7791f;
  --risk: #9f1239;
  --audit: #475569;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

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

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

.login-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.login-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  margin-top: 18px;
}

.login-panel input {
  padding-left: 12px;
}

.login-panel button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.login-panel button:hover {
  background: #115e59;
}

.login-panel small {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.login-error {
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  background: #fff1f2;
  color: var(--risk);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

.status-strip {
  display: flex;
  gap: 10px;
}

.status-strip > div {
  min-width: 136px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.status-strip > div:last-child {
  min-width: 112px;
}

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

.status-strip strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

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

.workspace {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.pool-nav {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 8px;
}

.pool-button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.pool-button:hover,
.pool-button.active {
  border-color: var(--accent);
  background: #f0fdfa;
}

.pool-button span {
  font-weight: 700;
}

.pool-text {
  min-width: 0;
}

.pool-text small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pool-button em {
  min-width: 28px;
  height: 24px;
  line-height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-style: normal;
  font-size: 12px;
}

.table-region,
.stability-section {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px 170px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  position: relative;
}

.search-mark {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  padding: 0 12px 0 32px;
}

select {
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
}

.section-head h2 {
  font-size: 18px;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.count-badge {
  padding: 7px 10px;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  font-weight: 700;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

td {
  vertical-align: top;
  padding: 12px;
  border-bottom: 1px solid #edf1f5;
}

tr:hover td {
  background: #fbfcfd;
}

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

.stock-code {
  margin-top: 4px;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
}

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tag.core {
  background: #ccfbf1;
  color: var(--core);
}

.tag.quality {
  background: #ede9fe;
  color: var(--quality);
}

.tag.near {
  background: #fef3c7;
  color: var(--near);
}

.tag.risk {
  background: #ffe4e6;
  color: var(--risk);
}

.theme {
  max-width: 320px;
  line-height: 1.45;
}

.numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 6px;
}

.num {
  padding: 6px 7px;
  border-radius: 6px;
  background: var(--surface-2);
}

.num span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.num strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.positive {
  color: #b42318;
}

.negative {
  color: #087443;
}

.reason {
  max-width: 420px;
  line-height: 1.45;
}

.reason small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.stability-section {
  margin-top: 14px;
}

.stability-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.stability-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

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

.stability-card strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

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

@media (max-width: 980px) {
  .topbar,
  .status-strip {
    display: block;
  }

  .status-strip {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .status-strip > div + div {
    margin-top: 0;
  }

  .status-strip > div {
    min-width: 0;
  }

  main {
    padding: 12px;
  }

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

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

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

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

@media (max-width: 720px) {
  body {
    font-size: 13px;
  }

  .topbar {
    padding: 16px 14px 12px;
  }

  .login-panel {
    padding: 20px;
  }

  .login-panel form {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  .pool-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .pool-button {
    min-width: 194px;
    grid-template-columns: 1fr auto;
    scroll-snap-align: start;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    padding: 12px;
  }

  .section-head h2 {
    font-size: 16px;
  }

  .count-badge {
    white-space: nowrap;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    margin: 0 10px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
  }

  tr:hover td {
    background: transparent;
  }

  td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf1f5;
  }

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

  td::before {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
  }

  td:nth-child(1)::before {
    content: "股票";
  }

  td:nth-child(2)::before {
    content: "状态";
  }

  td:nth-child(3)::before {
    content: "主题";
  }

  td:nth-child(4)::before {
    content: "业务技术";
  }

  td:nth-child(5)::before {
    content: "短期";
  }

  td:nth-child(6)::before {
    content: "基本面";
  }

  td:nth-child(7)::before {
    content: "原因";
  }

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

  .theme,
  .reason {
    max-width: none;
  }

  .tag {
    max-width: 100%;
    white-space: normal;
  }

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