/* 杭州冰工厂 CRM 后台 */
:root {
  --adm-primary: #003366;
  --adm-accent: #1a7ab5;
  --adm-bg: #f0f4f8;
  --adm-border: #d0e3f0;
  --adm-text: #333;
  --adm-muted: #666;
  --adm-danger: #c62828;
  --adm-ok: #2e7d32;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.admin-body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--adm-bg);
  color: var(--adm-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--adm-accent); text-decoration: none; }
a:hover { color: var(--adm-primary); }

.admin-wrap { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 220px;
  background: linear-gradient(180deg, var(--adm-primary), #004080);
  color: #fff;
  flex-shrink: 0;
  padding: 20px 0;
}

.admin-sidebar .brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
}

.admin-sidebar .brand strong { display: block; font-size: 16px; }
.admin-sidebar .brand small { opacity: 0.75; font-size: 12px; }

.admin-nav a {
  display: block;
  padding: 12px 20px;
  color: rgba(255,255,255,0.9);
  border-left: 3px solid transparent;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: rgba(255,255,255,0.1);
  border-left-color: #ffd54f;
  color: #fff;
}

.admin-main { flex: 1; min-width: 0; }

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--adm-border);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-content { padding: 24px; }

.admin-card {
  background: #fff;
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.admin-card h2 {
  font-size: 1.15rem;
  color: var(--adm-primary);
  margin-bottom: 16px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-box {
  background: #fff;
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-box .num {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--adm-accent);
}

.stat-box .lbl { font-size: 13px; color: var(--adm-muted); margin-top: 4px; }

.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.adm-table th,
.adm-table td {
  border: 1px solid var(--adm-border);
  padding: 10px 12px;
  text-align: left;
}

.adm-table th {
  background: #e8f4fc;
  color: var(--adm-primary);
  font-weight: bold;
}

.adm-table tr:hover td { background: #fafcfe; }

.adm-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.adm-form .field label {
  display: block;
  font-size: 13px;
  color: var(--adm-muted);
  margin-bottom: 4px;
}

.adm-form input,
.adm-form select,
.adm-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--adm-border);
  border-radius: 4px;
  font-size: 14px;
}

.adm-form textarea { min-height: 80px; resize: vertical; }

.adm-form .full { grid-column: 1 / -1; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--adm-accent); color: #fff; }
.btn-primary:hover { background: var(--adm-primary); color: #fff; }

.btn-danger { background: var(--adm-danger); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--adm-border); color: var(--adm-text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filter-bar .field { min-width: 140px; }

.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
}

.pagination a,
.pagination span {
  padding: 6px 12px;
  border: 1px solid var(--adm-border);
  border-radius: 4px;
  background: #fff;
}

.pagination .current {
  background: var(--adm-accent);
  color: #fff;
  border-color: var(--adm-accent);
}

.msg-ok { background: #e8f5e9; color: var(--adm-ok); padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; }
.msg-err { background: #ffebee; color: var(--adm-danger); padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #e8f4fc;
  color: var(--adm-primary);
}

.badge-deal { background: #e8f5e9; color: var(--adm-ok); }
.badge-lost { background: #ffebee; color: var(--adm-danger); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--adm-primary), var(--adm-accent));
}

.login-box {
  background: #fff;
  padding: 36px 32px;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-box h1 {
  font-size: 1.25rem;
  color: var(--adm-primary);
  margin-bottom: 8px;
  text-align: center;
}

.login-box p.sub { text-align: center; color: var(--adm-muted); font-size: 13px; margin-bottom: 24px; }

/* 表格容器（桌面横向滚动兜底） */
.adm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.adm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.adm-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.adm-btn-row .btn { min-height: 44px; }

/* 手机端底部快捷栏 */
.admin-mobile-tabs {
  display: none;
}

.adm-menu-btn {
  display: none;
}

.admin-sidebar-overlay {
  display: none;
}

.admin-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.admin-topbar-title {
  font-weight: bold;
  color: var(--adm-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-topbar-time {
  font-size: 13px;
  color: var(--adm-muted);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  body.admin-body {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  }

  body.adm-menu-open { overflow: hidden; }

  .admin-wrap { flex-direction: column; }

  .adm-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--adm-border);
    border-radius: 8px;
    background: #fff;
    color: var(--adm-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  .admin-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
  }

  .admin-sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 400;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-sidebar.open { transform: translateX(0); }

  .admin-nav {
    display: block;
  }

  .admin-nav a {
    padding: 14px 20px;
    font-size: 15px;
    border-left: 3px solid transparent;
    text-align: left;
  }

  .admin-topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .admin-content { padding: 14px; }

  .admin-card {
    padding: 16px;
    margin-bottom: 14px;
  }

  .admin-card h2 { font-size: 1.05rem; margin-bottom: 12px; }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-box { padding: 14px 10px; }
  .stat-box .num { font-size: 1.5rem; }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-bar .field {
    min-width: 0;
    width: 100%;
  }

  .filter-bar .btn,
  .filter-bar a.btn {
    width: 100%;
    min-height: 44px;
    line-height: 28px;
  }

  .adm-form .row { grid-template-columns: 1fr; gap: 12px; }

  .adm-form input,
  .adm-form select,
  .adm-form textarea {
    padding: 12px 10px;
    font-size: 16px;
    min-height: 44px;
  }

  .adm-form textarea { min-height: 100px; }

  .adm-btn-row {
    flex-direction: column;
    align-items: stretch;
  }

  .adm-btn-row .btn {
    width: 100%;
    margin-left: 0 !important;
    padding: 12px 16px;
    font-size: 15px;
  }

  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 15px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .pagination a,
  .pagination span {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
  }

  /* 表格卡片化 */
  .adm-table-wrap .adm-table thead { display: none; }

  .adm-table-wrap .adm-table,
  .adm-table-wrap .adm-table tbody,
  .adm-table-wrap .adm-table tr,
  .adm-table-wrap .adm-table td {
    display: block;
    width: 100%;
  }

  .adm-table-wrap .adm-table tr {
    background: #fff;
    border: 1px solid var(--adm-border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 4px 0;
    overflow: hidden;
  }

  .adm-table-wrap .adm-table tr:hover td { background: transparent; }

  .adm-table-wrap .adm-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border: none;
    border-bottom: 1px dashed #eef4f9;
    padding: 10px 14px;
    text-align: right;
    word-break: break-word;
  }

  .adm-table-wrap .adm-table td:last-child { border-bottom: none; }

  .adm-table-wrap .adm-table td::before {
    content: attr(data-label);
    font-weight: bold;
    color: var(--adm-primary);
    text-align: left;
    flex-shrink: 0;
    max-width: 42%;
    font-size: 13px;
  }

  .adm-table-wrap .adm-table td.adm-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .adm-table-wrap .adm-table td.adm-actions::before {
    margin-bottom: 4px;
    max-width: none;
  }

  .adm-table-wrap .adm-table td.adm-actions .btn {
    width: 100%;
    text-align: center;
  }

  .adm-table-wrap .adm-table td a[href^="tel:"] {
    font-size: 16px;
    font-weight: bold;
  }

  /* 底部快捷导航 */
  .admin-mobile-tabs {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    background: #fff;
    border-top: 1px solid var(--adm-border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0, 51, 102, 0.08);
  }

  .admin-mobile-tabs a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px 10px;
    color: var(--adm-muted);
    font-size: 11px;
    min-height: 56px;
  }

  .admin-mobile-tabs a.active {
    color: var(--adm-accent);
    font-weight: bold;
  }

  .admin-mobile-tabs .tab-ico {
    font-size: 18px;
    line-height: 1;
  }

  .login-page {
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .login-box {
    padding: 28px 22px;
    max-width: 100%;
  }

  .login-box input[type="password"],
  .login-box input[type="text"] {
    font-size: 16px;
    min-height: 48px;
  }
}
