:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #66727f;
  --line: #d8dee4;
  --blue: #1d6fa5;
  --blue-dark: #15567f;
  --green: #19765c;
  --red: #b42318;
  --amber: #936300;
  --shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--blue-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
}

button.secondary:hover:not(:disabled) {
  background: #eef3f6;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(29, 111, 165, 0.25);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 28px;
  font-weight: 700;
}

.login-panel p {
  margin-top: 4px;
  color: var(--muted);
}

.login-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
}

.language-picker {
  width: auto;
  min-width: 112px;
  min-height: 34px;
  padding: 5px 8px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.2;
}

.topbar span {
  color: var(--muted);
  font-size: 13px;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.config-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.config-collapsed .run-panel {
  display: none;
}

.main-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 4px 18px rgba(31, 41, 51, 0.05);
}

.run-panel,
.job-panel,
.recent-panel {
  padding: 16px;
}

.run-panel form,
.job-panel,
.recent-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.panel-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  font-size: 16px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

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

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.icon-button {
  width: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  background: #eef3f6;
}

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

.upload-list {
  display: grid;
  gap: 10px;
}

.upload-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.upload-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.upload-card-head div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.upload-card-head strong {
  font-size: 14px;
}

.upload-card-head span,
.file-field span {
  color: var(--muted);
  font-size: 12px;
}

.upload-card-head button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  white-space: nowrap;
}

.drop-zone {
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px dashed #b8c5cf;
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone.dragover,
.drop-zone:hover {
  border-color: var(--blue);
  background: #eef7fc;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: rgba(25, 118, 92, 0.5);
  background: #f0faf6;
}

.drop-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.drop-file {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfb;
}

.switch {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.switch input {
  width: 18px;
  min-height: 18px;
}

.profile-meta {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  background: #f9fbfb;
  font-size: 13px;
}

.profile-meta strong {
  color: var(--text);
}

.profile-meta p {
  color: var(--muted);
  line-height: 1.4;
}

.error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 86px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.idle {
  color: var(--muted);
  background: #eef1f4;
}

.queued,
.running {
  color: var(--amber);
  background: #fff4d6;
}

.completed {
  color: var(--green);
  background: #e7f5ef;
}

.failed {
  color: var(--red);
  background: #fde7e4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 22px;
}

.reasons {
  display: grid;
  gap: 8px;
}

.reasons h3 {
  font-size: 14px;
}

.reasons div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  font-size: 13px;
}

.reasons span {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.logs {
  min-height: 340px;
  max-height: 52vh;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: #26313b;
  background: #f8fafb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.job-item {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
  text-align: left;
  background: #fff;
}

.job-item:hover {
  background: #f5f8fa;
}

.job-item.selected {
  border-color: rgba(29, 111, 165, 0.55);
  background: #eef7fc;
}

.job-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-item strong {
  font-size: 12px;
  text-transform: uppercase;
}

.job-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.empty {
  padding: 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .topbar,
  .userbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-head {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .config-collapsed .run-panel {
    display: none;
  }

  .form-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
