/* Page Report — admin UI. Hand-written CSS, no frameworks.
   Layout target: ~1400px wide, dark theme per mockups/01..03. */

:root {
  --bg: #0b0b0d;
  --panel: #151518;
  --panel-alt: #1b1b1f;
  --panel-border: #26262c;
  --row-hover: #202026;
  --row-selected: #232329;

  --text: #f4f4f7;
  --text-mid: #c3c3cb;
  --text-dim: #8b8b94;
  --text-faint: #66666e;

  --blue: #3478f6;
  --blue-bright: #3b82f6;
  --blue-soft: rgba(52, 120, 246, 0.22);
  --green: #2e9e4f;
  --red: #b03632;
  --yellow: #c9a227;
  --orange: #f0912d;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas,
          "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; }

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  height: 100vh;
}

/* ---------- Sidebar (mockup 01, left) ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #101013;
  border-right: 1px solid var(--panel-border);
  padding: 18px 16px 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sidebar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--row-hover); color: var(--text); }

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#search::placeholder { color: var(--text-faint); }
#search:focus { border-color: #3d3d46; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  padding: 4px 11px;
  border: 1px solid #3a3a42;
  border-radius: 999px;
  background: transparent;
  color: var(--text-mid);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: #4d4d57; color: var(--text); }
.chip.active {
  background: #d4d4da;
  border-color: #d4d4da;
  color: #16161a;
  font-weight: 600;
}

.job-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -16px;
  padding: 0 8px 12px;
}
.job-list::-webkit-scrollbar { width: 8px; }
.job-list::-webkit-scrollbar-thumb { background: #2c2c33; border-radius: 4px; }

/* Job rows (mockup 01, sidebar list) */

.job-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 10px 11px 12px;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.job-row:hover { background: var(--row-hover); }
.job-row.selected {
  background: var(--row-selected);
  border-left-color: var(--blue);
}

.job-clock { flex: none; color: var(--text-faint); }

.job-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.job-time {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.list-note {
  padding: 18px 14px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}
.list-note.error { color: #e08b86; }

/* ---------- Status pills (mockup 01) ---------- */

.badge {
  flex: none;
  padding: 3px 10px 2px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.queued  { background: #57491a; color: #ecd98b; border-color: #6d5c22; }
.badge.running { background: #2f52b8; color: #cfe0ff; border-color: #3f63c9; }
.badge.done    { background: #2b7440; color: #cdeed7; border-color: #35874d; }
.badge.failed  { background: #74302c; color: #f2cbc8; border-color: #8b3a35; }

.badge-lg {
  padding: 5px 14px 4px;
  font-size: 11.5px;
}
.badge-lg.running { background: var(--blue-bright); color: #fff; border-color: #5b98f7; }
.badge-lg.done    { background: var(--green); color: #fff; border-color: #46b166; }
.badge-lg.failed  { background: var(--red); color: #fff; border-color: #c74a45; }
.badge-lg.queued  { background: var(--yellow); color: #fff; border-color: #d9b23c; }

/* ---------- Main pane ---------- */

.main {
  min-width: 0;
  overflow-y: auto;
  padding: 22px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.main::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-thumb { background: #2c2c33; border-radius: 5px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 26px;
}

/* Job header (mockup 01, right pane top) */

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.job-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.job-id {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.job-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}

.job-relative {
  font-size: 13.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.divider {
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 20px -26px;
}

/* ---------- Stage timeline (mockup 01) ---------- */

.timeline { padding: 6px 4px 4px; }

.tl-names,
.tl-dots {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
}

.tl-names { margin-bottom: 10px; }

.tl-stage {
  position: relative;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 15px;
  color: var(--text-dim);
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}
.tl-stage:hover { color: var(--text-mid); }
.tl-stage.done    { color: #6f9df6; }
.tl-stage.current { color: var(--blue-bright); font-weight: 700; }
.tl-stage.selected:not(.current) { text-decoration: underline; text-underline-offset: 4px; }

.tl-arrow {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-faint);
  font-size: 15px;
  pointer-events: none;
}

.tl-track {
  position: relative;
  height: 24px;
}
.tl-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: #33333a;
  border-radius: 2px;
}

.tl-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: var(--blue);
  border-radius: 3px;
}

.tl-dots { position: absolute; inset: 0; }

.tl-dot-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tl-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid #3d3d46;
}
.tl-dot.done {
  background: var(--blue);
  border-color: var(--blue);
}
.tl-dot.current {
  width: 18px;
  height: 18px;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 0 5px var(--blue-soft);
}

/* ---------- Section headers (mockups 02/03) ---------- */

.section-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-mid);
}
.section-title b {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* ---------- Screenshot grid (mockup 02) ---------- */

.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px 24px;
}

.shot-cell { min-width: 0; }

.shot-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  overflow: hidden;
  cursor: zoom-in;
}
.shot-card:hover,
.shot-card:focus-visible {
  border-color: var(--blue-bright);
  outline: none;
}

/* Browser-chrome styled thumbnail */
.shot-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  background: #26262b;
  border-bottom: 1px solid #101013;
}
.shot-chrome i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
}
.shot-chrome i:nth-child(1) { background: #ec6a5e; }
.shot-chrome i:nth-child(2) { background: #f4bf4f; }
.shot-chrome i:nth-child(3) { background: #61c454; }
.shot-chrome .urlbar {
  flex: 1;
  height: 11px;
  margin-left: 6px;
  border-radius: 6px;
  background: #3a3a41;
}

.shot-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #101013;
}

.shot-caption {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-mid);
}

.pre-advance {
  padding: 2px 11px;
  border: 1px solid var(--orange);
  border-radius: 999px;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Requests table (mockup 03) ---------- */

.requests-wrap { overflow-x: auto; }

table.requests {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 14px;
}
.requests thead th {
  padding: 11px 16px;
  background: var(--panel-alt);
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.requests tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid #202026;
  color: var(--text-mid);
  vertical-align: middle;
}
.requests tbody tr:nth-child(odd) td  { background: var(--panel); }
.requests tbody tr:nth-child(even) td { background: var(--panel-alt); }
.requests tbody tr:hover td { background: var(--row-hover); }

.requests .col-num {
  width: 44px;
  color: var(--text-faint);
}
.requests .col-url {
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.requests .col-method { width: 110px; }
.requests .col-ip { width: 160px; white-space: nowrap; }
.requests .col-country { width: 110px; white-space: nowrap; }
.requests .col-requester { width: 140px; }

.country {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid #3a3a42;
  border-radius: 4px;
  background: var(--panel-alt);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-mid);
}
.country-unknown { color: var(--text-faint); }

.method {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.method.get  { background: var(--blue-bright); color: #0a2540; }
.method.post { background: var(--orange); color: #3c2200; }
.method.other { background: #4a4a54; color: #e2e2e8; }

/* ---------- Empty / error states ---------- */

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  color: var(--text-dim);
}
.empty .empty-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-mid);
}
.empty .empty-sub { font-size: 14px; color: var(--text-faint); }

.empty-inline {
  padding: 26px 8px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.error-panel { border-color: #4a2422; }
.error-panel .section-title b { color: #f0a7a2; }
.error-msg {
  margin: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  color: #e08b86;
  overflow-wrap: anywhere;
}

/* ---------- Popup image viewer (mockup 01, center) ---------- */

.popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.62);
}
.popup-backdrop[hidden] { display: none; }

.popup-panel {
  position: relative;
  width: min(760px, 92vw);
  padding: 30px 30px 18px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: #1c1c20;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.popup-close:hover { background: #2b2b31; color: var(--text); }

.popup-img {
  display: block;
  width: 100%;
  max-height: 66vh;
  object-fit: contain;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #0e0e11;
}

.popup-caption {
  margin-top: 14px;
  text-align: center;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-mid);
}

/* ---------- Responsive fallbacks ---------- */

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 42vh) minmax(0, 1fr);
    height: 100vh;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
    padding-top: 12px;
  }
  .main { padding: 16px; }
  .panel { padding: 16px; }
  .divider { margin: 16px -16px; }
  .job-head { flex-direction: column; gap: 12px; }
  .job-meta { align-items: flex-start; flex-direction: row-reverse; gap: 14px; }
  .shot-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
  .tl-stage { font-size: 12.5px; white-space: normal; }
}
