/* IndexPilot — clean light SaaS theme (emerald accent) */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --primary-border: #a7f3d0;
  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --warning-border: #fde68a;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.engines-nav { font-size: 12px; font-weight: 500; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #10b981; margin-right: 2px; }
.dot-ok { background: #10b981; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* Layout */
.main { max-width: 1200px; margin: 0 auto; padding: 20px; width: 100%; flex: 1; }
.footer { border-top: 1px solid var(--border); background: #fff; margin-top: auto; }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 14px 20px;
  font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* Tabs */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.tab {
  padding: 8px 14px; border-radius: 10px; text-decoration: none;
  color: var(--muted); font-weight: 500; font-size: 14px;
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab-active { background: var(--primary); color: #fff !important; }
.tab-active:hover { background: var(--primary); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 16px; }
.card-title { margin: 0 0 6px; font-size: 16px; }

/* Hero */
.hero { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 24px; }
.hero h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 560px; font-size: 14px; }
.hero-form { display: flex; gap: 8px; flex: 1 1 320px; max-width: 460px; }
.hero-form .input { flex: 1; height: 44px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 16px; margin-bottom: 0; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat-hint { font-size: 12px; color: var(--faint); }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 16px; }
.submit-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; align-items: start; }

.engine-card { margin-bottom: 0; padding: 16px; }
.engine-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.step-card { margin-bottom: 0; }
.step-card p { margin: 4px 0 0; }

.section-title { font-size: 14px; color: var(--muted); margin: 0 0 10px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge-soft { background: var(--bg); border-color: var(--border); color: var(--muted); }
.badge-success { background: var(--primary-soft); border-color: var(--primary-border); color: #047857; }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-ghost.danger:hover { color: var(--danger-text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-link { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; font-size: 13px; padding: 0; }
.link { color: var(--primary); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Forms */
.input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font-size: 14px; color: var(--text); background: #fff;
  font-family: inherit;
}
.input:focus { outline: 2px solid rgba(5, 150, 105, .25); border-color: var(--primary); }
textarea.input { resize: vertical; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.field .input { margin-top: 0; }
.input-narrow { width: 90px; text-align: center; }
.select-inline { width: auto; min-width: 220px; }
.inline-label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: #334155; }
.hint { font-size: 12px; color: var(--faint); margin: 8px 0 0; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.search-form { flex: 1 1 220px; max-width: 320px; }
.toolbar-actions { display: flex; gap: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafcfa; }
.ta-right { text-align: right; }
.site-cell strong { display: block; }
.row-actions { display: inline-flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.response-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Activity list */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f1f5f9; }
.activity-list li:last-child { border-bottom: 0; }
.activity-text { min-width: 0; flex: 1; }
.activity-text strong { display: block; font-size: 14px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-success { background: #10b981; }
.status-warning { background: #f59e0b; }
.status-failed { background: #ef4444; }

/* Pick list (submit page) */
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.pick-list li { margin-bottom: 6px; }
.pick-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #f1f5f9; border-radius: 10px; padding: 9px 12px; cursor: pointer;
}
.pick-item:hover { background: var(--bg); }
.pick-item input { width: 16px; height: 16px; accent-color: var(--primary); }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-text strong { font-size: 14px; }

.engine-list { list-style: none; margin: 0; padding: 0; }
.engine-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid #f1f5f9; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; height: 18px; width: 18px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* Run log */
.progress { height: 8px; background: var(--bg); border-radius: 999px; margin-bottom: 12px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.run-log { max-height: 560px; overflow-y: auto; }
.run-item { border: 1px solid #f1f5f9; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.run-head { display: flex; justify-content: space-between; gap: 10px; }
.run-site { font-size: 14px; }
.run-state.done { background: var(--primary-soft); border-color: var(--primary-border); color: #047857; }
.run-state.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.run-state.running { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.run-results { margin-top: 8px; }
.run-result {
  background: var(--bg); border-radius: 10px; padding: 9px 12px; margin-top: 6px; font-size: 13px;
}
.run-result-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.run-result-head strong { font-size: 12.5px; }
.run-result-msg { color: var(--muted); margin-top: 4px; line-height: 1.45; }
.run-result-count { color: #047857; font-size: 12px; margin-top: 3px; }

.info-card { border-color: var(--warning-border); background: var(--warning-bg); }
.tip-card { background: var(--primary-soft); border-color: var(--primary-border); margin-bottom: 0; }

/* Dialogs */
.dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 22px;
  width: min(480px, 92vw); box-shadow: 0 20px 50px rgba(15, 23, 42, .2);
}
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-title { margin: 0 0 4px; font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Check list (health) */
.check-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 320px; overflow-y: auto; border: 1px solid #f1f5f9; border-radius: 10px; }
.check-list li { display: flex; gap: 10px; padding: 9px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; }
.check-list li:last-child { border-bottom: 0; }
.ok-pass::before { content: "✔"; color: #059669; font-weight: 700; }
.ok-warn::before { content: "○"; color: #f59e0b; font-weight: 700; }
.ok-fail::before { content: "✖"; color: #ef4444; font-weight: 700; }
.check-list li::before { flex-shrink: 0; }
li.ok-pass, li.ok-warn, li.ok-fail { display: flex; }

/* Code box */
.code-box {
  background: var(--bg); border-radius: 10px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; overflow: auto; word-break: break-all; margin: 10px 0 0;
  border: 1px solid #f1f5f9;
}
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.verify-result { font-size: 13px; margin-top: 8px; }
.verify-result.ok { color: #047857; }
.verify-result.bad { color: var(--danger-text); }

/* Flash */
.flash { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; font-weight: 500; }
.flash-success { background: var(--primary-soft); border: 1px solid var(--primary-border); color: #047857; }
.flash-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); }

/* Empty state */
.empty { text-align: center; padding: 36px 16px; }
.empty p { margin: 0 0 12px; }

/* Auth pages */
.auth-body { background: var(--bg); }
.auth-card {
  width: min(430px, 92vw); margin: 8vh auto 0; background: #fff;
  border: 1px solid var(--border); border-radius: 18px; padding: 28px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .08);
}
.auth-brand { margin-bottom: 22px; }
.req-list { list-style: none; padding: 0; margin: 12px 0 0; }
.req-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.req-list li:last-child { border-bottom: 0; }
.req-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.req-ok { background: var(--primary-soft); color: #047857; border: 1px solid var(--primary-border); }
.req-fail { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

/* Responsive */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .submit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .engines-nav { display: none; }
  .hero { padding: 18px; }
}
@media (max-width: 560px) {
  .hide-md, .hide-lg { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: flex-end; }
}
