:root {
  --blue: #1F6FEB;
  --blue-dark: #185ABD;
  --blue-soft: #EFF6FF;
  --green: #16A34A;
  --orange: #D97706;
  --red: #DC2626;
  --purple: #7C3AED;
  --ink: #1E293B;
  --ink-2: #475569;
  --muted: #94A3B8;
  --line: #E8EEF7;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 8px 24px rgba(16, 30, 54, .06);
  --sidebar-w: 236px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; background: #EEF2F7; color: var(--ink-2);
  transition: filter .15s ease; white-space: nowrap;
}
.btn:active { filter: brightness(.95); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-size: 14px; font-family: inherit;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 111, 235, .18); border-color: var(--blue); }
input[type=date] { padding-right: 8px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: auto; min-height: 0; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-logo {
  width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg, var(--blue), #4C9AFF);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0;
}
.login-logo.small { width: 38px; height: 38px; border-radius: 11px; font-size: 13px; }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--muted); }
.login-error { background: #FEF2F2; color: var(--red); border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.login-remember { margin: 0 0 14px; font-size: 13px; color: var(--ink-2); }

/* ---------- 布局 ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  height: 54px; padding: 0 10px; background: #fff; border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-title { flex: 1; font-size: 16px; font-weight: 600; text-align: center; }
.topbar-right { display: flex; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent;
  color: var(--ink-2); font-size: 17px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: #F1F5F9; }

.view { padding: 14px 12px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-item {
  flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer;
}
.tabbar-item .ti-icon { font-size: 19px; line-height: 1; }
.tabbar-item.active { color: var(--blue); font-weight: 600; }

.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60; }

/* ---------- 卡片 / 列表 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); }
.section-title { font-size: 14px; font-weight: 700; margin: 18px 0 10px; }

.grid { display: grid; gap: 12px; }
.grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar > * { flex: 1 1 140px; min-width: 0; }
.toolbar .btn { flex: 0 0 auto; }

/* 快捷区间分段按钮 */
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.seg-item {
  flex: 1 1 auto; min-width: 82px; text-align: center; padding: 9px 12px;
  border: none; border-radius: 10px; background: #F1F5F9; color: var(--ink-2);
  font-size: 14px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.seg-item:active { filter: brightness(.96); }
.seg-item.active { background: var(--blue); color: #fff; font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px; }
.row-card.clickable { cursor: pointer; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-title { font-weight: 700; font-size: 15px; word-break: break-all; }
.row-meta { font-size: 13px; color: var(--ink-2); margin-top: 5px; }
.row-meta .k { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; background: #EEF2F7; color: var(--ink-2); white-space: nowrap; flex-shrink: 0; }
.tag-blue { background: rgba(31,111,235,.1); color: var(--blue); }
.tag-green { background: rgba(22,163,74,.12); color: var(--green); }
.tag-orange { background: rgba(217,119,6,.12); color: var(--orange); }
.tag-red { background: rgba(220,38,38,.1); color: var(--red); }
.tag-purple { background: rgba(124,58,237,.12); color: var(--purple); }
.tag-gray { background: #F1F5F9; color: var(--muted); }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }

/* 桌面表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.data td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; background: #FAFBFE; white-space: nowrap; }
/* 单元格内容不折行：列多时让表格横向滚动，而不是把「羽毛球 / 在售 / 免服务费」挤成两三行 */
table.data td { white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 趋势矩阵表：任何屏幕都保持表格形态，横向滚动 */
table.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
table.matrix th, table.matrix td {
  padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap;
}
table.matrix th:first-child, table.matrix td:first-child {
  text-align: left; position: sticky; left: 0; background: #fff; z-index: 1;
}
table.matrix thead th { background: #FAFBFE; color: var(--muted); font-weight: 600; }
table.matrix thead th:first-child { background: #FAFBFE; }
table.matrix tbody tr:last-child td { border-bottom: none; }

/* 详情 */
.detail-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-k { flex: 0 0 96px; color: var(--muted); }
.detail-v { flex: 1; word-break: break-word; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 10px; cursor: zoom-in; border: 1px solid var(--line); }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline-item { border-left: 2px solid var(--blue-soft); padding-left: 10px; }
.t-title { font-size: 13px; }
.t-time { font-size: 12px; color: var(--muted); }

/* 表单网格 */
.form-grid { display: grid; gap: 12px; }
.form-grid.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }

/* 图片预览 */
.image-mask { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 95; display: flex; align-items: center; justify-content: center; padding: 16px; }
.image-mask img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(15,23,42,.92); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  z-index: 120; max-width: 86vw; text-align: center;
}
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.5); z-index: 110; }
.loading .spinner { width: 26px; height: 26px; border: 3px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bar { height: 8px; border-radius: 5px; background: #EEF2F7; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); }
.bar > i.green { background: var(--green); }
.bar > i.purple { background: var(--purple); }
.bar > i.orange { background: var(--orange); }
.bar > i.red { background: var(--red); }

/* 下单时段逐小时明细 */
.hour-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hour-cell { background: #F8FAFC; border-radius: 10px; padding: 8px 4px; text-align: center; }
.hour-cell .hc-h { display: block; font-size: 11px; color: var(--muted); }
.hour-cell .hc-n { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; }
.hour-cell .hc-p { display: block; font-size: 11px; color: var(--muted); }
.hour-cell.zero { opacity: .42; }
@media (min-width: 900px) {
  .hour-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
.kv-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }

/* 窄屏：表格转卡片 */
@media (max-width: 899px) {
  table.data, table.data thead, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data { background: transparent; }
  table.data thead { display: none; }
  table.data tr {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 13px; margin-bottom: 10px;
  }
  table.data td { border: none; padding: 3px 0; display: flex; gap: 10px; }
  /* 卡片式布局宽度充足，长内容（备注、地址等）恢复自动换行 */
  table.data td { white-space: normal; }
  table.data td::before {
    content: attr(data-label); flex: 0 0 84px; color: var(--muted); font-size: 13px;
  }
  table.data td.cell-actions { margin-top: 8px; }
  table.data td.cell-actions::before { content: ''; flex: 0 0 0; }
}

/* ---------- 桌面端 ---------- */
@media (min-width: 900px) {
  .shell { display: flex; }
  .sidebar {
    display: flex; flex-direction: column; width: var(--sidebar-w); flex-shrink: 0;
    background: #fff; border-right: 1px solid var(--line);
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--line); }
  .sidebar-title { font-size: 15px; font-weight: 700; }
  .sidebar-sub { font-size: 12px; color: var(--muted); }
  .nav-list { flex: 1; overflow-y: auto; padding: 10px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin-bottom: 2px;
    border: none; background: none; border-radius: 10px; font-size: 14px; color: var(--ink-2);
    cursor: pointer; text-align: left;
  }
  .nav-item:hover { background: #F5F8FE; }
  .nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
  .nav-item.parent-active { color: var(--blue); font-weight: 600; }
  .nav-item .ni-icon { width: 18px; text-align: center; }
  .nav-item .ni-caret { margin-left: auto; font-size: 12px; color: var(--muted); }
  .nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 0 0 6px 28px; }
  .nav-subitem {
    text-align: left; border: none; background: none; padding: 7px 10px; border-radius: 8px;
    font-size: 13px; color: var(--ink-2); cursor: pointer; font-family: inherit;
  }
  .nav-subitem:hover { background: #F5F8FE; }
  .nav-subitem.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
  .sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }

  .main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
  .topbar { padding: 0 20px; height: 60px; }
  .topbar-title { text-align: left; font-size: 18px; }
  #menuBtn { display: none; }
  .tabbar { display: none; }
  .drawer-mask { display: none !important; }
  .view { padding: 18px 20px 40px; }
  .grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal-mask { align-items: center; }
  .modal { max-width: 680px; border-radius: 16px; max-height: 88vh; }
  .modal-foot .btn { flex: 0 0 auto; min-width: 108px; margin-left: auto; }
  .modal-foot { justify-content: flex-end; }
  .form-grid.cols { gap: 14px; }
}

@media (max-width: 899px) {
  .sidebar {
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: 260px;
    background: #fff; z-index: 70; transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
  .sidebar-title { font-size: 15px; font-weight: 700; }
  .sidebar-sub { font-size: 12px; color: var(--muted); }
  .nav-list { flex: 1; overflow-y: auto; padding: 8px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; margin-bottom: 2px;
    border: none; background: none; border-radius: 10px; font-size: 15px; color: var(--ink-2); cursor: pointer; text-align: left;
  }
  .nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
  .nav-item.parent-active { color: var(--blue); font-weight: 600; }
  .nav-item .ni-icon { width: 18px; text-align: center; }
  .nav-item .ni-caret { margin-left: auto; font-size: 12px; color: var(--muted); }
  .nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 0 0 6px 28px; }
  .nav-subitem {
    text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 8px;
    font-size: 14px; color: var(--ink-2); cursor: pointer; font-family: inherit;
  }
  .nav-subitem.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
  .sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
  .form-grid.cols { grid-template-columns: 1fr; }
}
/* ===== 投诉对话 ===== */
.cp-thread {
  max-height: 300px;
  overflow-y: auto;
  padding: 10px 12px;
  background: #F6F8FB;
  border-radius: 10px;
}
.cp-info {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.cp-info-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cp-info-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.cp-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 10px;
}
.cp-msg.mine { align-items: flex-end; }
.cp-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(16, 30, 54, .06);
}
.cp-msg.mine .cp-bubble { background: var(--blue); color: #fff; }
.cp-meta { margin-top: 3px; font-size: 11px; color: var(--muted); }
/* 回复模板快捷按钮 */
.cp-tpl { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.cp-tpl-btn {
  border: 1px solid var(--line);
  background: #F8FAFF;
  color: var(--blue);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.cp-tpl-btn:hover { background: #EAF2FE; }

/* 二级菜单：可收起 / 展开（点击带子菜单的一级菜单切换） */
.nav-item .ni-caret {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  display: inline-block;
  transition: transform .18s ease;
  transform: rotate(90deg);   /* 展开时朝下 */
}
.nav-item .ni-caret.collapsed {
  transform: rotate(0deg);    /* 收起时朝右 */
}
.nav-sub.collapsed {
  display: none;
}
