:root {
  --bg: #f3f5f9;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #2563eb;
  --card: #ffffff;
  --card-border: #e2e8f0;
  --sidebar: #0d1b36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.container,
.auth-wrap {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 16px;
}

body.has-sidebar .container {
  max-width: none;
  margin: 20px 20px 20px 274px;
  padding: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.form { display: flex; flex-direction: column; gap: 8px; }

input, select, textarea, button {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
}

input[type="file"] {
  display: none;
}

.btn {
  display: inline-block;
  border-radius: 10px;
  padding: 10px 16px;
  text-decoration: none;
  font-weight: 600;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-light { background: #fff; color: #0f172a; border: 1px solid #cbd5e1; }
.btn-ghost { background: transparent; color: #fff; border: 1px solid #4b5d87; }

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.metric-card h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.2px;
  color: var(--muted);
}

.metric-card p {
  margin: 6px 0 0;
  font-size: 26px;
  font-weight: 700;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3b82f6;
}

.metric-card-accent {
  border-color: #dbeafe;
  background: linear-gradient(145deg, #f8fbff, #ffffff 60%);
}

.msg { color: #334155; }
.hint { color: var(--muted); }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td {
  border: 1px solid #e5e7eb;
  padding: 10px;
  text-align: left;
  background: #fff;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
thead th { background: #f8fafc; }

/* 具体风险列样式 */
.risk-details-cell {
  max-width: 300px;
  white-space: normal;
  line-height: 1.6;
  font-size: 13px;
}

/* 表格列宽度控制 */
table th:nth-child(1), table td:nth-child(1) { width: 12%; } /* 成分名称 */
table th:nth-child(2), table td:nth-child(2) { width: 8%; }  /* 等级 */
table th:nth-child(3), table td:nth-child(3) { width: 18%; } /* 一句话总结 */
table th:nth-child(4), table td:nth-child(4) { width: 35%; } /* 具体风险 */
table th:nth-child(5), table td:nth-child(5) { width: 27%; } /* 建议 */

.tag {
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
}
.tag-red { background: #dc2626; }
.tag-yellow { background: #d97706; }
.tag-white { background: #6b7280; }
.tag-green { background: #16a34a; }

.landing-nav {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-brand {
  font-size: 20px;
  font-weight: 700;
}

.landing-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.landing-nav-actions { display: flex; gap: 10px; }

.lang-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-select:hover {
  border-color: var(--primary);
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.landing-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 16px 36px;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  background: linear-gradient(145deg, #e8f0ff 0%, #f6f9ff 55%, #ffffff 100%);
  border: 1px solid #d6e4ff;
  border-radius: 20px;
  padding: 30px;
}

.landing-hero h1 { margin: 0 0 10px; font-size: 34px; }
.landing-hero p { line-height: 1.75; color: #334155; }
.landing-cta { display: flex; gap: 10px; margin-top: 18px; }

.hero-card {
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 16px;
}

.hero-card ul { margin: 0; padding-left: 18px; line-height: 1.9; }

.auth-wrap {
  min-height: calc(100vh - 60px);
  display: grid;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px 16px;
}

.auth-container {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-brand-title {
  font-size: 42px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.auth-brand-subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  font-weight: 500;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.auth-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.lang-select-inline {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.lang-select-inline:hover {
  border-color: var(--primary);
  background: #ffffff;
}

.lang-select-inline:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-hint {
  margin: 0 0 24px;
  font-size: 14px;
}

.auth-submit-btn {
  margin-top: 8px;
  font-weight: 600;
  font-size: 15px;
  padding: 12px;
  transition: all 0.2s ease;
}

.auth-submit-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.auth-links {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-divider {
  margin: 0 8px;
  color: #cbd5e1;
}

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

.password-input-wrapper input {
  flex: 1;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.password-toggle:hover {
  color: #334155;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

.verification-code-wrapper {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.verification-code-wrapper input {
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

.verification-code-wrapper input::placeholder {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  font-size: 14px;
}

.send-code-btn {
  flex-shrink: 0;
  min-width: 110px;
  padding: 10px 16px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.send-code-btn:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.send-code-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  background: var(--sidebar);
  color: #dbeafe;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
}

.app-sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}

.app-sidebar a,
.app-sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  border-radius: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: #dbeafe;
  border: 1px solid transparent;
  background: transparent;
}

.nav-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  justify-content: center;
  color: #b7c8ee;
  vertical-align: middle;
}

.app-sidebar a.active,
.app-sidebar a:hover,
.app-sidebar button:hover {
  background: #1e2f56;
  border-color: #2f467a;
}

#logout-btn {
  background: #1e2f56;
  border-color: #2f467a;
  color: #dbeafe;
}

#logout-btn:hover {
  background: #253a69;
  border-color: #365089;
}

.app-sidebar .spacer { flex: 1; }

.page-title { 
  margin: 0 0 20px; 
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.page-header {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.page-header .page-title {
  margin-bottom: 8px;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.card-title-icon svg {
  width: 18px;
  height: 18px;
}

.dashboard-hero {
  margin-bottom: 20px;
}

.dashboard-hero .page-title {
  font-size: 26px;
  margin-bottom: 8px;
}

.dashboard-subtitle {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.dashboard-meta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #1e3a8a;
  font-size: 12px;
}

.dashboard-panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.section-icon svg {
  width: 16px;
  height: 16px;
}

.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafcff;
}

.task-item p {
  margin: 4px 0 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-pending {
  background: #fff7ed;
  color: #b45309;
}

.status-completed {
  background: #ecfdf5;
  color: #047857;
}

.status-failed {
  background: #fef2f2;
  color: #b91c1c;
}

.status-red {
  background: #fef2f2;
  color: #b91c1c;
}

.status-yellow {
  background: #fff7ed;
  color: #b45309;
}

.status-green {
  background: #ecfdf5;
  color: #047857;
}

.status-white {
  background: #f3f4f6;
  color: #374151;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sidebar-user-card {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid #2f467a;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: #122447;
}

.sidebar-lang-card {
  border: 1px solid #2f467a;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: #122447;
}

.sidebar-lang-title {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.sidebar-lang-hint {
  color: #bcd0fb;
  font-size: 12px;
  margin-bottom: 8px;
}

.sidebar-lang-select {
  width: 100%;
  border: 1px solid #365089;
  background: #1e2f56;
  color: #dbeafe;
  border-radius: 10px;
}

.sidebar-lang-select:focus {
  outline: none;
  border-color: #5a7ac4;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #1f3d74;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.sidebar-user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user-meta {
  color: #bcd0fb;
  font-size: 12px;
}

.upload-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  width: 100%;
  border: 1.5px dashed #9bb4e8;
  background: #f8fbff;
  color: #1e40af;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-trigger:hover {
  background: #eef5ff;
  border-color: #7da3e5;
}

@media (max-width: 992px) {
  body.has-sidebar .container {
    margin: 14px;
  }
  .app-sidebar {
    position: static;
    width: auto;
    height: auto;
    margin: 12px;
    border-radius: 12px;
  }
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-two,
  .metric-grid,
  .landing-hero {
    grid-template-columns: 1fr;
  }
  .landing-cta { flex-wrap: wrap; }
  .quick-actions {
    grid-template-columns: 1fr;
  }
}
