:root {
  --brand: #3b82f6;
  --brand-dark: #2563eb;
  --brand-soft: #e8f1fc;
  --bg: #f5f8fc;
  --panel: #ffffff;
  --text: #1f2329;
  --text-sub: #8a8f99;
  --line: #e4e9f0;
  --ok: #2ea36b;
  --warn: #e8a33d;
  --danger: #d6443c;
  --shadow: 0 2px 10px rgba(20, 24, 35, 0.06);
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #e9eaee;            /* 宽屏时作为「手机外」底色 */
  color: var(--text);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-behavior: smooth; }

/* 全站作为一个居中的手机宽度容器（窄屏自动铺满） */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, .08);
}

/* ---------- 底部固定标签栏（替代桌面侧边栏） ---------- */
.sidebar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: row;
  padding: 5px 2px calc(5px + env(safe-area-inset-bottom));
  background: #1f1d22;
  z-index: 50;
  border-top: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .18);
  flex-shrink: 0;
}
.brand, .store-card { display: none; }   /* 手机端不需要侧边品牌/门店卡 */

.nav {
  display: flex;
  flex-direction: row;
  width: 100%;
  gap: 0;
  justify-content: space-around;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: 1 1 0;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #c9c9d0;
  padding: 7px 2px;
  font-size: 11px;
  line-height: 1.2;
  min-height: 54px;
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  transition: .15s;
}
.nav-item .ico { font-size: 19px; }
.nav-item:active { background: rgba(255, 255, 255, .06); }
.nav-item.active { background: transparent; color: var(--brand); }
.nav-item.active::after {
  content: "";
  position: absolute; top: 0; left: 28%; right: 28%;
  height: 3px; border-radius: 0 0 3px 3px;
  background: var(--brand);
}

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; gap: 8px; flex-wrap: wrap;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.view-desc { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-switch { font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; }
.role-switch select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; background: #fff; color: var(--text); cursor: pointer;
}
.employee-select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; background: #fff; color: var(--text); cursor: pointer;
  max-width: 96px;
}
.view { padding: 16px 14px 90px; }
.hidden { display: none !important; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi-grid.small { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
/* 第一个 KPI 做成整行蓝色主卡（今日营业额） */
.kpi-grid > .kpi:first-child {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff; border-color: transparent;
}
.kpi-grid > .kpi:first-child .k-label { color: rgba(255, 255, 255, .85); }
.kpi-grid > .kpi:first-child .k-value { font-size: 30px; }
.kpi-grid > .kpi:first-child .k-value .unit { color: rgba(255, 255, 255, .8); }
.kpi-grid > .kpi:first-child .k-trend { color: rgba(255, 255, 255, .92) !important; }
.kpi {
  background: var(--panel); border-radius: 14px; padding: 13px 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.kpi .k-label { font-size: 13px; color: var(--text-sub); }
.kpi .k-value { font-size: 21px; font-weight: 700; margin-top: 8px; }
.kpi .k-value .unit { font-size: 14px; font-weight: 500; color: var(--text-sub); margin-left: 2px; }
.kpi .k-trend { font-size: 12px; margin-top: 6px; }
.k-trend.up { color: var(--ok); }
.k-trend.down { color: var(--danger); }

/* ---------- 面板 ---------- */
.panel-row { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
.panel {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden; margin-top: 14px;
}
.panel-row .panel { margin-top: 0; }
.panel-head { padding: 14px 16px 0; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-body { padding: 14px 16px 16px; }
.chart-box { position: relative; width: 100%; height: 220px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

/* ---------- 提醒 ---------- */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.alert-item:last-child { border-bottom: none; }
.alert-tag { font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; flex-shrink: 0; }
.alert-tag.warn { background: #fdf1e1; color: var(--warn); }
.alert-tag.danger { background: #fbe7e6; color: var(--danger); }
.alert-tag.info { background: var(--brand-soft); color: var(--brand); }
.alert-text { font-size: 13px; line-height: 1.5; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.week-label { font-size: 14px; font-weight: 600; color: var(--text); }
.btn {
  background: var(--brand); color: #fff; border: none; border-radius: 9px;
  padding: 9px 16px; font-size: 13px; cursor: pointer; transition: .15s;
}
.btn:hover { background: var(--brand-dark); }
.search {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 14px;
  font-size: 13px; width: 100%; background: #fff;
}
.search:focus { outline: none; border-color: var(--brand); }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; min-width: 540px; }
.tbl th, .tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
.tbl th { background: #fafbfc; color: var(--text-sub); font-weight: 600; white-space: nowrap; }
.tbl tbody tr:hover { background: #fafbfc; }
.tbl tbody tr:last-child td { border-bottom: none; }
.status { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.status.ok { background: #e6f6ee; color: var(--ok); }
.status.warn { background: #fdf1e1; color: var(--warn); }
.status.danger { background: #fbe7e6; color: var(--danger); }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 考勤 ---------- */
.schedule-grid {
  display: grid; grid-template-columns: 64px repeat(7, 1fr); gap: 6px;
  padding: 10px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.panel-body.no-pad { padding: 0; }
.schedule-head { padding: 12px 16px; }
.schedule-head .toolbar { margin-bottom: 0; }
.sch-cell { min-width: 64px; border-radius: 9px; padding: 6px; min-height: 56px; }
.sch-head { background: #f5f8fc; font-weight: 600; font-size: 12px; text-align: center; display: flex; align-items: center; justify-content: center; }
.sch-rowlabel { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-sub); }
.sch-rowlabel.name { font-weight: 600; color: var(--text); }
.sch-shift { background: var(--brand-soft); border-radius: 7px; padding: 6px 4px; font-size: 11px; line-height: 1.35; color: var(--brand-dark); text-align: center; }
.sch-shift.off { background: #f1f2f4; color: var(--text-sub); }

.today-shift-panel { margin-top: 0; }
.today-card {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  border-radius: 14px; padding: 18px; color: #fff; text-align: center;
}
.today-emp { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.today-shift {
  display: inline-block; background: rgba(255,255,255,.2);
  border-radius: 20px; padding: 8px 24px; font-size: 22px; font-weight: 700;
}
.today-shift.off { background: rgba(255,255,255,.15); opacity: .85; }
.today-break {
  margin-top: 10px; font-size: 12px; color: rgba(255,255,255,.92);
  background: rgba(255,255,255,.18); border-radius: 20px;
  padding: 5px 14px; display: block; margin-left: auto; margin-right: auto; width: fit-content;
}

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  text-align: center;
}
.cal-weekday {
  font-size: 11px; font-weight: 600; color: var(--text-sub);
  padding: 6px 0;
}
.cal-cell {
  min-height: 46px; border-radius: 10px; padding: 7px 4px;
  background: #f5f8fc; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: .12s;
}
.cal-cell:active { background: #e4eefc; }
.cal-cell.today { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.cal-cell.cal-empty { background: transparent; cursor: default; }
.cal-day { font-size: 13px; line-height: 1; }
.cal-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #ef4444; margin-top: 5px;
}
.calendar-detail {
  margin-top: 14px; padding: 12px 16px;
  background: var(--brand-soft); border-radius: 12px;
  text-align: center; font-size: 14px; line-height: 1.6;
  color: var(--text);
}
.calendar-detail.hidden { display: none; }

.hours-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hours-stat {
  background: #f5f8fc; border-radius: 12px; padding: 14px 10px;
  text-align: center;
}
.hours-stat-label { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.hours-stat-value { font-size: 22px; font-weight: 700; color: var(--brand); }
.hours-stat-unit { font-size: 12px; color: var(--text-sub); margin-left: 2px; }

/* ---------- 清洁任务 ---------- */
.clean-list { display: flex; flex-direction: column; gap: 12px; }
.clean-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
  padding: 13px 14px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.clean-check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line);
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; transition: .15s;
}
.clean-check.done { background: var(--ok); border-color: var(--ok); }
.clean-main { flex: 1; min-width: 0; }
.clean-title { font-size: 14px; font-weight: 600; }
.clean-title.done { text-decoration: line-through; color: var(--text-sub); }
.clean-meta { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.clean-prio { font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; flex-shrink: 0; }
.clean-prio.high { background: #fbe7e6; color: var(--danger); }
.clean-prio.mid { background: #fdf1e1; color: var(--warn); }
.clean-prio.low { background: #e6f0fa; color: #3a78c2; }

/* ---------- 超小屏微调 ---------- */
@media (max-width: 380px) {
  .nav-item { min-width: 54px; font-size: 10px; }
  .topbar h1 { font-size: 16px; }
  .kpi .k-value { font-size: 19px; }
  .kpi-grid > .kpi:first-child .k-value { font-size: 26px; }
  .chart-box { height: 200px; }
  .tbl { min-width: 480px; }
}
