:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f3f5f6;
  color: #172026;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: #f3f5f6;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid #cfd6d9;
  background: #ffffff;
}

.title-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.product-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 6px;
  background: #174f46;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

#statusText {
  margin-top: 4px;
  overflow: hidden;
  color: #58646a;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  min-width: 108px;
  padding: 7px 10px;
  border: 1px solid #aeb8bc;
  border-radius: 5px;
  background: #f8fafb;
  color: #405058;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.status-badge[data-phase="captcha-ready"] {
  border-color: #c7901f;
  background: #fff7df;
  color: #76500a;
}

.status-badge[data-phase="results-ready"],
.status-badge[data-phase="complete"] {
  border-color: #2f7d62;
  background: #e9f6f0;
  color: #205b46;
}

.status-badge[data-phase="capturing"] {
  border-color: #2a6482;
  background: #eaf4f8;
  color: #1f536d;
}

.status-badge[data-phase="error"] {
  border-color: #b44840;
  background: #fff0ef;
  color: #8f2e28;
}

main {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 20px 28px 40px;
}

.step-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
  border: 1px solid #d2d9dc;
  border-radius: 6px;
  background: #ffffff;
}

.step-strip div {
  position: relative;
  min-width: 0;
  padding: 13px 18px 13px 52px;
  border-right: 1px solid #dce1e3;
}

.step-strip div:last-child {
  border-right: 0;
}

.step-strip div::before {
  position: absolute;
  top: 14px;
  left: 17px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #e8eeef;
  color: #33454c;
  content: attr(data-step);
  font-size: 11px;
  font-weight: 800;
}

.step-strip strong,
.step-strip span {
  display: block;
}

.step-strip strong {
  font-size: 13px;
}

.step-strip span {
  margin-top: 3px;
  color: #66747a;
  font-size: 12px;
}

.setup-band,
.captcha-band,
.action-band,
.metrics,
.table-section,
.failure-section {
  border-top: 1px solid #cfd6d9;
}

.setup-band,
.captcha-band {
  padding: 18px 0;
}

.mode-band {
  padding: 18px 0;
  border-top: 1px solid #cfd6d9;
}

.mode-description {
  margin-top: 4px;
  color: #66747a;
  font-size: 12px;
}

.mode-security {
  color: #205b46;
  font-size: 11px;
  font-weight: 800;
}

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

.mode-option {
  display: flex;
  min-height: 64px;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid #c4ced1;
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
}

.mode-option.is-selected {
  border-color: #276d8b;
  background: #eef7fa;
  box-shadow: inset 3px 0 0 #276d8b;
}

.mode-option input {
  width: 16px;
  height: 16px;
  accent-color: #276d8b;
}

.mode-option span {
  display: grid;
  gap: 3px;
}

.mode-option strong {
  color: #263d46;
  font-size: 12px;
}

.mode-option small {
  color: #66747a;
  font-size: 11px;
  font-weight: 500;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.section-title span,
.action-band p,
.section-header p {
  color: #66747a;
  font-size: 12px;
}

.setup-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
}

.setup-meta span:last-child {
  color: #205d77;
  font-weight: 800;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(210px, 1.4fr) auto 90px 90px 145px auto auto auto;
  align-items: end;
  gap: 10px;
}

label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #45545a;
  font-size: 11px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #aeb9bd;
  border-radius: 5px;
  background: #ffffff;
  color: #172026;
  font-size: 13px;
  font-weight: 500;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(35, 112, 138, 0.2);
  outline-offset: 1px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button:disabled,
.button.disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.button-primary {
  border-color: #174f46;
  background: #174f46;
  color: #ffffff;
}

.button-primary:hover:not(:disabled) {
  background: #113e37;
}

.button-secondary {
  border-color: #276d8b;
  background: #ffffff;
  color: #205d77;
}

.button-danger {
  border-color: #b44840;
  background: #ffffff;
  color: #97352f;
}

.button-ghost {
  border-color: #aeb9bd;
  background: #ffffff;
  color: #2f3e44;
}

.captcha-controls {
  display: grid;
  grid-template-columns: 280px minmax(180px, 260px) 150px 170px;
  align-items: end;
  gap: 10px;
}

.captcha-preview-wrap {
  display: flex;
  width: 280px;
  height: 96px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #c8d0d3;
  border-radius: 5px;
  background: #ffffff;
}

#captchaPreview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.action-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 0;
}

.action-band p {
  margin-top: 4px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.error-message {
  min-height: 22px;
  padding: 7px 0;
  color: #99342e;
  font-size: 12px;
  font-weight: 700;
}

.live-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid #cfd6d9;
}

.live-darpan-panel,
.scrape-monitor {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #cbd3d6;
  border-radius: 6px;
  background: #ffffff;
}

.live-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid #dce2e4;
  flex-wrap: wrap;
}

.browser-unlock,
.browser-text-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #dce2e4;
}

.browser-unlock label,
.browser-text-entry label { grid-column: 1 / -1; }
.browser-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 18px;
  border-bottom: 1px solid #dce2e4;
  background: #eef7fa;
}
.browser-toolbar strong { font-size: 12px; margin-right: auto; }
.browser-feedback { padding: 10px 18px; color: #45545a; font-size: 12px; min-height: 36px; }
.is-interactive .live-darpan-frame { min-height: 0; max-height: none; aspect-ratio: 1280 / 900; overflow: hidden; }
.is-interactive #liveDarpanPreview { min-height: 0; height: auto; cursor: text; }
.live-darpan-panel.is-expanded { grid-column: 1 / -1; }
.live-darpan-panel.is-expanded + .scrape-monitor { grid-column: 1 / -1; }
.live-darpan-frame:focus-visible { outline: 3px solid #276d8b; outline-offset: -3px; }

.live-panel-header p,
.monitor-summary {
  margin-top: 4px;
  color: #66747a;
  font-size: 12px;
}

.live-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.live-darpan-frame {
  position: relative;
  display: grid;
  min-height: 410px;
  max-height: 620px;
  place-items: start center;
  overflow: auto;
  background: #edf2f3;
}

#liveDarpanPreview {
  display: block;
  width: 100%;
  height: auto;
  min-height: 410px;
  object-fit: contain;
  object-position: top center;
  background: #ffffff;
}

#liveDarpanPreview:not([src]) {
  display: none;
}

#liveDarpanEmpty {
  position: absolute;
  top: 50%;
  margin: 0;
  color: #66747a;
  font-size: 12px;
  transform: translateY(-50%);
}

.scrape-monitor .section-header {
  margin: 0;
  padding: 16px 18px 12px;
}

.range-progress {
  padding: 0 18px 14px;
}

.range-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #66747a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.range-progress-label strong {
  color: #205d77;
  font-size: 11px;
}

.progress-track {
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3eaec;
}

#rangeProgressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #276d8b;
  transition: width 180ms ease;
}

.monitor-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #dce2e4;
  border-bottom: 0;
}

.monitor-metrics div {
  padding: 15px 18px;
  border-right: 1px solid #dce2e4;
  border-bottom: 1px solid #dce2e4;
}

.monitor-metrics div:nth-child(even) {
  border-right: 0;
}

.monitor-summary {
  min-height: 42px;
  margin: 0;
  padding: 13px 18px;
}

.metrics {
  display: grid;
  grid-template-columns: 150px repeat(4, 110px) minmax(240px, 1fr);
  border-bottom: 1px solid #cfd6d9;
}

.metrics div {
  min-width: 0;
  padding: 15px 16px 15px 0;
}

.metrics span,
.metrics strong {
  display: block;
}

.metrics span {
  margin-bottom: 5px;
  color: #728087;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.table-section,
.failure-section {
  padding-top: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.section-header p {
  margin-top: 4px;
}

#currentPage {
  color: #57666c;
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #cbd3d6;
  border-radius: 6px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e5e7;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #263d46;
  color: #ffffff;
  font-size: 11px;
  text-transform: uppercase;
}

td {
  color: #2d3a40;
  font-size: 12px;
}

tbody tr:hover {
  background: #f6faf9;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(2),
td:nth-child(2) {
  width: 64px;
  text-align: center;
}

th:nth-child(3),
td:nth-child(3) {
  width: 290px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 165px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 235px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 125px;
}

.name-cell {
  font-weight: 800;
}

.empty-row td {
  height: 104px;
  color: #75838a;
  text-align: center;
}

.failure-section h2 {
  margin-bottom: 10px;
}

.failure-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 80px minmax(260px, 2fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #dce2e4;
  font-size: 12px;
}

.failure-row span,
.failure-row p {
  color: #67757b;
}

@media (max-width: 1100px) {
  .controls-grid {
    grid-template-columns: minmax(240px, 1fr) auto 120px 150px;
  }

  .controls-grid .button-secondary,
  .controls-grid .button-ghost {
    width: 100%;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .live-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-header,
  .action-band,
  .section-header,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header,
  main {
    padding-right: 16px;
    padding-left: 16px;
  }

  #statusText {
    white-space: normal;
  }

  .step-strip,
  .mode-options,
  .controls-grid,
  .captcha-controls,
  .metrics {
    grid-template-columns: 1fr;
  }

  .live-panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .step-strip div {
    border-right: 0;
    border-bottom: 1px solid #dce1e3;
  }

  .step-strip div:last-child {
    border-bottom: 0;
  }

  .controls-grid .button,
  .captcha-controls .button,
  .captcha-preview-wrap,
  .action-buttons,
  .action-buttons .button {
    width: 100%;
  }

  .metrics div {
    padding: 11px 0;
    border-bottom: 1px solid #dce2e4;
  }

  .failure-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
