:root {
  --bg-paper: #f6f7f3;
  --bg-surface: #fcfcfa;
  --bg-subtle: #eef1eb;
  --bg-hover: #e7ece4;

  --text-primary: #1d2925;
  --text-secondary: #4a5852;
  --text-muted: #6d7b74;

  --accent-green: #315f49;
  --accent-green-hover: #254a38;
  --accent-green-soft: #e3ede7;
  --accent-green-border: #adc6b9;

  --rule-light: #dfe4dc;
  --rule-strong: #c8d0c5;

  --status-found-bg: #e3efe8;
  --status-found-fg: #214d38;
  --status-found-border: #9ec0ae;

  --status-queued-bg: #edf0ec;
  --status-queued-fg: #44534c;
  --status-queued-border: #c5cec4;

  --status-running-bg: #e5eef2;
  --status-running-fg: #1f4d61;
  --status-running-border: #9ec0cf;

  --status-error-bg: #f7e9e7;
  --status-error-fg: #7d2c23;
  --status-error-border: #dfb3ad;

  --status-warn-bg: #f6efe0;
  --status-warn-fg: #6f5118;
  --status-warn-border: #d9c396;

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Source Han Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --shadow-subtle: 0 1px 2px rgba(29, 41, 37, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono-text {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Auth / Login View */
.auth-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background-color: var(--bg-surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-subtle);
}

.auth-header {
  border-bottom: 1px solid var(--rule-light);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.badge-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent-green);
  background-color: var(--accent-green-soft);
  border: 1px solid var(--accent-green-border);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.meta-sep {
  color: var(--rule-strong);
}

.auth-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.auth-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  margin: 0.45rem 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.text-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  color: var(--text-primary);
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.text-input.mono-input {
  font-family: var(--font-mono);
}

.text-input-sm {
  padding: 0.42rem 0.65rem;
  font-size: 0.86rem;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-green);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 2px rgba(49, 95, 73, 0.14);
}

.form-actions {
  margin-top: 0.35rem;
}

.auth-footer {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-light);
}

.policy-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.policy-item dt {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.policy-item dd {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.58rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--accent-green);
  color: #ffffff;
  border-color: var(--accent-green);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-green-hover);
  border-color: var(--accent-green-hover);
}

.btn-subtle {
  background-color: var(--bg-paper);
  color: var(--text-primary);
  border-color: var(--rule-strong);
}

.btn-subtle:hover:not(:disabled) {
  background-color: var(--bg-hover);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--rule-strong);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.32rem 0.68rem;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

/* Notices / Alerts */
.notice-banner {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  border: 1px solid var(--rule-strong);
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.notice-error {
  background-color: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error-fg);
}

.notice-info {
  background-color: var(--bg-subtle);
  border-color: var(--rule-strong);
  color: var(--text-secondary);
}

.notice-success {
  background-color: var(--status-found-bg);
  border-color: var(--status-found-border);
  color: var(--status-found-fg);
}

/* Workspace Stage */
.workspace-stage {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule-strong);
}

.brand-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--accent-green);
  display: inline-block;
  transform: translateY(-1px);
}

.brand-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.brand-policy {
  margin: 0.35rem 0 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.session-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.session-label {
  color: var(--text-muted);
}

.session-name {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.workspace-alert {
  margin-bottom: 1.25rem;
}

/* Main Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-column {
  min-width: 0;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Panels */
.panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-subtle);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule-light);
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.count-pill {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--rule-light);
}

.poll-status {
  font-size: 0.76rem;
  color: var(--accent-green);
  background-color: var(--accent-green-soft);
  border: 1px solid var(--accent-green-border);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Search Form */
.search-form {
  margin-bottom: 0.25rem;
}

.search-input-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

#search-feedback {
  margin-top: 0.85rem;
  margin-bottom: 0;
}

/* Jobs History List */
.jobs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 540px;
  overflow-y: auto;
}

.job-item {
  margin: 0;
}

.job-card-btn {
  width: 100%;
  text-align: left;
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--text-primary);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.job-card-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--rule-strong);
}

.job-card-btn.is-selected {
  background-color: var(--accent-green-soft);
  border-color: var(--accent-green);
}

.job-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.job-card-username {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.job-card-counts {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.52rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-queued {
  background-color: var(--status-queued-bg);
  color: var(--status-queued-fg);
  border-color: var(--status-queued-border);
}

.status-running {
  background-color: var(--status-running-bg);
  color: var(--status-running-fg);
  border-color: var(--status-running-border);
}

.status-completed,
.status-found {
  background-color: var(--status-found-bg);
  color: var(--status-found-fg);
  border-color: var(--status-found-border);
}

.status-failed,
.status-error {
  background-color: var(--status-error-bg);
  color: var(--status-error-fg);
  border-color: var(--status-error-border);
}

.status-interrupted,
.status-invalid {
  background-color: var(--status-warn-bg);
  color: var(--status-warn-fg);
  border-color: var(--status-warn-border);
}

.status-not_found {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--rule-light);
}

/* Detail Placeholder / Empty States */
.detail-placeholder {
  padding: 2.75rem 2rem;
}

.placeholder-inner {
  max-width: 560px;
}

.placeholder-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.placeholder-desc {
  margin: 0 0 1.15rem 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.placeholder-notes {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.empty-box {
  padding: 1.75rem 1rem;
  text-align: center;
  background-color: var(--bg-paper);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-sm);
}

.empty-title {
  margin: 0 0 0.25rem 0;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.empty-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Detail Header Panel */
.detail-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule-light);
}

.detail-kicker {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.detail-username {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.detail-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.csv-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.65rem;
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-sm);
}

/* Honest Indeterminate Progress */
.progress-panel {
  background-color: var(--bg-paper);
  border: 1px solid var(--accent-green-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.progress-title {
  font-size: 0.88rem;
  color: var(--accent-green);
}

.progress-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  background-color: var(--rule-light);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-indeterminate {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  background-color: var(--accent-green);
  border-radius: 999px;
  animation: sherlock-indeterminate 1.6s infinite ease-in-out;
}

@keyframes sherlock-indeterminate {
  0% {
    left: -40%;
    width: 35%;
  }
  50% {
    left: 30%;
    width: 45%;
  }
  100% {
    left: 100%;
    width: 35%;
  }
}

.progress-desc {
  margin: 0.55rem 0 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Metrics & Timestamps */
.metrics-strip {
  margin: 0 0 1rem 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.metric-cell {
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}

.metric-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.metric-value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-found {
  color: var(--accent-green);
}

.metric-error {
  color: var(--status-error-fg);
}

.timestamps-strip {
  margin: 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule-light);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.time-item dt {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.time-item dd {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

/* Results Section */
.results-disclaimer {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background-color: var(--bg-paper);
  border-left: 3px solid var(--accent-green);
  padding: 0.55rem 0.85rem;
  margin-bottom: 1rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--rule-light);
}

.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.tab-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.is-active {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background-color: rgba(29, 41, 37, 0.08);
  color: inherit;
}

.tab-btn.is-active .tab-count {
  background-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.filter-box {
  min-width: 210px;
  flex: 0 1 250px;
}

/* Table */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-sm);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.results-table th,
.results-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: middle;
}

.results-table thead th {
  background-color: var(--bg-paper);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.results-table tbody tr:hover {
  background-color: var(--bg-paper);
}

.col-site {
  width: 22%;
  font-weight: 600;
}

.col-status {
  width: 15%;
  white-space: nowrap;
}

.col-http {
  width: 13%;
  white-space: nowrap;
}

.col-url {
  width: 50%;
  word-break: break-all;
}

.result-link {
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.result-link:hover {
  color: var(--accent-green-hover);
}

.muted-dash {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Responsive / Mobile Layout */
@media (max-width: 980px) {
  .workspace-stage {
    padding: 1.15rem 1rem 2.25rem;
  }

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

  .jobs-list {
    max-height: 300px;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timestamps-strip {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }
}

@media (max-width: 640px) {
  .auth-card {
    padding: 1.5rem 1.25rem;
  }

  .policy-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .topbar-user {
    justify-content: space-between;
  }

  .search-input-group {
    flex-direction: column;
  }

  .detail-top-row {
    flex-direction: column;
  }

  .results-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-box {
    flex: 1 1 auto;
    width: 100%;
  }
}
