:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172026;
  background: #eef1f3;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #d7dde1;
}

.topbar > div { display: flex; align-items: center; gap: 12px; }
.topbar-actions { min-width: 0; justify-content: flex-end; }
.cdk-badge {
  max-width: min(52vw, 620px);
  overflow: hidden;
  color: #40515b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; font-weight: 700; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

.server-state { color: #60707a; font-size: 12px; }
.server-state.online { color: #16784a; }
.server-state.offline { color: #b42318; }

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.setup-panel {
  background: #ffffff;
  border-right: 1px solid #d7dde1;
  padding: 20px;
  overflow-y: auto;
}

.panel-heading, .section-row, .workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-heading { margin-bottom: 16px; }
.cdk-panel { padding-bottom: 18px; }
.cdk-panel p { margin-bottom: 14px; color: #687780; font-size: 12px; line-height: 1.6; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 650; color: #34444e; }
.field small { color: #73818a; line-height: 1.4; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid.compact { grid-template-columns: 88px minmax(0, 1fr); }

input, textarea, select {
  width: 100%;
  border: 1px solid #c7d0d6;
  border-radius: 5px;
  padding: 9px 10px;
  color: #172026;
  background: #ffffff;
  outline: none;
  letter-spacing: 0;
}

input:focus, textarea:focus, select:focus { border-color: #147d64; box-shadow: 0 0 0 2px rgba(20, 125, 100, .12); }
textarea { resize: vertical; min-height: 64px; }

.button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 650;
  letter-spacing: 0;
}
.button:disabled { opacity: .45; cursor: default; }
.button.primary { color: #ffffff; background: #147d64; }
.button.secondary { color: #263740; background: #ffffff; border-color: #c7d0d6; }
.button.danger { color: #a32922; background: #fff; border-color: #e2aaa6; }
.button.full { width: 100%; }
.form-error { min-height: 20px; padding-top: 8px; color: #b42318; font-size: 12px; }

.jobs-section { margin-top: 26px; padding-top: 20px; border-top: 1px solid #e1e6e9; }
.jobs-list { display: grid; gap: 8px; }
.job-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  text-align: left;
  padding: 10px;
  border: 1px solid #d7dde1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.job-item.active { border-color: #147d64; background: #f1faf7; }
.job-id { font-family: Consolas, monospace; font-size: 12px; }
.job-summary { color: #6a7881; font-size: 11px; }
.status { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #53636d; }
.status.running, .status.queued { color: #996600; }
.status.completed { color: #16784a; }
.status.error, .status.stopped { color: #b42318; }

.workspace { padding: 22px 24px 28px; min-width: 0; }
.workspace-head { min-height: 42px; margin-bottom: 18px; }
.workspace-head p { margin-top: 5px; color: #687780; font-size: 12px; }
.empty-state { min-height: 220px; display: grid; place-items: center; color: #77858e; border: 1px dashed #c7d0d6; }
.hidden { display: none !important; }
.job-view { display: grid; gap: 20px; }
.account-section, .log-section, .results-section { background: #fff; border: 1px solid #d7dde1; padding: 16px; }
.account-states { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 12px; }
.account-state { border-left: 3px solid #147d64; background: #f5f8f9; padding: 10px 12px; min-height: 72px; }
.account-state strong { display: block; overflow-wrap: anywhere; }
.account-state span { display: block; margin-top: 5px; color: #5d6c75; font-size: 12px; }

.section-row { margin-bottom: 12px; }
.section-row span { color: #6d7a82; font-size: 12px; }
.log-console {
  height: 520px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid #26343c;
  background: #182229;
  color: #d8e1e6;
  font: 12px/1.65 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.results-list { display: grid; gap: 8px; margin-top: 12px; }
.result-actions { display: flex; gap: 8px; }
.result-actions .button { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.result-item { display: grid; grid-template-columns: minmax(0, 1.1fr) 90px 80px 70px 120px minmax(0, 1.5fr) minmax(0, 1.8fr); gap: 10px; padding: 10px; background: #f5f8f9; }
.result-item > * { min-width: 0; }
.result-cell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-header { margin-top: 12px; background: #e9eef1; color: #52616a; font-size: 12px; font-weight: 700; }
.extraction-status { font-weight: 700; }
.extraction-status.running { color: #8a6100; }
.extraction-status.success { color: #16784a; }
.extraction-status.failed { color: #b42318; }
.extraction-status.stopped { color: #6a7881; }
.result-links { display: grid; gap: 5px; min-width: 0; }
.result-links a { display: block; min-width: 0; overflow: hidden; color: #0969a2; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .setup-panel { border-right: 0; border-bottom: 1px solid #d7dde1; }
  .workspace { padding: 18px 14px; }
  .result-item { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; gap: 10px; }
  .topbar-actions { gap: 6px !important; }
  .cdk-badge { display: none; }
  .topbar .button { padding: 7px 9px; }
  .field-grid, .field-grid.compact { grid-template-columns: 1fr; }
  .result-item { grid-template-columns: 1fr; }
}
