:root {
  --bg-page: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --brand-primary: #1e3a8a;
  --brand-primary-hover: #1e40af;
  --brand-accent: #2563eb;
  --brand-accent-light: #eff6ff;
  
  --status-occupied: #2563eb;
  --status-full: #dc2626;
  --status-full-bg: #fef2f2;
  
  --weekend-bg: #f8fafc;
  --today-bg: #f0f9ff;
  --today-border: #0284c7;
  
  --hour-h: 76px;
  --head-h: 88px;
  --axis-w: 68px;
  --head-gap: 0px;
  
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-num: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  color: var(--text-primary);
  font-family: var(--font-ui);
  background: var(--bg-page);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.atmosphere {
  display: none;
}

.top,
.live,
.board,
.drawer,
.scrim,
.toast {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand__info {
  display: flex;
  flex-direction: column;
}

.brand__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand__note {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.weeknav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-subtle);
  padding: 3px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.weeknav__title {
  margin: 0;
  min-width: 200px;
  text-align: center;
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.top__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.iconbtn,
.textbtn,
.primary,
.danger {
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.iconbtn {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
}

.iconbtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.textbtn {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.textbtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.primary {
  padding: 8px 16px;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.primary:hover {
  background: var(--brand-primary-hover);
}

.primary:active {
  transform: translateY(1px);
}

.danger {
  padding: 8px 14px;
  color: var(--status-full);
  background: var(--status-full-bg);
  border: 1px solid rgba(220, 38, 38, 0.2);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.danger:hover {
  background: #fee2e2;
}

.live {
  margin: 0;
  padding: 8px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.live::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
}

.board {
  height: calc(100vh - 110px);
  margin: 12px 24px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.calendar {
  display: grid;
  grid-template-columns: var(--axis-w) repeat(5, minmax(160px, 1fr));
  min-width: 1080px;
}

.cell {
  position: relative;
}

.head {
  position: sticky;
  top: 0;
  z-index: 4;
  height: var(--head-h);
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
}

.head--axis {
  left: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-right: 1px solid var(--border-strong);
  background: var(--bg-surface-subtle);
}

.weekday {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.daynum {
  margin: 2px 0 0;
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.seats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.seats span {
  padding: 2px 0;
  font-size: 10px;
  font-weight: 500;
  text-align: center;
  border-radius: 2px;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.seats span.is-on {
  background: var(--brand-accent-light);
  color: var(--brand-accent);
  border-color: rgba(37, 99, 235, 0.3);
}

.seats span.is-full {
  background: var(--status-full-bg);
  color: var(--status-full);
  border-color: rgba(220, 38, 38, 0.3);
}

.head.is-today {
  background: var(--today-bg);
}

.head.is-today .daynum {
  color: var(--today-border);
}

.head.is-weekend {
  background: var(--weekend-bg);
}

.head.is-full .daynum::after {
  content: "满席";
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--status-full);
  background: var(--status-full-bg);
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}

.axis {
  position: sticky;
  left: 0;
  z-index: 3;
  padding-top: var(--head-gap);
  background: var(--bg-surface-subtle);
  border-right: 1px solid var(--border-strong);
}

.hour {
  position: relative;
  height: var(--hour-h);
  padding: 0 10px 0 0;
  text-align: right;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.hour span {
  position: absolute;
  top: 0;
  right: 10px;
  transform: translateY(-50%);
  line-height: 1;
}

.day {
  padding-top: var(--head-gap);
  border-right: 1px solid var(--border-subtle);
}

.day-body {
  position: relative;
  user-select: none;
  background-image:
    linear-gradient(
      to right,
      transparent calc(33.333% - 0.5px),
      rgba(226, 232, 240, 0.3) calc(33.333% - 0.5px),
      rgba(226, 232, 240, 0.3) 33.333%,
      transparent 33.333%,
      transparent calc(66.666% - 0.5px),
      rgba(226, 232, 240, 0.3) calc(66.666% - 0.5px),
      rgba(226, 232, 240, 0.3) 66.666%,
      transparent 66.666%
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--hour-h) / 2 - 1px),
      rgba(226, 232, 240, 0.4) calc(var(--hour-h) / 2 - 1px),
      rgba(226, 232, 240, 0.4) calc(var(--hour-h) / 2)
    );
}

.day.is-today .day-body {
  background-color: rgba(240, 249, 255, 0.4);
}

.day.is-weekend .day-body {
  background-color: rgba(248, 250, 252, 0.6);
}

.slot-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.slot-lines i {
  display: block;
  height: var(--hour-h);
  border-top: 1px solid var(--border-subtle);
}

.lane-label {
  position: absolute;
  top: 6px;
  width: 33.333%;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  pointer-events: none;
}

.meeting {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  padding: 4px 6px;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--dept);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.meeting:hover,
.meeting:focus-visible {
  z-index: 2;
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  border-left-color: var(--dept);
}

.meeting.is-muted {
  opacity: 0.3;
}

.meeting.is-past {
  opacity: 0.6;
  background: var(--bg-surface-subtle);
}

.meeting__time {
  margin: 0;
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meeting__tag {
  margin-left: 6px;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 2px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 500;
}

.meeting__title {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
  word-break: break-all;
}

.meeting__who {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.now {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  height: 2px;
  background: var(--status-full);
  pointer-events: none;
}

.now::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-full);
}

.ghost {
  position: absolute;
  z-index: 2;
  left: 3px;
  right: 3px;
  border: 1px dashed var(--brand-accent);
  background: rgba(37, 99, 235, 0.08);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.ghost.is-blocked {
  border-color: var(--status-full);
  background: rgba(220, 38, 38, 0.08);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(460px, 100%);
  padding: 24px 28px;
  overflow: auto;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer.is-open {
  transform: none;
}

.drawer__head {
  position: relative;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer__kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brand-accent);
}

.drawer__title {
  margin: 4px 0 0;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.drawer__close {
  position: absolute;
  top: 0;
  right: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.field span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field--inline {
  flex-direction: row;
  align-items: center;
  margin: 0;
  gap: 8px;
}

.field--inline span {
  font-size: 13px;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field select:disabled,
.field input:disabled {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

.seat-hint {
  min-height: 1.4em;
  margin: -6px 0 16px;
  font-size: 12px;
  color: var(--brand-accent);
  line-height: 1.5;
  padding: 6px 10px;
  background: var(--brand-accent-light);
  border-radius: var(--radius-sm);
}

.seat-hint.is-full {
  color: var(--status-full);
  background: var(--status-full-bg);
}

.drawer__foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  padding: 10px 20px;
  background: var(--text-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 900px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 12px;
  }

  .top__actions {
    justify-content: space-between;
  }

  .weeknav__title {
    min-width: 0;
    font-size: 14px;
  }

  .board {
    height: calc(100vh - 180px);
    margin: 10px;
  }

  .live {
    padding: 8px 16px;
  }
}
