:root {
  --bg: #f4efe7;
  --card: #fffdf8;
  --line: #d8cdbd;
  --text: #2c241b;
  --muted: #6d6256;
  --accent: #b45309;
  --accent-soft: #fde6cf;
  --danger: #b91c1c;
  --ok: #166534;
  --shadow: 0 10px 30px rgba(67, 49, 30, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #fff4db 0, transparent 25%),
    linear-gradient(135deg, #efe5d6, #f8f5ef 55%, #ece3d4);
}

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
}
.sidebar h1 { margin-top: 0; font-size: 28px; }
.sidebar nav { display: grid; gap: 8px; margin: 24px 0; }
.sidebar button, .nav-link {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.nav-link.active { background: linear-gradient(135deg, #fff0da, #fffaf2); border-color: var(--accent); }
.main { padding: 28px; }
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}
.eyebrow { letter-spacing: 0.18em; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.hero h2 { margin: 0; font-size: 38px; }
.hero-text { max-width: 720px; color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { font-size: 32px; font-weight: 700; margin-top: 8px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 28px 0 16px;
}
.title-inline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.title-inline h3 {
  margin: 0;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); }
th, td { border-bottom: 1px solid #eee3d1; padding: 12px 14px; text-align: left; vertical-align: top; }
th { background: #fbf5ec; }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbf5ec;
}
.table-wrap {
  max-height: 72vh;
  overflow: auto;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.table-wrap table {
  box-shadow: none;
  border-radius: 0;
}
.table-wrap thead th:first-child { border-top-left-radius: 20px; }
.table-wrap thead th:last-child { border-top-right-radius: 20px; }
.room-row.unavailable td {
  background: #f3f4f6;
  color: #6b7280;
}
.room-row.unavailable td:first-child {
  box-shadow: inset 4px 0 0 #9ca3af;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-badge.active {
  background: #dcfce7;
  color: #166534;
}
.status-badge.inactive {
  background: #e5e7eb;
  color: #4b5563;
}
form.card { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #c96a16, #974f13);
  color: white;
  font-weight: 600;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #c96a16, #974f13);
  color: white;
  font-weight: 600;
  text-decoration: none;
}
.button-link.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger { background: linear-gradient(135deg, #dc2626, #991b1b); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.room-card h4 { margin: 0 0 10px; }
.room-meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.member-list { display: grid; gap: 6px; }
.member {
  padding: 10px 12px;
  border: 1px solid #efe5d6;
  border-radius: 12px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.progress {
  width: 100%;
  height: 14px;
  background: #efe3d4;
  border-radius: 999px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #b45309);
}
.toast {
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  box-shadow: var(--shadow);
}
.hidden { display: none; }
.split { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
.split.projects-layout { grid-template-columns: minmax(440px, 1.2fr) minmax(0, 1fr); }
.split.participants-layout { align-items: start; }
.participants-list-wrap {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 160px);
  height: calc(100vh - 160px);
  overflow: auto;
}
.stack { display: grid; gap: 18px; }
.messages { display: grid; gap: 8px; }
.message { padding: 12px 14px; border-radius: 14px; }
.message.info { background: #f8fafc; color: #334155; }
.message.warning { background: #fff7ed; }
.message.error { background: #fef2f2; color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.validation-summary {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffaf3;
  margin-bottom: 14px;
}
.validation-summary.error {
  background: #fef2f2;
  border-color: #f3c5c5;
}
.validation-summary.warning {
  background: #fff7ed;
  border-color: #f6d7bb;
}
.validation-summary.ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.validation-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.validation-headline {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}
.validation-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.validation-metric {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #eee3d1;
  background: #fff;
}
.validation-metric .label {
  color: var(--muted);
  font-size: 12px;
}
.validation-metric .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
}
.validation-sections {
  display: grid;
  gap: 14px;
}
.validation-section {
  display: grid;
  gap: 8px;
}
.validation-section h4 {
  margin: 0;
}
.validation-empty {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: #fffaf3;
}
.inline-subcard {
  margin-bottom: 16px;
  display: grid;
  gap: 12px;
}
.inline-subcard h4 {
  margin: 0;
}
.masked-display {
  letter-spacing: 0.08em;
  background: #f8f3eb;
}
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 60vh;
}
.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
}
.bulk-preview {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fffaf3;
  min-height: 24px;
}
.transfer-field {
  display: grid;
  gap: 8px;
}
.transfer-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.transfer-actions {
  display: grid;
  gap: 10px;
}
.transfer-search {
  margin-bottom: 8px;
}
.transfer-grid select {
  min-height: 240px;
}
.hidden-select {
  display: none;
}
.result-actions {
  margin-bottom: 12px;
}
.failure-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.failure-card h3 {
  margin-bottom: 12px;
}
.failure-hero {
  font-weight: 700;
}
.preview-list, .preview-errors {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}
.result-sheet-wrap {
  overflow-x: auto;
  padding: 12px;
}
.sheet-block + .sheet-block {
  margin-top: 16px;
}
.result-sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  box-shadow: none;
  background: transparent;
}
.result-sheet th,
.result-sheet td {
  min-width: 120px;
  border: 1px solid #d7ccbc;
  padding: 8px 10px;
  vertical-align: top;
}
.sheet-side,
.sheet-index {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f8f2ea;
  min-width: 72px !important;
}
.sheet-capacity {
  color: #c2410c;
  font-weight: 700;
  text-align: center;
}
.sheet-room {
  font-size: 18px;
  font-weight: 700;
}
.sheet-capacity.dam,
.sheet-room.dam {
  background: linear-gradient(135deg, #dff1d7, #edf6e6);
  color: #1f5134;
}
.sheet-capacity.joy,
.sheet-room.joy {
  background: linear-gradient(135deg, #ffe5cf, #fff2e4);
  color: #8a4a08;
}
.sheet-room.dam {
  box-shadow: inset 0 4px 0 #6aa66f;
}
.sheet-room.joy {
  box-shadow: inset 0 4px 0 #d98b38;
}
.sheet-cell {
  background: #fff;
  min-height: 42px;
}
.sheet-member {
  cursor: grab;
  user-select: none;
}
.sheet-member.female {
  color: #b91c1c;
  font-weight: 700;
}
.sheet-member.dragging {
  opacity: 0.45;
}
.sheet-cell.drag-over {
  outline: 3px solid #c96a16;
  outline-offset: -3px;
}
.sheet-cell.empty {
  color: #b91c1c;
  background: #fde2e2;
  text-align: center;
}
.sheet-footer {
  text-align: center;
  color: #2563eb;
  background: #f8fbff;
}
.dam {
  background: #edf6e6;
}
.joy {
  background: #fff2e4;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .result-grid, .failure-layout, .split { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .transfer-grid { grid-template-columns: 1fr; }
  .transfer-actions { grid-template-columns: 1fr 1fr; }
  .validation-metrics { grid-template-columns: 1fr; }
  .participants-list-wrap {
    position: static;
    top: auto;
    max-height: none;
    height: auto;
  }
}
