/* ============================================================
   摆烂申请办 管理后台样式
   布局：顶栏（上） + 左侧栏（左） + 内容区（右下）
   适配：桌面浏览器 / 平板 / 手机（侧栏自动变抽屉）
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #c0392b;
  --red-dark: #a93226;
  --red-light: #fdf0ee;
  --text: #333;
  --text-sub: #888;
  --line: #f0f0f0;
  --line-2: #e8e8e8;
  --bg: #f5f6f8;
  --card: #fff;
  --radius: 10px;
  --topbar-h: 56px;
  --sidebar-w: 218px;
  --shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
               'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; }
code { background: #f6f2f1; border-radius: 4px; padding: 1px 6px; font-size: 12px; color: var(--red-dark); word-break: break-all; }

/* ============================================================
   外层布局
   ============================================================ */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.body-row { flex: 1; display: flex; align-items: flex-start; }

/* ============================================================
   顶部栏（上方）
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(160, 40, 30, .22);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { color: #fff; opacity: .92; }
.brand-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.brand-short { display: none; }
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  padding-left: 12px;
  margin-left: 2px;
  border-left: 1px solid rgba(255, 255, 255, .28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-name {
  font-size: 13px;
  color: rgba(255, 255, 255, .92);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-link {
  font-size: 13px;
  color: rgba(255, 255, 255, .88);
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar-link:hover { background: rgba(255, 255, 255, .18); color: #fff; }

/* 汉堡按钮（移动端显示） */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, .16);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle span {
  display: block;
  width: 20px; height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform .2s, opacity .2s;
}
.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
/* BLOCK1 */

/* ============================================================
   左侧导航栏
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  border-right: 1px solid rgba(0, 0, 0, .06);
  box-shadow: 2px 0 14px rgba(160, 40, 30, .16);
  padding: 14px 0 24px;
}
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  padding: 10px 18px 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, .72);
  letter-spacing: .5px;
}
.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  color: rgba(255, 255, 255, .9);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar .nav a:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.sidebar .nav a.active {
  background: #fff;
  color: var(--red);
  font-weight: 600;
  border-left-color: #fff;
}
.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: .9;
  flex-shrink: 0;
}
.sidebar-foot {
  margin-top: 14px;
  padding: 14px 18px 0;
  border-top: 1px solid rgba(255, 255, 255, .22);
  font-size: 12px;
  color: rgba(255, 255, 255, .72);
}
.sidebar-foot .admin-name {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-foot a { color: #fff; text-decoration: underline; }

/* 抽屉遮罩（移动端） */
.sidebar-mask {
  display: none;
  position: fixed;
  top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .38);
  z-index: 70;
}
.sidebar-mask.show { display: block; }

/* ============================================================
   内容区
   ============================================================ */
.main { flex: 1; min-width: 0; }
.page-head {
  background: var(--card);
  border-bottom: 1px solid var(--line-2);
  padding: 16px 20px;
}
.page-head-inner {
  max-width: 1680px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.page-title { font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.page-desc { color: var(--text-sub); font-size: 13px; margin-top: 4px; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.container { max-width: 1680px; margin: 0; padding: 18px 20px 8px; }

/* ============================================================
   TAB 页签
   ============================================================ */
.tabs-wrap { margin-bottom: 4px; }
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: #666;
  padding: 10px 16px;
  min-height: 42px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--red); }
.tab.active { color: var(--red); font-weight: 600; border-bottom-color: var(--red); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: tabFade .18s ease; }
@keyframes tabFade { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* 卡片内的页签（更紧凑） */
.card .tabs { margin: -4px 0 14px; }
.card .tab { padding: 8px 14px; font-size: 13px; min-height: 38px; }

/* 筛选页签（行内胶囊） */
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-tabs a {
  font-size: 13px;
  color: #555;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 5px 14px;
  white-space: nowrap;
}
.filter-tabs a:hover { border-color: var(--red); color: var(--red); }
.filter-tabs a.active { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
/* BLOCK2 */

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
}
.card-body { padding: 18px; }
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-form .input { width: 220px; max-width: 100%; padding: 6px 12px; }

/* ============================================================
   统计卡片
   ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 15px 18px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--red);
}
.stat .num { font-size: 26px; font-weight: 700; color: var(--red); line-height: 1.2; }
.stat .label { font-size: 13px; color: var(--text-sub); margin-top: 2px; }

/* ============================================================
   表格（窄屏横向滚动）
   ============================================================ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; min-width: 760px; border-collapse: collapse; }
table.table th, table.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
table.table th {
  background: #fafafa;
  color: #666;
  font-weight: 600;
  white-space: nowrap;
}
table.table tbody tr:hover td { background: #fcf7f6; }
table.table tbody tr:last-child td { border-bottom: none; }
.cell-main { max-width: 340px; word-break: break-all; }
.cell-sub { color: #999; font-size: 12px; margin-top: 4px; }

/* ============================================================
   标签
   ============================================================ */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  line-height: 1.6;
}
.tag-red { background: #fdecea; color: var(--red); }
.tag-green { background: #e6f4ea; color: #1e8e3e; }
.tag-orange { background: #fff7e6; color: #d48806; }
.tag-gray { background: #f0f0f0; color: #666; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid #e3e3e3;
  background: #fff;
  color: #555;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  transition: border-color .15s, color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--red); color: var(--red); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #e5b7b1; color: var(--red); }
.btn-danger:hover { background: #fdecea; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ============================================================
   表单
   ============================================================ */
.form-row { margin-bottom: 18px; }
.form-row:last-child { margin-bottom: 0; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-row .desc { color: var(--text-sub); font-size: 12px; font-weight: 400; margin-left: 6px; }
.form-tip { color: var(--text-sub); font-size: 12px; margin-top: 6px; line-height: 1.7; }
.input, .textarea, .select {
  width: 100%;
  max-width: 520px;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.textarea { min-height: 88px; max-width: 640px; resize: vertical; }
.select {
  max-width: 320px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, .12);
}
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.checkbox-line input { width: 18px; height: 18px; accent-color: var(--red); flex-shrink: 0; margin-top: 2px; }
/* 勾选项后的说明文字允许换行，避免窄屏把布局撑破 */
.checkbox-line .desc { margin-left: 0; flex: 1 1 auto; min-width: 0; line-height: 1.7; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
/* 按钮行尾随说明：可换行收缩，不与按钮挤在一行 */
.form-actions .desc { flex: 0 1 auto; min-width: 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row .form-tip { margin-top: 4px; }

/* ============================================================
   提示条 / 分页 / 详情
   ============================================================ */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; line-height: 1.7; }
.alert-success { background: #e6f4ea; color: #1e8e3e; border: 1px solid #b7e4c7; }
.alert-error { background: #fdecea; color: var(--red); border: 1px solid #f5c6c0; }
.alert-info { background: #eaf2fb; color: #2d6da4; border: 1px solid #c5ddf2; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 14px 18px; }
.pagination a, .pagination span {
  min-width: 34px; min-height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  background: #fff;
}
.pagination .current { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.pagination .total { border: none; background: none; color: var(--text-sub); }

.detail-grid { display: grid; grid-template-columns: 120px 1fr; gap: 12px 18px; }
.detail-grid dt { color: var(--text-sub); white-space: nowrap; }
.detail-grid dd { word-break: break-all; }
.comment-item, .order-item { padding: 12px 0; border-bottom: 1px dashed #eee; }
.comment-item:last-child, .order-item:last-child { border-bottom: none; }

/* ============================================================
   登录页
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, var(--red) 0%, #7b241c 100%);
}
.login-box {
  width: min(380px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.login-box h1 { font-size: 21px; text-align: center; color: var(--red); margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--text-sub); font-size: 13px; margin-bottom: 24px; }
.login-box .btn-primary { width: 100%; min-height: 44px; font-size: 15px; }

/* ============================================================
   页脚
   ============================================================ */
.footer {
  text-align: center;
  color: #b3b3b3;
  font-size: 12px;
  padding: 18px 16px calc(26px + env(safe-area-inset-bottom));
  line-height: 1.6;
}
/* BLOCK3 */

/* ============================================================
   响应式：平板（侧栏收窄）
   ============================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 190px; }
  .container { padding: 16px 14px 8px; }
  .cell-main { max-width: 260px; }
}

/* ============================================================
   响应式：手机（侧栏变抽屉）
   ============================================================ */
@media (max-width: 900px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .nav-toggle { display: flex; }
  .user-name { display: none; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 250px;
    height: auto;
    transform: translateX(-100%);
    transition: transform .24s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, .12);
    z-index: 75;
  }
  .sidebar.open { transform: none; }
  .sidebar .nav a { padding: 13px 18px; font-size: 15px; }

  .topbar-title { font-size: 14px; }
  .page-head { padding: 13px 14px; }
  .page-title { font-size: 17px; }
  .container { padding: 14px 12px 8px; }
  .card { border-radius: 12px; margin-bottom: 12px; }
  .card-header { padding: 12px 14px; font-size: 14px; }
  .card-body { padding: 14px; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px; border-left-width: 3px; }
  .stat .num { font-size: 22px; }

  .input, .textarea, .select { max-width: 100%; font-size: 15px; padding: 11px 12px; }
  .btn { min-height: 42px; padding: 8px 16px; font-size: 14px; }
  .btn-sm { min-height: 38px; padding: 7px 13px; font-size: 13px; }
  .form-actions .btn { flex: 1 1 auto; }
  .tab { padding: 10px 13px; font-size: 14px; }

  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { margin-top: 12px; font-weight: 600; }
  .detail-grid dd { margin-bottom: 2px; }

  .pagination { padding: 12px 14px; }
  .pagination a, .pagination span { min-width: 38px; min-height: 38px; }
}

/* ============================================================
   响应式：窄屏手机 / 小平板（≤560px）
   —— 断点取 560 而非 480，避免 490~560px 视口顶栏挤爆
   ============================================================ */
@media (max-width: 560px) {
  /* 顶栏：品牌 + 账号操作（页面标题已在页面头显示，避免重复占位） */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-title { display: none; }
  .topbar-link.hide-xs { display: none; }
  .topbar-link { padding: 6px 8px; font-size: 12px; }

  /* 页面头：标题与操作按钮竖排，按钮铺满 */
  .page-head-inner { flex-direction: column; align-items: stretch; }
  .page-head-actions .btn { flex: 1 1 auto; }

  /* 按钮区：说明文字独占一行，避免被裁切 */
  .form-actions { gap: 8px; }
  .form-actions .btn { flex: 1 1 auto; }
  .form-actions .desc { flex: 1 1 100%; min-width: 0; }

  /* 卡片头：竖排，搜索框铺满 */
  .card-header { flex-direction: column; align-items: stretch; }
  .card-header .search-form { width: 100%; }
  .card-header .search-form .input { width: 100%; }
  .card-header .search-form .btn { flex: 1; }

  .filter-tabs a { padding: 6px 12px; }
  .form-tip { font-size: 11px; }
}

/* 打印优化 */
@media print {
  .topbar, .sidebar, .sidebar-mask, .footer, .pagination, .btn, .tabs { display: none !important; }
  body, .layout, .body-row { display: block; background: #fff; }
  .card { box-shadow: none; border: 1px solid #eee; }
  .tab-panel { display: block !important; }
}

