body {
  font-family: "Lato", Arial, sans-serif;
  margin: 0;
  background: #ebebeb;
  color: #111827;
}

main {
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin-bottom: 0.2rem;
}

.subtitle {
  margin-top: 0;
  color: #4b5563;
}

.layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 1rem;
}

.panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
}

.panel-head h2 {
  margin: 0;
}

.view-switch {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.view-pill {
  min-width: 9rem;
  padding: 0.4rem 1.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 600;
}

.view-pill:hover {
  border-color: #9ca3af;
  background: #e5e7eb;
}

.view-pill.active {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
}

.map-grid-playback-section.is-hidden,
.config-view-section.is-hidden {
  display: none;
}

.panel-head-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
}

.panel-head-link:hover {
  text-decoration: underline;
}

.entry-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 0.75rem 0;
  text-decoration: none;
}

.entry-links code {
  font-size: 0.8125rem;
  background: #e5e7eb;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

#git-branch {
  font-weight: 600;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

form {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.form-autosave-hint {
  font-size: 0.75rem;
  margin: 0.45rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  color: #059669;
  background: #ecfdf5;
}

label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
}

input,
textarea,
select,
button {
  font: inherit;
  padding: 0.5rem;
}

button {
  border: 0;
  background: #1d4ed8;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  padding: .5rem 1.5rem;
}

button.secondary {
  background: #374151;
}

[data-action="delete"] {
  background: #7f1d1d;
  color: #fffcfc;
}

[data-action="delete"]:hover {
  background: #991b1b;
}

[data-action="new"] {
  background: #14532d;
  color: #ffffff;
}

[data-action="new"]:hover {
  background: #166534;
}

ul,
ol {
  margin: 0;
  padding-left: 1.2rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.scenario-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
  margin-top: 0.7rem;
  margin-bottom: 0.5rem;
}

.scenario-toolbar .scenario-controls {
  flex: 0 1 auto;
  min-width: min(100%, 280px);
}

.active-real-scenarios,
.active-idle-scenarios {
  flex: 0 0 15rem;
  width: 15rem;
  height: 7.2rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fafafa;
  font-size: 0.72rem;
  line-height: 1.3;
  color: #374151;
}

.active-real-scenarios-title,
.active-idle-scenarios-title {
  display: block;
  flex: none;
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.15rem;
}

.active-real-scenarios-list,
.active-idle-scenarios-list {
  flex: 1 1 auto;
  min-height: 0;
  list-style: none;
  padding-left: 0;
  margin: 0;
  overflow-y: auto;
}

.active-real-scenarios-list li,
.active-idle-scenarios-list li {
  padding: 0.05rem 0;
  border-top: 1px solid #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen-pill {
  display: inline-block;
  min-width: 1.1rem;
  margin-right: 0.3rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  box-sizing: border-box;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
  vertical-align: 0.05rem;
  color: #fff;
}

.screen-pill--0 { background: #2563eb; }
.screen-pill--1 { background: #16a34a; }
.screen-pill--2 { background: #ea580c; }
.screen-pill--3 { background: #9333ea; }
.screen-pill--4 { background: #db2777; }
.screen-pill--5 { background: #0891b2; }
.screen-pill--6 { background: #ca8a04; }
.screen-pill--7 { background: #475569; }

.active-real-scenarios-list li:first-child,
.active-idle-scenarios-list li:first-child {
  border-top: none;
}

.active-real-scenarios-list li.muted,
.active-idle-scenarios-list li.muted {
  color: #9ca3af;
  font-style: italic;
}

.scenario-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0;
}

.scenario-controls .sc-group {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0 0.75rem;
  border-left: 1px solid #e5e7eb;
}

.scenario-controls .sc-group:first-child {
  padding-left: 0;
  border-left: none;
}

.scenario-controls label {
  white-space: nowrap;
}

.scenario-controls input[type="number"],
.scenario-controls select {
  box-sizing: border-box;
  height: 32px;
  padding: 0 0.4rem;
}

.scenario-controls .sc-scenario select {
  width: 16rem;
}

/* ch-based widths plus room for padding and the spinner */
.scenario-controls .sc-num-2 {
  width: calc(2ch + 2.2rem);
}

.scenario-controls .sc-num-4 {
  width: calc(4ch + 2.2rem);
}

.scenario-controls .sc-transport {
  display: flex;
  gap: 0.25rem;
}

.scenario-controls button {
  width: 32px;
  height: 32px;
  min-width: unset;
  padding: 0;
  font-size: 0.9rem;
}

.scenario-controls .sc-check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 32px;
  font-size: 0.72rem;
  color: #4b5563;
  cursor: pointer;
}

.scenario-controls .sc-check input {
  margin: 0;
}

.scenario-pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0.4rem 0 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 0.3rem;
  box-sizing: border-box;
  padding-left: 10px;
}

.scenario-pick-btn {
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  min-width: unset;
}

.scenario-pick-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.scenario-pick-btn.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.work-list-header-empty {
  font-size: 0.82rem;
  color: #9ca3af;
  margin: 0.4rem 0;
}


.scenario-step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 5px 10px;
  border-radius: 5px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 0.8rem;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.scenario-step-item:hover {
  background: #e9eaf0;
  border-color: #d1d5db;
}

.scenario-step-item.selected {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

.scenario-step-item.selected .step-number {
  background: #3b82f6;
  color: #fff;
}

.scenario-step-item.playing {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
  font-weight: 600;
}

.scenario-step-item.playing .step-number {
  background: #dc2626;
  color: #fff;
}

.scenario-step-item.dragging {
  opacity: 0.4;
}

.scenario-step-item.drag-over {
  border-color: #6366f1;
  background: #eef2ff;
}

.step-drag-handle {
  color: #9ca3af;
  font-size: 1rem;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d1d5db;
  color: #111827;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.scenario-step-item.playing .step-route {
  color: #b91c1c;
}

.step-type {
  font-weight: 600;
  flex-shrink: 0;
}

.step-route {
  color: #89909a;
  color: color-mix(in srgb, #6b7280 80%, white 20%);
  flex: 1;
  font-size: 0.8em;
}


.step-data {
  font-style: italic;
  color: #9ca3af;
  font-size: 0.75rem;
}

/* Folder tabs, same look as the Event Overview site tabs (Server/public/cpa-theme.css `.site-tabs`). */
.work-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.6rem 0 0.8rem;
  border-bottom: 1px solid #d1d5db;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 8rem;
  margin-bottom: -1px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  color: #4b5563;
}

.tab-button:hover {
  color: #1d4ed8;
  background: color-mix(in srgb, #ffffff 60%, transparent);
}

.work-tab-icon {
  flex-shrink: 0;
  width: 1.1em;
  height: 1.1em;
}

.tab-button.active {
  color: #1d4ed8;
  background: #ffffff;
  border-color: #d1d5db;
  border-bottom-color: #ffffff;
}

.work-area {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.work-list-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.work-list-wrap {
  border: 1px solid #d1d5db;
  border-radius: 6px;
 max-height: 1040px; 
  overflow: auto;
  background: #fff;
}

.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.work-list-item {
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
}

.work-list-node-name {
  display: inline-block;
  vertical-align: middle;
}

.work-list-node-code-text {
  font-weight: 700;
}

.work-list-node-code-pill {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 0.5rem;
  vertical-align: middle;
  background: var(--node-code-color, #6b7280);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.work-list-item:nth-child(odd) {
  background: #f9fafb;
}

.work-list-item:nth-child(even) {
  background: #eef2ff;
}

.work-list-item.active {
  outline: 2px solid #1d4ed8;
  background: #dbeafe;
}

#workListActions {
  display: flex;
}

#workListActions button {
  width: 100%;
}

.steps-panel-actions {
  display: flex;
}

.steps-panel-actions button {
  width: 100%;
}

.work-detail {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.7rem;
  background: #f8fafc;
}

.work-detail .actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.work-detail .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
  font-weight: 500;
  cursor: pointer;
}

.hint {
  color: #4b5563;
  margin-bottom: 0;
}

.step-type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

#selectedNodePanel {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 1rem;
  background: #f9fafb;
}

#status {
  min-height: 1rem;
  font-weight: 600;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.action-panel {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.action-panel.expanded {
  border-color: #93c5fd;
}

.action-panel-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  user-select: none;
  background: #f9fafb;
  border-bottom: 1px solid transparent;
  transition: background 0.12s;
}

.action-panel.expanded .action-panel-header {
  background: #eff6ff;
  border-bottom-color: #dbeafe;
}

.action-panel-header:hover {
  background: #f3f4f6;
}

.action-panel.expanded .action-panel-header:hover {
  background: #dbeafe;
}

.action-panel-toggle {
  font-size: 0.75rem;
  color: #6b7280;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.action-panel-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: #374151;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-remove-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
  min-width: unset;
  border-radius: 3px;
}

.action-remove-btn:hover {
  color: #dc2626;
  background: #fef2f2;
}

.action-panel-body {
  padding: 0.6rem;
  display: grid;
  gap: 0.5rem;
}

action-data-editor {
  display: block;
  grid-column: 1 / -1;
}

.action-panel-body input,
.action-panel-body select,
.action-panel-body textarea {
  font-size: 0.77rem;
  line-height: 1.26;
  padding: 0.22rem 0.33rem;
}

.action-data-label {
  grid-column: 1 / -1;
}

.action-field-disclosure {
  grid-column: 1 / -1;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fafafa;
  overflow: hidden;
}

.action-field-disclosure.is-open {
  border-color: #d1d5db;
  background: #fff;
}

.action-field-disclosure-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #374151;
  transition: background 0.12s;
}

.action-field-disclosure-btn:hover {
  background: #f3f4f6;
}

.action-field-disclosure.is-open .action-field-disclosure-btn {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.action-field-disclosure.is-open .action-field-disclosure-btn:hover {
  background: #f3f4f6;
}

.action-field-disclosure--widget {
  --action-field-bg: #f4f0d2;
  --action-field-header-bg: #fff7d1;
  border-color: var(--action-field-header-bg);
  background: var(--action-field-bg);
}

.action-field-disclosure--widget .action-field-disclosure-btn,
.action-field-disclosure--widget .action-field-disclosure-btn:hover,
.action-field-disclosure--widget.is-open .action-field-disclosure-btn,
.action-field-disclosure--widget.is-open .action-field-disclosure-btn:hover {
  background: var(--action-field-header-bg);
}

.action-field-disclosure--widget.is-open .action-field-disclosure-btn {
  border-bottom-color: var(--action-field-header-bg);
}

.action-field-disclosure--widget .action-field-disclosure-body {
  background: var(--action-field-bg);
}

.action-field-disclosure--message {
  --action-field-bg: #d6f4d2;
  --action-field-header-bg: #e4ffe6;
  border-color: var(--action-field-header-bg);
  background: var(--action-field-bg);
}

.action-field-disclosure--message .action-field-disclosure-btn,
.action-field-disclosure--message .action-field-disclosure-btn:hover,
.action-field-disclosure--message.is-open .action-field-disclosure-btn,
.action-field-disclosure--message.is-open .action-field-disclosure-btn:hover {
  background: var(--action-field-header-bg);
}

.action-field-disclosure--message.is-open .action-field-disclosure-btn {
  border-bottom-color: var(--action-field-header-bg);
}

.action-field-disclosure--message .action-field-disclosure-body {
  background: var(--action-field-bg);
}

.action-field-disclosure-title {
  font-size: 0.82rem;
  font-weight: 500;
  flex: 1;
}

.action-field-disclosure-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7280;
  font-style: italic;
}

.action-field-disclosure-body {
  padding: 0.45rem 0.5rem 0.55rem;
}

.widget-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 28rem;
  overflow-y: auto;
}

.widget-picker-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #111827;
  transition: border-color 0.12s, background 0.12s;
}

.widget-picker-row:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}

.widget-picker-row.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.widget-picker-thumb {
  flex-shrink: 0;
  max-height: 160px;
}

.widget-picker-thumb--none {
  width: 4.5rem;
  height: 3rem;
  border-radius: 0.375rem;
  border: 1px dashed #d1d5db;
  background: #f3f4f6;
}

.widget-picker-name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.action-data-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 3.47rem;
  resize: vertical;
  line-height: 1.26;
}

.action-data-table {
  width: 100%;
  border-collapse: collapse;
}

.action-data-table th,
.action-data-table td {
  padding: 0.2rem;
  text-align: left;
}

.action-data-table th {
  font-size: 0.72rem;
  color: #4b5563;
}

.action-data-cell {
  width: 100%;
  box-sizing: border-box;
}

.action-data-cell-select {
  min-height: 1.75rem;
}

.action-data-actions-col {
  width: 2rem;
  text-align: center;
  vertical-align: middle;
}

.action-data-row-remove {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
}

.action-data-row-remove:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.action-data-row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.action-data-row-actions-sep {
  display: block;
  width: 1px;
  align-self: stretch;
  min-height: 1.5rem;
  margin: 0 0.35rem 0 0.15rem;
  background: #d1d5db;
  flex-shrink: 0;
}

.action-data-add-row,
.action-data-load-keys,
.action-data-clear-all {
  border: 1px dashed #d1d5db;
  background: #f9fafb;
  color: #374151;
  border-radius: 0.35rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.action-data-add-row:hover,
.action-data-load-keys:hover,
.action-data-clear-all:hover {
  background: #f3f4f6;
}

.action-data-load-keys {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.action-data-load-keys:hover:not(:disabled) {
  background: #dbeafe;
}

.action-data-load-keys:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-data-clear-all {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.action-data-clear-all:hover {
  background: #fee2e2;
}

.action-data-empty {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

.save-success-flash {
  border-color: #16a34a !important;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.action-add-btn {
  width: 100%;
  background: #f0fdf4;
  color: #166534;
  border: 1px dashed #86efac;
  border-radius: 6px;
  padding: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.action-add-btn:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .work-area {
    grid-template-columns: 1fr;
  }
}
