:root {
  --bg: #f3ecd8;
  --panel: #fffaf0;
  --surface: #f8f1df;
  --surface-soft: #eef5e6;
  --ink: #203329;
  --muted: #637163;
  --line: #ddd1b8;
  --line-strong: #bda985;
  --accent: #4f7f52;
  --accent-dark: #244b36;
  --accent-soft: #dcebd2;
  --sky-soft: #d7e9e4;
  --sun-soft: #f3d58f;
  --warning: #94642d;
  --danger: #a24d40;
  --shadow: 0 22px 60px rgba(74, 79, 50, 0.16);
  --radius: 8px;
  --mono: "SFMono-Regular", "Cascadia Mono", "Liberation Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(160deg, rgba(243, 213, 143, 0.22), transparent 36%),
    linear-gradient(180deg, rgba(215, 233, 228, 0.44) 0%, rgba(238, 245, 230, 0.5) 42%, rgba(243, 236, 216, 0.72) 100%),
    var(--bg);
  font-family: var(--sans);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: var(--accent-dark);
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(36, 75, 54, 0.24);
}

.brand strong {
  display: block;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #52624f;
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.hero-panel,
.custom-extraction,
.metrics-grid,
.export-panel,
.detail-layout,
.quality-panel {
  scroll-margin-top: 24px;
}

.section-focus {
  outline: 2px solid rgba(79, 127, 82, 0.32);
  outline-offset: 4px;
}

.policy-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.policy-label,
.kicker {
  display: block;
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.policy-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.policy-card a {
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 13px;
}

.workspace {
  padding: 32px;
  display: grid;
  gap: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.topbar h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 0.95;
  letter-spacing: 0;
}

.health-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.user-pill,
.admin-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.admin-link {
  color: var(--accent-dark);
  font-weight: 800;
}

.admin-link[hidden] {
  display: none !important;
}

.ghost-button.compact {
  min-height: 38px;
  border-radius: 999px;
}

.auth-gate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(162, 77, 64, 0.24);
  border-radius: var(--radius);
  background: #fff1e6;
  box-shadow: var(--shadow);
}

body.signed-in .auth-gate {
  display: none !important;
}

.auth-gate strong,
.auth-gate span {
  display: block;
}

.auth-gate span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-actions {
  display: flex;
  gap: 10px;
}

.auth-actions a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--radius);
  color: white;
  background: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.auth-actions a:first-child {
  color: var(--accent-dark);
  background: var(--panel);
  border: 1px solid var(--line-strong);
}

.session-card {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.session-card span,
.session-card strong {
  display: block;
}

.session-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.session-card strong {
  margin-top: 7px;
  color: var(--accent-dark);
  font-size: 14px;
}

.health-pill.good {
  color: var(--accent-dark);
  border-color: rgba(79, 127, 82, 0.25);
  background: var(--accent-soft);
}

.health-pill.bad {
  color: var(--danger);
  background: #fff1e6;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(148, 100, 45, 0.14);
}

.health-pill.good .pulse {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(79, 127, 82, 0.15);
}

.health-pill.bad .pulse {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(162, 77, 64, 0.14);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  align-items: stretch;
}

.crawl-form-wrap,
.scope-card,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.crawl-form {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.disabled-panel {
  opacity: 0.58;
}

.disabled-panel input,
.disabled-panel select,
.disabled-panel button {
  pointer-events: none;
}

label {
  display: grid;
  gap: 8px;
}

label > span {
  color: #405540;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 127, 82, 0.16);
}

.url-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
}

#startButton,
.search-form button,
.export-actions button:first-child {
  min-height: 46px;
  border-radius: var(--radius);
  color: white;
  background: var(--accent-dark);
  font-weight: 800;
}

#startButton:hover,
.search-form button:hover,
.export-actions button:first-child:hover {
  background: var(--accent);
}

#startButton:active,
.search-form button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.form-row {
  display: grid;
  gap: 12px;
}

.form-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.toggle-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.check input {
  width: auto;
  min-height: auto;
}

.check span {
  font-size: 13px;
  font-weight: 700;
}

.muted-check {
  color: var(--muted);
}

.custom-extraction {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.custom-extraction[hidden] {
  display: none !important;
}

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

.custom-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.custom-fields {
  display: grid;
  gap: 12px;
}

.custom-field {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.custom-field-top,
.custom-field-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.custom-remove {
  min-height: 46px;
}

.custom-required {
  justify-self: start;
}

.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--accent-dark);
  background: var(--panel);
  font-weight: 800;
}

.scope-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.scope-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.scope-head span {
  color: var(--muted);
  font-size: 13px;
}

.scope-head strong {
  color: var(--accent-dark);
  font-size: 13px;
}

dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

dl div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 700;
}

.mini-terminal {
  min-height: 118px;
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: #20382d;
  color: #e0ebd1;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.mini-terminal div + div {
  margin-top: 5px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.content-grid,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.count-chip {
  flex: 0 0 auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface);
}

td strong {
  display: block;
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.page-row {
  cursor: pointer;
}

.page-row:hover {
  background: var(--surface-soft);
}

.empty-cell,
.empty-state,
.detail-empty {
  color: var(--muted);
}

.search-form {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 98px;
  gap: 10px;
}

.export-panel {
  overflow: hidden;
}

.export-body {
  padding: 18px 20px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
}

.export-copy {
  display: grid;
  gap: 5px;
}

.export-copy strong,
.export-copy span {
  display: block;
}

.export-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.export-scope-toggle {
  white-space: nowrap;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.export-actions button {
  min-width: 136px;
}

.result-list {
  padding: 0 20px 20px;
  display: grid;
  gap: 10px;
}

.result-item,
.field-card,
.seo-card,
.contact-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.result-item strong,
.field-card strong,
.seo-card strong,
.contact-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.result-item span,
.field-card span,
.seo-card span,
.contact-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.page-detail-panel {
  min-height: 440px;
}

.detail-empty {
  padding: 48px 20px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
}

.detail-body {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.detail-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.detail-summary h3 {
  margin: 0;
  font-size: 18px;
}

.detail-summary a {
  color: var(--accent-dark);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.detail-group {
  display: grid;
  gap: 10px;
}

.detail-group h3 {
  margin: 0;
  font-size: 15px;
}

.quality-list {
  padding: 18px 20px 20px;
  display: grid;
  gap: 12px;
}

.quality-list div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.quality-list strong,
.quality-list span {
  display: block;
}

.quality-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: var(--radius);
  color: white;
  background: var(--accent-dark);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .policy-card {
    margin-top: 0;
    flex: 1 1 260px;
  }

  .nav-list {
    grid-auto-flow: column;
    overflow-x: auto;
  }
}

@media (max-width: 920px) {
  .workspace {
    padding: 20px;
  }

  .topbar,
  .hero-panel,
  .export-body,
  .content-grid,
  .detail-layout,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .health-pill {
    width: fit-content;
  }

  .form-row.two,
  .form-row.four,
  .url-control,
  .custom-field-top,
  .custom-field-rules {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 16px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 36px;
  }

  .crawl-form,
  .scope-card {
    padding: 16px;
  }

  .panel-header {
    display: grid;
  }

  .auth-gate {
    display: grid;
  }

  .custom-head {
    display: grid;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .export-actions {
    justify-content: stretch;
  }

  .export-actions button {
    flex: 1 1 180px;
  }
}
