:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2236;
    --bg-card-hover: #1f2a40;
    --border: #2d3a52;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ─── Header ──────────────────────────────────── */
.header {
    text-align: center;
    padding: 3rem 1rem 2rem;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header .tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.search-container .description {
    max-width: 680px;
    margin: 1.5rem auto 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.65;
    text-align: center;
}

/* ─── Search Box ──────────────────────────────── */
.search-container {
    max-width: 700px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.search-box {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.search-box button:hover {
    background: #2563eb;
}

.search-box button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* ─── Proxy Panel ────────────────────────────── */

.proxy-toggle {
    display: block;
    margin: 0.75rem auto 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.2s;
}

.proxy-toggle:hover,
.proxy-toggle.open {
    color: var(--accent);
}

.proxy-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin 0.3s ease;
    margin-top: 0;
}

.proxy-panel.open {
    max-height: 200px;
    margin-top: 0.75rem;
}

.proxy-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.proxy-panel input,
.proxy-panel select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.proxy-panel input:focus,
.proxy-panel select:focus {
    border-color: var(--accent);
}

.proxy-row input {
    flex: 1;
}

.proxy-row select {
    width: 110px;
}

.proxy-panel > input {
    width: 100%;
}

.proxy-panel input::placeholder {
    color: var(--text-muted);
}

/* ─── Block Banner ───────────────────────────── */
.block-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--danger);
}

.block-banner strong {
    font-size: 1.05rem;
    display: block;
    margin-bottom: 0.4rem;
}

.block-banner p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* ─── Loading ─────────────────────────────────── */
.loading {
    display: none;
    text-align: center;
    padding: 3rem 1rem;
}

.loading.active {
    display: block;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 1rem;
    min-height: 1.4em;
}

.progress-container {
    max-width: 420px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-outer {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ─── Error ───────────────────────────────────── */
.error-msg {
    display: none;
    max-width: 700px;
    margin: 0 auto 2rem;
    padding: 1rem 1.25rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    color: var(--danger);
    text-align: center;
}

.error-msg.active {
    display: block;
}

/* ─── Results Container ───────────────────────── */
.results {
    display: none;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

.results.active {
    display: block;
}

/* ─── Summary Bar ─────────────────────────────── */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}

.summary-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.summary-item .value {
    font-size: 1.6rem;
    font-weight: 700;
}

.summary-item .value.grade-a { color: var(--success); }
.summary-item .value.grade-b { color: #84cc16; }
.summary-item .value.grade-c { color: var(--warning); }
.summary-item .value.grade-f { color: var(--danger); }

/* ─── Section Cards ───────────────────────────── */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.section-header:hover {
    background: var(--bg-card-hover);
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-header .icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1rem;
}

.section-header .toggle {
    color: var(--text-muted);
    transition: transform 0.3s;
    font-size: 1.2rem;
}

.section.open .section-header .toggle {
    transform: rotate(180deg);
}

.section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.section.open .section-body {
    max-height: 2000px;
}

.section-content {
    padding: 0 1.5rem 1.5rem;
}

/* ─── Data Table ──────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

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

/* ─── Badges ──────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-info {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

/* ─── Tag List ────────────────────────────────── */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ─── Key-Value Rows ──────────────────────────── */
.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(45, 58, 82, 0.5);
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-row .key {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.kv-row .val {
    font-weight: 500;
    font-size: 0.9rem;
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

/* ─── Progress Bar ────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.75rem 0;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* ─── Inline Alerts ──────────────────────────── */
.inline-alert {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.inline-alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.inline-alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.inline-alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--info);
}

/* ─── Subsection Labels ─────────────────────── */
.subsection-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* ─── Redirect Chain ─────────────────────────── */
.redirect-chain {
    padding: 0.5rem 0;
}

.chain-hop {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: 0.25rem 0;
}

.chain-arrow {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.1rem 0;
}

/* ─── Crawlability Score Bar ──────────────────── */
.crawl-score-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.crawl-grade {
    font-size: 1.8rem;
    font-weight: 800;
    min-width: 120px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.crawl-meter {
    flex: 1;
}

.crawl-meter-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.crawl-hurdle-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
}

.crawl-stack {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .crawl-score-bar {
        flex-direction: column;
        text-align: center;
    }
    .crawl-hurdle-count { text-align: center; }
}

/* ─── Recommendation Cards ───────────────────── */
.rec-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.rec-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rec-card {
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--border);
    background: var(--bg-secondary);
}

.rec-critical { border-left-color: var(--danger); }
.rec-high { border-left-color: var(--warning); }
.rec-medium { border-left-color: var(--info); }
.rec-low { border-left-color: var(--text-muted); }

.rec-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.rec-cat {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rec-title {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.rec-detail {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    line-height: 1.5;
}

.rec-fix {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.rec-fix-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--info);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.rec-fix-code {
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    margin: 0;
}

/* ─── Issue Cards (inline per-section) ───────── */
.issue-card {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--border);
}

.issue-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.issue-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.issue-fix {
    font-size: 0.83rem;
    color: var(--text-secondary);
    padding-top: 0.4rem;
    line-height: 1.5;
    word-break: break-word;
}

.issue-fix-label {
    color: var(--info);
    font-weight: 600;
}

/* ─── Code Block ─────────────────────────────── */
.code-block {
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 0.82rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0.5rem 0;
}

/* ─── Summary Critical Pulse ─────────────────── */
.summary-critical {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

/* ─── Empty State ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ─── Footer ──────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    max-width: 1100px;
    margin: 0 auto;
}

/* ─── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
    .header h1 { font-size: 1.8rem; }
    .search-box { flex-direction: column; }
    .search-box button { padding: 0.85rem; }
    .summary-bar { grid-template-columns: repeat(2, 1fr); }
    .kv-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .kv-row .val { text-align: left; max-width: 100%; }
}
