/* Finlens Web design system */

/* --- Tokens (hex only defined here) --- */
:root {
  --color-bg: #f7f8f5;
  --color-surface: #ffffff;
  --color-surface-muted: #f3f5f1;
  --color-surface-hover: #edf1ea;
  --color-header: rgba(247, 248, 245, 0.9);
  --color-text: #18181b;
  --color-text-secondary: #3f3f46;
  --color-text-tertiary: #71717a;
  /* 修复：此前从未定义，var(--color-muted) 全部失效回退为继承色 */
  --color-muted: #71717a;
  --color-text-on-brand: #ffffff;
  --color-border: #e2e5dc;
  --color-border-strong: #cfd6c8;
  --color-border-input: #9ca3af;
  --color-brand: #18181b;
  --color-brand-hover: #000000;
  --color-brand-muted: rgba(24, 24, 27, 0.1);
  --color-brand-shadow-btn: rgba(24, 24, 27, 0.16);
  --color-accent-muted: rgba(182, 106, 80, 0.12);
  --color-insight: #0f766e;
  --color-danger: #ef4444;
  /* semantic states — muted to match warm neutral + slate brand */
  --color-info-bg: #e8ecef;
  --color-info-border: #d4dde3;
  --color-info-text: #1e4f73;
  --color-pending-bg: #e6ecef;
  --color-pending-text: #215a7a;
  --color-pending-border: #cdd6dc;
  --color-success-bg: #e9efe8;
  --color-success-text: #3f5e48;
  --color-success-border: #d2ddd0;
  --color-failed-bg: #f3ebe8;
  --color-failed-text: #8f4a42;
  --color-failed-border: #e5d4cf;
  --color-tag-brand-bg: #e8ecef;
  --color-tag-brand-text: #1e4f73;
  --color-tag-brand-border: #d4dde3;
  --color-overlay-shadow: rgba(15, 23, 42, 0.12);
  --color-overlay-shadow-lg: rgba(15, 23, 42, 0.14);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  --leading-tight: 1.2;
  --leading-normal: 1.6;
  --leading-relaxed: 1.7;

  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-md: 0 8px 24px var(--color-overlay-shadow);
  --shadow-lg: 0 18px 40px var(--color-overlay-shadow-lg);
  --shadow-brand: 0 4px 12px var(--color-brand-shadow-btn);

  --duration-fast: 150ms;
  --focus-ring: 0 0 0 3px var(--color-brand-muted);

  --shell-max: 1080px;
  --sidebar-width: 380px;
  --auth-form-width: 420px;
}

/* --- Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Make the hidden attribute win over component display rules (e.g. .field
   uses display:flex, which would otherwise override [hidden]). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: var(--color-brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Layout --- */
.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) 48px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, var(--auth-form-width));
  justify-content: center;
  align-content: safe center;
  min-height: calc(100vh - 64px - var(--space-8) - 48px);
}

/* Auth card spacing scales with viewport height so the form stays compact on
   short viewports (and high browser zoom) without breakpoints, falling back to
   scrolling only when content truly exceeds the viewport. */
/* Trim the gap above the auth card on short viewports (auth pages only). */
.shell:has(.layout) {
  padding-top: clamp(var(--space-3), 2.2vh, var(--space-8));
}

.layout .card {
  padding: clamp(var(--space-4), 3vh, var(--space-8));
}

.layout .oauth-btn {
  min-height: clamp(36px, 5.6vh, 40px);
}

.layout .auth-title {
  margin-bottom: clamp(var(--space-3), 3vh, var(--space-6));
  font-size: clamp(20px, 3vh, 28px);
}

.layout .oauth-divider {
  margin: clamp(var(--space-3), 2.5vh, var(--space-5)) 0 clamp(var(--space-2), 2vh, var(--space-4));
}

.layout .oauth-buttons {
  gap: clamp(var(--space-2), 1.6vh, var(--space-3));
}

.layout .field {
  margin-bottom: clamp(var(--space-2), 1.8vh, var(--space-4));
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, var(--sidebar-width));
  gap: 22px;
  align-items: start;
}

.dash-left {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.dash-side {
  min-width: 0;
}

.card-tagline {
  margin: 0 0 var(--space-5);
  font-size: var(--text-2xl);
  font-weight: var(--font-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-align: center;
  text-wrap: balance;
}

/* --- Auth card (login) --- */
.auth-title {
  margin: 0 0 var(--space-6);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 28px;
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-align: center;
  text-wrap: balance;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .input {
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  padding: 4px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  background: none;
  border: 0;
}

.password-toggle:hover {
  color: var(--color-text);
}

.btn.auth-primary {
  justify-content: center;
  width: 100%;
  margin-top: 0;
  padding: 13px 18px;
  color: var(--color-text-on-brand);
  background: var(--color-text);
  box-shadow: none;
}

.btn.auth-primary:hover {
  background: #000000;
}

.auth-switch {
  margin: var(--space-2) 0 0;
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  text-align: center;
}

.auth-switch a {
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: clamp(44px, 9vh, 64px);
  padding: 0 max(var(--space-5), calc((100vw - var(--shell-max)) / 2 + var(--space-5)));
  background: var(--color-header);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: var(--font-bold);
  letter-spacing: -0.015em;
  text-decoration: none;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--color-bg);
  background: var(--color-text);
  box-shadow: none;
}

.brand small {
  display: block;
  margin-top: -2px;
  font-size: 11px;
  font-weight: var(--font-medium);
  letter-spacing: 0;
  color: var(--color-text-tertiary);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Short viewports (browser zoom / small windows): compress topbar before hiding it. */
@media (max-height: 740px) {
  .topbar {
    min-height: clamp(40px, 8vh, 52px);
  }

  .brand {
    gap: 8px;
    font-size: 15px;
  }

  .brand small {
    display: none;
  }

  .logo {
    width: clamp(22px, 4vh, 26px);
    height: clamp(22px, 4vh, 26px);
  }

  .pill {
    padding: 4px 9px;
    font-size: var(--text-xs);
  }
}

/* Auth pages only: drop the topbar when content still overflows at high zoom. */
@media (max-height: 660px) {
  body:has(.layout) .topbar {
    display: none;
  }

  body:has(.layout) .shell {
    padding-top: clamp(var(--space-2), 1.5vh, var(--space-4));
  }
}

.pill {
  padding: 6px 11px;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.nav-link {
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
}

.nav-link.is-active {
  color: var(--color-text);
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

.pill:hover,
.user-menu[open] .user-menu-trigger {
  color: var(--color-text);
  text-decoration: none;
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.user-menu-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-caret {
  font-size: 10px;
  color: var(--color-text-tertiary);
  transition: transform var(--duration-fast) ease;
}

/* 窄屏顶栏：email 收进菜单，触发器只留人形图标（见 860px 断点） */
.user-icon {
  display: none;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.user-menu-email {
  display: none;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  word-break: break-all;
}

.user-menu[open] .user-menu-caret {
  transform: rotate(180deg);
}

.user-menu-panel {
  position: fixed;
  top: -9999px;
  right: auto;
  z-index: 9999;
  min-width: 160px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-weight: var(--font-semibold);
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
}

.user-menu-item:hover {
  background: var(--color-surface-hover);
}

.user-menu-item.is-active,
.user-menu-item:disabled {
  color: var(--color-text-tertiary);
  cursor: default;
}

.user-menu-item.is-active:hover,
.user-menu-item:disabled:hover {
  background: transparent;
}

.locale-menu-trigger {
  min-width: 0;
  padding-inline: 10px;
}

.locale-menu .user-menu-panel {
  min-width: 96px;
  width: max-content;
}

.locale-menu .user-menu-item {
  padding: 8px 12px;
  white-space: nowrap;
}

.locale-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.locale-menu-trigger:hover .locale-icon,
.user-menu[open] .locale-menu-trigger .locale-icon {
  color: var(--color-text);
}

.locale-code {
  font-size: 12px;
  font-weight: var(--font-semibold);
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.locale-menu-trigger:hover .locale-code,
.user-menu[open] .locale-menu-trigger .locale-code {
  color: var(--color-text);
}

/* --- Card --- */
.card {
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

.card .hint {
  margin: 0 0 var(--space-6);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-tertiary);
}

#login-register-hint {
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
}

.msg {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) 14px;
  font-size: var(--text-base);
  color: var(--color-info-text);
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-md);
}

/* --- Form --- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.field label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.input {
  width: 100%;
  padding: var(--space-3) 14px;
  font-size: var(--text-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.input:focus {
  border-color: var(--color-brand);
  box-shadow: var(--focus-ring);
}

.readonly-field {
  width: 100%;
  padding: var(--space-3) 14px;
  font-size: var(--text-md);
  color: var(--color-text-tertiary);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: default;
  user-select: text;
}

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

/* --- Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 18px;
  font-size: var(--text-base);
  line-height: var(--leading-tight);
  font-weight: var(--font-semibold);
  color: var(--color-text-on-brand);
  text-decoration: none;
  cursor: pointer;
  background: var(--color-brand);
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-brand);
  transition: background var(--duration-fast);
}

.btn:hover {
  background: var(--color-brand-hover);
  text-decoration: none;
}

.btn.secondary {
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: none;
}

.btn.secondary:hover {
  background: var(--color-surface-muted);
}

.oauth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-tertiary);
}

.oauth-divider::before,
.oauth-divider::after {
  flex: 1;
  height: 1px;
  content: "";
  background: var(--color-border);
}

.oauth-buttons {
  display: grid;
  gap: var(--space-3);
}

.oauth-form {
  margin: 0;
}

.oauth-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast), border-color var(--duration-fast), background var(--duration-fast), box-shadow var(--duration-fast);
}

button.oauth-btn {
  margin: 0;
  appearance: none;
}

.oauth-btn > span {
  width: 100%;
  text-align: center;
}

.oauth-btn:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.oauth-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.oauth-btn:active {
  transform: translateY(0);
}

.oauth-btn:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.oauth-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
}

.oauth-icon.google-icon {
  width: 18px;
  height: 18px;
}

.oauth-icon.apple-icon {
  width: 22px;
  height: 22px;
  color: #111827;
}

.oauth-error {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-danger);
}

.btn.sample-btn {
  padding: var(--space-2) 14px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hint strong,
.doc strong {
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

/* --- Doc --- */
.doc {
  display: grid;
  gap: var(--space-2);
}

.doc > div {
  padding: 6px 0;
}

.doc h3 {
  margin: 18px 0 10px;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.doc > div:first-child h3,
.doc > div:first-child h2 {
  margin-top: 0;
}

.doc p,
.doc li {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

.doc ol,
.doc ul {
  margin: 0;
  padding-left: var(--space-5);
}

.doc li {
  margin-bottom: var(--space-1);
}

/* --- Request list --- */
.request-list {
  list-style: none;
  max-height: 560px;
  margin: 0;
  padding: 0 6px 0 0;
  overflow-y: auto;
  display: grid;
  gap: var(--space-2);
}

.request-list::-webkit-scrollbar {
  width: 8px;
}

.request-list::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 4px;
}

.request-list::-webkit-scrollbar-track {
  background: transparent;
}

.request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 14px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.request-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast),
    background var(--duration-fast);
}

.request-link:hover {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.request-link:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.request-main {
  min-width: 0;
  flex: 1;
}

.request-item strong {
  display: block;
  font-size: var(--text-base);
  line-height: var(--leading-tight);
}

.request-meta {
  display: block;
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.request-id {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.request-item code {
  font-family: var(--font-mono);
}

/* --- Status --- */
.status {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  align-self: center;
  max-width: 100%;
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  text-align: center;
  overflow-wrap: anywhere;
  white-space: normal;
  border-radius: var(--radius-full);
}

.status-pending {
  color: var(--color-pending-text);
  background: var(--color-pending-bg);
  border: 1px solid var(--color-pending-border);
}

.status-success {
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
}

.status-failed {
  color: var(--color-failed-text);
  background: var(--color-failed-bg);
  border: 1px solid var(--color-failed-border);
}

.empty {
  padding: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.footer {
  margin-top: var(--space-7);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.footer a {
  font-weight: var(--font-medium);
  color: var(--color-brand);
}

.report-view-frame {
  width: 100%;
  min-height: 76vh;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* --- Samples --- */
.samples-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.samples-card > .samples-head {
  margin: 0;
}

.samples-head h2 {
  margin: 0 0 6px;
  font-size: var(--text-xl);
  letter-spacing: -0.015em;
}

.samples-head p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text-tertiary);
}

.samples-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.samples-more {
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.samples-more summary {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.samples-more .samples-list {
  margin-top: var(--space-3);
}

/* --- Entity cards (samples) --- */
.sample-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.sample-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sample-symbol {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: 17px;
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
}

.sample-symbol small {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  letter-spacing: 0;
  color: var(--color-text-tertiary);
}

.sample-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-tags span {
  padding: 2px var(--space-2);
  font-size: 11px;
  font-weight: var(--font-semibold);
  color: var(--color-tag-brand-text);
  background: var(--color-tag-brand-bg);
  border: 1px solid var(--color-tag-brand-border);
  border-radius: var(--radius-full);
}

.sample-thesis {
  margin: 0;
  padding: 10px var(--space-3);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border-left: 3px solid var(--color-brand);
  border-radius: var(--radius-sm);
}

.sample-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.sample-body section h4 {
  margin: 0 0 var(--space-1);
  font-size: 12.5px;
  font-weight: var(--font-bold);
  color: var(--color-text);
  letter-spacing: -0.005em;
}

.sample-body ul {
  margin: 0;
  padding-left: 18px;
}

.sample-body li {
  margin-bottom: 3px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}

.sample-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  margin-top: 2px;
  border-top: 1px dashed var(--color-border);
}

.sample-foot small {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* --- Combobox --- */
.combo {
  position: relative;
}

.combo .input {
  padding-right: 38px;
}

.combo-clear {
  position: absolute;
  top: 50%;
  right: 10px;
  display: none;
  padding: 4px 6px;
  font-size: 18px;
  line-height: 1;
  color: var(--color-text-tertiary);
  cursor: pointer;
  background: transparent;
  border: 0;
  transform: translateY(-50%);
}

.combo-clear.visible {
  display: inline-block;
}

.combo-list {
  position: fixed;
  z-index: 9999;
  display: none;
  max-height: 280px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.combo-list.open {
  display: block;
}

.combo-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.combo-item:hover,
.combo-item.active {
  background: var(--color-info-bg);
}

.combo-item .sym {
  font-weight: var(--font-bold);
  letter-spacing: -0.01em;
}

.combo-item .name {
  flex: 1;
  margin-left: var(--space-2);
  overflow: hidden;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-item .sec {
  padding: 2px var(--space-2);
  font-size: 11px;
  color: var(--color-insight);
  white-space: nowrap;
  background: var(--color-accent-muted);
  border-radius: var(--radius-full);
}

.combo-empty {
  padding: 14px;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: center;
}

/* --- Chips --- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 var(--space-3);
}

.chip {
  padding: 5px 11px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.chip:hover {
  border-color: var(--color-border-input);
}

.chip.on {
  color: var(--color-text-on-brand);
  background: var(--color-brand);
  border-color: transparent;
}

/* --- Responsive --- */
@media (max-width: 860px) {
  .desktop-only {
    display: none;
  }

  .layout,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .layout {
    align-content: start;
    min-height: 0;
  }

  .topbar {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-2) var(--space-3);
  }

  .top-actions {
    justify-content: flex-end;
  }

  /* 顶栏收成单行：隐藏副标题与 email 文本，email 收进菜单面板 */
  .brand small {
    display: none;
  }

  .user-menu-trigger .user-menu-label {
    display: none;
  }

  .user-icon {
    display: inline-flex;
  }

  .user-menu-email {
    display: block;
  }

  .topbar .pill {
    padding: 4px 8px;
    font-size: var(--text-xs);
  }

  .shell {
    padding-top: var(--space-5);
  }

  /* Shrink the auth title on narrow screens; keep the short Chinese title on a
     single line, but let the longer English title wrap so it never overflows. */
  .layout .auth-title {
    font-size: clamp(17px, 6.2vw, 26px);
  }

  html[lang="zh-CN"] .layout .auth-title {
    white-space: nowrap;
  }

  /* Auth pages: extra bottom space (plus iOS safe area) so the sign-in switch
     link below the submit button is never trapped behind the mobile browser
     toolbar, which otherwise occludes the bottom of a 100vh-tall document. */
  .shell:has(.layout) {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .request-item {
    flex-wrap: wrap;
  }

  .status {
    max-width: 100%;
  }

  .sample-body {
    grid-template-columns: 1fr;
  }

  .request-list {
    max-height: none;
  }

  .report-view-frame {
    min-height: 60vh;
    border-radius: var(--radius-md);
  }
}

/* --- Report detail: in-progress state --- */
.report-progress {
  max-width: 820px;
  margin: var(--space-6) auto var(--space-8);
  padding: 0 var(--space-4);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-tertiary);
}

.back-link:hover {
  color: var(--color-brand);
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: var(--space-4);
}

.progress-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: min(100%, 560px);
  min-height: 320px;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.progress-side {
  width: min(100%, 680px);
  text-align: center;
}

.progress-spinner {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border: 4px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .progress-spinner {
    animation: none;
  }
}

.progress-symbol {
  margin: 0;
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
}

.progress-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  text-align: center;
}

.progress-hint {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

.progress-steps {
  display: grid;
  grid-template-columns: auto minmax(0, max-content);
  column-gap: var(--space-3);
  row-gap: var(--space-2);
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: var(--space-2) auto 0;
  padding: 0;
  list-style: none;
}

.progress-step {
  display: contents;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.progress-step-marker {
  width: 18px;
  height: 18px;
  align-self: center;
  justify-self: end;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
}

.progress-step-label {
  align-self: center;
  min-width: 0;
  overflow-wrap: break-word;
}

.progress-step.is-done {
  color: var(--color-text-secondary);
}

.progress-step.is-done .progress-step-marker {
  border-color: var(--color-brand);
  background: var(--color-brand);
}

.progress-step.is-current {
  color: var(--color-text-primary);
  font-weight: var(--font-medium);
}

.progress-step.is-current .progress-step-marker {
  border-color: var(--color-brand);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-brand-muted);
  animation: progress-current-blink 1s steps(2, end) infinite;
}

@keyframes progress-current-blink {
  0%,
  45% {
    background: var(--color-brand);
  }
  55%,
  100% {
    background: var(--color-surface);
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-step.is-current .progress-step-marker {
    animation: none;
  }
}

/* --- Report detail: completed state --- */
.report-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  max-width: 940px;
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-4);
}

.report-breadcrumb > a {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-tertiary);
}

.report-breadcrumb > a:hover {
  color: var(--color-brand);
}

.report-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 940px;
  margin: 0 auto;
}

.report-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.report-hero-heading {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.report-hero-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
}

.report-hero-sub {
  font-size: var(--text-md);
  font-weight: var(--font-medium);
  color: var(--color-text-tertiary);
}

.report-hero-status {
  flex-shrink: 0;
}

.report-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.report-hero-actions .btn {
  flex: 1 1 200px;
  justify-content: center;
  min-height: 48px;
}

.report-frame-card {
  padding: 0;
  overflow: hidden;
}

.report-frame-card .report-view-frame {
  display: block;
  min-height: 80vh;
  margin: 0;
  border: 0;
  border-radius: 0;
}

/* --- Responsive: report detail --- */
@media (max-width: 860px) {
  .report-progress {
    margin: var(--space-4) auto var(--space-6);
    padding: 0 var(--space-3);
  }

  .progress-layout {
    gap: var(--space-4);
  }

  .progress-main {
    min-height: 280px;
    padding: var(--space-6) var(--space-4);
  }

  .progress-symbol {
    font-size: var(--text-2xl);
  }

  .progress-hint {
    font-size: var(--text-xs);
  }

  .report-breadcrumb {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: 0 var(--space-3);
  }

  .report-layout {
    gap: var(--space-4);
  }

  .report-hero-heading {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .report-hero-status {
    align-self: flex-start;
  }

  .report-hero-title {
    font-size: var(--text-xl);
  }

  .report-hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .report-hero-actions .btn {
    flex: 0 0 auto;
    width: 100%;
  }

  .report-frame-card .report-view-frame {
    min-height: 60vh;
  }
}

/* Single-column, centered (2026-07-23 产品二轮反馈第三项): the sidebar this
   grid used to reserve a column for (.pool-side / job-status sidebar) was
   removed in 裁定6, which left an empty phantom column pushing .pool-main
   left with dead space on the right. max-width + auto margins matches the
   existing single-column dashboard-page convention (see .report-layout). */
.pool-layout {
  /* 合并单表（买入+观察）比旧双表多一列状态徽标，940px 会截断右侧
     护城河/结论列，放开到外层 shell 的 1080px。 */
  max-width: var(--shell-max);
  margin: 0 auto;
}

.pool-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.pool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.pool-head-filters {
  flex-wrap: wrap;
  margin-bottom: 0;
}

.pool-updated-at {
  margin-left: var(--space-2);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted, #888);
  white-space: nowrap;
}

.pool-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.pool-filters .input {
  width: auto;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.pool-filters .btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

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

.pool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.pool-table th,
.pool-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

.pool-table th {
  color: var(--color-muted);
  font-weight: 600;
  /* CJK 两字表头（市场/估值）在窄列会竖排折行，锁横排 */
  white-space: nowrap;
}

.pool-conclusion-cell {
  vertical-align: top;
}

.pool-conclusion-item {
  margin-bottom: 0.3rem;
}

.pool-conclusion-item:last-child {
  margin-bottom: 0;
}

.pool-moat-reason {
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* 列头「?」口径提示：hover/键盘 focus 展示，同一时刻只会有一个，天然不重叠。
   th 是 nowrap，弹层要恢复 normal */
.pool-hint {
  display: inline-block;
  position: relative;
  margin-left: 0.2rem;
  font-weight: normal;
}

.pool-hint-mark {
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-tertiary);
  font-size: 0.65rem;
  line-height: 1;
}

.pool-hint-pop {
  display: none;
  position: absolute;
  top: 1.25rem;
  left: 0;
  z-index: 20;
  width: 16rem;
  white-space: normal;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.pool-hint:hover .pool-hint-pop,
.pool-hint:focus-within .pool-hint-pop {
  display: block;
}

/* 靠右的列弹层往左弹，避免撑出横向滚动 */
th:nth-last-child(-n+4) .pool-hint-pop {
  left: auto;
  right: 0;
}

/* 结论依据/护城河长文本默认折叠。展开内容是右对齐浮层：不撑开单元格、
   不改行高，向左展开保证最后一列也能完整阅读，长文在浮层内滚动 */
.pool-fold {
  position: relative;
}

.pool-fold > summary {
  cursor: pointer;
  color: var(--color-muted);
  white-space: nowrap;
}

.pool-fold > .pool-fold-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 25;
  width: min(32rem, 85vw);
  max-height: 22rem;
  overflow-y: auto;
  white-space: normal;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.pool-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
  font-size: var(--text-sm);
}

/* 分页下拉（页码 / 每页数量）与筛选栏的 select 同尺寸，而不是 .input 的满宽。 */
.pool-pagination .input {
  width: auto;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.pool-page-size {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  color: var(--color-muted);
}

.pool-page-status {
  color: var(--color-muted);
}

.pool-page-disabled {
  color: var(--color-muted);
  opacity: 0.5;
}

.pool-valuation {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
}

.pool-valuation-cheap {
  background: #e8f5e9;
  color: #2e7d32;
}

.pool-valuation-fair {
  background: #fff8e1;
  color: #f57f17;
}

.pool-valuation-expensive {
  background: #ffebee;
  color: #c62828;
}

.pool-valuation-undefined {
  background: #eceff1;
  color: #546e7a;
}

/* 「PE/扣现PE」合并列：两个数值不拆行 */
.pool-table td.pool-cell-nowrap {
  white-space: nowrap;
}

.pool-runs {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* --- Responsive: stock pool --- */
@media (max-width: 860px) {
  .pool-head-filters {
    flex-direction: column;
    align-items: stretch;
  }

  /* 市场/行业两个下拉一行，状态+筛选按钮一行 */
  .pool-filters .input {
    flex: 1 1 40%;
    min-width: 0;
  }

  .pool-filters .btn {
    flex: 1 1 30%;
    justify-content: center;
  }

  /* 表格转卡片：每行一张卡，指标排成两列小格（标签在上、值在下） */
  .pool-table thead {
    display: none;
  }

  .pool-table,
  .pool-table tbody,
  .pool-table td {
    display: block;
  }

  .pool-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3) var(--space-4);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border);
  }

  .pool-table tr:last-child {
    border-bottom: 0;
  }

  .pool-table td {
    min-width: 0;
    padding: 0;
    border-bottom: 0;
  }

  /* 窄屏浮层内联展开：占满整行、向下顶开内容，不悬浮遮挡 */
  .pool-table td:has(.pool-fold[open]) {
    grid-column: 1 / -1;
  }

  .pool-fold > .pool-fold-pop {
    position: static;
    width: auto;
    max-height: none;
    margin-top: var(--space-2);
    box-shadow: none;
  }

  .pool-table td.pool-cell-symbol {
    grid-column: 1 / -1;
    font-size: var(--text-md);
  }

  .pool-table td.empty {
    grid-column: 1 / -1;
  }

  .pool-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: var(--text-xs);
    color: var(--color-muted);
  }

  .pool-table td.pool-cell-metric {
    font-weight: var(--font-medium);
    font-variant-numeric: tabular-nums;
  }
}

