:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --ink: #172122;
  --muted: #657174;
  --line: #d8e0df;
  --teal: #0f766e;
  --teal-soft: #d8f0ec;
  --green: #5f8f3f;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 16px 35px rgba(22, 33, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: clamp(420px, 30vw, 480px) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
  background: #162524;
  color: #f7faf8;
}

.mobile-pane-toggle {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #f7faf8;
  color: #162524;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.planner-header h3,
.dialog-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  margin-top: 4px;
  color: #b9c9c6;
  font-size: 13px;
}

.week-switch,
.view-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.week-switch {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.week-tab,
.view-tab {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.week-tab.active,
.view-tab.active {
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.view-tab:not(.active) {
  color: var(--muted);
}

.view-tab:not(.active):hover {
  background: #e2eceb;
  color: var(--ink);
}

.view-toggle {
  grid-template-columns: repeat(2, 1fr);
}

.panel {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 14px;
}

.calendar-panel {
  flex: 0 0 auto;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-toolbar div {
  min-width: 0;
  text-align: center;
}

.calendar-toolbar strong,
.calendar-toolbar span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-toolbar span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid transparent;
  background: #fbfcfc;
  color: var(--ink);
  font-weight: 800;
}

.calendar-day.outside-month {
  color: #aab4b4;
  background: #f4f6f6;
}

.calendar-day.selected-week {
  border-color: #b9ded8;
  background: var(--teal-soft);
}

.calendar-day.today {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.calendar-day.holiday::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 5px;
  height: 5px;
  background: var(--red);
}

.calendar-day.makeup-workday::after {
  background: var(--green);
}

.calendar-day small {
  position: absolute;
  left: 4px;
  bottom: 3px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  color: var(--red);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title,
.planner-header,
.dialog-head,
.topbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin-bottom: 12px;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-body {
  display: grid;
  gap: 10px;
}

.panel.collapsed .panel-body {
  display: none;
}

.project-panel .panel-body {
  gap: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.project-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 9px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.project-list,
.people-pool,
.leave-list {
  display: grid;
  gap: 8px;
  max-height: 28vh;
  overflow: auto;
}

.project-pill,
.person-card,
.booking-card,
.leave-card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px;
}

.project-pill {
  display: grid;
  gap: 5px;
  border-left: 5px solid var(--project-color);
  cursor: grab;
}

.project-pill.is-focused {
  border-color: color-mix(in srgb, var(--project-color) 58%, var(--line));
  background: color-mix(in srgb, var(--project-color) 8%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--project-color) 28%, transparent);
}

.project-pill:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.person-card {
  display: grid;
  gap: 7px;
}

.card-main {
  min-width: 0;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mini-action {
  min-height: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.mini-action.danger {
  border-color: #f2b8a6;
  background: #fff7f4;
  color: var(--red);
}

.project-pill:active {
  cursor: grabbing;
}

.mini-danger {
  justify-self: start;
  min-height: 26px;
  border: 1px solid #f2b8a6;
  background: #fff7f4;
  color: var(--red);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.project-pill strong,
.person-card strong,
.booking-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.tag.frontend {
  background: #e8f2ff;
  color: var(--blue);
}

.tag.backend {
  background: #edf7e9;
  color: var(--green);
}

.tag.qa {
  background: #fff4df;
  color: var(--amber);
}

.tag.ba {
  background: #f1e8ff;
  color: #6d3bbd;
}

.tag.pm {
  background: #e5f4f0;
  color: #0f766e;
}

.workspace {
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
}

.topbar {
  min-height: 66px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 28px;
}

.toolbar {
  flex-wrap: wrap;
}

.primary-action,
.secondary-action {
  min-height: 38px;
  border: 1px solid var(--teal);
  padding: 8px 14px;
  font-weight: 700;
}

.primary-action {
  background: var(--teal);
  color: #fff;
}

.secondary-action {
  background: var(--surface);
  color: var(--teal);
}

.save-status {
  display: inline-flex;
  align-items: center;
  align-self: center;
  min-height: 30px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.save-status.is-success {
  border-color: #b8d9bb;
  background: #f0f8ef;
  color: var(--green);
}

.save-status.is-error {
  border-color: #f2b8a6;
  background: #fff7f4;
  color: var(--red);
}

.save-status.is-dirty {
  border-color: #e8c98c;
  background: #fff9eb;
  color: var(--amber);
}

.save-status.is-pending {
  border-color: #b8d0f4;
  background: #f1f6ff;
  color: var(--blue);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 86px;
  border-left: 4px solid var(--teal);
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric.alert {
  border-left-color: var(--red);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 24px;
}

.planner-shell {
  min-height: calc(100vh - 190px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.planner-header {
  align-items: flex-start;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.booking-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
  padding: 10px 16px;
}

.booking-action-summary {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booking-action-buttons {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.danger-action {
  min-height: 38px;
  border: 1px solid #f2b8a6;
  background: #fff7f4;
  color: var(--red);
  padding: 8px 14px;
  font-weight: 700;
}

.planner-header h3 {
  font-size: 18px;
}

.planner-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.selection-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-left: 3px solid var(--line);
  padding-left: 8px;
  font-size: 12px !important;
  font-weight: 800;
}

.selection-status.has-selection {
  border-left-color: var(--teal);
  color: var(--teal);
}

.view-toggle {
  width: 260px;
}

.matrix-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.matrix-week-nav {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
}

.matrix-week-nav span {
  min-width: 190px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.role-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-quick {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.role-quick.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.matrix-weekend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.matrix-weekend-toggle input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--teal);
}

.matrix-weekend-toggle input:disabled {
  cursor: not-allowed;
}

.matrix-weekend-toggle:has(input:disabled) {
  cursor: default;
  opacity: 0.55;
}

.matrix-actions .primary-action:disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.person-card.warning,
.booking-card.warning,
.warning-row .person-summary {
  border-color: #f2b8a6;
  background: #fff7f4;
}

.person-card.overbooked,
.overbooked-row .person-summary {
  border-color: var(--red);
}

.booking-card {
  display: grid;
  gap: 7px;
}

.booking-card button {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.leave-card {
  display: grid;
  gap: 6px;
}

.leave-card button {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.util-bar {
  height: 7px;
  overflow: hidden;
  background: var(--surface-2);
}

.util-bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--teal);
}

.util-bar.low span {
  background: var(--red);
}

.matrix-view,
.summary-view,
.archive-view {
  padding: 16px;
}

.distribution-table,
.archive-table,
.resource-matrix {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
}

.hours-cell {
  min-width: 130px;
}

.hours-bar {
  height: 8px;
  margin-top: 6px;
  background: var(--surface-2);
}

.hours-bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--green);
}

.matrix-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  overscroll-behavior-x: contain;
}

.matrix-empty {
  height: 180px;
  text-align: center;
  vertical-align: middle;
}

.empty-state {
  margin: 0;
  padding: 18px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.resource-matrix {
  --person-column-width: clamp(138px, 18vw, 180px);
  --summary-column-width: clamp(112px, 15vw, 150px);
  width: 100%;
  min-width: calc(var(--person-column-width) + var(--summary-column-width) + var(--matrix-days-min-width));
  table-layout: fixed;
}

.resource-matrix th,
.resource-matrix td {
  border: 1px solid var(--line);
}

.resource-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.person-head,
.person-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  width: var(--person-column-width);
  min-width: var(--person-column-width);
}

.person-cell[data-person-drag] {
  cursor: grab;
  user-select: none;
}

.person-cell[data-person-drag]:hover {
  cursor: grab;
  background: #eef8f5;
}

.person-cell[data-person-drag]:active {
  cursor: grabbing;
}

.summary-head,
.person-summary {
  position: sticky;
  left: var(--person-column-width);
  z-index: 2;
  background: #fbfcfc;
  width: var(--summary-column-width);
  min-width: var(--summary-column-width);
}

.person-head,
.summary-head {
  z-index: 8;
  top: 0;
}

.person-head {
  z-index: 9;
}

.person-cell strong,
.person-cell span,
.person-summary span {
  display: block;
}

.person-cell span,
.person-summary span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.matrix-cell {
  min-width: 150px;
  height: 108px;
  padding: 6px;
  background: #ffffff;
}

.matrix-cell.drag-over {
  background: #eef8f5;
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.matrix-cell.locked,
.holiday-head {
  background: #f1f3f3;
  color: var(--muted);
}

.makeup-workday-head {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
}

.matrix-cell.over-day {
  background: #fff7f4;
}

.timeline-cell {
  min-width: var(--matrix-days-min-width);
  padding: 0;
}

.timeline-track {
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(38px, auto));
  position: relative;
  min-width: var(--timeline-min-width);
  min-height: calc(var(--rows) * 44px);
}

.timeline-dropzone {
  min-height: 100%;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  padding: 5px;
}

.timeline-dropzone span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.timeline-dropzone.drag-over {
  background: #eef8f5;
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.timeline-dropzone.selected-range {
  background: #d8f0ec;
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.timeline-dropzone:focus-visible {
  position: relative;
  z-index: 3;
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

.timeline-dropzone.locked {
  background: #f1f3f3;
}

.timeline-dropzone.over-day {
  background: #fff7f4;
}

.timeline-bar {
  position: relative;
  z-index: 2;
  align-self: center;
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 34px;
  margin: 4px 8px;
  border-left: 5px solid var(--project-color);
  background: #f8fbfb;
  box-shadow: 0 8px 18px rgba(23, 33, 34, 0.08);
  padding: 6px 34px 6px 14px;
}

.timeline-bar.is-project-focused {
  z-index: 4;
  background: color-mix(in srgb, var(--project-color) 8%, #ffffff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--project-color) 42%, transparent), 0 12px 24px rgba(23, 33, 34, 0.14);
  cursor: help;
  transform: translateY(-1px);
}

.timeline-bar.is-booking-selected {
  z-index: 5;
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  cursor: pointer;
}

.timeline-bar > strong,
.timeline-bar > span:not(.resize-handle) {
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-bar strong {
  font-size: 12px;
}

.timeline-bar span {
  color: var(--muted);
  font-size: 11px;
}

.timeline-bar.is-compact {
  min-height: 30px;
  gap: 0;
  padding: 5px 28px 5px 10px;
}

.timeline-bar.is-compact > span:not(.resize-handle) {
  display: none;
}

.timeline-bar .booking-remove {
  position: absolute;
  top: 5px;
  right: 13px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.timeline-bar .resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}

.timeline-bar .resize-handle.left {
  left: 0;
}

.timeline-bar .resize-handle.right {
  right: 0;
}

.timeline-bar .resize-handle:hover,
.timeline-bar .resize-handle:focus-visible {
  background: rgba(15, 118, 110, 0.14);
}

.row-dragging th,
.row-dragging td {
  background: #d8f0ec !important;
  box-shadow: inset 0 0 0 2px var(--teal);
}

.row-dragging .timeline-bar {
  background: #e8f7f4;
  box-shadow: 0 0 0 2px var(--teal), 0 12px 24px rgba(15, 118, 110, 0.18);
  transform: translateY(-1px);
}

.row-dragging {
  opacity: 0.82;
}

.row-drop-target .person-cell {
  position: sticky;
  background: var(--teal-soft);
}

.person-sort-active .timeline-cell {
  pointer-events: none;
}

.row-drop-before .person-cell::before,
.row-drop-after .person-cell::after {
  content: "";
  position: absolute;
  left: 0;
  right: -150px;
  height: 3px;
  background: var(--teal);
  z-index: 12;
}

.row-drop-before .person-cell::before {
  top: -2px;
}

.row-drop-after .person-cell::after {
  bottom: -2px;
}

.row-drop-before .person-cell strong::before,
.row-drop-after .person-cell strong::before {
  position: absolute;
  left: -14px;
  color: var(--teal);
  font-size: 18px;
  line-height: 1;
  z-index: 13;
}

.row-drop-before .person-cell strong::before {
  content: "➜";
  top: -11px;
}

.row-drop-after .person-cell strong::before {
  content: "➜";
  bottom: -13px;
}

.person-row-drag-image {
  position: fixed;
  top: -10000px;
  left: -10000px;
  width: 1100px;
  border-collapse: collapse;
  opacity: 0.92;
  pointer-events: none;
  box-shadow: 0 18px 40px rgba(23, 33, 34, 0.25);
}

.person-row-drag-image th,
.person-row-drag-image td {
  border: 1px solid var(--line);
  background: #d8f0ec;
}

.cell-capacity {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.matrix-chip {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 42px;
  margin-bottom: 5px;
  border-left: 4px solid var(--project-color);
  background: #f8fbfb;
  padding: 6px 22px 6px 7px;
}

.matrix-chip strong,
.matrix-chip span {
  overflow-wrap: anywhere;
}

.matrix-chip strong {
  font-size: 12px;
}

.matrix-chip span {
  color: var(--muted);
  font-size: 11px;
}

.matrix-chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.summary-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  padding: 12px;
}

.summary-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-range-text {
  align-self: center;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.chart-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fbfcfc;
  padding: 12px;
}

.chart-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-title-row h4 {
  margin: 0;
}

.chart-select {
  width: min(180px, 100%);
  min-height: 32px;
  font-size: 12px;
}

.pie-card-body {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.pie-chart-wrap {
  position: relative;
  width: 142px;
  height: 142px;
}

.pie-chart {
  position: absolute;
  left: 15px;
  top: 15px;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--surface-2);
  animation: pie-draw 520ms ease-out both;
}

.pie-chart span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.pie-chart.empty span {
  color: var(--muted);
}

.pie-percent {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.pie-percent.inside {
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 33, 34, 0.12);
}

.pie-percent.outside {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.pie-callout {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.chart-legend {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.chart-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
}

.chart-legend span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend strong {
  color: var(--ink);
}

@keyframes pie-draw {
  from {
    clip-path: circle(0% at 50% 50%);
  }
  to {
    clip-path: circle(75% at 50% 50%);
  }
}

.ut-input-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) repeat(3, 54px);
  gap: 6px;
}

.ut-input-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.summary-grid section {
  min-width: 0;
}

.summary-grid h4 {
  margin: 0 0 10px;
}

.summary-grid .wide {
  grid-column: 1 / -1;
}

.summary-table-link {
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.summary-table-link:hover,
.summary-table-link:focus-visible {
  color: var(--ink);
}

.pm-summary-table tr.is-selected {
  background: var(--teal-soft);
}

.pm-related-projects {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.pm-related-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pm-related-heading strong {
  color: var(--ink);
  font-size: 13px;
}

.related-project-table {
  margin-top: 8px;
}

.related-project-table th,
.related-project-table td {
  padding: 7px 8px;
  font-size: 12px;
}

.history-download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  padding: 12px;
}

.history-download span {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 20px);
  border: 1px solid var(--line);
  overflow: auto;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(12, 20, 20, 0.4);
}

.booking-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.booking-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.booking-option {
  display: flex !important;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 8px !important;
  color: var(--ink) !important;
}

.booking-option input {
  width: auto;
  min-height: 16px;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.holiday-warning {
  margin: 0 0 14px;
  border: 1px solid #e2a08d;
  background: #fff7f4;
  color: #8d2f1d;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.booking-capacity {
  border-left: 3px solid var(--line);
  padding-left: 8px;
}

.booking-capacity.warning {
  border-left-color: var(--red);
  background: #fff7f4;
  color: var(--red);
  padding-top: 6px;
  padding-bottom: 6px;
}

.booking-edit-confirm {
  border: 1px solid #f2b8a6;
  background: #fff7f4;
  padding: 8px;
}

.booking-edit-confirm label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--red) !important;
}

.booking-edit-confirm input {
  width: auto;
  margin: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .mobile-pane-toggle {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    height: 52px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    padding: 6px;
  }

  .mobile-pane-toggle button {
    min-height: 40px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 800;
  }

  .mobile-pane-toggle button[aria-pressed="true"] {
    border-color: var(--teal);
    background: var(--teal);
    color: #fff;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: calc(100dvh - 52px);
  }

  body[data-mobile-pane="controls"] .workspace,
  body[data-mobile-pane="workspace"] .sidebar {
    display: none;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .planner-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .view-toggle {
    width: 100%;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .toolbar .primary-action,
  .toolbar .secondary-action {
    min-height: 44px;
  }

  .toolbar .save-status {
    grid-column: 1 / -1;
  }

  .metrics-grid,
  .dashboard-grid,
  .summary-controls,
  .summary-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .pie-card-body {
    grid-template-columns: 1fr;
  }

  .icon-button,
  .primary-action,
  .secondary-action,
  .role-quick,
  .matrix-weekend-toggle,
  .booking-form menu button {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
  }

  .matrix-actions {
    width: 100%;
    justify-content: stretch;
  }

  .matrix-actions > .primary-action,
  .matrix-actions > .secondary-action {
    flex: 1 1 calc(50% - 10px);
  }

  .role-quick-actions {
    width: 100%;
  }

  .role-quick {
    flex: 1 1 calc(50% - 5px);
  }

  .matrix-view,
  .summary-view {
    padding: 10px;
  }

  .matrix-scroll {
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
  }

  .matrix-week-nav {
    justify-content: stretch;
  }

  .matrix-week-nav span {
    min-width: 0;
    flex: 1;
  }

  .booking-form {
    padding: 14px;
  }

  .booking-form menu {
    flex-wrap: wrap;
  }

  .booking-form menu button {
    flex: 1 1 140px;
  }

  .booking-action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .booking-action-summary {
    white-space: normal;
  }

  .booking-action-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .booking-action-buttons button {
    min-height: 44px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (max-width: 430px) {
  .ut-input-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


.project-panel .project-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 46vh;
}

.project-panel {
  flex: 1 1 auto;
  min-height: 420px;
}

.project-panel.collapsed {
  flex: 0 0 auto;
  min-height: 0;
}

.project-form {
  grid-template-columns: 1fr 1fr;
}

.project-form #projectName,
.project-form #projectNote {
  grid-column: 1 / -1;
}

.project-pill .meta-row span {
  overflow-wrap: anywhere;
}

.bulk-project-picker {
  display: grid;
  gap: 8px;
}

.project-picker-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.project-picker-filters label {
  min-width: 0;
}

@media (max-width: 1100px) {
  .project-panel .project-list {
    max-height: 34vh;
  }

  .project-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .project-panel .project-list {
    grid-template-columns: 1fr;
  }
}

/* Keep a large project pool inside its panel instead of extending the sidebar. */
.project-panel {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  height: min(56vh, 640px);
  max-height: min(56vh, 640px);
  min-width: 0;
  overflow: hidden;
}

.project-panel .project-list {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-height: none;
  overflow-y: auto;
}

.project-pill {
  min-width: 0;
}

.project-panel.collapsed {
  height: auto;
  max-height: none;
}

@media (max-width: 1100px) and (min-width: 901px) {
  .project-panel {
    height: min(52vh, 560px);
    max-height: min(52vh, 560px);
  }
}

@media (max-width: 900px) {
  .project-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .project-panel .project-list {
    flex: 0 1 auto;
    max-height: 34vh;
  }
}

/* UIX-12: compact planning workspace, explicit states, and resilient narrow layouts. */
:root {
  color-scheme: light dark;
  --green: #356b2b;
  --amber: #7a4b00;
  --shadow: 0 5px 16px rgba(22, 33, 34, 0.06);
}

.app-shell {
  grid-template-columns: clamp(320px, 29vw, 420px) minmax(0, 1fr);
}

.sidebar {
  gap: 12px;
  padding: 18px;
}

.panel,
.metric,
.planner-shell {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 12px;
}

.calendar-toolbar {
  grid-template-columns: 1fr;
}

.calendar-toolbar div {
  text-align: left;
}

.project-panel {
  flex: 0 1 auto;
  height: min(38vh, 390px);
  max-height: min(38vh, 390px);
  min-height: 230px;
}

.project-panel .project-list {
  grid-template-columns: 1fr;
  align-content: start;
  gap: 6px;
}

.project-pill {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  padding: 8px 10px;
}

.project-card-main {
  min-width: 0;
}

.project-pill .meta-row {
  margin-top: 3px;
  gap: 5px;
  line-height: 1.25;
}

.project-pill .project-usage {
  color: var(--muted);
}

.project-pill .card-actions {
  grid-template-columns: 1fr;
  gap: 4px;
}

.project-pill .card-actions button {
  min-height: 30px;
  padding: 3px 7px;
}

.workspace {
  padding: 18px;
}

.topbar h2 {
  font-size: 24px;
}

.planner-shell {
  overflow: visible;
}

.planner-header {
  gap: 14px 20px;
}

.planner-header > div:first-child {
  flex: 1 1 300px;
  min-width: 240px;
}

.matrix-actions {
  flex: 1 1 440px;
  min-width: 280px;
}

.matrix-week-nav {
  align-items: center;
  flex: 0 0 100%;
  justify-content: flex-end;
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.matrix-week-nav span {
  min-width: 170px;
}

.matrix-week-nav .secondary-action {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.view-toggle {
  width: 180px;
}

.booking-action-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
}

.selection-status {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.timeline-dropzone {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.timeline-dropzone .cell-state {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-dropzone.is-weekend {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 82%, transparent) 0 5px, color-mix(in srgb, var(--line) 42%, transparent) 5px 7px);
}

.timeline-dropzone.is-weekend .cell-state {
  color: var(--amber);
}

.timeline-dropzone.is-holiday {
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
}

.timeline-dropzone.is-holiday .cell-state {
  color: var(--red);
}

.timeline-dropzone.is-makeup-workday {
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
}

.timeline-dropzone.is-makeup-workday .cell-state {
  color: var(--green);
}

.timeline-dropzone.is-leave {
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
}

.timeline-dropzone.is-leave .cell-state {
  color: var(--blue);
}

.timeline-dropzone.is-release {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--red) 10%, var(--surface)) 0 5px, color-mix(in srgb, var(--red) 22%, var(--surface)) 5px 7px);
}

.timeline-dropzone.is-release .cell-state {
  color: var(--red);
}

.timeline-bar {
  border-radius: 3px;
  box-shadow: 0 4px 12px rgba(23, 33, 34, 0.08);
}

.timeline-bar.is-project-focused {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--project-color) 42%, transparent), 0 6px 14px rgba(23, 33, 34, 0.12);
}

.timeline-bar .resize-handle {
  z-index: 2;
}

.timeline-bar .resize-handle::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 3px;
  width: 3px;
  background: color-mix(in srgb, var(--project-color) 58%, transparent);
}

.distribution-total {
  margin: 2px 0 14px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.distribution-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.distribution-list {
  display: grid;
  gap: 11px;
}

.distribution-row {
  display: grid;
  gap: 5px;
}

.distribution-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.distribution-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distribution-label strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 12px;
}

.distribution-bar {
  height: 7px;
  overflow: hidden;
  background: var(--surface-2);
}

.distribution-bar span {
  display: block;
  width: var(--value);
  height: 100%;
  background: var(--teal);
  animation: distribution-grow 360ms ease-out both;
  animation-delay: calc(var(--bar-index) * 35ms);
}

@keyframes distribution-grow {
  from { width: 0; }
}

.confirm-impact {
  margin: 0;
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
  color: var(--ink);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(23, 33, 34, 0.16);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.toast-region > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.toast-region.is-success {
  border-left: 4px solid var(--green);
}

.toast-region.is-warning {
  border-left: 4px solid var(--amber);
}

.toast-region.is-error {
  border-left: 4px solid var(--red);
}

.toast-action {
  min-height: 30px;
  border: 1px solid var(--teal);
  background: var(--surface);
  color: var(--teal);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 1120px) and (min-width: 901px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .sidebar {
    padding: 14px;
  }

  .project-panel {
    height: min(34vh, 300px);
    max-height: min(34vh, 300px);
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .matrix-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .project-panel {
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .project-panel .project-list {
    max-height: 36vh;
  }
}

@media (max-width: 760px) {
  .matrix-week-nav {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .matrix-week-nav span {
    min-width: 0;
    flex: 1 1 150px;
  }

  .matrix-week-nav .secondary-action {
    flex: 1 1 120px;
  }

  .toast-region {
    right: 16px;
    bottom: 16px;
  }
}

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

@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: 4px;
  }

  .timeline-dropzone,
  .timeline-bar,
  .project-pill,
  .metric,
  .panel {
    border-color: currentColor;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101716;
    --surface: #182321;
    --surface-2: #233330;
    --ink: #edf5f1;
    --muted: #b5c3bf;
    --line: #3c5450;
    --teal: #55c5b5;
    --teal-soft: #17433e;
    --green: #9ad58b;
    --amber: #f1c36e;
    --red: #ff9f91;
    --blue: #8bb7ff;
    --shadow: 0 5px 16px rgba(0, 0, 0, 0.22);
  }

  body,
  .workspace {
    background: var(--bg);
  }

  .sidebar {
    background: #0e1b19;
  }

  .panel,
  .metric,
  .planner-shell,
  .chart-card,
  .summary-controls,
  .history-download,
  .booking-action-bar,
  .toast-region,
  dialog {
    background: var(--surface);
    color: var(--ink);
  }

  input,
  select,
  textarea,
  .calendar-day,
  .project-pill,
  .person-card,
  .leave-card,
  .secondary-action,
  .icon-button,
  .mini-action,
  .toast-action {
    background: var(--surface);
    color: var(--ink);
  }

  .calendar-day.outside-month,
  th,
  .summary-head,
  .person-summary,
  .timeline-dropzone.locked {
    background: var(--surface-2);
  }

  .timeline-bar,
  .matrix-chip {
    background: color-mix(in srgb, var(--surface) 88%, var(--teal));
  }

  .holiday-warning,
  .booking-capacity.warning,
  .booking-edit-confirm,
  .warning-row .person-summary,
  .person-card.warning {
    background: color-mix(in srgb, var(--red) 12%, var(--surface));
    color: var(--ink);
  }

  .tag.frontend,
  .tag.backend,
  .tag.qa,
  .tag.ba,
  .tag.pm {
    background: var(--surface-2);
    color: var(--ink);
  }

  .confirm-impact {
    background: color-mix(in srgb, var(--amber) 14%, var(--surface));
  }
}

/* UIX-12 follow-up: keep the project pool visual language from main. */
.app-shell {
  grid-template-columns: clamp(420px, 30vw, 480px) minmax(0, 1fr);
}

.project-panel {
  flex: 1 1 0;
  height: min(56vh, 640px);
  max-height: min(56vh, 640px);
  min-height: 420px;
}

.project-panel .project-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 auto;
  max-height: none;
}

.project-pill {
  grid-template-columns: none;
  align-items: stretch;
  min-height: 0;
  padding: 10px;
}

.project-pill .card-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.project-pill .card-actions .mini-action {
  min-height: 28px;
  padding: 4px 8px;
}

.project-pill .card-actions .mini-danger {
  min-height: 26px;
  padding: 3px 8px;
}

@media (max-width: 1100px) and (min-width: 901px) {
  .app-shell {
    grid-template-columns: clamp(420px, 30vw, 480px) minmax(0, 1fr);
  }

  .project-panel {
    height: min(52vh, 560px);
    max-height: min(52vh, 560px);
  }
}

@media (max-width: 900px) {
  .project-panel {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .project-panel .project-list {
    grid-template-columns: 1fr;
    flex: 0 1 auto;
    max-height: 34vh;
  }
}

/* UIX-13: Google Calendar-inspired planning workspace. */
:root {
  color-scheme: light dark;
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --ink: #3c4043;
  --muted: #5f6368;
  --line: #dadce0;
  --teal: #1a73e8;
  --teal-soft: #e8f0fe;
  --green: #188038;
  --amber: #b06000;
  --red: #d93025;
  --blue: #1a73e8;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Google Sans", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.app-shell {
  grid-template-columns: clamp(300px, 22vw, 360px) minmax(0, 1fr);
}

.sidebar {
  gap: 8px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.brand {
  gap: 10px;
  padding: 4px 6px 8px;
}

.mark {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  font-size: 11px;
}

.brand h1 {
  font-size: 16px;
}

.brand p {
  color: var(--muted);
}

.workspace {
  padding: 16px 20px 24px;
  background: var(--bg);
}

.panel,
.metric,
.planner-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 6px 8px 6px 12px;
}

.panel-heading {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-toggle {
  display: flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  line-height: 20px;
}

.module-toggle:hover,
.module-toggle:focus-visible {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.module-toggle:hover .module-chevron,
.module-toggle:focus-visible .module-chevron {
  color: var(--teal);
}

.module-chevron {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.panel-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.panel.collapsed .panel-body {
  display: none;
}

.project-panel {
  display: flex;
  flex: 1 1 260px;
  flex-direction: column;
  height: auto;
  max-height: none;
  min-height: 220px;
  overflow: visible;
}

.project-panel.collapsed {
  flex: 0 0 auto;
  min-height: 0;
}

.project-panel .panel-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.project-panel .project-list {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.project-pill {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--project-color);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: none;
  padding: 9px;
}

.project-pill.is-focused {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.project-pill .card-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.project-pill .card-actions .mini-action,
.project-pill .card-actions .mini-danger {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  justify-self: stretch;
  overflow: hidden;
  border-radius: 4px;
  padding: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-pool,
.leave-list {
  max-height: 22vh;
  overflow-y: auto;
}

.person-card,
.leave-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: none;
}

.icon-button,
.primary-action,
.secondary-action,
.danger-action,
.mini-action,
.mini-danger,
.role-quick,
.matrix-weekend-toggle,
.toast-action {
  border-radius: 4px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.panel-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 6px;
  height: 32px;
}

.module-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto;
  min-width: 58px;
  height: 32px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.module-action .action-glyph {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.module-action.add-holiday .action-glyph {
  background: color-mix(in srgb, var(--amber) 18%, var(--surface));
  color: var(--amber);
}

.module-action.add-makeup .action-glyph {
  background: color-mix(in srgb, var(--green) 18%, var(--surface));
  color: var(--green);
}

.module-action.add-leave .action-glyph {
  background: color-mix(in srgb, var(--blue) 16%, var(--surface));
  color: var(--blue);
}

input,
select,
textarea {
  border-radius: 4px;
  border-color: var(--line);
}

.topbar {
  min-height: 56px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  color: var(--ink);
  font-size: 22px;
}

.eyebrow,
.topbar .eyebrow {
  color: var(--muted);
}

.primary-action {
  border-color: var(--teal);
  background: var(--teal);
}

.secondary-action {
  border-color: var(--line);
  background: var(--surface);
  color: var(--teal);
}

.secondary-action:hover {
  background: var(--teal-soft);
}

.history-button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.history-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.metrics-grid {
  gap: 8px;
  margin-bottom: 10px;
}

.metric {
  min-height: 68px;
  border-left: 3px solid var(--teal);
  background: var(--surface);
  padding: 10px 12px;
}

.metric strong {
  font-size: 20px;
}

.metric.alert {
  border-left-color: var(--amber);
}

.planner-shell {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.planner-header {
  padding: 12px 14px;
}

.planner-header h3 {
  font-size: 16px;
}

.booking-action-bar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.matrix-view,
.summary-view {
  padding: 12px 14px 16px;
}

.matrix-actions {
  gap: 8px;
}

.view-toggle {
  border-color: var(--line);
  border-radius: 4px;
  background: var(--surface-2);
}

.view-tab.active,
.role-quick.active {
  background: var(--teal);
  color: #ffffff;
}

.resource-matrix {
  --person-column-width: clamp(112px, 13vw, 160px);
  --summary-column-width: clamp(104px, 11vw, 132px);
}

.resource-matrix th,
.resource-matrix td {
  border-color: var(--line);
}

.person-head,
.person-cell,
.summary-head,
.person-summary,
.matrix-cell,
.timeline-dropzone {
  background: var(--surface);
}

.person-cell:hover {
  background: var(--teal-soft);
}

.timeline-dropzone.locked {
  background: var(--surface-2);
}

.timeline-dropzone.drag-over {
  background: #d2e3fc;
  outline-color: var(--teal);
}

.timeline-dropzone.selected-range {
  background: var(--teal-soft);
  outline-color: var(--teal);
}

.timeline-dropzone.is-weekend {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, #e5e7e9 5px 7px);
}

.timeline-dropzone.is-weekend .cell-state {
  color: var(--amber);
}

.timeline-dropzone.is-holiday {
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
}

.timeline-dropzone.is-holiday .cell-state {
  color: var(--red);
}

.timeline-dropzone.is-leave {
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
}

.timeline-dropzone.is-leave .cell-state {
  color: var(--blue);
}

.timeline-dropzone.is-release {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--red) 10%, var(--surface)) 0 5px, color-mix(in srgb, var(--red) 22%, var(--surface)) 5px 7px);
}

.timeline-dropzone.is-release .cell-state {
  color: var(--red);
}

.timeline-bar {
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.18);
}

.timeline-bar.is-booking-selected {
  outline-color: var(--teal);
}

.summary-controls,
.chart-card {
  border-radius: 8px;
  box-shadow: none;
}

/* UIX-13 layout consolidation: single source of truth for sidebar panel
   headers, collapse behaviour, and card action rows. Earlier scattered
   redefinitions of these selectors conflicted in the cascade; the rules
   below win at desktop width, and the narrow-width media queries that
   follow still override where needed. */

/* -- Panel header: keep the add button and collapse toggle on one axis -- */
.panel-title {
  align-items: center;
  gap: 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-actions > * {
  align-self: center;
}

.panel-actions .icon-button,
.panel-actions .module-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  line-height: 1;
}

/* text-labelled actions (节假日 / 休假) keep their intrinsic width */
.panel-actions .module-action {
  width: auto;
  min-width: 0;
  padding: 4px 8px;
}

/* Draw the collapse chevron with CSS so it is optically centred and its
   direction follows aria-expanded, instead of relying on the unicode
   arrowhead glyph whose metrics sit off-centre. */
.panel-actions .module-toggle .module-chevron {
  display: none;
}

.panel-actions .module-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(2px) rotate(225deg);
}

.panel-actions .module-toggle[aria-expanded="false"]::before {
  transform: translateY(-2px) rotate(45deg);
}

/* -- Card lists: rows size to content so action buttons never clip -- */
.project-list,
.people-pool,
.leave-list {
  align-content: start;
  grid-auto-rows: min-content;
}

.project-pill,
.person-card,
.leave-card {
  align-items: stretch;
  overflow: visible;
}

/* -- Card action rows: two equal, full-width buttons inside the card -- */
.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}

.card-actions .mini-action,
.card-actions .mini-danger {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  margin: 0;
  justify-self: stretch;
  box-sizing: border-box;
}

@media (max-width: 1120px) and (min-width: 901px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .sidebar {
    padding: 10px;
  }

  .project-panel .project-list {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .workspace {
    padding: 12px 14px 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .matrix-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .project-panel .project-list {
    grid-template-columns: 1fr;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 10px;
  }

  .planner-header,
  .topbar {
    padding: 10px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --surface: #292a2d;
    --surface-2: #3c4043;
    --ink: #e8eaed;
    --muted: #bdc1c6;
    --line: #5f6368;
    --teal: #8ab4f8;
    --teal-soft: #1f3b5e;
    --green: #81c995;
    --amber: #fdd663;
    --red: #f28b82;
    --blue: #8ab4f8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }

  .sidebar,
  .workspace {
    background: var(--bg);
  }

  .mark {
    background: var(--teal);
    color: #202124;
  }

  .project-pill,
  .person-card,
  .leave-card,
  .timeline-bar {
    background: var(--surface);
  }

  .timeline-dropzone.is-weekend {
    background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, #4a4c50 5px 7px);
  }

  .timeline-dropzone.drag-over {
    background: #304b6b;
  }
}

/* UIX-13 desktop proportion pass: give the sidebar a single scroll axis and
   a tighter month grid. Scoped to >=1121px so the narrow / mobile-pane
   layouts below are left untouched. Previously the sidebar scrolled while
   the project pool and people pool each scrolled internally — competing
   scrollbars that made the vertical proportions feel cramped, with the
   static month calendar dominating the space. */
@media (min-width: 1121px) {
  /* Panels size to their content; the sidebar itself is the only scroller. */
  .calendar-panel,
  .project-panel,
  .resource-panel,
  .leave-panel {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .project-panel .panel-body,
  .project-list,
  .people-pool,
  .leave-list {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  /* Reclaim vertical space from the week-selector month grid. */
  .calendar-day {
    min-height: 28px;
  }
}

/* UIX-14: restore month paging in the left calendar. */
.calendar-toolbar {
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 8px;
}

.calendar-toolbar > div {
  min-width: 0;
  text-align: center;
}

.calendar-toolbar > .icon-button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.month-nav-glyph {
  display: inline-block;
  position: relative;
  left: 50%;
  transform: translateX(-50%) translateY(-30%);
  width: auto;
  height: auto;
  color: currentColor;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", Arial, sans-serif;
  font-size: 25px;
  font-weight: 600;
  line-height: 1;
}

.calendar-toolbar > .icon-button:hover,
.calendar-toolbar > .icon-button:focus-visible {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

/* UIX-15: split the project pool by lifecycle status. */
.project-status-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
}

.project-status-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 32px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.project-status-tab:hover,
.project-status-tab:focus-visible,
.project-status-tab.active {
  background: var(--surface);
  color: var(--teal);
}

.project-status-tab.active {
  box-shadow: var(--shadow);
}

.tab-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.project-status-chip {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 20px;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.project-status-chip.active {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
}

.project-status-chip.completed {
  background: var(--surface-2);
  color: var(--muted);
}

.project-pill.is-completed {
  border-left-color: var(--muted);
}

/* Keep the month controls smaller than the module collapse controls at the
   end of the cascade, including after the desktop sidebar overrides. */
.calendar-toolbar > .icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-width: 1px;
  font-size: 18px;
}

.month-nav-glyph {
  display: grid;
  position: static;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transform: translate(0.5px, -1px);
}

/* UIX-16 rework: the Overview control sits beside its title like sidebar modules. */
.resource-overview {
  margin-bottom: 10px;
}

.resource-overview .overview-header {
  min-height: 44px;
  margin: 0;
  padding: 6px 8px 6px 12px;
}

.overview-title {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.overview-title .eyebrow {
  flex: 0 0 auto;
  margin: 0;
  line-height: 20px;
}

.overview-title .panel-heading {
  display: block;
  flex: 0 0 auto;
}

.overview-title .panel-actions {
  flex: 0 0 auto;
}

.resource-overview .metrics-grid {
  margin-bottom: 0;
}

.resource-overview .metrics-grid.hidden {
  display: none;
}

.matrix-span-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  padding: 3px;
}

.matrix-span-tab {
  min-height: 26px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.matrix-span-tab:hover,
.matrix-span-tab:focus-visible,
.matrix-span-tab.active {
  background: var(--surface);
  color: var(--teal);
  box-shadow: var(--shadow);
}

.timeline-dropzone {
  user-select: none;
}

/* UIX-16 follow-up: keep horizontal matrix scrolling below fixed columns. */
.matrix-scroll {
  position: relative;
  isolation: isolate;
}

.resource-matrix thead th,
.resource-matrix tbody td {
  isolation: isolate;
}

.resource-matrix thead th:not(.person-head):not(.summary-head) {
  z-index: 1;
}

.matrix-header-shell {
  position: relative;
  z-index: 9;
  overflow: clip;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transform: translateY(var(--matrix-header-float-offset, 0px));
}

.matrix-header-shell.is-floating {
  z-index: 20;
  box-shadow: 0 2px 8px rgba(23, 33, 34, 0.14);
}

.matrix-header-table {
  --matrix-header-offset: 0px;
}

.matrix-header-table .matrix-date-head {
  transform: translate3d(var(--matrix-header-offset), 0, 0);
}

.resource-matrix thead th.current-week-head {
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  box-shadow: inset 0 -3px 0 var(--teal);
}

.resource-matrix tbody .timeline-cell {
  position: relative;
  z-index: 0;
}

.resource-matrix tbody .timeline-track {
  position: relative;
  z-index: 0;
}

.resource-matrix tbody .person-cell,
.resource-matrix tbody .person-summary {
  position: sticky;
  background: var(--surface);
  z-index: 4;
}

.resource-matrix thead .person-head,
.resource-matrix thead .summary-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 8;
}

.resource-matrix thead .person-head {
  left: 0;
  z-index: 9;
}

.resource-matrix thead .summary-head {
  left: var(--person-column-width);
}

/* Keep the UT boundary visibly attached to the UT cell itself. */
.resource-matrix .summary-head,
.resource-matrix .person-summary {
  border-right-color: transparent;
}

.resource-matrix .summary-head::after,
.resource-matrix .person-summary::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2px;
  background: color-mix(in srgb, var(--teal) 62%, var(--line));
  content: "";
  pointer-events: none;
}

/* Use the measured first column width so double-week and infinite views do not leave a gap. */
.resource-matrix .summary-head,
.resource-matrix .person-summary {
  left: var(--matrix-summary-left, var(--person-column-width));
}

@media (max-width: 760px) {
  .matrix-span-toggle {
    flex: 1 1 130px;
  }

  .matrix-span-tab {
    flex: 1 1 0;
  }
}

@media (max-width: 430px) {
  .project-picker-filters {
    grid-template-columns: 1fr;
  }
}
