/* ============================================================
   客户拜访管理系统 - 原生CSS响应式样式
   电脑端 / 手机端自适应, 不引入任何UI框架
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  background: #f5f6f8;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶部导航 ---------- */
.topbar {
  background: #1e3a5f;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 56px;
  position: relative;
}
.logo {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin-right: 24px;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav a {
  color: #cbd5e1;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav a.active { background: #2563eb; color: #fff; }
.nav-user {
  margin-left: auto;
  color: #94a3b8;
  font-size: 13px;
  padding: 0 10px;
}
.nav-logout {
  color: #fca5a5 !important;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  margin-left: auto;
  padding: 4px 10px;
}

/* ---------- 容器 ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---------- 卡片 / 面板 ---------- */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h2 {
  font-size: 18px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger  { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 14px;
  color: #374151;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
  min-height: 40px;
}
.form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: auto; }

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 200px; }

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;          /* 手机端横向滚动 */
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 600px;          /* 保证手机端可横向滚动 */
}
table.data-table th,
table.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
table.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  position: sticky;
  top: 0;
}
table.data-table tr:hover td { background: #f8fafc; }
.level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.level-A { background: #fee2e2; color: #b91c1c; }
.level-B { background: #fef3c7; color: #92400e; }
.level-C { background: #dbeafe; color: #1e40af; }
.level-D { background: #e0e7ff; color: #3730a3; }
.level-E { background: #f3f4f6; color: #4b5563; }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 14px;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }
.filter-bar .form-control { min-height: 38px; }

/* ---------- 提示框 ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- 分页 ---------- */
.pagination {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-info { font-size: 13px; color: #6b7280; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
}
.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.login-box h1 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
  color: #1e3a5f;
}

/* ---------- 统计卡片 ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-card .num { font-size: 28px; font-weight: 700; color: #2563eb; }
.stat-card .label { font-size: 13px; color: #6b7280; margin-top: 4px; }

/* ---------- 订单明细行 ---------- */
.order-items { margin-bottom: 14px; }
.order-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.order-item-row .form-control { min-height: 38px; padding: 6px 8px; font-size: 14px; }
.order-total {
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: #dc2626;
  padding: 10px 0;
}

/* ---------- 详情字段 ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 20px;
}
.detail-item { font-size: 14px; }
.detail-item .k { color: #6b7280; margin-right: 6px; }
.detail-item .v { color: #111; font-weight: 500; }

.footer {
  text-align: center;
  padding: 20px;
  color: #9ca3af;
  font-size: 13px;
}

/* ============================================================
   移动端适配 ( <= 768px )
   ============================================================ */
@media (max-width: 768px) {
  .topbar-inner { height: 52px; padding: 0 12px; }
  .logo { font-size: 16px; margin-right: 0; }

  /* 汉堡菜单 */
  .nav-toggle { display: block; }
  .nav {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: #1e3a5f;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px 14px;
    gap: 2px;
    box-shadow: 0 4px 10px rgba(0,0,0,.2);
  }
  .nav.open { display: flex; }
  .nav a {
    padding: 12px 10px;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .nav-user {
    margin: 8px 0 4px;
    padding: 6px 10px;
    font-size: 13px;
    order: 99;
  }
  .nav-logout { order: 100; }

  .container { padding: 14px 10px 30px; }
  .card { padding: 14px; }
  .card h2 { font-size: 16px; }

  /* 表单触屏友好 */
  .form-control { min-height: 44px; font-size: 16px; }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 15px; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-group { width: 100%; }

  /* 订单明细行改为纵向 */
  .order-item-row {
    grid-template-columns: 1fr 1fr;
  }
  .order-item-row > *:nth-child(5) {
    grid-column: span 2;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .num { font-size: 22px; }

  table.data-table { font-size: 13px; min-width: 560px; }
  table.data-table th, table.data-table td { padding: 8px 10px; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}
