:root {
  --red: #E2231A;
  --red-dark: #B81810;
  --red-soft: #FFF2F1;
  --red-line: #F6C9C5;
  --ink: #1A1614;
  --ink-2: #6B635D;
  --ink-3: #A09890;
  --bg: #F6F4F2;
  --card: #FFFFFF;
  --line: #EAE5E0;
  --green: #127A5B;
  --green-soft: #E6F4EF;
  --amber: #9A6410;
  --amber-soft: #FBF0DA;
  --blue: #1B5EA8;
  --blue-soft: #E9F1FB;
  --gray-soft: #F1EFEC;
  --r: 12px;
  --r-sm: 8px;
  --sh: 0 1px 2px rgba(26, 22, 20, .05);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
input, select, textarea, button { font-family: inherit; font-size: 15px; }

/* ============ 整体布局 ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 14px; border-bottom: 1px solid var(--line); }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--line);
  object-fit: contain; padding: 3px; margin-bottom: 8px;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--ink-3); }

.nav { padding: 10px; flex: 1; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); cursor: pointer; margin-bottom: 2px; font-size: 14.5px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--gray-soft); }
.nav-item.on { background: var(--red-soft); color: var(--red-dark); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 14px; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav-label { font-size: 11.5px; color: var(--ink-3); padding: 6px 12px 4px; letter-spacing: .5px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.user-box { font-size: 13px; }
.user-box .n { font-weight: 600; }
.user-box .r { color: var(--ink-3); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 16.5px; white-space: nowrap; }
.topbar .sp { flex: 1; }
.page { padding: 20px; max-width: 1080px; width: 100%; }

.mode-pill {
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap;
}
.mode-pill.cloud { background: var(--green-soft); color: var(--green); border-color: #BFE3D4; }
.mode-pill.local { background: var(--amber-soft); color: var(--amber); border-color: #F0DDB4; }
.mode-pill.off { background: var(--red-soft); color: var(--red-dark); border-color: var(--red-line); }

/* ============ 离线模式横幅 ============ */
.offline-bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  background: var(--red-soft); border-bottom: 1px solid var(--red-line); color: var(--red-dark);
  position: sticky; top: 58px; z-index: 25;
}
.offline-bar .ob-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.offline-bar .ob-txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; }
.offline-bar .ob-tip { font-size: 12px; color: #9d3b33; font-weight: 400; }
.offline-bar .ob-btn {
  flex: none; background: #fff; border-color: var(--red-line); color: var(--red-dark); font-weight: 500;
}
@media (max-width: 900px) {
  .offline-bar { top: 52px; padding: 8px 12px; gap: 8px; }
  .offline-bar .ob-txt { font-size: 12.5px; }
  .offline-bar .ob-tip { font-size: 11.5px; }
}

/* ============ 移动端 ============ */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-in { display: flex; }
.tab {
  flex: 1; padding: 7px 0 6px; text-align: center; color: var(--ink-3); font-size: 11px;
  border: none; background: none; cursor: pointer; line-height: 1.3;
}
.tab .ti { display: block; font-size: 17px; margin-bottom: 1px; }
.tab.on { color: var(--red); font-weight: 600; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { padding: 0 14px; height: 52px; }
  .page { padding: 14px 12px 84px; }
  .tabbar { display: block; }
  /* 手机端顶栏空间有限：退出走「设置 → 退出登录 / 切换账号」 */
  #btn-out-top { display: none; }
  .topbar .mode-pill { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
}

/* ============ 通用组件 ============ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); margin-bottom: 14px; overflow: hidden; }
.card-hd { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-hd h3 { font-size: 15px; }
.card-hd .sp { flex: 1; }
.card-bd { padding: 16px; }
.card-bd.tight { padding: 8px 16px 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 14.5px; white-space: nowrap; transition: .15s;
}
.btn:hover { background: var(--gray-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger { color: var(--red-dark); border-color: var(--red-line); background: var(--red-soft); }
.btn-danger:hover { background: #FFE3E0; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-sm { padding: 6px 11px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { 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(--ink-3); margin-top: 5px; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); outline: none; transition: .15s;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(226, 35, 26, .09); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .col { flex: 1; min-width: 0; }
.col-2 { flex: 0 0 calc(50% - 6px); min-width: 0; }
.col-3 { flex: 0 0 calc(33.333% - 8px); min-width: 0; }
@media (max-width: 640px) {
  .col-2 { flex: 0 0 100%; }
  .col-3 { flex: 0 0 calc(50% - 6px); }
}

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 20px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13.5px; cursor: pointer; margin: 0 6px 6px 0;
}
.chip:hover { border-color: var(--red-line); }
.chip.on { background: var(--red-soft); border-color: var(--red-line); color: var(--red-dark); font-weight: 500; }
.chip.static { cursor: default; }
.chip .x { color: var(--ink-3); font-size: 13px; }
.chip.on .x { color: var(--red); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; line-height: 1.7; }
.b-gray { background: var(--gray-soft); color: var(--ink-2); }
.b-red { background: var(--red-soft); color: var(--red-dark); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-blue { background: var(--blue-soft); color: var(--blue); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; box-shadow: var(--sh); }
.stat .k { font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.stat .v { font-size: 25px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; }
.stat .u { font-size: 12px; color: var(--ink-3); margin-left: 3px; font-weight: 400; }
.stat.red .v { color: var(--red); }
.stat.green .v { color: var(--green); }

.list { }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: none; }
.li-body { flex: 1; min-width: 0; }
.li-t { font-size: 14.5px; font-weight: 500; }
.li-s { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.li-r { text-align: right; flex: none; }
.li.clickable { cursor: pointer; }
.li.clickable:hover { background: var(--red-soft); }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }
.empty .ei { font-size: 26px; margin-bottom: 8px; opacity: .45; }

.seg { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: none; background: none; padding: 6px 13px; border-radius: 7px; color: var(--ink-2); cursor: pointer; font-size: 13.5px; }
.seg button.on { background: #fff; color: var(--red-dark); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th { text-align: left; padding: 10px 12px; background: var(--gray-soft); color: var(--ink-2); font-weight: 500; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--red-soft); }
table.tbl td.num, table.tbl th.num { text-align: right; }

.bar-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13.5px; }
.bar-wrap .bar-name { width: 92px; flex: none; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 9px; background: var(--gray-soft); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--red); border-radius: 5px; }
.bar-val { width: 84px; flex: none; text-align: right; font-weight: 500; }

/* ============ 弹层 ============ */
.mask { position: fixed; inset: 0; background: rgba(26, 22, 20, .42); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .mask { align-items: center; } }
.sheet {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 700px) { .sheet { border-radius: var(--r); max-height: 88vh; } }
.sheet-hd { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
.sheet-hd h3 { font-size: 15.5px; }
.sheet-hd .sp { flex: 1; }
.sheet-bd { padding: 16px 18px; }
.sheet-ft { padding: 12px 18px 18px; display: flex; gap: 10px; }
.sheet-ft .btn { flex: 1; }

.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: 88px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 900px) { .toast-wrap { bottom: 28px; } }
.toast { background: rgba(26, 22, 20, .92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.18); animation: tin .22s ease; max-width: 82vw; text-align: center; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red-dark); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ 登录 ============ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #FFF6F5 0%, #F6F4F2 46%); }
.login-box { width: 100%; max-width: 400px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 26px 24px; box-shadow: 0 6px 26px rgba(26,22,20,.06); }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .m { width: 76px; height: 76px; border-radius: 16px; display: inline-block; margin-bottom: 10px; object-fit: contain; background: #fff; box-shadow: 0 2px 10px rgba(226,35,26,.10); }
.login-logo h1 { font-size: 19px; }
.login-logo p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.login-card .field:last-of-type { margin-bottom: 18px; }
.login-note { margin-top: 16px; text-align: center; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-2); flex: none; }
.kv .v { text-align: right; font-weight: 500; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }
.muted { color: var(--ink-3); font-size: 13px; }
.small { font-size: 12.5px; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.flex { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }

.timeline-day { margin-bottom: 6px; }
.tl-hd { display: flex; align-items: center; gap: 8px; padding: 10px 2px 6px; }
.tl-date { font-size: 13.5px; font-weight: 600; }
.tl-line { flex: 1; height: 1px; background: var(--line); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 4px; font-size: 12.5px; cursor: pointer; position: relative; overflow: hidden; }
.cal-cell.out { opacity: .35; }
.cal-cell.on { border-color: var(--red); background: var(--red-soft); font-weight: 600; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--red-line); }
.cal-cell .d { line-height: 1.2; }
.cal-cell .dot { position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--red); }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--ink-3); text-align: center; }

.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-grid img { width: 74px; height: 74px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }

.scroll-x { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.scroll-x > * { flex: none; }

/* ============ 图表（charts.js） ============ */
.chart-grid { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap { position: relative; flex: none; }
.donut-wrap svg { display: block; }
.donut-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-c b { font-size: 24px; line-height: 1.1; color: var(--ink); }
.donut-c span { font-size: 11.5px; color: var(--ink-3); }
.legend { flex: 1; min-width: 150px; }
.lg { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.lg .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg .nm { flex: 1; }
.lg .vv { font-weight: 700; }
.lg .pc { color: var(--ink-3); font-size: 12px; width: 42px; text-align: right; }

.gbar { margin-bottom: 12px; }
.gbar:last-child { margin-bottom: 0; }
.gbar-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.gbar-name .sp { flex: 1; }
.gbar-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gbar-line .lb { width: 32px; flex: none; font-size: 12px; color: var(--ink-2); }
.gbar-track { flex: 1; height: 10px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; font-size: 0; }
.gbar-fill { height: 100%; border-radius: 6px; background: var(--red); }
.gbar-val { width: 34px; flex: none; text-align: right; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* 分类标签 */
.cat-tag { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.cat-tag.bath { background: var(--red-soft); color: var(--red-dark); }
.cat-tag.groom { background: var(--amber-soft); color: var(--amber); }

@media (max-width: 520px) {
  .chart-grid { gap: 12px; }
  .legend { min-width: 120px; }
  .gbar-line .lb { width: 28px; }
}

/* ============ 时段占用看板（预约管理） ============ */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; }
.slot {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; padding: 8px 10px; transition: transform .08s ease, box-shadow .12s ease;
}
.slot:active { transform: scale(.97); }
.slot .s-t { font-size: 13px; font-weight: 700; line-height: 1.35; }
.slot .s-n { font-size: 12px; margin-top: 2px; line-height: 1.4; }
.slot .s-p { font-size: 11.5px; margin-top: 3px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.free { border-style: dashed; background: var(--gray-soft); }
.slot.free .s-t { color: var(--ink-2); }
.slot.free .s-n { color: var(--ink-3); }
.slot.free .s-p { color: var(--ink-3); }
.slot.busy { border-color: var(--red-line); background: var(--red-soft); }
.slot.busy .s-t { color: var(--red-dark); }
.slot.busy .s-n { color: var(--red-dark); font-weight: 700; }
.slot.busy .s-p { color: var(--ink-2); }
@media (max-width: 520px) {
  .slot-grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 7px; }
  .slot { padding: 7px 8px; }
  .slot .s-t { font-size: 12.5px; }
}

/* ============ 美容师数据统计（经营报表） ============ */
.op-card { border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 10px; overflow: hidden; }
.op-hd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 12px; cursor: pointer; background: #fff;
}
.op-hd:active { background: var(--gray-soft); }
.op-hd-l { flex: 1; min-width: 130px; }
.op-hd-l b { font-size: 14.5px; }
.op-arrow { font-size: 12.5px; color: var(--red); font-weight: 600; flex: none; }
.op-bd { padding: 0 12px 12px; border-top: 1px solid var(--line); background: #fcfcfd; padding-top: 12px; }
.op-bd .tbl td { white-space: nowrap; }
@media (max-width: 520px) {
  .op-hd { padding: 10px; }
  .op-hd-l b { font-size: 14px; }
  .op-bd { padding: 10px 10px 12px; }
}
