/* ========================================
   电商仓库优化诊断调研系统
   简洁专业风格，深蓝灰主色 + 仓储警示橙
   ======================================== */

:root {
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-surface-2: #f1f5f9;
  --c-border: #e2e8f0;
  --c-text: #0f172a;
  --c-text-2: #475569;
  --c-text-3: #94a3b8;
  --c-primary: #1e293b;
  --c-primary-hover: #0f172a;
  --c-accent: #ea580c;
  --c-accent-hover: #c2410c;
  --c-success: #16a34a;
  --c-danger: #dc2626;
  --c-warning: #ca8a04;
  --c-info: #0284c7;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

  --t: 0.15s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-accent); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--c-accent-hover); text-decoration: underline; }

/* ===== 布局 ===== */
.topbar {
  background: var(--c-primary);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .logo {
  width: 28px;
  height: 28px;
  background: var(--c-accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.topbar .nav { display: flex; gap: 4px; }
.topbar .nav a {
  color: rgba(255,255,255,0.75);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--t);
}
.topbar .nav a:hover { color: #fff; background: rgba(255,255,255,0.1); text-decoration: none; }
.topbar .nav a.active { color: #fff; background: rgba(255,255,255,0.15); }
.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.topbar .user-info .badge {
  background: var(--c-accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.topbar .user-info .logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--t);
}
.topbar .user-info .logout-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 6px;
}
.page-header p {
  color: var(--c-text-2);
  font-size: 13px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-family: inherit;
}
.btn:hover { background: var(--c-border); }
.btn-primary {
  background: var(--c-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-accent {
  background: var(--c-accent);
  color: #fff;
}
.btn-accent:hover { background: var(--c-accent-hover); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-danger  { background: var(--c-danger);  color: #fff; }
.btn-outline {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-text-2);
}
.btn-outline:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field label .req {
  color: var(--c-danger);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--c-text);
  transition: border-color var(--t), box-shadow var(--t);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
}
.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}
.field .hint {
  font-size: 11px;
  color: var(--c-text-3);
}

/* ===== 模块分组 ===== */
.module-group {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.module-header {
  background: linear-gradient(135deg, var(--c-primary) 0%, #334155 100%);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.module-header .title {
  font-size: 14px;
  font-weight: 600;
}
.module-header .progress {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-header .progress-bar {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}
.module-header .progress-fill {
  height: 100%;
  background: var(--c-accent);
  transition: width 0.3s ease;
}

.diagnosis-item {
  border-top: 1px solid var(--c-border);
  padding: 16px 20px;
}
.diagnosis-item:first-child { border-top: none; }
.diagnosis-item .item-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.diagnosis-item .item-id {
  background: var(--c-surface-2);
  color: var(--c-text-2);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  flex-shrink: 0;
}
.diagnosis-item .item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
  flex: 1;
}
.diagnosis-item .criterion {
  background: var(--c-surface-2);
  border-left: 3px solid var(--c-info);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--c-text-2);
  margin-bottom: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.diagnosis-item .item-fields {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 12px;
}
.diagnosis-item .item-fields .full {
  grid-column: 1 / -1;
}

/* 风险等级单选 —— 胶囊式 segmented control */
.risk-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.risk-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--c-text-2);
  transition: border-color var(--t), background var(--t), color var(--t), box-shadow var(--t);
  position: relative;
  user-select: none;
}
.risk-options label:hover {
  border-color: var(--c-primary);
  color: var(--c-text);
}
.risk-options label:has(input:checked) {
  border-color: var(--c-primary);
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(30, 41, 59, 0.15);
}
.risk-options input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: auto;
  height: auto;
  margin: 0;
  pointer-events: none;
}
.risk-options .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

/* ===== 表格 ===== */
.table-wrap {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table th,
table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
table th {
  background: var(--c-surface-2);
  font-weight: 600;
  color: var(--c-text-2);
  font-size: 12px;
  white-space: nowrap;
}
table tbody tr:hover { background: rgba(241, 245, 249, 0.5); }
table tbody tr:last-child td { border-bottom: none; }

/* 风险等级徽章 */
.risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.risk-urgent { background: var(--c-danger); }
.risk-high   { background: #ea580c; }
.risk-medium { background: var(--c-warning); }
.risk-low    { background: var(--c-success); }
.risk-none   { background: var(--c-text-3); }

/* 状态徽章 */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-draft     { background: var(--c-surface-2); color: var(--c-text-2); }
.status-submitted { background: #dbeafe; color: var(--c-info); }

/* ===== 工具类 ===== */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--c-text-3); font-size: 12px; }

/* ===== 提示 / Toast ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--c-text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.5s forwards;
  min-width: 200px;
}
.toast.success { background: var(--c-success); }
.toast.error   { background: var(--c-danger); }
.toast.warning { background: var(--c-warning); color: #1f2937; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-10px); } }

/* ===== Hero（首页） ===== */
.hero {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 48px 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  background: var(--c-accent);
  opacity: 0.15;
  border-radius: 50%;
}
.hero h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}
.hero p {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  max-width: 640px;
  line-height: 1.7;
  margin-bottom: 20px;
}
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.feature {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.feature .icon {
  width: 36px;
  height: 36px;
  background: var(--c-surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--c-accent);
  font-size: 18px;
}
.feature h3 { font-size: 14px; margin-bottom: 6px; }
.feature p { font-size: 12px; color: var(--c-text-2); line-height: 1.6; }

/* ===== 登录页 ===== */
.auth-page {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.auth-card .subtitle {
  font-size: 13px;
  color: var(--c-text-2);
  margin-bottom: 24px;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--c-surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.auth-tabs button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-2);
  transition: all var(--t);
  font-family: inherit;
}
.auth-tabs button.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-sm);
}

/* ===== 筛选条 ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-text);
}
.filter-bar input { min-width: 200px; }

/* ===== 模式徽章 ===== */
.mode-badge {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--c-text-2);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 100;
}
.mode-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.mode-badge.local .dot { background: var(--c-warning); }
.mode-badge.api   .dot { background: var(--c-success); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar .brand { font-size: 14px; }
  .diagnosis-item .item-fields { grid-template-columns: 1fr; }
  .hero { padding: 32px 20px; }
  .hero h1 { font-size: 22px; }
  table { font-size: 12px; }
  table th, table td { padding: 8px 10px; }
}

/* ===== 工具 ===== */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--c-text-3);
}
.empty .icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .num {
  font-size: 24px;
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: 4px;
}
.stat-card .lbl {
  font-size: 12px;
  color: var(--c-text-2);
}
.stat-card.urgent .num { color: var(--c-danger); }
.stat-card.high   .num { color: #ea580c; }
.stat-card.medium .num { color: var(--c-warning); }
.stat-card.low    .num { color: var(--c-success); }