:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #fdfefe;
  --ink: #162033;
  --muted: #6c778c;
  --line: #dbe1ea;
  --line-strong: #c6d0dd;
  --accent: #176b87;
  --accent-strong: #0f5269;
  --accent-soft: #e6f5f8;
  --success: #13795b;
  --warning: #a05a00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 42, 69, 0.12);
  --radius: 8px;
  --sidebar: 284px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(23, 107, 135, 0.08), rgba(246, 248, 251, 0) 340px),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  padding: 28px 20px;
  background: #101828;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: #aab6c8;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #7dd3fc;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.route-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: transparent;
  color: #d9e2ef;
  font-size: 14px;
  font-weight: 650;
}

.route-button span:last-child {
  color: #91d5e8;
}

.route-button:hover,
.route-button.is-active {
  border-color: rgba(125, 211, 252, 0.46);
  background: rgba(125, 211, 252, 0.12);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar label {
  color: #aab6c8;
}

.input-row,
.filter-row,
.action-row,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-row > input,
.filter-row > input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.workspace {
  min-width: 0;
  overflow-x: hidden;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.04;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.topbar p,
.panel-heading p,
.run-box p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(360px, 1.15fr) minmax(300px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field.split {
  grid-template-columns: 1fr 160px;
  align-items: center;
}

.project-list {
  display: grid;
  gap: 8px;
  height: 310px;
  margin-bottom: 14px;
  overflow: auto;
  padding-right: 4px;
}

.project-option {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.project-option:hover {
  border-color: var(--line-strong);
}

.project-option input {
  width: 16px;
  min-height: 16px;
}

.project-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.project-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.project-kind {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 750;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.button {
  min-height: 40px;
  gap: 8px;
  padding: 0 14px;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.secondary {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--ink);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.sidebar .icon-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2f6;
  color: #536174;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill.success {
  background: #e4f6ef;
  color: var(--success);
}

.status-pill.warning {
  background: #fff4df;
  color: var(--warning);
}

.status-pill.danger {
  background: #feeceb;
  color: var(--danger);
}

.preview-output {
  min-height: 520px;
  max-height: 65vh;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1220;
  color: #d8e6ff;
  font: 12px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.activity-panel {
  display: grid;
  gap: 14px;
}

.run-box {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.run-box strong {
  font-size: 14px;
}

.artifact-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.artifact-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
}

.artifact-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 750;
}

.artifact-link small {
  color: var(--muted);
  font-size: 11px;
}

.artifact-link.is-disabled {
  opacity: 0.58;
  pointer-events: none;
}

.run-state {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.audit-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.audit-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.audit-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.audit-item strong {
  font-size: 13px;
}

.audit-item p {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: 1fr 1fr;
  }

  .activity-panel {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    position: static;
    width: 100vw;
    max-width: 100vw;
    padding: 18px;
  }

  .route-list {
    grid-template-columns: 1fr;
  }

  .route-button {
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 36px;
  }

  .sidebar-footer .input-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar-footer .icon-button {
    width: 100%;
  }

  .workspace {
    width: 100vw;
    max-width: 100vw;
    padding: 18px;
  }

  .topbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .content-grid {
    display: grid;
    width: calc(100vw - 36px);
    max-width: calc(100vw - 36px);
  }

  .panel,
  .route-button,
  .sidebar-footer input,
  .sidebar-footer .icon-button {
    max-width: calc(100vw - 36px);
  }

  .preview-output {
    min-height: 360px;
  }
}
