:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg-panel: rgba(12, 22, 38, 0.92);
  --bg-panel-strong: #0f1d33;
  --bg-card: rgba(16, 29, 49, 0.96);
  --bg-card-soft: rgba(15, 27, 46, 0.68);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(96, 165, 250, 0.28);
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --accent: #60a5fa;
  --accent-strong: #2563eb;
  --success: #34d399;
  --warning: #f59e0b;
  --muted: #64748b;
  --shadow: 0 18px 50px rgba(2, 8, 23, 0.34);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.24), transparent 28%),
    radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.16), transparent 24%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

.sidebar,
.dashboard {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar__brand h1,
.dashboard__header h2,
.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.sidebar__intro,
.dashboard__summary {
  margin: 8px 0 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.sidebar__section--compact {
  margin-top: auto;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading--wide {
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill--muted {
  background: rgba(100, 116, 139, 0.16);
  color: var(--text-soft);
}

.pill--accent {
  background: rgba(96, 165, 250, 0.18);
  color: #bfdbfe;
}

.pill--success {
  background: rgba(52, 211, 153, 0.18);
  color: #a7f3d0;
}

.pill--warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.app-nav__button {
  width: 100%;
  border: 1px solid transparent;
  background: var(--bg-card-soft);
  border-radius: var(--radius-md);
  padding: 13px;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.app-nav__button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.app-nav__button[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.24), rgba(15, 27, 46, 0.96));
  border-color: rgba(96, 165, 250, 0.34);
}

.app-nav__button:focus-visible,
.pipeline-card:focus-visible {
  outline: 2px solid #bfdbfe;
  outline-offset: 3px;
}

.app-nav__title-row,
.pipeline-card__title-row,
.meta-card,
.overview-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.app-nav__name,
.pipeline-card__title {
  font-weight: 700;
}

.app-nav__meta,
.app-nav__request,
.metric-list li,
.meta-card__label,
.overview-card__label,
.column__meta,
.pipeline-card__detail {
  color: var(--text-soft);
}

.app-nav__request {
  margin: 8px 0 0;
  line-height: 1.4;
  font-size: 0.86rem;
}

.app-nav__request--full {
  display: none;
}

.app-nav__button:hover .app-nav__request:not(.app-nav__request--full) {
  display: none;
}

.app-nav__button:hover .app-nav__request--full {
  display: block;
}

.app-nav__link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.app-nav__link:hover {
  text-decoration: underline;
}

.metric-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.metric-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.metric-list strong {
  color: var(--text);
}

.dashboard {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.dashboard__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
  width: min(340px, 100%);
}

.meta-card,
.overview-card,
.action-card {
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--bg-card-soft);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.meta-card strong,
.overview-card__value {
  font-size: 1rem;
  margin-top: 10px;
}

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

.feedback-iteration {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-soft);
}

.feedback-iteration__label {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.overview-card__value {
  margin-bottom: 0;
  line-height: 1.5;
}

.pipeline-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  background: rgba(7, 15, 29, 0.36);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
}

.pipeline-column {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background:
    linear-gradient(180deg, rgba(var(--phase-rgb), 0.16), rgba(7, 15, 29, 0.62) 46%),
    rgba(7, 15, 29, 0.56);
  border: 1px solid rgba(var(--phase-rgb), 0.36);
  border-top: 4px solid var(--phase-color);
  border-radius: var(--radius-md);
  padding: 10px;
  min-width: 0;
}

.column__header {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.column__header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--phase-color);
}

.column__cards {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.pipeline-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px;
  background: var(--bg-card);
  min-width: 0;
}

.pipeline-card--active {
  border-color: rgba(52, 211, 153, 0.36);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.18);
  animation: pulse 2s ease-in-out infinite;
}

.pipeline-card--complete {
  opacity: 0.72;
}

.pipeline-card__title-row {
  align-items: flex-start;
  margin-bottom: 6px;
  flex-direction: column;
  gap: 6px;
}

.pipeline-card__detail {
  margin: 6px 0 0;
  line-height: 1.35;
  font-size: 0.78rem;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  cursor: pointer;
}

.pipeline-card.expanded .pipeline-card__detail {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.status-badge {
  align-self: flex-start;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-badge--active {
  background: rgba(52, 211, 153, 0.18);
  color: #a7f3d0;
}

.status-badge--queued {
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

.status-badge--complete {
  background: rgba(100, 116, 139, 0.18);
  color: #cbd5e1;
}

.status-badge--blocked {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.status-badge--failed {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-soft);
  background: rgba(15, 27, 46, 0.36);
  font-size: 0.78rem;
}

.operator-actions {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.1fr);
  gap: 12px;
}

.action-card {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.action-card .action-link,
.action-card .feedback-form {
  margin-top: auto;
}

.action-card--deployment {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.14), rgba(15, 27, 46, 0.82));
}

.action-link--pause {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.action-link,
.feedback-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #eff6ff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 140ms ease, transform 140ms ease;
}

.action-link:hover,
.feedback-form button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.feedback-form button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.feedback-form textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-link:focus-visible,
.feedback-form button:focus-visible,
.feedback-form textarea:focus-visible {
  outline: 2px solid #bfdbfe;
  outline-offset: 3px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.feedback-form button[type="submit"] {
  margin-top: auto;
}

.feedback-form textarea {
  width: 100%;
  min-height: 78px;
  flex: 1;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(2, 8, 23, 0.38);
  color: var(--text);
}

.feedback-form textarea::placeholder {
  color: var(--text-soft);
}

.feedback-status {
  min-height: 20px;
  margin: 0;
  color: #a7f3d0;
  font-size: 0.88rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Create App button */
.create-app-btn {
  width: 100%;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(20, 184, 166, 0.08));
  color: var(--accent);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, transform 140ms ease;
  letter-spacing: 0.02em;
}

.create-app-btn:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(20, 184, 166, 0.14));
  transform: translateY(-1px);
}

.create-app-btn:focus-visible {
  outline: 2px solid #bfdbfe;
  outline-offset: 3px;
}

/* Create App dialog */
.create-dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--bg-panel-strong);
  color: var(--text);
  padding: 0;
  max-width: 520px;
  width: 90vw;
  box-shadow: 0 32px 80px rgba(2, 8, 23, 0.6);
}

.create-dialog::backdrop {
  background: rgba(2, 8, 23, 0.7);
  backdrop-filter: blur(6px);
}

.create-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
}

.create-dialog__form h2 {
  margin: 0;
  font-size: 1.3rem;
}

.create-dialog__subtitle {
  margin: -10px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.create-dialog__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.88rem;
}

.create-dialog__field input,
.create-dialog__field textarea,
.create-dialog__field select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(2, 8, 23, 0.38);
  color: var(--text);
  font-weight: 400;
}

.create-dialog__field input:focus,
.create-dialog__field textarea:focus,
.create-dialog__field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.create-dialog__field select {
  cursor: pointer;
}

.create-dialog__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-soft);
  cursor: pointer;
}

.create-dialog__toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.create-dialog__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 6px;
}

.create-dialog__cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 140ms ease;
}

.create-dialog__cancel:hover {
  border-color: var(--text-soft);
}

/* Pulse animation for active pipeline cards */
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.18); }
  50% { box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.38), 0 0 12px rgba(52, 211, 153, 0.12); }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }
}

@media (max-width: 900px) {
  .dashboard__header,
  .dashboard__meta {
    grid-template-columns: 1fr;
    display: grid;
  }

  .overview-grid,
  .operator-actions {
    grid-template-columns: 1fr;
  }

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

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

  .sidebar,
  .dashboard {
    padding: 20px;
    border-radius: 20px;
  }
  .pipeline-board {
    grid-template-columns: 1fr;
  }
}
