:root {
  --color-background: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-subtle: #f8fafc;
  --color-text: #172033;
  --color-text-muted: #667085;
  --color-border: #d8dee8;
  --color-border-control: #b9c3d2;
  --color-accent: #175cd3;
  --color-accent-hover: #1849a9;
  --color-accent-soft: #eff4ff;
  --color-accent-contrast: #ffffff;
  --color-success: #067647;
  --color-success-soft: #ecfdf3;
  --color-warning: #b54708;
  --color-warning-soft: #fffaeb;
  --color-danger: #b42318;
  --color-danger-soft: #fef3f2;
  --color-idle: #667085;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-control: 3px;
  --radius-panel: 6px;
  --control-height: 34px;
  --font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --shadow-focus: 0 0 0 3px rgba(23, 92, 211, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.4;
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.app-header {
  height: 52px;
  border-bottom: 1px solid #101828;
  background: #172033;
  color: #ffffff;
}

.app-header__content {
  display: flex;
  width: min(100% - 48px, 1360px);
  height: 100%;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand__mark {
  position: relative;
  width: 20px;
  height: 20px;
  border: 1px solid #84adff;
  background:
    linear-gradient(90deg, transparent 47%, #84adff 48%, #84adff 52%, transparent 53%),
    linear-gradient(transparent 47%, #84adff 48%, #84adff 52%, transparent 53%);
}

.brand__mark::after {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 4px;
  height: 4px;
  background: #84adff;
  content: "";
}

.brand__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.header-context {
  color: #c7d7fe;
  font-size: 12px;
}

.shell {
  width: min(100% - 48px, 1360px);
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-8);
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-4);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.page-description,
.panel__description {
  color: var(--color-text-muted);
}

.page-description {
  max-width: 720px;
  margin-top: var(--space-1);
}

.panel__description {
  margin-top: 2px;
  font-size: 12px;
}

.button {
  display: inline-flex;
  min-height: var(--control-height);
  padding: 6px var(--space-3);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.button:focus-visible,
.view-switch__button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.button:disabled {
  border-color: var(--color-border);
  background: #f2f4f7;
  color: #98a2b3;
  cursor: not-allowed;
}

.button--primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.button--primary:hover:not(:disabled) {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
  color: var(--color-accent-contrast);
}

.button--secondary {
  background: var(--color-surface);
}

.button--quiet {
  min-height: 28px;
  padding: 4px var(--space-2);
  border-color: transparent;
  background: transparent;
  color: var(--color-accent);
}

.button--block {
  width: 100%;
  margin-top: var(--space-4);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: var(--space-4);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
}

.status-fact {
  display: grid;
  min-width: 0;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-right: 1px solid var(--color-border);
}

.status-fact:last-child {
  border-right: 0;
}

.status-fact__label {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.status-fact__value {
  overflow: hidden;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-4);
  align-items: start;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
}

.panel__header {
  display: flex;
  min-height: 58px;
  padding: var(--space-3) var(--space-4);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.panel__body {
  padding: var(--space-4);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.side-column {
  position: sticky;
  top: var(--space-4);
  display: grid;
  gap: var(--space-4);
}

.view-switch {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
}

.view-switch__button {
  min-width: 52px;
  min-height: 30px;
  padding: 4px var(--space-2);
  border: 0;
  border-right: 1px solid var(--color-border-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.view-switch__button:last-child {
  border-right: 0;
}

.view-switch__button:hover {
  color: var(--color-accent);
}

.view-switch__button.is-active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.source-path {
  display: flex;
  min-width: 0;
  padding: var(--space-2) var(--space-4);
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
}

.source-path__label {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.source-path code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-toolbar {
  display: flex;
  min-height: 42px;
  padding: 6px var(--space-4);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12px;
}

.selection-toolbar__actions {
  display: flex;
  gap: var(--space-1);
}

.loading-state,
.empty-state {
  display: grid;
  min-height: 180px;
  padding: var(--space-6);
  place-content: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-state strong {
  color: var(--color-text);
  font-weight: 600;
}

.file-list {
  width: 100%;
}

.file-list__header,
.file-row {
  display: grid;
  grid-template-columns: 36px minmax(260px, 1fr) 92px 152px;
  align-items: center;
}

.file-list__header {
  min-height: 34px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.file-list__header > span,
.file-row > * {
  min-width: 0;
  padding: 0 var(--space-3);
}

.file-row {
  min-height: 48px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: #fafcff;
}

.file-row.is-selected {
  background: var(--color-accent-soft);
}

.file-row__check {
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-row__identity {
  display: grid;
  gap: 1px;
}

.file-row__identity strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row__path {
  overflow: hidden;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row__meta {
  color: var(--color-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--color-accent);
}

.file-tree {
  padding: var(--space-2) 0;
}

.tree-directory > summary {
  display: flex;
  min-height: 34px;
  padding: 5px var(--space-4);
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  list-style: none;
}

.tree-directory > summary::-webkit-details-marker {
  display: none;
}

.tree-directory > summary::before {
  width: 12px;
  color: var(--color-text-muted);
  content: "›";
  font-size: 17px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.tree-directory[open] > summary::before {
  transform: rotate(90deg);
}

.tree-directory > summary:hover {
  background: var(--color-surface-subtle);
}

.tree-directory__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-directory__count {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.tree-directory__expand {
  min-height: 24px;
  padding: 2px var(--space-1);
  flex: 0 0 auto;
  font-size: 11px;
}

.tree-children {
  margin-left: var(--space-4);
  border-left: 1px solid var(--color-border);
}

.tree-file {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 84px;
  min-height: 38px;
  padding: 0 var(--space-4) 0 var(--space-2);
  align-items: center;
  cursor: pointer;
}

.tree-file:hover {
  background: #fafcff;
}

.tree-file.is-selected {
  background: var(--color-accent-soft);
}

.tree-file__name {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-file__size {
  color: var(--color-text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.checkbox-field input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.checkbox-field span {
  display: grid;
  gap: 2px;
}

.checkbox-field strong {
  font-size: 13px;
  font-weight: 600;
}

.checkbox-field small {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 400;
}

.field {
  margin-top: var(--space-4);
}

.field > label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 12px;
  font-weight: 600;
}

.field input[type="text"] {
  width: 100%;
  min-height: var(--control-height);
  padding: 6px var(--space-2);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.field input[type="text"]:disabled {
  border-color: var(--color-border);
  background: #f2f4f7;
  color: #98a2b3;
}

.field input[type="text"].is-invalid {
  border-color: var(--color-danger);
}

.field__hint {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: 11px;
}

.form-message {
  margin-top: var(--space-3);
  padding: var(--space-2);
  border: 1px solid #fecdca;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 12px;
}

.submit-note {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: 11px;
  text-align: center;
}

.job-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.status-indicator {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  color: var(--color-idle);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-indicator__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-indicator--running {
  color: var(--color-warning);
}

.status-indicator--succeeded {
  color: var(--color-success);
}

.status-indicator--failed {
  color: var(--color-danger);
}

.job-stage {
  overflow: hidden;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-message {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.job-details {
  display: grid;
  margin: var(--space-4) 0 0;
  gap: var(--space-2);
}

.job-details > div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: var(--space-2);
}

.job-details dt {
  color: var(--color-text-muted);
  font-size: 11px;
}

.job-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.progress-line {
  position: relative;
  height: 3px;
  margin: var(--space-4) calc(var(--space-4) * -1) calc(var(--space-4) * -1);
  overflow: hidden;
  background: var(--color-accent-soft);
}

.progress-line::after {
  position: absolute;
  width: 38%;
  height: 100%;
  background: var(--color-accent);
  content: "";
  animation: progress-slide 1.2s ease-in-out infinite;
}

.noscript {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid #fedf89;
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

[hidden] {
  display: none !important;
}

@keyframes progress-slide {
  from {
    transform: translateX(-110%);
  }

  to {
    transform: translateX(285%);
  }
}

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

  .side-column {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-header__content,
  .shell {
    width: min(100% - 24px, 1360px);
  }

  .header-context {
    display: none;
  }

  .shell {
    padding-top: var(--space-4);
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-3);
  }

  .page-heading .button {
    align-self: flex-start;
  }

  h1 {
    font-size: 21px;
  }

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

  .status-fact:nth-child(2) {
    border-right: 0;
  }

  .status-fact:nth-child(-n + 2) {
    border-bottom: 1px solid var(--color-border);
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .panel__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
  }

  .source-path {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-1);
  }

  .source-path code {
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .file-list__header {
    display: none;
  }

  .file-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 62px;
  }

  .file-row__modified {
    display: none;
  }

  .file-row__size {
    padding-left: 0;
  }
}

@media (max-width: 480px) {
  .status-strip {
    grid-template-columns: 1fr;
  }

  .status-fact,
  .status-fact:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .status-fact:last-child {
    border-bottom: 0;
  }

  .selection-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .selection-toolbar__actions {
    margin-left: -8px;
  }

  .tree-children {
    margin-left: var(--space-2);
  }

  .tree-file {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .tree-file__size {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
