* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    "Helvetica Neue", Arial, sans-serif;
  background: #f7f5f1;
  color: #1f1f1f;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.hero {
  margin-bottom: 24px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8b847b;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.subtitle {
  margin: 0;
  max-width: 760px;
  color: #625d57;
  line-height: 1.5;
}

.panel {
  background: transparent;
  border: 0;
  border-top: 1px dashed #d7d0c7;
  border-radius: 0;
  padding: 18px 0;
  box-shadow: none;
}

.tabs-panel {
  margin-bottom: 18px;
}

.mode-switch {
  display: inline-flex;
  border: 1px solid #1f1f1f;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-button {
  border: 0;
  border-left: 1px solid #1f1f1f;
  border-radius: 0;
  padding: 12px 26px;
  background: transparent;
  color: #1f1f1f;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.mode-button:first-child {
  border-left: 0;
}

.mode-button.active {
  background: #1f1f1f;
  color: #faf8f4;
}

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

.tab-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: #7a746c;
  font: inherit;
  cursor: pointer;
}

.tab-button.active {
  background: #1f1f1f;
  color: #faf8f4;
  font-weight: 600;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-view,
.page-add {
  display: none;
}

.page-view.active,
.page-add.active {
  display: block;
}

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

.controls-grid label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.controls-grid span {
  color: #625d57;
}

select,
button {
  font: inherit;
}

select {
  width: 100%;
  padding: 11px 0 12px;
  border: 0;
  border-bottom: 1px dashed #d7d0c7;
  border-radius: 0;
  background: transparent;
  color: #1f1f1f;
}

select:focus,
button:focus {
  outline: 2px solid rgba(31, 31, 31, 0.08);
  outline-offset: 2px;
}

.city-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 28px;
}

.list-panel,
.detail-panel {
  min-height: 640px;
}

.list-panel {
  padding-right: 24px;
  border-right: 1px dashed #d7d0c7;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h2,
.section-card h3 {
  margin: 0 0 6px;
}

.section-copy {
  margin: 0;
  color: #625d57;
  line-height: 1.5;
}

.add-search-label {
  display: grid;
  gap: 8px;
  flex: 1;
}

.add-search-label span {
  color: #625d57;
  font-weight: 600;
}

.add-search-label input {
  width: 100%;
  padding: 11px 0 12px;
  border: 0;
  border-bottom: 1px dashed #d7d0c7;
  background: transparent;
  color: #1f1f1f;
  font: inherit;
}

.add-search-label input:focus {
  outline: 2px solid rgba(31, 31, 31, 0.08);
  outline-offset: 2px;
}

.add-input-row {
  display: flex;
  align-items: end;
  gap: 18px;
}

.add-city-button {
  border: 1px solid #1f1f1f;
  border-radius: 999px;
  padding: 11px 18px;
  background: #1f1f1f;
  color: #faf8f4;
  cursor: pointer;
  white-space: nowrap;
}

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

.search-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.queue-item {
  min-height: 132px;
  border: 1px dashed #cfc6bb;
  border-radius: 14px;
  background: rgba(255, 253, 250, 0.45);
  overflow: hidden;
}

.job-item[open] {
  background: rgba(255, 253, 250, 0.9);
}

.job-summary {
  display: grid;
  gap: 10px;
  padding: 18px 16px;
  cursor: pointer;
  list-style: none;
}

.job-summary::-webkit-details-marker {
  display: none;
}

.queue-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.queue-item-top strong {
  font-size: 1.05rem;
  font-weight: 600;
}

.queue-item-top span {
  color: #8b847b;
  font-size: 0.95rem;
}

.queue-item-copy {
  margin: 0;
  color: #625d57;
  line-height: 1.5;
}

.job-summary-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  color: #8b847b;
  font-size: 0.85rem;
}

.job-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfc6bb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.job-status-queued,
.job-status-starting,
.job-status-running,
.job-status-cancelling {
  background: #1f1f1f;
  color: #faf8f4;
  border-color: #1f1f1f;
}

.job-status-completed {
  background: #e8f4ea;
  color: #24623c;
  border-color: #bfd8c7;
}

.job-status-failed {
  background: #f8e5e3;
  color: #8a3025;
  border-color: #e3beb8;
}

.job-status-orphaned {
  background: #f3e6f6;
  color: #6c2a78;
  border-color: #dfc0e8;
}

.job-status-cancelled,
.job-status-skipped {
  background: #ece9e3;
  color: #5c554d;
  border-color: #d7d0c7;
}

.job-status-stalled,
.job-status-timed_out {
  background: #fff3d8;
  color: #8a5a00;
  border-color: #ecd29a;
}

.job-detail {
  display: grid;
  gap: 16px;
  padding: 0 16px 18px;
}

.job-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.job-detail-grid div {
  border-top: 1px dashed #ddd5cc;
  padding-top: 12px;
}

.job-detail-grid dt {
  margin-bottom: 6px;
  color: #8b847b;
  font-size: 0.85rem;
}

.job-detail-grid dd {
  margin: 0;
}

.job-section-label {
  margin: 0 0 8px;
  color: #8b847b;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.job-command-block,
.job-log-block {
  border-top: 1px dashed #ddd5cc;
  padding-top: 12px;
}

.job-actions {
  display: flex;
  justify-content: flex-end;
}

.job-cancel-button {
  border: 1px solid #8a3025;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: #8a3025;
  cursor: pointer;
}

.job-cancel-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.job-command-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  color: #3f3b37;
}

.job-log-output {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  background: #181818;
  color: #f5f5f5;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.title-item {
  width: 100%;
  text-align: left;
  padding: 14px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed #ddd5cc;
  border-radius: 0;
  color: inherit;
  cursor: pointer;
}

.title-item.active {
  border-bottom-color: #1f1f1f;
  box-shadow: none;
}

.title-item-top,
.title-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.title-item-top {
  margin-bottom: 8px;
}

.title-item-sub {
  margin-bottom: 8px;
  color: #3f3b37;
}

.title-item-meta {
  color: #8b847b;
  font-size: 0.9rem;
}

.detail-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 18px;
  margin-bottom: 22px;
}

.detail-card,
.section-card {
  background: transparent;
  border: 0;
  border-top: 1px dashed #ddd5cc;
  border-radius: 0;
  padding: 14px 0;
}

.detail-card h3 {
  margin: 0;
  line-height: 1.35;
  font-size: 1.1rem;
  font-weight: 600;
}

.detail-label,
.detail-secondary {
  margin: 0 0 8px;
  color: #8b847b;
}

.detail-secondary {
  margin-top: 8px;
  margin-bottom: 0;
}

.detail-source,
.table-source {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #8b847b;
}

.source-link {
  color: #6f685f;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}

.source-link:hover {
  color: #1f1f1f;
}

.meta-block,
.programs {
  display: grid;
  gap: 18px;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.meta-list div {
  background: transparent;
  border: 0;
  border-top: 1px dashed #ddd5cc;
  border-radius: 0;
  padding: 12px 0;
}

.meta-list dt {
  margin-bottom: 6px;
  color: #8b847b;
  font-size: 0.9rem;
}

.meta-list dd {
  margin: 0;
}

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

.program-item {
  border: 0;
  border-top: 1px dashed #ddd5cc;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.program-item summary {
  display: grid;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
}

.program-item summary span {
  color: #8b847b;
  text-transform: capitalize;
  font-size: 0.9rem;
}

.program-body {
  padding: 0 16px 16px;
}

.rule-table-wrap,
.comparison-wrap {
  overflow-x: auto;
}

.rule-table,
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

.rule-table th,
.rule-table td,
.comparison-table th,
.comparison-table td {
  border-bottom: 1px dashed #ddd5cc;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.rule-table th,
.comparison-table th {
  color: #8b847b;
  font-weight: 600;
  background: transparent;
}

.empty-state {
  padding: 32px 20px;
  color: #8b847b;
  text-align: center;
}

.status-panel {
  margin-top: 18px;
}

.status {
  margin: 0;
  color: #8b847b;
  min-height: 1.5em;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 20px 14px 28px;
  }

  .tabs {
    flex-direction: column;
  }

  .hero-top,
  .controls-grid,
  .detail-cards,
  .meta-list,
  .city-layout,
  .job-detail-grid {
    grid-template-columns: 1fr;
  }

  .add-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel {
    padding: 16px 0;
  }

  .list-panel {
    padding-right: 0;
    border-right: 0;
  }

  .search-results {
    grid-template-columns: 1fr;
  }
}
