:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

* { box-sizing: border-box; }
body { margin: 0; background: #0f172a; }
button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

h1, h2, p { margin: 0; }
h1 { font-size: 21px; color: #fff; }
h1 span { color: #818cf8; font-weight: 400; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #cbd5e1; }
.topbar p, .section-head p { margin-top: 4px; color: #94a3b8; font-size: 12px; }

.status-strip { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.status-strip span { padding: 6px 8px; border: 1px solid #334155; background: #111827; color: #a5b4fc; border-radius: 6px; }

.layout {
  max-width: 1700px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 36px rgba(0,0,0,.22);
}
.controls, .logs { grid-column: 1; }
.editor, .results, .history { grid-column: 2; }

label { display: block; margin-top: 16px; }
label span { display: block; margin-bottom: 7px; color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 11px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.45; font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.16); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.button-row, .feedback-row, .section-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.button-row { margin-top: 18px; }
.feedback-row { margin-top: 12px; }
button {
  border: 1px solid #334155;
  color: #cbd5e1;
  background: #1e293b;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}
button:hover { border-color: #64748b; color: #fff; }
button.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 700; }
button:disabled { opacity: .55; cursor: wait; }

.manual { margin-top: 14px; }
.manual button { margin-top: 10px; width: 100%; }
.hidden { display: none !important; }
.error { margin-top: 14px; padding: 10px; border: 1px solid #7f1d1d; background: rgba(127,29,29,.3); color: #fecaca; border-radius: 6px; font-size: 13px; }
.screenshot { display: block; margin-top: 12px; color: #fca5a5; font-size: 13px; }

#xpathEditor { min-height: 430px; margin-top: 14px; }
.logs pre, #logsOutput {
  min-height: 230px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  color: #86efac;
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
}

.table-wrap { margin-top: 14px; overflow: auto; }
.table-wrap.empty { color: #64748b; font-size: 13px; padding: 18px; border: 1px dashed #334155; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; vertical-align: top; border-bottom: 1px solid #1f2937; padding: 9px; }
th { color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; background: #111827; }
td { color: #dbeafe; max-width: 320px; }
a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
.product-image { width: 74px; height: 96px; object-fit: cover; border-radius: 4px; border: 1px solid #334155; background: #020617; }
.muted { color: #94a3b8; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .controls, .logs, .editor, .results, .history { grid-column: 1; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

.pass { color: #86efac; font-weight: 700; }
.fail { color: #fca5a5; font-weight: 700; }
.xpath-preview { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.toggle-row input { width: auto; }
.toggle-row span { margin: 0; }
.compare-block { margin: 16px 0; padding: 12px; border: 1px solid #334155; border-radius: 6px; background: #0f172a; }
.compare-block h3 { margin: 0 0 10px; font-size: 13px; color: #cbd5e1; }

.detail-button { padding: 5px 8px; font-size: 11px; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(2, 6, 23, .78); }
.modal-panel { width: min(1100px, 96vw); max-height: 88vh; display: flex; flex-direction: column; background: #111827; border: 1px solid #334155; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #1f2937; }
.modal-head h2 { font-size: 13px; }
.modal-body { margin: 0; padding: 16px; overflow: auto; white-space: pre-wrap; color: #dbeafe; background: #020617; font-size: 12px; line-height: 1.45; }
.modal-body pre { margin: 0; white-space: pre-wrap; }
.modal-body img { display: block; max-width: 100%; height: auto; border: 1px solid #334155; border-radius: 6px; background: #fff; }
