* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8dee8;
  --line-strong: #b9c2d0;
  --text: #182235;
  --muted: #667085;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

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

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

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button-link:hover {
  background: var(--accent-strong);
}

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

button.secondary,
.button-link.secondary-link {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover,
.button-link.secondary-link:hover {
  background: var(--surface-soft);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

textarea.compact-text {
  min-height: 104px;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: 0;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 20px;
}

h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

pre {
  margin: 0;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 7px;
  background: #101828;
  color: #e4e7ec;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

code {
  display: block;
  overflow-wrap: anywhere;
  color: #344054;
}

.hidden {
  display: none !important;
}

.empty {
  color: var(--muted);
  padding: 20px;
}

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

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

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

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

.login-brand p {
  margin: 3px 0 0;
  color: var(--muted);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(250px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 18px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(10px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #e7f5f2;
  color: var(--accent-strong);
  font-weight: 760;
}

.brand-block span,
.page-header p,
#runtimeMeta,
#configMeta,
#uploadMeta,
#detailMeta,
#jobActionState,
#uploadState,
#configState,
#verifyState,
#jobPageInfo {
  margin: 3px 0 0;
  color: var(--muted);
}

.app-tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
}

.app-tab {
  min-height: 34px;
  white-space: nowrap;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.app-tab:hover,
.app-tab.active {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.app-tab.active {
  border-color: #99d4cb;
  color: var(--accent-strong);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.spa-page {
  display: none;
  padding: 18px;
}

.spa-page.active {
  display: block;
}

.jobs-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 82px);
}

.jobs-sidebar,
.page-panel,
.detail-head,
.tab-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.jobs-sidebar {
  min-width: 0;
  overflow: hidden;
}

.section-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.filters button {
  grid-column: 1 / -1;
}

.job-list {
  max-height: calc(100vh - 225px);
  overflow: auto;
}

.job-row {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.job-row:hover,
.job-row.active {
  background: #f0fdfa;
}

.job-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta,
.row-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.detail {
  min-width: 0;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.detail-actions,
.actions,
.check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.check-row label {
  display: inline-flex;
  width: auto;
  grid-template-columns: auto;
  align-items: center;
  color: var(--text);
}

.check-row input {
  width: auto;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.pill.posted,
.pill.parsed {
  border-color: #abefc6;
  background: #ecfdf3;
  color: var(--ok);
}

.pill.running,
.pill.queued {
  border-color: #b2ddff;
  background: #eff8ff;
  color: var(--blue);
}

.pill.error {
  border-color: #fecdca;
  background: #fef3f2;
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0;
  overflow-x: auto;
}

.tab {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.tab.active {
  border-color: #99d4cb;
  background: #e7f5f2;
  color: var(--accent-strong);
}

.tab-panel {
  display: none;
  padding: 14px;
}

.tab-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

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

.metric-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.json-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.json-grid section {
  min-width: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 12px;
}

.file-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 12px;
}

.file-list,
.events,
.logs,
.status-counts {
  display: grid;
  gap: 8px;
}

.file-row,
.event-row,
.log-row,
.recent-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 10px;
}

.file-row {
  width: 100%;
  color: var(--text);
  text-align: left;
}

.file-row.active {
  border-color: #99d4cb;
  background: #e7f5f2;
}

.file-preview {
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.file-preview iframe,
.file-preview img {
  width: 100%;
  min-height: 520px;
  border: 0;
  object-fit: contain;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.page-panel {
  margin-bottom: 14px;
  padding: 14px;
}

.page-panel.narrow {
  max-width: 820px;
}

.upload-form,
.config-form {
  display: grid;
  gap: 12px;
}

.form-grid,
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.upload-drop-zone {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
}

.upload-drop-zone.dragover {
  border-color: var(--accent);
  background: #e7f5f2;
  color: var(--accent-strong);
}

.endpoint-preview {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.ok {
  color: var(--ok);
}

.error-text {
  color: var(--danger);
}

@media (max-width: 980px) {
  .app-topbar,
  .jobs-workspace,
  .file-workspace {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .job-list {
    max-height: 420px;
  }

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

.hint-text {
  color: var(--muted);
  font-size: 0.85em;
  margin: 0;
}

.token-reveal-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-reveal-row code {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow-x: auto;
  white-space: nowrap;
}
