:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222633;
    --bg-input: #141620;
    --border: #2a2e3d;
    --text: #e4e6f0;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #7c6ef7;
    --green: #00b894;
    --yellow: #fdcb6e;
    --red: #e17055;
    --orange: #f0932b;
    --blue: #0984e3;
    --purple: #a29bfe;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

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

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #1a1d27 0%, #2d1f5e 50%, #1a1d27 100%);
    padding: 48px 24px 36px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo span {
    color: var(--accent);
}

.tagline {
    color: var(--text-dim);
    margin-top: 8px;
    font-size: 1.05rem;
}

.main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

.search-box {
    margin-bottom: 32px;
}

.search-form {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.search-form input {
    flex: 1;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-form input:focus {
    border-color: var(--accent);
}

.search-form button {
    padding: 16px 32px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.search-form button:hover {
    background: var(--accent-hover);
}

.search-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 60px 0;
}

.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 16px;
}

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

.error-box {
    background: rgba(225,112,85,0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 16px 20px;
    border-radius: var(--radius);
    max-width: 800px;
    margin: 0 auto;
}

.hidden {
    display: none !important;
}

.score-overview {
    display: flex;
    gap: 24px;
    align-items: stretch;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.main-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    padding: 24px;
}

.score-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    flex: 1;
    gap: 16px;
}

.score-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, border-color 0.2s;
}

.score-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.score-value {
    font-size: 2rem;
    font-weight: 800;
}

.score-label {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 4px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--accent);
    font-weight: 600;
}

.card-grid-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.card-grid-item .label {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.card-grid-item .value {
    font-size: 1.4rem;
    font-weight: 700;
}

.card-grid-item .value.green { color: var(--green); }
.card-grid-item .value.yellow { color: var(--yellow); }
.card-grid-item .value.red { color: var(--red); }
.card-grid-item .value.blue { color: var(--blue); }
.card-grid-item .value.orange { color: var(--orange); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td {
    background: rgba(108,92,231,0.05);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-good { background: rgba(0,184,148,0.15); color: var(--green); }
.badge-warn { background: rgba(253,203,110,0.15); color: var(--yellow); }
.badge-bad { background: rgba(225,112,85,0.15); color: var(--red); }
.badge-info { background: rgba(9,132,227,0.15); color: var(--blue); }

.meta-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.meta-item:last-child {
    border-bottom: none;
}

.meta-key {
    color: var(--text-dim);
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    min-width: 160px;
    flex-shrink: 0;
}

.meta-val {
    word-break: break-all;
    font-size: 0.9rem;
}

.heading-tree {
    padding-left: 0;
    list-style: none;
}

.heading-tree li {
    padding: 6px 0;
}

.heading-tree .h2 { padding-left: 24px; }
.heading-tree .h3 { padding-left: 48px; }
.heading-tree .h4 { padding-left: 72px; }
.heading-tree .h5 { padding-left: 96px; }
.heading-tree .h6 { padding-left: 120px; }

.heading-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: monospace;
    margin-right: 8px;
}

.h1 .heading-tag { background: rgba(108,92,231,0.2); color: var(--accent); }
.h2 .heading-tag { background: rgba(9,132,227,0.2); color: var(--blue); }
.h3 .heading-tag { background: rgba(0,184,148,0.2); color: var(--green); }
.h4 .heading-tag { background: rgba(253,203,110,0.2); color: var(--yellow); }
.h5 .heading-tag { background: rgba(240,147,43,0.2); color: var(--orange); }
.h6 .heading-tag { background: rgba(162,155,254,0.2); color: var(--purple); }

.issue-list {
    list-style: none;
    padding: 0;
}

.issue-list li {
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.issue-list li::before {
    flex-shrink: 0;
    font-size: 1rem;
}

.issue-list .issue-error {
    background: rgba(225,112,85,0.08);
    border: 1px solid rgba(225,112,85,0.2);
    color: #f0a898;
}

.issue-list .issue-warn {
    background: rgba(253,203,110,0.08);
    border: 1px solid rgba(253,203,110,0.2);
    color: #fde3a7;
}

.issue-list .issue-ok {
    background: rgba(0,184,148,0.08);
    border: 1px solid rgba(0,184,148,0.2);
    color: #7dcea0;
}

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .score-overview {
        flex-direction: column;
        align-items: center;
    }
    .score-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .search-form {
        flex-direction: column;
    }
    .tabs {
        flex-wrap: nowrap;
    }
}

.main-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.nav-btn {
    padding: 12px 24px;
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-btn:hover { color: var(--text); background: var(--bg-card-hover); }
.nav-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.view { }
.view.hidden { display: none !important; }

.saved-banner {
    background: rgba(0,184,148,0.1);
    border: 1px solid var(--green);
    color: var(--green);
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.history-header h2 {
    font-size: 1.4rem;
}

.history-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.stat-pill strong {
    color: var(--text);
}

.history-search {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 500px;
}

.search-input-sm {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

.search-input-sm:focus { border-color: var(--accent); }

.btn-sm {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-sm:hover { background: var(--accent-hover); }

.history-list {
    margin-bottom: 24px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 10px;
    border-bottom: 2px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.history-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.history-table tr:hover td {
    background: rgba(108,92,231,0.05);
}

.url-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}

.date-cell {
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.score-inline {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
    min-width: 32px;
    text-align: center;
}

.score-inline.green { background: rgba(0,184,148,0.15); color: var(--green); }
.score-inline.yellow { background: rgba(253,203,110,0.15); color: var(--yellow); }
.score-inline.red { background: rgba(225,112,85,0.15); color: var(--red); }

.btn-action {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.2s;
    margin-right: 4px;
}

.btn-view:hover { border-color: var(--accent); color: var(--accent); }
.btn-delete:hover { border-color: var(--red); color: var(--red); }

.history-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.btn-pager {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-pager:hover { border-color: var(--accent); background: var(--bg-card-hover); }

.pager-info {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.btn-back {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.btn-back:hover { border-color: var(--accent); background: var(--bg-card-hover); }

.detail-header {
    margin-bottom: 24px;
}

.detail-header h2 {
    font-size: 1.3rem;
    word-break: break-all;
}

.detail-meta {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 4px;
}

.loading-inline {
    text-align: center;
    padding: 40px 0;
}

.spinner.small {
    width: 32px;
    height: 32px;
    border-width: 3px;
    margin-bottom: 8px;
}

.rec-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.rec-summary-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: center;
    flex: 1;
    min-width: 100px;
}

.rec-summary-count {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.rec-summary-count.critical { color: var(--red); }
.rec-summary-count.high { color: var(--orange); }
.rec-summary-count.medium { color: var(--yellow); }
.rec-summary-count.low { color: var(--blue); }

.rec-summary-item.potential { border-color: var(--green); }
.rec-summary-item.potential .rec-summary-count { color: var(--green); }

.rec-group { margin-bottom: 20px; }

.rec-group-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.rec-group-title.rec-critical { color: var(--red); }
.rec-group-title.rec-high { color: var(--orange); }
.rec-group-title.rec-medium { color: var(--yellow); }
.rec-group-title.rec-low { color: var(--blue); }

.rec-item {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.rec-item.rec-critical { border-left: 3px solid var(--red); }
.rec-item.rec-high { border-left: 3px solid var(--orange); }
.rec-item.rec-medium { border-left: 3px solid var(--yellow); }
.rec-item.rec-low { border-left: 3px solid var(--blue); }

.rec-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.rec-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.rec-impact {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.impact-bar {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.impact-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

.rec-desc {
    color: var(--text-dim);
    font-size: 0.88rem;
    line-height: 1.5;
}

.rec-empty {
    text-align: center;
    color: var(--green);
    font-size: 1.1rem;
    padding: 40px 0;
}

.analytics-tags, .tech-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.analytics-tag, .tech-tag {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
}

.analytics-tag {
    background: rgba(0,184,148,0.1);
    border-color: rgba(0,184,148,0.3);
    color: var(--green);
}

.tech-tag {
    background: rgba(108,92,231,0.1);
    border-color: rgba(108,92,231,0.3);
    color: var(--accent);
}

.compare-toggle {
    text-align: center;
    margin-top: 8px;
}

.compare-form {
    max-width: 800px;
    margin: 12px auto 0 !important;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.compare-results {
    margin-bottom: 32px;
}

.btn-accent {
    background: var(--green) !important;
}

.btn-accent:hover {
    background: #00a381 !important;
}

.banner-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.history-chart-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.serp-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    max-width: 650px;
    font-family: Arial, sans-serif;
}

.serp-url {
    color: #202124;
    font-size: 0.82rem;
    margin-bottom: 2px;
}

.serp-title {
    color: #1a0dab;
    font-size: 1.15rem;
    font-weight: 400;
    margin-bottom: 4px;
    line-height: 1.3;
}

.serp-title-long { color: #c5221f; }
.serp-title-short { color: #f0932b; }

.serp-desc {
    color: #4d5156;
    font-size: 0.88rem;
    line-height: 1.4;
}

.serp-desc-long { color: #c5221f; }
.serp-desc-short { color: #f0932b; }

.serp-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .serp-metrics { grid-template-columns: 1fr; }
    .banner-actions { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .main-nav { flex-direction: column; }
    .nav-btn { border-radius: 8px; }
    .history-table { font-size: 0.75rem; }
    .history-table th, .history-table td { padding: 6px 4px; }
    .btn-action { font-size: 0.7rem; padding: 3px 6px; }
    .rec-summary { flex-direction: column; }
    .rec-header { flex-direction: column; align-items: flex-start; }
    .rec-impact { margin-left: 0; }
}
