:root {
  --ink: #1c2430;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f3f5f8;
  --card: #fff;
  --soft: #f7f8fa;
  --blue: #1d4e89;
  --blue-d: #163a66;
  --blue-soft: #e8f0f8;
  --green: #0f7a4a;
  --green-soft: #e7f6ee;
  --amber: #9a6700;
  --amber-soft: #fff6db;
  --red: #b42318;
  --side: #162033;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.5 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.6; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  padding: 28px;
}
.login-side, .login-card, .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.login-side { padding: 28px 32px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 8px;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.brand b { display: block; font-size: 18px; }
.brand small { color: var(--muted); }
.login-side h2 { margin: 28px 0 8px; font-size: 28px; }
.login-side .lead { margin: 0; color: var(--muted); max-width: 460px; }
.points { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.point { background: var(--soft); border-radius: 8px; padding: 14px 14px 12px; }
.point b { display: block; margin-bottom: 4px; }
.point span { color: var(--muted); font-size: 13px; }
.login-card { padding: 32px 28px; align-self: center; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .sub { margin: 0 0 18px; color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field > span, .section-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}
.field input, .field select, .field textarea, .search, .time-row input, .pick-search {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.field textarea { height: auto; min-height: 76px; padding: 8px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus, .time-row input:focus, .pick-search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 137, 0.12);
}
.field-error, .err { margin: 8px 0 0; color: var(--red); font-size: 13px; }
.field-error:empty { display: none; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.primary, .ghost, .danger, .link {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #fff;
}
.primary { background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-d); }
.ghost { border-color: #d0d5dd; background: #fff; }
.danger { color: var(--red); border-color: #f3c3be; background: #fff; }
.link { height: auto; padding: 0; border: 0; background: none; color: var(--blue); }
.link.danger-text { color: var(--red); }
.login-card .primary { width: 100%; height: 42px; margin-top: 4px; }

.shell { display: flex; min-height: 100vh; }
.side {
  width: 220px;
  flex: none;
  background: var(--side);
  color: #d5dbe6;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
}
.side .brand { color: #fff; padding: 0 8px 16px; }
.side .brand small { color: #93a0b5; }
.nav-btn {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  margin-bottom: 4px;
  padding: 0 12px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 8px;
}
.nav-btn.on { background: var(--blue); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nav-btn svg { width: 16px; height: 16px; margin-right: 8px; flex: none; }
.top {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.top-title { margin-right: auto; font-weight: 650; font-size: 15px; }
.who { color: var(--muted); margin-right: 4px; }
.content { padding: 18px 22px 28px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.page-head-slim { justify-content: flex-end; align-items: center; margin-bottom: 10px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.count { margin-left: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.metrics.six { grid-template-columns: repeat(6, 1fr); }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric b { font-size: 22px; font-variant-numeric: tabular-nums; }

.sheet { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.years { display: flex; gap: 8px; align-items: center; overflow-x: auto; flex: 1; }
.year {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.year.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.search { width: 240px; flex: none; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filter > span { color: var(--muted); font-size: 12px; }
.filter input, .filter select {
  height: 36px;
  width: 148px;
  padding: 0 10px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.filter.grow input { width: 200px; }
.filter input:focus, .filter select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 137, 0.12);
}
.filter-actions { display: flex; gap: 8px; }
.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
}
.pager button { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pager button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.when { white-space: nowrap; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; }
.orders-table { min-width: 1080px; }
.orders-table th.fit, .orders-table td.fit { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.orders-table th.deliver, .orders-table td.deliver { white-space: nowrap; width: 1%; }
.orders-table th.name, .orders-table td.name { width: 18%; min-width: 140px; }
.orders-table th.party, .orders-table td.party { width: 14%; min-width: 120px; }
.orders-table th.remark, .orders-table td.remark { width: 9%; min-width: 72px; max-width: 140px; }
.remark-text { line-height: 1.45; white-space: normal; word-break: break-word; }
.sheet { overflow: auto; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.title { font-weight: 650; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.pill.on { color: var(--green); background: var(--green-soft); }
.pill.off { color: var(--amber); background: var(--amber-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions button { height: 30px; padding: 0 10px; }
.empty {
  padding: 56px 20px;
  text-align: center;
}
.empty-mark {
  width: 44px; height: 44px; margin: 0 auto 12px;
  border-radius: 10px; background: var(--blue-soft); color: var(--blue);
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.empty b { display: block; font-size: 16px; margin-bottom: 6px; }
.empty p { margin: 0 auto 14px; max-width: 360px; color: var(--muted); }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}
.dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.18);
}
.dialog.narrow { width: min(440px, 100%); }
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.icon-x {
  width: 32px; height: 32px; padding: 0; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 20px;
}
.icon-x:hover { background: var(--soft); color: var(--ink); }
.dialog-body { padding: 16px 18px 8px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: #fff;
}
.primary.danger-fill { background: var(--red); }
.primary.danger-fill:hover { background: #912018; }
.field input.invalid, .field select.invalid, .field textarea.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid .wide { grid-column: 1 / -1; }
.section {
  margin: 0 0 12px;
  padding: 12px 12px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}
.section-title { font-weight: 650; color: var(--ink); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label {
  position: relative;
  height: 40px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
}
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-d);
  font-weight: 650;
}
.money { position: relative; }
.money em {
  position: absolute;
  left: 12px;
  top: 9px;
  color: var(--muted);
  font-style: normal;
}
.money input { padding-left: 26px; }
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  background: var(--soft);
  border-radius: 8px;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}
.checks input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.checks label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.empty-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--soft);
  border-radius: 8px;
  color: var(--muted);
}
.switch-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  background: var(--soft);
  border-radius: 8px;
}
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d0d5dd; border-radius: 999px; }
.slider:before {
  content: "";
  position: absolute;
  width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .15s ease;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.times { display: flex; flex-direction: column; gap: 8px; }
.time-row { display: grid; grid-template-columns: 1fr 1.25fr auto; gap: 8px; align-items: center; }
.time-row .danger-text { height: 40px; padding: 0 4px; }
.pick-face, .time-face {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.pick-text, .time-face span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-text.is-empty, .time-face .is-empty, .caret { color: var(--muted); }
.pick-pop, .time-pop {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 16px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.16);
  padding: 12px;
}
.pick-pop[hidden], .time-pop[hidden] { display: none; }
.pick-search { margin-bottom: 8px; }
.pick-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.pick-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px;
  border-radius: 8px;
}
.pick-item:hover { background: var(--soft); }
.pick-item input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--blue); }
.pick-item span { line-height: 1.4; }
.pick-empty:empty { display: none; }
.time-grid { display: grid; grid-template-columns: 1.4fr 0.7fr 0.7fr; gap: 8px; }
.time-grid .field { margin-bottom: 0; }
.time-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.notice {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  padding: 12px 12px 12px 14px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.18);
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
  pointer-events: none;
}
.notice.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.notice.error { border-color: #f3c3be; }
.notice.error .notice-text { color: var(--red); font-weight: 650; }
.notice.ok { background: #1c2430; color: #fff; border-color: #1c2430; }
.notice-text { flex: 1; line-height: 1.45; }
.notice-x {
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 18px;
}
.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 40;
  padding: 8px 14px;
  border-radius: 8px;
  background: #1c2430;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transform: translateX(-50%) translateY(-6px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px 16px;
}
.panel h3 { margin: 0 0 4px; font-size: 15px; }
.panel.wide { grid-column: 1 / -1; }
.bars, .incomes, .schedule { display: flex; flex-direction: column; gap: 10px; }
.bar-row, .income-row { display: grid; grid-template-columns: 132px 1fr auto; gap: 10px; align-items: center; }
.bar-name { font-size: 13px; line-height: 1.35; }
.bar-name small, .schedule small { display: block; color: var(--muted); font-size: 12px; }
.bar-track, .stack { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.stack { display: flex; }
.bar-fill, .stack span { display: block; height: 100%; }
.bar-fill.c0, .legend .dep, .stack .dep { background: #1d4e89; }
.bar-fill.c1 { background: #0f7a4a; }
.bar-fill.c2 { background: #9a6700; }
.bar-fill.c3 { background: #3d6b8a; }
.bar-fill.c4 { background: #8a4b2f; }
.stack .gap, .legend .gap { background: #d4a017; }
.bar-num { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-num small { display: block; color: var(--muted); font-weight: 500; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 4px; }
.income-meta { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; line-height: 1.45; }
.schedule-block + .schedule-block { margin-top: 14px; }
.schedule button {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}
.schedule button:hover { border-color: #b9c6d6; }
.schedule em { color: var(--blue); font-style: normal; font-size: 13px; }

@media (max-width: 900px) {
  .login-wrap, .metrics, .metrics.six, .grid, .time-row, .points, .stats-grid { grid-template-columns: 1fr; }
  .panel.wide { grid-column: auto; }
  .bar-row, .income-row { grid-template-columns: 72px 1fr; }
  .bar-num, .income-meta { grid-column: 2; text-align: left; }
  .shell { flex-direction: column; }
  .side { width: auto; flex-direction: row; align-items: center; gap: 6px; overflow: auto; }
  .side .brand { display: none; }
  .side-foot { flex-direction: row; margin: 0 0 0 auto; padding-top: 0; }
  .nav-btn { width: auto; }
  .page-head, .toolbar { flex-wrap: wrap; }
  .search, .filter, .filter.grow { width: 100%; }
  .filter input, .filter select, .filter.grow input { width: 100%; }
  .top-title { display: none; }
}
