/* 许贵班线记账 App —— 浅色主题 */
:root {
  --surface: #fcfcfb;
  --page: #f4f4f1;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --line: #c3c2b7;
  --border: rgba(11, 11, 11, 0.08);
  --blue: #2a78d6;
  --blue-dk: #1c5cab;
  --blue-bg: #e8f1fc;
  --aqua: #1baf7a;
  --yellow: #eda100;
  --violet: #4a3aa7;
  --red: #e34948;
  --orange: #eb6834;
  --good: #006300;
  --good-bg: #e9f3e9;
  --crit: #d03b3b;
  --crit-bg: #fbe9e9;
  --radius: 16px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ── 顶栏 ── */
header.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(252, 252, 251, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grid);
  padding: calc(10px + env(safe-area-inset-top, 0)) 16px 8px;
}
.topbar .title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.role-chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.role-chips::-webkit-scrollbar { display: none; }
.role-chip {
  flex: none; border: 1px solid var(--grid); border-radius: 999px;
  padding: 3px 12px; font-size: 12.5px; color: var(--ink2);
  background: var(--surface); cursor: pointer; user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.role-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* ── 主区 ── */
main#screen { flex: 1; padding: 16px 16px 88px; overflow-x: hidden; }
.screen-in { animation: rise .3s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.screen-title { font-size: 16px; font-weight: 750; margin: 2px 0 14px; letter-spacing: -0.2px; }
.screen-title small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; letter-spacing: 0; }

/* ── 底部导航 ── */
nav.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 30;
  display: flex; background: rgba(252, 252, 251, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--grid);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1; text-align: center; padding: 8px 0 9px; cursor: pointer;
  color: var(--muted); font-size: 11px; user-select: none;
  transition: color .15s;
}
.tab .ico { display: block; font-size: 20px; line-height: 1.2; transition: transform .18s; }
.tab.active { color: var(--blue); font-weight: 600; }
.tab.active .ico { transform: translateY(-1px) scale(1.06); }
.tab:active .ico { transform: scale(.9); }

/* ── 卡片 ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
  min-width: 0;
}
.card h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 12px; color: var(--ink); display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.card h3 .tag { font-weight: 400; color: var(--muted); font-size: 11.5px; }

/* 分段切换（图表周期） */
.seg { display: inline-flex; background: var(--page); border-radius: 999px; padding: 2px; margin-left: auto; }
.seg-btn {
  border-radius: 999px; padding: 2px 10px; font-size: 11px; color: var(--muted);
  cursor: pointer; user-select: none; transition: all .15s; font-weight: 500;
}
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: 0 1px 2px rgba(11,11,11,.08); }

/* 班次卡片 */
.trip-card { display: flex; align-items: center; gap: 12px; cursor: pointer; transition: transform .12s; }
.trip-card:active { transform: scale(.985); }
.trip-card .when { flex: none; text-align: center; width: 54px; }
.trip-card .when .t { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trip-card .when .s { font-size: 11px; color: var(--muted); }
.trip-card .mid { flex: 1; min-width: 0; }
.trip-card .dir { font-size: 15px; font-weight: 600; }
.trip-card .who { font-size: 12px; color: var(--ink2); margin-top: 2px; }
.trip-card .stat { flex: none; text-align: right; }
.trip-card .stat .n { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trip-card .stat .m { font-size: 11.5px; color: var(--muted); }
.trip-card.pending .stat .n { color: var(--yellow); font-size: 13px; }
.trip-card.canceled { opacity: .55; }
.trip-card.canceled .dir { text-decoration: line-through; }
.badge {
  display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  vertical-align: 2px; margin-left: 6px; font-weight: 600;
}
.badge.extra { background: #fdf1dc; color: #8a5c00; }
.badge.round { background: var(--blue-bg); color: var(--blue-dk); }
.badge.stop { background: var(--crit-bg); color: var(--crit); }
.badge.unsplit { background: #efeee9; color: var(--ink2); }

/* ── 统计瓦片 ── */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
  min-width: 0; overflow: hidden;
}
.tile .lbl { font-size: 11.5px; color: var(--muted); letter-spacing: 0.2px; }
.tile .val {
  font-size: clamp(17px, 5.8vw, 24px);
  font-weight: 750; margin-top: 3px; letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tiles.three .tile .val { font-size: clamp(14px, 4.4vw, 18px); }
.tile .val small { font-size: 0.58em; font-weight: 500; color: var(--ink2); }
.tile .delta {
  display: inline-block; font-size: 10.5px; margin-top: 5px; color: var(--muted);
  background: var(--page); border-radius: 999px; padding: 1px 8px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .delta.up { color: var(--good); background: var(--good-bg); }
.tile .delta.down { color: var(--crit); background: var(--crit-bg); }

/* ── 图表 ── */
.chart-wrap { position: relative; width: 100%; min-width: 0; }
.legend-list { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; min-width: 0; }
.legend-list .li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-list .nm { color: var(--ink2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .vv { font-weight: 650; font-variant-numeric: tabular-nums; flex: none; }
.legend-list .pp { color: var(--muted); font-size: 11px; width: 36px; text-align: right; flex: none; }
.donut-row { display: flex; align-items: center; gap: 18px; }
.donut-row .chart-wrap { width: 128px; flex: none; }

/* 日历热力图 */
.heatmap { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.heatmap .hd { text-align: center; font-size: 10.5px; color: var(--muted); padding: 2px 0; }
.hm-cell {
  aspect-ratio: 1; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-variant-numeric: tabular-nums; border: 1px solid transparent;
  cursor: pointer; position: relative; min-width: 0;
  transition: transform .12s;
}
.hm-cell:active { transform: scale(.9); }
.hm-cell.empty { background: transparent; cursor: default; }
.hm-cell.zero { background: var(--surface); border-color: var(--grid); color: var(--muted); }
.hm-cell.td { outline: 2px solid var(--blue); outline-offset: 1px; }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 10.5px; color: var(--muted); justify-content: flex-end; }
.hm-legend .sw { width: 14px; height: 9px; border-radius: 2px; }

/* ── 日历（排班） ── */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .hd { text-align: center; font-size: 10.5px; color: var(--muted); padding: 2px 0; }
.cal-cell {
  min-height: 46px; border-radius: 9px; border: 1px solid var(--grid);
  background: var(--surface); padding: 3px 4px; font-size: 10.5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px; overflow: hidden; min-width: 0;
  transition: transform .12s;
}
.cal-cell:active { transform: scale(.94); }
.cal-cell.empty { border-color: transparent; background: transparent; cursor: default; }
.cal-cell .d { font-size: 11px; font-weight: 600; }
.cal-cell.today { border-color: var(--blue); border-width: 1.5px; }
.cal-cell.sel { background: var(--blue-bg); }
.cal-cell .duty { font-size: 9.5px; line-height: 1.25; color: var(--ink2); white-space: nowrap; overflow: hidden; }
.cal-cell .duty.rd { color: var(--blue-dk); font-weight: 650; }
.cal-cell.off .d { color: var(--muted); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav .mo { font-size: 15px; font-weight: 700; }
.cal-nav button { width: 36px; height: 32px; }

/* ── 表单 ── */
.field { margin-bottom: 12px; min-width: 0; }
.field label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 5px; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="month"], input[type="password"], select, textarea {
  width: 100%; border: 1px solid var(--grid); border-radius: 10px;
  padding: 9px 12px; font-size: 15px; background: var(--surface); color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--grid); border-radius: 999px; padding: 5px 13px;
  font-size: 13px; color: var(--ink2); background: var(--surface); cursor: pointer; user-select: none;
  transition: all .15s;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* 步进器 */
.steppers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stepper { border: 1px solid var(--grid); border-radius: 13px; padding: 8px 10px; background: var(--surface); min-width: 0; }
.stepper .lb { font-size: 12px; color: var(--ink2); text-align: center; }
.stepper .ctr { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.stepper .num {
  font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums;
  min-width: 44px; text-align: center; cursor: text;
  border-bottom: 1.5px dashed var(--grid); line-height: 1.3;
}
.stepper .num input {
  width: 58px; text-align: center; font-size: 20px; font-weight: 700;
  border: 1.5px solid var(--blue); border-radius: 8px; padding: 2px 4px;
}
.stepper button {
  width: 40px; height: 40px; border-radius: 11px; border: none;
  background: var(--blue-bg); color: var(--blue-dk); font-size: 22px; font-weight: 600;
  cursor: pointer; touch-action: manipulation; transition: background .12s;
}
.stepper button:active { background: var(--blue); color: #fff; }
.stepper-hint { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; }

/* 按钮 */
button.btn {
  display: block; width: 100%; border: none; border-radius: 13px;
  padding: 12px; font-size: 15.5px; font-weight: 650; cursor: pointer;
  background: var(--blue); color: #fff; font-family: inherit;
  transition: transform .12s, background .15s;
}
button.btn:active { background: var(--blue-dk); transform: scale(.98); }
button.btn.ghost { background: var(--surface); color: var(--ink2); border: 1px solid var(--grid); }
button.btn.danger { background: var(--surface); color: var(--crit); border: 1px solid var(--grid); }
button.btn.sm { padding: 8px 12px; font-size: 13.5px; width: auto; display: inline-block; }
button.iconbtn {
  border: 1px solid var(--grid); background: var(--surface); border-radius: 9px;
  font-size: 15px; color: var(--ink2); cursor: pointer; padding: 4px 10px; font-family: inherit;
  transition: transform .12s;
}
button.iconbtn:active { transform: scale(.92); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ── 弹层 ── */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(11, 11, 11, .42); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--page); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(22px + env(safe-area-inset-bottom, 0));
  max-height: 88vh; overflow-y: auto; overflow-x: hidden;
  animation: sheetUp .28s cubic-bezier(.2, .8, .25, 1) both;
}
@keyframes sheetUp { from { transform: translateY(48px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.sheet .sheet-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }

/* 列表行 */
.lrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); min-width: 0; }
.lrow:last-child { border-bottom: none; }
.lrow .main { flex: 1; min-width: 0; }
.lrow .t1 { font-size: 14px; font-weight: 600; }
.lrow .t2 { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .amt { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.lrow .amt.in { color: var(--good); }
.lrow .amt.out { color: var(--crit); }
.cat-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* 日期导航条 */
.datenav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-width: 0; }
.datenav input[type="date"] { flex: 1; min-width: 0; text-align: center; font-weight: 600; }
.datenav button { flex: none; }

/* 空态 / 提示 */
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 0; }
.note { font-size: 12px; color: var(--muted); line-height: 1.65; }
.divider { height: 1px; background: var(--grid); margin: 12px 0; }

/* 设置行 */
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.setrow:last-child { border-bottom: none; }
.setrow .sl { font-size: 14.5px; }
.setrow .sd { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .knob { position: absolute; inset: 0; background: var(--grid); border-radius: 999px; transition: .15s; }
.switch .knob::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .knob { background: var(--blue); }
.switch input:checked + .knob::after { left: 23px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(6px);
  background: rgba(11, 11, 11, .86); color: #fff; font-size: 13.5px;
  padding: 9px 18px; border-radius: 999px; z-index: 99; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: 86vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 司机今日大卡 */
.big-duty { text-align: center; padding: 6px 0 2px; }
.big-duty .role { font-size: 13px; color: var(--blue-dk); font-weight: 650; }
.big-duty .none { font-size: 17px; color: var(--muted); padding: 12px 0; }

.mono { font-variant-numeric: tabular-nums; }
.tr { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
