:root {
  --bg: #f6f8fb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --line: rgba(148, 163, 184, 0.22);
  --text: #111827;
  --muted: #6b7280;
  --accent: #e5ebf3;
  --accent-strong: #334155;
  --accent-soft: rgba(226, 232, 240, 0.75);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Apple SD Gothic Neo', 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 24%),
    radial-gradient(circle at bottom right, rgba(226, 232, 240, 0.72), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.auth-screen,
.onboarding-screen {
  min-height: 100vh;
  padding: 32px;
}

.auth-screen {
  display: grid;
  place-items: center;
}

.onboarding-screen {
  display: grid;
  place-items: start center;
}

.auth-card,
.onboarding-shell {
  width: min(100%, 860px);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(100%, 480px);
  padding: 32px;
  display: grid;
  gap: 20px;
}

.auth-copy {
  display: grid;
  gap: 8px;
}

.auth-copy h1,
.onboarding-hero h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.auth-copy p,
.onboarding-copy,
.guide-completion p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
}

.auth-status {
  min-height: 24px;
}

.onboarding-shell {
  width: 100%;
  max-width: 1220px;
  padding: 28px;
  display: grid;
  gap: 24px;
  transition: padding 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.onboarding-hero {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  justify-items: stretch;
  text-align: left;
}

.onboarding-hero .eyebrow {
  justify-self: start;
}

.onboarding-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
}

.guide-stack {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.guide-card {
  display: grid;
  grid-template-rows: 0fr;
  margin: 0;
  scroll-margin-top: 40px;
  border-radius: 28px;
  border: 0 solid rgba(148, 163, 184, 0.18);
  background: rgba(248, 250, 252, 0.82);
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px);
  box-shadow: none;
  transition:
    grid-template-rows 980ms cubic-bezier(0.22, 1, 0.36, 1),
    border-width 420ms ease,
    opacity 420ms ease,
    transform 980ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 520ms ease,
    border-color 520ms ease,
    background-color 520ms ease,
    visibility 0s linear 980ms;
}

.guide-card.is-active,
.guide-card.is-complete {
  visibility: visible;
  opacity: 1;
  border-width: 1px;
  transition-delay: 0s;
  grid-template-rows: 1fr;
}

.guide-card.is-active {
  border-color: rgba(51, 65, 85, 0.34);
  background: rgba(255, 255, 255, 0.98);
  transform: translateY(0);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.12);
}

.guide-card.is-locked {
  pointer-events: none;
}

.guide-card.is-complete {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(148, 163, 184, 0.24);
  transform: translateY(0);
}

.guide-card-inner {
  min-height: 0;
  overflow: hidden;
  padding: 24px;
  transition:
    padding 680ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 380ms ease,
    transform 980ms cubic-bezier(0.22, 1, 0.36, 1);
}

.guide-card.is-complete .guide-card-inner {
  padding: 18px 20px;
}

.guide-period-row,
.field-row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.guide-shift-row,
.field-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.guide-card .hint,
.guide-card .field-row,
.guide-card .guide-team-section,
.guide-card .chip-panel,
.guide-card .table-section,
.guide-card .guide-actions .primary-btn,
.guide-card .guide-action-buttons .ghost-btn {
  opacity: 1;
  max-height: 1200px;
  transition:
    opacity 280ms ease,
    max-height 680ms cubic-bezier(0.22, 1, 0.36, 1),
    margin 420ms ease;
}

.guide-card.is-complete .hint,
.guide-card.is-complete .field-row,
.guide-card.is-complete .guide-team-section,
.guide-card.is-complete .chip-panel,
.guide-card.is-complete .table-section,
.guide-card.is-complete .guide-actions .primary-btn,
.guide-card.is-complete .guide-action-buttons .ghost-btn {
  opacity: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
}

.guide-card.is-complete .card-head {
  margin-bottom: 0;
}

.guide-card.is-complete .guide-actions {
  margin-top: 10px;
  justify-content: flex-start;
}

.guide-card.is-complete .guide-action-buttons .ghost-btn,
.guide-card.is-complete .guide-action-buttons .primary-btn {
  display: none;
}

.guide-step-badge {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
}

.guide-action-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.guide-completion {
  padding: 22px 24px;
  border-radius: 24px;
  background: rgba(236, 253, 245, 0.92);
  border: 1px solid rgba(74, 222, 128, 0.34);
}

.guide-completion strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.onboarding-table-section {
  margin-top: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 20px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(18px);
}

.sidebar-main {
  display: grid;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  font-family: 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sidebar h1,
.panel-header h2,
.card-head h3 {
  margin: 0;
  line-height: 1.15;
}

.sidebar h1 {
  font-size: 34px;
}

.sidebar-copy {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-top: -4px;
}

.sidebar-account-email {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  color: #475569;
  cursor: pointer;
  flex: 0 0 auto;
}

.sidebar-logout-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-logout-btn:hover {
  background: rgba(226, 232, 240, 0.96);
  color: #0f172a;
}

.step-list {
  display: grid;
  gap: 12px;
}

.step-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  text-align: left;
  padding: 14px 16px;
  border-radius: 20px;
  cursor: pointer;
  overflow: hidden;
}

.step-item span {
  font-family: 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  color: var(--muted);
  flex: 0 0 auto;
}

.step-item strong {
  display: inline;
  font-size: 16px;
}

.step-complete-badge {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.14);
  color: #166534;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateX(8px) scale(0.92);
  pointer-events: none;
}

.step-item.is-active {
  background: linear-gradient(135deg, rgba(241, 245, 249, 0.96), rgba(226, 232, 240, 0.9));
  border-color: rgba(148, 163, 184, 0.42);
  box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.75);
}

.step-item.is-completion-celebrating {
  animation: step-completion-glow 2.3s ease forwards;
}

.step-item.is-completion-celebrating .step-complete-badge {
  animation: step-complete-badge-pop 2.3s ease forwards;
}

@keyframes step-completion-glow {
  0% {
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0), 0 0 0 rgba(34, 197, 94, 0);
    background: rgba(255, 255, 255, 0.72);
  }
  18% {
    border-color: rgba(34, 197, 94, 0.52);
    box-shadow: inset 0 0 0 1px rgba(187, 247, 208, 0.88), 0 10px 24px rgba(34, 197, 94, 0.16);
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(255, 255, 255, 0.94));
  }
  72% {
    border-color: rgba(74, 222, 128, 0.42);
    box-shadow: inset 0 0 0 1px rgba(187, 247, 208, 0.6), 0 4px 10px rgba(34, 197, 94, 0.08);
    background: linear-gradient(135deg, rgba(240, 253, 244, 0.98), rgba(255, 255, 255, 0.92));
  }
  100% {
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0);
    background: rgba(255, 255, 255, 0.72);
  }
}

@keyframes step-complete-badge-pop {
  0% {
    opacity: 0;
    transform: translateX(8px) scale(0.92);
  }
  16%,
  58% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(2px) scale(0.96);
  }
}

.history-toolbar-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.history-toolbar-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
}

.sidebar-history-btn {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.history-graph {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.history-empty {
  min-width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.history-node-item {
  position: relative;
  flex: 0 0 auto;
  min-width: 208px;
  overflow: visible;
}

.history-node-item::before,
.history-node-item::after {
  content: '';
  position: absolute;
  top: 20px;
  height: 3px;
  background: rgba(37, 99, 235, 0.55);
  z-index: 0;
}

.history-node-item::before {
  left: -6px;
  width: 6px;
}

.history-node-item::after {
  right: -6px;
  width: 6px;
}

.history-node-item:first-child::before {
  display: none;
}

.history-node-item:last-child::after {
  display: none;
}

.history-node-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 38px 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-width: 0;
  z-index: 1;
}

.history-node-btn.is-selected,
.history-node-btn.is-current {
  border: 2px solid #2563eb;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.96));
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.history-node-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #334155;
  box-shadow: 0 0 0 3px rgba(226, 232, 240, 0.92);
}

.history-node-btn.is-selected .history-node-dot,
.history-node-btn.is-current .history-node-dot {
  background: #2563eb;
  box-shadow: 0 0 0 4px rgba(219, 234, 254, 0.95);
}

.history-node-copy {
  display: grid;
  gap: 0;
  min-width: 0;
}

.history-node-copy strong,
.history-node-copy small {
  display: block;
}

.history-node-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.history-node-badge {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 3px 7px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.history-node-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(248, 113, 113, 0.16);
  background: rgba(255, 255, 255, 0.92);
  color: #b91c1c;
  padding: 0;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.history-node-item:hover .history-node-delete,
.history-node-item:focus-within .history-node-delete {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.history-node-delete:hover,
.history-node-delete:focus {
  outline: none;
  background: rgba(254, 242, 242, 0.96);
  border-color: rgba(248, 113, 113, 0.34);
}

.main-panel {
  display: grid;
  gap: 20px;
  padding: 20px;
  align-content: start;
}

.history-toolbar {
  position: sticky;
  top: 20px;
  z-index: 30;
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 28px;
}

.panel.is-active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.period-preview {
  min-width: 160px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-weight: 700;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.card {
  padding: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 26px;
}

.card-large {
  grid-column: 1 / -1;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.card-head-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.hint {
  margin: 0;
  max-width: 280px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.field-row {
  display: grid;
  gap: 16px;
}

.field-row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #fff;
  color: var(--text);
}

.summary-box,
.placeholder-card,
.insight-card,
.table-section {
  padding: 18px;
  margin-top: 18px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.16);
  line-height: 1.7;
}

.summary-box strong,
.placeholder-title {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.chip-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.chip-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shift-editor-field {
  align-content: start;
}

.shift-editor {
  display: grid;
  gap: 12px;
}

.shift-editor-chips {
  min-height: 42px;
  align-items: flex-start;
}

.shift-editor-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.shift-editor-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #fff;
  color: var(--text);
}

.shift-editor-add-btn {
  padding-inline: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 13px;
  font-weight: 700;
}

.chip.is-fixed {
  background: #fff;
  border-color: rgba(148, 163, 184, 0.18);
  color: var(--text);
}

.chip-removable {
  padding-right: 8px;
}

.chip-remove-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.chip-remove-btn:hover {
  color: var(--text);
}

.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}

.validation-message {
  color: var(--muted);
  line-height: 1.6;
}

.validation-message.is-error {
  color: #dc2626;
}

.actions {
  display: flex;
  gap: 12px;
}

.primary-btn,
.ghost-btn {
  border: 0;
  padding: 14px 18px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #1f2937, #334155);
  color: #fff;
}

.ghost-btn {
  background: #f8fafc;
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.inline-action-btn {
  padding: 10px 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #ffffff;
}

.inline-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.team-config-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.team-config-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    linear-gradient(180deg, rgba(241, 245, 249, 0.9), rgba(255, 255, 255, 0.98)),
    #fff;
}

.team-config-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.team-config-title {
  display: grid;
  gap: 3px;
}

.team-config-title strong {
  font-size: 18px;
}

.team-remove-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.team-count-input {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.team-card-preview {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.guide-team-section {
  display: grid;
  gap: 14px;
}

.guide-team-toolbar {
  display: flex;
  justify-content: flex-end;
}

.guide-team-section .team-card-preview {
  display: none;
}

.primary-btn.is-disabled,
.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-preview {
  margin-top: 16px;
  overflow-x: auto;
}

.insight-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.table-section {
  padding: 22px;
}

.table-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
}

.preview-table,
.matrix-table,
.assignment-table,
.skill-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  table-layout: fixed;
}

.preview-table th,
.preview-table td,
.matrix-table th,
.matrix-table td,
.assignment-table th,
.assignment-table td,
.skill-table th,
.skill-table td {
  min-width: 0;
  padding: 6px 4px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  text-align: center;
  font-size: 12px;
}

.preview-table th:first-child,
.preview-table td:first-child,
.matrix-table th:first-child,
.matrix-table td:first-child {
  width: 74px;
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 1;
}

.assignment-table th:first-child,
.assignment-table td:first-child {
  width: 136px;
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 1;
}

.matrix-table thead th,
.assignment-table thead th,
.preview-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 2;
}

.matrix-table thead th:first-child,
.assignment-table thead th:first-child,
.preview-table thead th:first-child {
  z-index: 3;
}

.day-total {
  font-size: 10px;
  color: var(--muted);
}

.date-head {
  display: grid;
  gap: 2px;
  justify-items: center;
  line-height: 1.1;
}

.date-number {
  font-weight: 700;
}

.weekday-label {
  font-size: 10px;
  color: var(--muted);
}

.is-holiday .date-number,
.is-holiday .weekday-label {
  color: #dc2626;
}

.holiday-name {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  color: #dc2626;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-table th:not(:first-child),
.matrix-table td:not(:first-child),
.assignment-table th:not(:first-child):not(.assignment-summary-head),
.assignment-table td:not(:first-child):not(.assignment-summary-cell) {
  width: calc((100% - 136px) / var(--day-count, 31));
}

.matrix-table td,
.assignment-table td {
  height: 42px;
}

.assignment-summary-head,
.assignment-summary-cell {
  width: 56px;
  min-width: 56px;
  white-space: nowrap;
}

.assignment-summary-head {
  background: #eef4ff;
}

.assignment-summary-head.is-summary-start,
.assignment-summary-cell.is-summary-start {
  border-left-width: 2px;
  border-left-color: rgba(59, 130, 246, 0.22);
}

.skill-table th:first-child,
.skill-table td:first-child {
  position: static;
  left: auto;
  width: 60%;
  background: #ffffff;
  z-index: auto;
}

.skill-table th:not(:first-child),
.skill-table td:not(:first-child) {
  width: 40%;
}

.skill-table thead th {
  position: static;
  top: auto;
  background: #f8fafc;
  z-index: auto;
}

.skill-table td {
  height: 32px;
}

.matrix-cell {
  cursor: cell;
  user-select: none;
  padding: 0;
}

.assignment-cell {
  cursor: cell;
  user-select: none;
  padding: 0;
}

.assignment-name-cell {
  padding: 0;
  min-width: 136px;
  background: rgba(255, 255, 255, 0.9);
}

.skill-name-cell {
  padding: 0;
  min-width: 0;
  background: rgba(255, 255, 255, 0.9);
}

.skill-cell {
  cursor: cell;
  user-select: none;
  padding: 0;
}

.matrix-cell.is-selected {
  background: rgba(226, 232, 240, 0.7);
}

.assignment-cell.is-selected {
  background: rgba(219, 234, 254, 0.72);
}

.skill-cell.is-selected {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.78);
}

.matrix-cell.is-active {
  box-shadow: inset 0 0 0 2px rgba(100, 116, 139, 0.7);
}

.matrix-table th.is-over-capacity {
  background: rgba(254, 226, 226, 0.9);
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.38);
}

.matrix-cell.is-over-capacity {
  background: rgba(254, 242, 242, 0.92);
  box-shadow: inset 0 0 0 2px rgba(248, 113, 113, 0.34);
}

.matrix-cell.is-over-capacity.is-selected {
  background: rgba(254, 226, 226, 0.92);
}

.matrix-cell.is-over-capacity.is-active {
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.7);
}

.assignment-cell.is-active {
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.7);
}

.assignment-name-cell.is-active,
.skill-name-cell.is-active {
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.7);
  background: rgba(239, 246, 255, 0.92);
}

.skill-cell.is-active {
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    inset 0 0 0 3px rgba(29, 78, 216, 0.98),
    inset 0 0 0 5px rgba(191, 219, 254, 0.72);
}

.matrix-cell:focus {
  outline: none;
}

.assignment-cell:focus {
  outline: none;
}

.assignment-name-input,
.skill-name-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.assignment-name-input::placeholder,
.skill-name-input::placeholder {
  color: rgba(100, 116, 139, 0.72);
}

.assignment-name-input:focus,
.skill-name-input:focus {
  outline: none;
}

.skill-cell:focus {
  outline: none;
}

.matrix-value {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 40px;
  font-weight: 600;
}

.assignment-value {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 40px;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 700;
}

.assignment-value.is-multi {
  color: #2563eb;
}

.assignment-value.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.generated-schedule-cell {
  padding: 0;
  overflow: visible;
}

.generated-schedule-cell .assignment-value {
  position: relative;
  z-index: 0;
  isolation: isolate;
  box-sizing: border-box;
  height: 100%;
  min-height: 42px;
  padding: 0 2px;
  transition: background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-highlight {
  color: var(--pattern-text, #0f172a);
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-highlight::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 2px;
  right: 2px;
  z-index: -1;
  box-sizing: border-box;
  background: var(--pattern-surface, rgba(226, 232, 240, 0.94));
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-start::before {
  right: -4px;
  border-top: 2px solid var(--pattern-accent, #475569);
  border-bottom: 2px solid var(--pattern-accent, #475569);
  border-left: 2px solid var(--pattern-accent, #475569);
  border-radius: 12px 0 0 12px;
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-middle::before {
  left: -4px;
  right: -4px;
  border-top: 2px solid var(--pattern-accent, #475569);
  border-bottom: 2px solid var(--pattern-accent, #475569);
  border-radius: 0;
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-end::before {
  left: -4px;
  border-top: 2px solid var(--pattern-accent, #475569);
  border-right: 2px solid var(--pattern-accent, #475569);
  border-bottom: 2px solid var(--pattern-accent, #475569);
  border-radius: 0 12px 12px 0;
}

.generated-schedule-cell.is-pattern-cell .assignment-value.is-pattern-single::before {
  border: 2px solid var(--pattern-accent, #475569);
  border-radius: 12px;
}

.pattern-tone-nod {
  --pattern-accent: #b91c1c;
  --pattern-surface: rgba(254, 226, 226, 0.94);
  --pattern-text: #7f1d1d;
}

.pattern-tone-wanted {
  --pattern-accent: #be185d;
  --pattern-surface: rgba(252, 231, 243, 0.96);
  --pattern-text: #9d174d;
}

.pattern-tone-o {
  --pattern-accent: #0369a1;
  --pattern-surface: rgba(224, 242, 254, 0.96);
  --pattern-text: #075985;
}

.pattern-tone-eod {
  --pattern-accent: #c2410c;
  --pattern-surface: rgba(255, 237, 213, 0.94);
  --pattern-text: #9a3412;
}

.pattern-tone-noe {
  --pattern-accent: #0f766e;
  --pattern-surface: rgba(204, 251, 241, 0.94);
  --pattern-text: #115e59;
}

.pattern-tone-alternating {
  --pattern-accent: #7c3aed;
  --pattern-surface: rgba(237, 233, 254, 0.94);
  --pattern-text: #5b21b6;
}

.pattern-tone-streak {
  --pattern-accent: #1d4ed8;
  --pattern-surface: rgba(219, 234, 254, 0.94);
  --pattern-text: #1e3a8a;
}

.skill-editor-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.skill-team-section {
  margin-top: 0;
}

.skill-team-head {
  margin-bottom: 8px;
}

.skill-team-summary {
  max-width: none;
  text-align: right;
}

.skill-table-wrap {
  max-height: 72vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.personal-preference-grid {
  grid-template-columns: 1fr;
}

.personal-preference-table-wrap {
  max-height: none;
}

.skill-table th,
.skill-table td {
  padding: 4px 3px;
  font-size: 11px;
}

.skill-value {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 30px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
}

.skill-value.is-skill-lead,
.skill-palette-main.is-skill-lead,
.skill-palette-input.is-skill-lead,
.skill-palette-menu-toggle.is-skill-lead {
  color: #1e3a8a;
  background: #dbeafe;
}

.skill-value.is-skill-senior,
.skill-palette-main.is-skill-senior,
.skill-palette-input.is-skill-senior,
.skill-palette-menu-toggle.is-skill-senior {
  color: #0f766e;
  background: #ccfbf1;
}

.skill-value.is-skill-staff,
.skill-palette-main.is-skill-staff,
.skill-palette-input.is-skill-staff,
.skill-palette-menu-toggle.is-skill-staff {
  color: #92400e;
  background: #fef3c7;
}

.skill-value.is-skill-support,
.skill-palette-main.is-skill-support,
.skill-palette-input.is-skill-support,
.skill-palette-menu-toggle.is-skill-support {
  color: #475569;
  background: #e2e8f0;
}

.skill-value.is-skill-reserve,
.skill-palette-main.is-skill-reserve,
.skill-palette-input.is-skill-reserve,
.skill-palette-menu-toggle.is-skill-reserve {
  color: #9a3412;
  background: #ffedd5;
}

.skill-palette {
  align-items: flex-start;
}

.skill-palette-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
}

.skill-palette-chip {
  display: inline-flex;
  align-items: stretch;
  min-height: 38px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
}

.skill-palette-main,
.skill-palette-input,
.skill-palette-menu-toggle {
  border: 0;
  border-radius: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.skill-palette-main,
.skill-palette-input {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 999px 0 0 999px;
}

.skill-palette-main {
  cursor: pointer;
}

.skill-palette-input {
  width: 84px;
  text-align: center;
}

.skill-palette-input:focus {
  outline: none;
}

.skill-palette-menu-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  padding: 0;
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0 999px 999px 0;
  cursor: pointer;
}

.skill-palette-main:hover,
.skill-palette-main:focus,
.skill-palette-input:focus,
.skill-palette-menu-toggle:hover,
.skill-palette-menu-toggle:focus {
  filter: brightness(0.98);
  outline: none;
}

.skill-palette-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 24;
  display: grid;
  gap: 4px;
  min-width: 108px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.skill-palette-menu-item {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.skill-palette-menu-item:hover,
.skill-palette-menu-item:focus {
  outline: none;
  background: rgba(241, 245, 249, 0.92);
}

.skill-palette-menu-item.is-danger {
  color: #b91c1c;
}

.skill-palette-menu-item.is-danger:hover,
.skill-palette-menu-item.is-danger:focus {
  background: rgba(254, 242, 242, 0.96);
}

.skill-palette-menu-item:disabled,
.skill-palette-add-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.skill-palette-add-btn {
  background: #f8fafc;
}

.skill-palette-btn {
  min-width: 64px;
}

.skill-palette-main.skill-palette-btn {
  border-radius: 999px 0 0 999px;
  padding: 8px 12px;
}

.skill-palette-add-btn.skill-palette-btn {
  border-radius: 999px;
}

.skill-constraint-panel {
  margin: 18px 0 22px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.72);
}

.skill-constraint-head {
  margin-bottom: 14px;
}

.skill-constraint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.skill-constraint-warning-list,
.skill-constraint-inline-warnings {
  display: grid;
  gap: 8px;
}

.skill-constraint-warning,
.skill-constraint-inline-warning {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(248, 113, 113, 0.24);
  background: rgba(254, 242, 242, 0.92);
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.skill-constraint-inline-warning {
  padding: 8px 10px;
}

.skill-constraint-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.skill-constraint-card {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  padding: 16px;
}

.skill-constraint-card.is-selected {
  border-color: rgba(59, 130, 246, 0.28);
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.08);
}

.skill-constraint-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.skill-constraint-card-head h4 {
  margin: 0;
  font-size: 14px;
}

.skill-constraint-preview {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.skill-constraint-card-body {
  display: grid;
  gap: 14px;
}

.skill-constraint-shift-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-constraint-shift-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.skill-constraint-shift-btn:hover,
.skill-constraint-shift-btn:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.26);
  background: rgba(239, 246, 255, 0.94);
}

.skill-constraint-shift-btn.is-active {
  border-color: rgba(59, 130, 246, 0.28);
  background: rgba(219, 234, 254, 0.88);
  color: #1d4ed8;
}

.skill-constraint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.skill-constraint-grid.is-with-count {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.skill-constraint-delete-btn {
  flex: 0 0 auto;
}

.assignment-toolbar {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.personal-preference-table th:first-child,
.personal-preference-table td:first-child {
  width: 22%;
}

.personal-preference-table th:nth-child(2),
.personal-preference-table th:nth-child(3),
.personal-preference-table td:nth-child(2),
.personal-preference-table td:nth-child(3) {
  width: 20%;
}

.personal-preference-table th:nth-child(4),
.personal-preference-table td:nth-child(4) {
  width: 28%;
}

.personal-preference-table th:nth-child(5),
.personal-preference-table td:nth-child(5) {
  width: 10%;
}

.personal-preference-name {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  font-weight: 600;
  color: var(--text);
}

.personal-preference-select-field {
  gap: 0;
  min-width: 0;
}

.personal-preference-select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.personal-preference-select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 0 3px rgba(191, 219, 254, 0.6);
}

.personal-preference-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
  align-items: center;
  padding: 0 8px;
}

.personal-preference-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(219, 234, 254, 0.78);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.personal-preference-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.personal-preference-clear-btn {
  width: 100%;
}

.personal-preference-clear-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.rotating-guide {
  min-height: 24px;
}

.relationship-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.relation-list {
  display: grid;
  gap: 10px;
}

.relation-empty {
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
}

.relation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.relation-row.is-with-count {
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) minmax(78px, auto) auto;
}

.relation-field {
  gap: 0;
}

.relation-select-field {
  position: relative;
}

.relation-select-field::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #6b7280;
  border-bottom: 1.5px solid #6b7280;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.relation-select {
  width: 100%;
  padding: 12px 34px 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

.relation-count-field {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 78px;
  padding: 0 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  cursor: text;
}

.relation-count-input {
  width: 28px;
  min-width: 0;
  padding: 12px 0 12px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
}

.relation-count-input::-webkit-outer-spin-button,
.relation-count-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.relation-count-input:focus {
  outline: none;
}

.relation-count-suffix {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.relation-link {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.relationship-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.relation-delete-btn {
  border: 1px solid rgba(248, 113, 113, 0.2);
  background: rgba(255, 255, 255, 0.96);
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.relation-delete-btn:hover,
.relation-delete-btn:focus {
  outline: none;
  background: rgba(254, 242, 242, 0.96);
  border-color: rgba(248, 113, 113, 0.34);
}

.shift-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shift-palette-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.shift-palette-btn.is-clear {
  background: #f8fafc;
}

.shift-palette-btn:hover,
.shift-palette-btn:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.32);
  background: rgba(219, 234, 254, 0.72);
}

.rules-list {
  display: grid;
  gap: 10px;
}

.rules-list.is-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12px;
}

.rule-chip strong {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rule-chip.is-hard strong {
  color: #334155;
}

.rule-chip.is-soft strong {
  color: #2563eb;
}

.rule-empty {
  padding: 18px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px dashed rgba(148, 163, 184, 0.22);
  color: var(--muted);
  line-height: 1.6;
}

.result-layout {
  display: grid;
  gap: 14px;
}

.result-pattern-block {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(191, 219, 254, 0.36), transparent 42%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.96));
}

.result-pattern-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.result-pattern-head h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.result-pattern-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-pattern-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--pattern-text, var(--text));
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.result-pattern-badge strong {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--pattern-surface, rgba(226, 232, 240, 0.94));
  color: inherit;
  font-size: 11px;
}

.result-pattern-badge:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--pattern-accent, rgba(59, 130, 246, 0.36));
  box-shadow: 0 10px 18px rgba(148, 163, 184, 0.16);
}

.result-pattern-badge.is-selected {
  border-color: var(--pattern-accent, rgba(59, 130, 246, 0.36));
  background: var(--pattern-surface, rgba(226, 232, 240, 0.94));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.result-pattern-badge:disabled {
  cursor: default;
  opacity: 0.5;
  box-shadow: none;
}

.result-pattern-empty {
  font-size: 12px;
  color: var(--muted);
}

.result-control-section {
  margin-top: 0;
}

.result-control-head {
  align-items: center;
}

.result-rule-block {
  max-height: min(56vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.result-rule-block::-webkit-scrollbar {
  width: 10px;
}

.result-rule-block::-webkit-scrollbar-track {
  background: #f8fafc;
}

.result-rule-block::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.7);
  border: 2px solid #f8fafc;
  border-radius: 999px;
}

.result-control-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.result-control-note {
  min-height: 20px;
}

.result-generate-btn {
  flex: 0 0 auto;
}

.result-table-wrap {
  max-height: 52vh;
  overflow-x: auto;
}

.result-note {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.floating-generate-action {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 260px;
  z-index: 40;
}

.sidebar-generate-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  min-height: 54px;
  background: linear-gradient(135deg, #1d4ed8, #0284c7);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2);
}

.sidebar-generate-btn-progress {
  position: absolute;
  inset: 0;
  width: var(--generate-progress, 0%);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, #38bdf8, #22c55e);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.18);
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: -1;
}

.sidebar-generate-btn-content {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  padding: 0 14px;
}

.sidebar-generate-btn-label,
.sidebar-generate-btn-value {
  position: relative;
  z-index: 1;
}

.sidebar-generate-btn-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 92px);
  text-align: center;
  letter-spacing: -0.01em;
  pointer-events: none;
  white-space: nowrap;
}

.sidebar-generate-btn-value {
  min-width: 40px;
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.sidebar-generate-btn.is-loading .sidebar-generate-btn-value {
  opacity: 0.96;
  transform: translateX(0);
}

.sidebar-generate-btn.is-loading:disabled {
  opacity: 1;
  cursor: progress;
}

.compact-rule-block {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.compact-rule-block.result-rule-block {
  max-height: min(56vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.sidebar-rule-block {
  max-height: 46vh;
  overflow: auto;
}

.rules-table {
  display: grid;
}

.rules-table-header,
.rules-table-row {
  display: grid;
  grid-template-columns: 58px minmax(160px, 0.8fr) minmax(360px, 1.9fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.rules-table-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  font-weight: 700;
  color: var(--text);
}

.rules-table-row {
  border-top: 1px solid rgba(226, 232, 240, 0.92);
}

.rules-table-type {
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rules-table-type.is-hard {
  color: #334155;
}

.rules-table-type.is-soft {
  color: #2563eb;
}

.rule-type-select {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.rule-type-select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.38);
}

.rules-table-main {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.3;
}

.rules-table-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.muted-cell {
  color: var(--muted);
}

.placeholder-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .auth-screen,
  .onboarding-screen {
    padding: 20px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px 20px;
  }

  .main-panel {
    padding: 16px;
  }

  .sidebar-main {
    display: grid;
  }

  .floating-generate-action {
    position: static;
    width: auto;
    padding: 0 20px 16px;
  }

  .result-rule-block {
    max-height: 44vh;
  }

  .history-toolbar {
    top: 16px;
  }
}

@media (max-width: 760px) {
  .onboarding-hero-head,
  .guide-actions,
  .guide-action-buttons,
  .result-control-footer {
    grid-template-columns: 1fr;
    display: grid;
  }

  .setup-grid,
  .guide-period-row,
  .guide-shift-row,
  .field-row-2,
  .field-row-3,
  .chip-panel,
  .insight-row,
  .page-footer,
  .panel-header,
  .history-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .result-pattern-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .page-footer,
  .panel-header,
  .guide-actions {
    align-items: stretch;
  }

  .card-head-actions {
    justify-items: stretch;
  }

  .actions {
    flex-direction: column;
  }

  .panel,
  .card {
    border-radius: 24px;
  }

  .relationship-editor-grid,
  .relation-row,
  .relation-row.is-with-count {
    grid-template-columns: 1fr;
  }

  .personal-preference-table-wrap {
    overflow-x: auto;
  }

  .personal-preference-table {
    min-width: 720px;
  }

  .skill-constraint-head,
  .skill-constraint-grid,
  .skill-constraint-grid.is-with-count {
    grid-template-columns: 1fr;
    display: grid;
  }

  .skill-constraint-actions {
    justify-content: stretch;
  }

  .relation-link {
    display: none;
  }

  .shift-editor-input-row {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    top: 12px;
    padding: 12px;
  }

  .history-toolbar-head {
    align-items: stretch;
    grid-template-columns: 1fr;
    display: grid;
  }

  .history-node-item {
    min-width: 180px;
  }

  .history-node-item::before,
  .history-node-item::after {
    top: 20px;
  }

  .history-node-delete {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .rules-table-header,
  .rules-table-row {
    grid-template-columns: 56px minmax(140px, 0.8fr) minmax(260px, 1.6fr);
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
  }
}
