/*
THESIS: 把排班系统变成值班室里可直接操作的手写排班册，拒绝常见蓝色渐变后台。
OWN-WORLD: 米白纸、卡纸、墨黑粗线、标记红、钢笔蓝与便利贴黄组成统一文具语言。
STORY: 用户先确认年月和同步状态，再执行当天排班或导入排休，随后在规整月表中核对结果。
FIRST VIEWPORT: 顶部纸条工具栏、主排班纸卡与右侧统计便签同时可见，主要动作位于年月之后。
FORM: 用户钉死的手绘纸张方向；外壳有机，数据核心保持直线、零旋转和高可读。
*/

@import url("/fonts/lxgw-wenkai-screen/1.522.0/lxgw-wenkai-screen.css");

@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/kalam/5.3.0/kalam-latin-400-normal.95441060.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/patrick-hand/5.3.0/patrick-hand-latin-400-normal.ac5bc903.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #F6F0E4;
  --paper-card: #FFFDF7;
  --paper-muted: #F1E6D3;
  --ink: #252522;
  --ink-muted: #595750;
  --marker-red: #C7363E;
  --pen-blue: #2358A5;
  --sticky-yellow: #FFF1A8;
  --tape: rgba(218, 216, 207, .82);
  --paper-dot: rgba(37, 37, 34, .12);

  --status-on-bg: #DDEEDC;
  --status-on-fg: #245C34;
  --status-group-bg: #DCEAF8;
  --status-group-fg: #204E7C;
  --status-off-bg: #F8DADB;
  --status-off-fg: #862831;
  --status-sub-bg: #F8E0B8;
  --status-sub-fg: #7A4312;
  --status-pending-bg: #E7DDF2;
  --status-pending-fg: #5A3B73;
  --status-past-bg: #E9E4DA;
  --status-past-fg: #5F5B54;

  --wobbly-1: 12px 8px 14px 7px / 8px 13px 7px 12px;
  --wobbly-2: 8px 14px 7px 12px / 13px 8px 12px 7px;
  --wobbly-3: 14px 7px 11px 9px / 7px 12px 8px 14px;
  --wobbly-4: 9px 12px 8px 14px / 12px 7px 14px 9px;

  --shadow-paper: 4px 4px 0 var(--ink);
  --shadow-control: 2px 2px 0 var(--ink);
  --font-title: "Kalam", "LXGW WenKai Screen", "STKaiti", "KaiTi", cursive;
  --font-hand: "Patrick Hand", "LXGW WenKai Screen", "STKaiti", "KaiTi", cursive;
  --font-ui: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --schedule-position-width: 108px;
  --schedule-default-width: 72px;
  --schedule-workload-width: 48px;
  --schedule-day-width: 56px;
}

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

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html {
  min-width: 0;
  background: var(--paper);
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--paper-dot) 1px, transparent 1.2px);
  background-size: 20px 20px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

button {
  touch-action: manipulation;
}

a {
  color: var(--pen-blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--pen-blue);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* 顶部纸条 */
#topbar {
  position: sticky;
  top: 8px;
  z-index: 100;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
  min-height: 58px;
  margin: 8px 12px 10px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--paper-card);
  border: 3px solid var(--ink);
  border-radius: var(--wobbly-1);
  box-shadow: var(--shadow-paper);
}

#topbar::before,
#schedule-area::before,
#memo-panel::before {
  position: absolute;
  z-index: 4;
  width: 52px;
  height: 14px;
  content: "";
  pointer-events: none;
  background: var(--tape);
  border: 1px solid rgba(89, 87, 80, .18);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .72) inset;
}

#topbar::before {
  top: -9px;
  left: 47%;
  transform: rotate(.7deg);
}

.topbar-brand-group,
.topbar-primary-actions,
.topbar-tool-actions,
.ctrl-group {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-brand-group {
  gap: 14px;
}

.topbar-primary-actions,
.topbar-tool-actions,
.ctrl-group {
  gap: 7px;
}

.topbar-tool-actions {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 4px 5px 1px;
  scrollbar-color: var(--ink-muted) transparent;
  scrollbar-width: thin;
}

#topbar .logo {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

#topbar .logo svg {
  width: 23px;
  height: 23px;
  flex-shrink: 0;
  color: var(--marker-red);
  stroke-width: 2.5;
}

.ctrl-group label {
  color: var(--ink-muted);
  font-family: var(--font-hand);
  font-size: 14px;
  line-height: 1;
}

.ctrl-group select,
.stat-date-sel select {
  height: 32px;
  padding: 4px 26px 4px 8px;
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.btn {
  min-height: 32px;
  padding: 5px 11px;
  flex: 0 0 auto;
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 7px 5px 8px 6px / 6px 8px 5px 7px;
  box-shadow: var(--shadow-control);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.15;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
  box-shadow: 1px 1px 0 var(--ink-muted);
}

.btn-orange {
  color: #702C1D;
  background: #F8D9C7;
}

.btn-green {
  color: var(--status-on-fg);
  background: var(--status-on-bg);
}

.btn-blue {
  color: #FFFFFF;
  background: var(--pen-blue);
}

.btn-red {
  color: #FFFFFF;
  background: var(--marker-red);
}

.btn-gray {
  color: var(--ink);
  background: var(--status-past-bg);
}

.btn-teal {
  color: #174E47;
  background: #D9EEE9;
}

.ip-hint,
#poll-indicator {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink-muted);
  font-family: var(--font-hand);
  font-size: 13px;
  line-height: 1;
}

#poll-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 7px;
  color: var(--status-on-fg);
  background: var(--status-on-bg);
  border: 1px dashed var(--status-on-fg);
  border-radius: 5px;
  cursor: default;
  transition: color .2s ease, background-color .2s ease;
}

#poll-indicator.flash {
  color: #FFFFFF;
  background: var(--status-on-fg);
  animation: poll-flash .6s ease;
}

@keyframes poll-flash {
  0%, 100% { background: var(--status-on-bg); color: var(--status-on-fg); }
  45% { background: var(--status-on-fg); color: #FFFFFF; }
}

#access-banner {
  display: none;
  margin: 0 12px 8px;
  padding: 8px 14px;
  color: #705000;
  background: var(--sticky-yellow);
  border: 2px dashed var(--ink);
  text-align: center;
  font-family: var(--font-hand);
  font-size: 14px;
}

@media (min-width: 1200px) and (max-width: 1599px) {
  #ip-hint {
    display: none;
  }
}

/* 主体纸卡 */
#main-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  align-items: stretch;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 3px 12px 14px;
}

#schedule-area,
#side-panel {
  min-width: 0;
  background: var(--paper-card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-paper);
}

#schedule-area {
  position: relative;
  overflow: auto;
  padding-bottom: 248px;
  border-radius: var(--wobbly-2);
}

#schedule-area::before {
  top: -5px;
  left: calc(50% - 26px);
  transform: rotate(-1.1deg);
}

#side-panel {
  position: relative;
  width: 288px;
  min-width: 288px;
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--wobbly-3);
}

#side-panel::after,
#memo-panel::after {
  position: absolute;
  z-index: 5;
  width: 12px;
  height: 12px;
  content: "";
  pointer-events: none;
  background: var(--marker-red);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 1px 2px 0 rgba(37, 37, 34, .35);
}

#side-panel::after {
  top: 7px;
  right: 18px;
}

#schedule-wrap {
  min-width: 0;
  padding: 12px 12px 0;
}

/* 排班表保持规整 */
#schedule-table {
  width: max-content;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  white-space: nowrap;
  color: var(--ink);
  background: var(--paper-card);
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
}

#schedule-table th,
#schedule-table td {
  height: 28px;
  padding: 0 2px;
  border: 1px solid #BEB8AD;
  text-align: center;
  vertical-align: middle;
}

#schedule-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 30px;
  color: var(--paper-card);
  background: var(--ink);
  font-size: 12px;
}

#schedule-table thead tr:nth-child(2) th {
  position: sticky;
  top: 30px;
  z-index: 9;
  height: 25px;
  color: var(--ink);
  background: var(--paper-muted);
  font-size: 11px;
}

.col-pos {
  width: var(--schedule-position-width);
  min-width: var(--schedule-position-width);
  max-width: var(--schedule-position-width);
  padding-left: 8px !important;
  text-align: left !important;
}

.col-def {
  width: var(--schedule-default-width);
  min-width: var(--schedule-default-width);
  max-width: var(--schedule-default-width);
}

.col-wl {
  width: var(--schedule-workload-width);
  min-width: var(--schedule-workload-width);
  max-width: var(--schedule-workload-width);
}

.col-day {
  width: var(--schedule-day-width);
  min-width: var(--schedule-day-width);
  max-width: var(--schedule-day-width);
  font-weight: 700;
}

#schedule-table tbody tr:nth-child(even) td {
  background: #FAF6ED;
}

#schedule-table tbody tr:hover td {
  background: #F3EBD9;
}

.week-sat {
  color: #705000 !important;
  background: var(--sticky-yellow) !important;
}

.week-sun {
  color: var(--status-off-fg) !important;
  background: var(--status-off-bg) !important;
}

.week-fri {
  color: var(--status-on-fg) !important;
  background: var(--status-on-bg) !important;
}

.is-today {
  color: #FFFFFF !important;
  background: var(--marker-red) !important;
  box-shadow: inset 0 -3px 0 var(--ink);
}

.cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 26px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  transition: box-shadow .1s ease;
  user-select: none;
}

.cell:hover { box-shadow: inset 0 0 0 1px var(--ink); }

.cell-on {
  color: var(--status-on-fg);
  background: var(--status-on-bg);
  border-color: #A8C5A8;
}

.cell-group-on {
  width: 100%;
  min-width: 0;
  padding: 0 1px;
  color: var(--status-group-fg);
  background: var(--status-group-bg);
  border-color: #AAC4DE;
  font-size: 9px;
  letter-spacing: -.3px;
}

.cell-off {
  color: var(--status-off-fg);
  background: var(--status-off-bg);
  border-color: #D9AEB0;
}

.cell-sub {
  color: var(--status-sub-fg);
  background: var(--status-sub-bg);
  border-color: #D7B482;
  padding: 0 2px;
  font-size: 10px;
}

.cell-pending {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
  border-color: #C1B1D1;
}

.cell-past {
  color: var(--status-past-fg);
  background: var(--status-past-bg);
  opacity: .72;
  cursor: default;
}

.cell-split {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 26px;
  overflow: hidden;
  border: 1px solid #BEB8AD;
  border-radius: 3px;
  cursor: context-menu;
  font-size: 11px;
  font-weight: 650;
  transition: box-shadow .1s ease;
  user-select: none;
}

.cell-split:hover { box-shadow: inset 0 0 0 1px var(--ink); }

.split-slot {
  display: flex;
  flex: 0 0 50%;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 50%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.split-slot:first-child {
  border-right: 1px solid var(--ink);
}

.split-slot .slot-person {
  display: block;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.split-slot.status-on {
  color: var(--status-on-fg);
  background: var(--status-on-bg);
}

.split-slot.status-off {
  color: var(--status-off-fg);
  background: var(--status-off-bg);
}

.split-slot.status-substitute {
  color: var(--status-sub-fg);
  background: var(--status-sub-bg);
}

.split-slot.status-pending {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.cell-weekend-week {
  background: var(--sticky-yellow);
}

.cell-sun-col {
  background: var(--status-off-bg);
}

.check-icon {
  color: var(--status-on-fg);
  font-size: 14px;
}

.cross-icon {
  color: var(--status-off-fg);
  font-size: 14px;
}

.week-start-col td,
.week-start-col th {
  border-left: 2px solid var(--pen-blue) !important;
}

/* 侧栏与统计 */
.side-tabs,
.mgr-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}

.side-tab,
.mgr-tab {
  min-height: 32px;
  padding: 5px 9px;
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 1px 1px 0 var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.side-tab.active,
.mgr-tab.active {
  color: #FFFFFF;
  background: var(--pen-blue);
}

.side-content {
  display: none;
}

.side-content.active {
  display: block;
}

.stat-title,
#memo-title,
.modal h2 {
  color: var(--ink);
  font-family: var(--font-title);
  font-weight: 400;
  text-decoration-line: underline;
  text-decoration-color: var(--marker-red);
  text-decoration-style: wavy;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

.stat-title {
  margin: 12px 0 9px;
  font-size: 17px;
}

.stat-date-sel {
  margin-bottom: 9px;
}

.stat-list {
  list-style: none;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 1px;
  border-bottom: 1px dashed #C9C0B2;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-name {
  width: 52px;
  flex-shrink: 0;
  color: var(--ink);
  font-size: 12px;
}

.stat-bar-wrap {
  height: 14px;
  flex: 1;
  overflow: hidden;
  background: var(--paper-muted);
  border: 1px solid var(--ink-muted);
  border-radius: 4px;
}

.stat-bar {
  height: 100%;
  border-right: 1px solid var(--ink);
  border-radius: 2px;
}

.stat-val {
  width: 31px;
  color: var(--ink-muted);
  font-size: 11px;
  text-align: right;
}

/* 图例与备忘 */
#legend {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  margin: 7px 12px 0;
  padding: 9px 10px;
  color: var(--ink-muted);
  background: #FAF6ED;
  border: 1px dashed var(--ink-muted);
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  transform-origin: center;
}

.legend-item:nth-child(4n + 1) { transform: rotate(-1.2deg); }
.legend-item:nth-child(4n + 2) { transform: rotate(.9deg); }
.legend-item:nth-child(4n + 3) { transform: rotate(-.7deg); }
.legend-item:nth-child(4n) { transform: rotate(1.3deg); }

.legend-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 1px solid var(--ink) !important;
  border-radius: 2px !important;
}

.legend-on,
.legend-jd {
  color: var(--status-on-fg);
  background: var(--status-on-bg);
}

.legend-sub {
  color: var(--status-sub-fg);
  background: var(--status-sub-bg);
  font-size: 9px;
}

.legend-sat {
  background: var(--sticky-yellow);
}

.legend-weekend {
  background: var(--status-group-bg);
}

.legend-pending,
.legend-cpin {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.legend-cpin,
.legend-jd {
  font-size: 9px;
}

.legend-past {
  color: var(--status-past-fg);
  background: var(--status-past-bg);
  opacity: .72;
}

#memo-panel {
  position: absolute;
  right: 12px;
  bottom: 14px;
  left: 12px;
  display: flex;
  flex-direction: column;
  height: 216px;
  gap: 9px;
  padding: 13px;
  background: var(--sticky-yellow);
  border: 3px solid var(--ink);
  border-radius: var(--wobbly-4);
  box-shadow: var(--shadow-paper);
}

#memo-panel::before {
  top: -9px;
  left: calc(50% - 26px);
  transform: rotate(1.4deg);
}

#memo-panel::after {
  top: 8px;
  right: 17px;
  background: var(--pen-blue);
}

#memo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

#memo-title {
  font-size: 18px;
  line-height: 1;
}

#memo-subtitle,
#day-plan-note,
#day-plan-meta,
#memo-meta {
  color: var(--ink-muted);
}

#memo-subtitle {
  margin-top: 6px;
  font-family: var(--font-hand);
  font-size: 14px;
  line-height: 1.2;
}

#memo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#memo-text {
  width: 100%;
  min-height: 0;
  flex: 1 1 96px;
  resize: vertical;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 253, 247, .82);
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.55;
}

#memo-text[readonly] {
  background: rgba(255, 253, 247, .58);
  cursor: default;
}

#memo-meta {
  min-height: 13px;
  flex: 0 0 auto;
  font-family: var(--font-hand);
  font-size: 13px;
  line-height: 1;
}

/* 当天排班与导入 */
#day-plan-note,
#schedule-import-note {
  padding: 10px 12px;
  background: var(--paper-muted);
  border: 1px dashed var(--ink-muted);
  border-radius: 6px;
  font-family: var(--font-hand);
  font-size: 14px;
  line-height: 1.55;
}

#day-plan-off-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 8px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  background: #FAF6ED;
  border: 1px solid #BEB8AD;
  border-radius: 6px;
}

.day-plan-person {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px;
  background: var(--paper-card);
  border: 1px solid #C9C0B2;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.2;
}

.day-plan-person:hover {
  background: var(--sticky-yellow);
  border-color: var(--ink-muted);
}

.day-plan-person input {
  margin: 0;
}

.day-plan-person-name {
  min-width: 0;
  flex: 1;
  color: var(--ink);
  font-size: 12px;
}

.day-plan-person-tag {
  flex-shrink: 0;
  padding: 2px 6px;
  color: var(--status-on-fg);
  background: var(--status-on-bg);
  border: 1px solid var(--status-on-fg);
  border-radius: 5px;
  font-size: 10px;
  line-height: 1;
}

#day-plan-meta {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
}

.schedule-import-file {
  display: block;
  width: 100%;
  padding: 10px;
  color: var(--ink);
  background: #FAF6ED;
  border: 2px dashed var(--ink-muted);
  border-radius: 6px;
  cursor: pointer;
}

.schedule-import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.schedule-import-stat {
  padding: 9px;
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: var(--wobbly-1);
  box-shadow: var(--shadow-control);
}

.schedule-import-stat:nth-child(4n + 2) { border-radius: var(--wobbly-2); }
.schedule-import-stat:nth-child(4n + 3) { border-radius: var(--wobbly-3); }
.schedule-import-stat:nth-child(4n) { border-radius: var(--wobbly-4); }

.schedule-import-stat strong {
  display: block;
  margin-bottom: 4px;
  color: var(--marker-red);
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.1;
}

.schedule-import-stat span {
  color: var(--ink-muted);
  font-size: 11px;
}

.schedule-import-detail {
  margin-top: 8px;
  padding: 9px 10px;
  color: var(--ink-muted);
  background: #FAF6ED;
  border: 1px solid #C9C0B2;
  border-radius: 5px;
  line-height: 1.55;
}

.schedule-import-detail strong {
  color: var(--ink);
}

.schedule-import-warning {
  color: #705000;
  background: var(--sticky-yellow);
  border-color: #A78017;
}

#schedule-import-error {
  display: none;
  margin-top: 10px;
  padding: 9px 10px;
  color: var(--status-off-fg);
  background: var(--status-off-bg);
  border: 2px solid var(--status-off-fg);
  border-radius: 5px;
  line-height: 1.45;
}

#schedule-import-password {
  min-width: 180px;
  flex: 1;
}

/* 弹窗与表单保持直线、零旋转 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(37, 37, 34, .62);
}

.modal {
  position: relative;
  width: min(100%, 540px);
  min-width: 0;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  transform: rotate(0);
  color: var(--ink);
  background: var(--paper-card);
  border: 3px solid var(--ink);
  border-radius: var(--wobbly-2);
  box-shadow: 5px 5px 0 var(--ink);
}

#day-plan-modal .modal { width: min(100%, 620px); }
#schedule-import-modal .modal { width: min(100%, 760px); }
#col-settings-modal .modal { width: min(100%, 590px); }
#mgr-modal .modal { width: min(100%, 760px); }

.modal h2 {
  margin: 0 42px 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px dashed #C9C0B2;
  font-size: 21px;
  line-height: 1.15;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 1px 1px 0 var(--ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  color: #FFFFFF;
  background: var(--marker-red);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.form-row label {
  width: 88px;
  flex-shrink: 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="password"],
.form-row select,
textarea {
  min-height: 34px;
  min-width: 100px;
  flex: 1;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 5px;
  font-size: 12px;
}

.form-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--pen-blue);
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.tag {
  display: inline-block;
  margin: 2px;
  padding: 2px 7px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  font-size: 11px;
}

.tag-cpin {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.tag-jd {
  color: var(--status-on-fg);
  background: var(--status-on-bg);
}

.tag-sat {
  color: #705000;
  background: var(--sticky-yellow);
}

.tag-weekend {
  color: var(--status-group-fg);
  background: var(--status-group-bg);
}

.tag-split {
  color: var(--status-group-fg);
  background: var(--status-group-bg);
}

/* 管理表格 */
.mgr-tab {
  padding: 5px 14px;
  font-size: 12px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  background: var(--paper-card);
  font-family: var(--font-ui);
  font-size: 12px;
}

table.data-table th {
  padding: 7px 8px;
  background: var(--paper-muted);
  border: 1px solid #BEB8AD;
  text-align: left;
}

table.data-table td {
  padding: 6px 8px;
  border: 1px solid #D3CBC0;
  vertical-align: middle;
}

table.data-table tr:hover td {
  background: #FAF3E4;
}

.action-btn {
  min-height: 30px;
  padding: 4px 8px;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.action-btn.edit {
  color: var(--status-group-fg);
  background: var(--status-group-bg);
}

.action-btn.del {
  color: var(--status-off-fg);
  background: var(--status-off-bg);
}

.col-settings-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.col-settings-item {
  display: flex;
  align-items: center;
  min-height: 34px;
  gap: 4px;
  padding: 5px 6px;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--ink-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color .12s ease;
  white-space: nowrap;
}

.col-settings-item:hover {
  background: var(--sticky-yellow);
}

.col-settings-item.hidden-col {
  color: var(--status-off-fg);
  background: var(--status-off-bg);
  border-color: var(--status-off-fg);
}

.col-settings-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--pen-blue);
  cursor: pointer;
}

.col-settings-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.col-settings-label .day-num {
  font-size: 13px;
  font-weight: 700;
}

.col-settings-label .day-wd {
  color: var(--ink-muted);
  font-size: 10px;
}

.col-settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px dashed #C9C0B2;
}

/* 拖动、右键菜单、反馈 */
.drag-handle {
  display: inline-block;
  width: 14px;
  margin-right: 4px;
  color: var(--ink-muted);
  cursor: grab;
  font-size: 14px;
  text-align: center;
  user-select: none;
}

.drag-handle:active {
  color: var(--pen-blue);
  cursor: grabbing;
}

tbody tr {
  cursor: grab;
}

tbody tr.dragging {
  background: var(--status-group-bg) !important;
  opacity: .58;
}

tbody tr.drag-over-top {
  border-top: 3px solid var(--pen-blue);
}

tbody tr.drag-over-bottom {
  border-bottom: 3px solid var(--pen-blue);
}

#ctx-menu {
  position: fixed;
  z-index: 2000;
  min-width: 150px;
  padding: 4px 0;
  transform: rotate(0);
  color: var(--ink);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: var(--shadow-control);
}

#ctx-menu .ctx-item,
#ctx-menu .ctx-staff-item {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 12px;
}

#ctx-menu .ctx-item {
  gap: 8px;
}

#ctx-menu .ctx-item:hover,
#ctx-menu .ctx-staff-item:hover {
  background: var(--sticky-yellow);
}

#ctx-menu .ctx-sep {
  height: 1px;
  margin: 3px 0;
  background: #C9C0B2;
}

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 9999;
  max-width: min(88vw, 620px);
  padding: 9px 18px;
  transform: translateX(-50%);
  color: var(--paper-card);
  background: var(--ink);
  border: 2px solid var(--paper-card);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--marker-red);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

#toast.show {
  opacity: 1;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: rgba(246, 240, 228, .86);
  font-family: var(--font-title);
  font-size: 21px;
}

@media (max-width: 1199px) {
  #main-wrap {
    grid-template-columns: minmax(0, 1fr) 236px;
  }

  #side-panel {
    width: 236px;
    min-width: 236px;
    padding: 10px;
  }

  #topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-tool-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 899px) {
  body {
    display: block;
  }

  #topbar {
    top: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin: 7px 8px 10px;
  }

  .topbar-brand-group {
    flex-wrap: wrap;
  }

  .topbar-tool-actions {
    grid-column: 1 / -1;
  }

  #main-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: visible;
    padding: 3px 8px 18px;
  }

  #schedule-area {
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-bottom: 0;
  }

  #schedule-wrap {
    max-height: 62vh;
    overflow: auto;
  }

  #legend {
    flex: 0 0 auto;
  }

  #memo-panel {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    width: auto;
    height: 216px;
    flex: 0 0 auto;
    margin: 18px 12px 13px;
  }

  #side-panel {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  #schedule-area::before,
  #memo-panel::before,
  #side-panel::after,
  #memo-panel::after {
    display: none;
  }

  .side-tabs {
    overflow-x: auto;
    padding-bottom: 3px;
  }
}

@media (max-width: 639px) {
  #topbar {
    position: relative;
    top: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    padding: 10px;
  }

  #topbar::before {
    left: calc(50% - 26px);
  }

  .topbar-brand-group {
    justify-content: space-between;
    gap: 8px;
  }

  #topbar .logo {
    font-size: 17px;
  }

  .ctrl-group {
    gap: 4px;
  }

  .ctrl-group label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .ctrl-group select {
    width: 68px;
    padding-right: 18px;
  }

  .topbar-primary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-primary-actions .btn {
    width: 100%;
  }

  .topbar-tool-actions {
    grid-column: auto;
    margin-inline: -2px;
  }

  .ip-hint {
    display: none;
  }

  #main-wrap {
    padding-inline: 6px;
  }

  #schedule-area,
  #side-panel,
  #memo-panel {
    border-width: 2px;
    border-radius: 8px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  #schedule-wrap {
    padding: 8px 6px 0;
  }

  #legend {
    margin-inline: 6px;
  }

  .legend-item {
    transform: none !important;
  }

  #memo-panel {
    height: 216px;
    margin-inline: 6px;
    transform: none;
  }

  .modal-overlay {
    align-items: stretch;
    padding: 6px;
  }

  .modal {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: calc(100dvh - 12px);
    padding: 17px 14px;
    transform: none;
    border-width: 2px;
    border-radius: 8px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .modal h2 {
    font-size: 20px;
  }

  .form-row {
    align-items: stretch;
  }

  .form-row label {
    width: 100%;
  }

  .form-row input,
  .form-row select {
    width: 100%;
  }

  .schedule-import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .col-settings-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .col-settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .col-settings-actions > div {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .mgr-tabs {
    overflow-x: auto;
    padding-bottom: 3px;
  }

  #mgr-modal .modal {
    overflow-x: auto;
  }
}

@media (pointer: coarse) {
  .btn,
  .side-tab,
  .mgr-tab,
  .action-btn,
  .modal-close,
  #ctx-menu .ctx-item,
  #ctx-menu .ctx-staff-item,
  .day-plan-person {
    min-width: 44px;
    min-height: 44px;
  }

  .form-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .btn,
  .btn:hover,
  .btn:active,
  .legend-item,
  #poll-indicator,
  #poll-indicator.flash {
    transform: none !important;
  }
}
