:root {
  color-scheme: light;
  font-family: "Segoe UI", "Hiragino Sans", sans-serif;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #d8e0ea;
  --text: #1f2937;
  --util-optimal: #bfdbfe;
  --util-low: #e5e7eb;
  --util-high: #fbcfe8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

header, main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header h1 {
  margin: 0 0 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel-primary {
  border-color: #93c5fd;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}

.panel-filter {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.panel-filter h2,
.panel-primary h2,
.panel-trend h2 {
  margin: 0 0 12px;
}

.analysis-filter {
  padding: 4px 0 0;
}

.panel-primary h2 {
  margin-bottom: 12px;
}

.panel-trend {
  border-color: #bfdbfe;
}

.panel-upload {
  background: #f8fafc;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.grid.compact {
  min-width: min(100%, 960px);
  margin-bottom: 0;
}

.grid.compact .period-field input[type="date"] {
  width: 11.5rem;
  min-width: 11.5rem;
}

#period-apply-btn {
  align-self: end;
  margin-bottom: 2px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

label.checkbox-row,
.trend-option,
.trend-room-item,
.dept-trend-item,
.trend-floor-bulk {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

label.checkbox-row input[type="checkbox"],
.trend-option input[type="checkbox"],
.trend-room-item input[type="checkbox"],
.dept-trend-item input[type="checkbox"],
.trend-floor-bulk input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
}

.grid.compact label.checkbox-row {
  align-self: end;
  margin-bottom: 2px;
}

input, select, button {
  font: inherit;
}

button {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin-top: 10px;
  font-size: 14px;
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: #4b5563;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2) {
  text-align: left;
}

.cell-util-optimal { background: var(--util-optimal); }
.cell-util-low { background: var(--util-low); }
.cell-util-high { background: var(--util-high); }

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0 0 12px;
  font-size: 13px;
  color: #4b5563;
}

.heatmap-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.heatmap-legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.import-list {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
  color: #4b5563;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.trend-room-list {
  margin: 0 0 16px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.trend-floor-accordion {
  display: flex;
  flex-direction: column;
}

.trend-floor-group {
  border-bottom: 1px solid var(--border);
}

.trend-floor-group:last-child {
  border-bottom: none;
}

.trend-floor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.trend-floor-header:hover {
  background: #f1f5f9;
}

.trend-floor-toggle {
  flex-shrink: 0;
  width: 1em;
  font-size: 11px;
  color: #64748b;
  transition: transform 0.15s ease;
}

.trend-floor-group.is-open .trend-floor-toggle {
  transform: rotate(90deg);
}

.trend-floor-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.trend-floor-count {
  font-size: 12px;
  color: #64748b;
  font-weight: normal;
}

.trend-floor-bulk {
  display: inline-flex;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}

.trend-floor-panel {
  display: none;
  padding: 6px 12px 10px 28px;
  background: #f8fafc;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 12px;
}

.trend-floor-group.is-open .trend-floor-panel {
  display: grid;
}

.trend-room-item {
  display: inline-flex;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.trend-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0 0 12px;
}

.trend-option {
  display: inline-flex;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

.panel-analysis.panel-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.panel-analysis.panel-pending {
  opacity: 0.25;
}

.panel-analysis.panel-revealed {
  opacity: 1;
}

.import-progress {
  margin: 8px 0 12px;
}

.import-progress.is-hidden {
  display: none;
}

.import-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.import-progress-fill {
  height: 100%;
  width: 0;
  background: #2563eb;
  transition: width 0.25s ease;
}

.dept-trend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  max-height: 160px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.dept-trend-item {
  display: inline-flex;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.dept-room-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 0 0 12px;
}

.dept-room-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.dept-room-controls select {
  min-width: 280px;
}

.detail-actions {
  margin: 0 0 12px;
}

.detail-actions button {
  min-width: 96px;
}

.panel-detail-analysis canvas {
  max-height: 280px;
}

#room-master-table button {
  font-size: 12px;
  padding: 4px 8px;
}
