/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }

.btn-warning { color: #fbbf24; border-color: #fbbf24; }
.btn-warning:hover { background: rgba(251,191,36,0.1); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { padding: var(--space-xs) var(--space-sm); font-size: var(--font-size-xs); }

/* ── Cards ── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.card-clickable {
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.card-clickable:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.card-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ── Stats grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-top: var(--space-xs);
}

/* ── Data tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table .clickable { cursor: pointer; }
.data-table .clickable:hover td:first-child { color: var(--accent); }

.data-table .cell-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
}

.cell-url {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
}

.cell-mono { font-family: var(--font-mono); font-size: var(--font-size-xs); }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-ok { background: rgba(34,197,94,0.15); color: var(--status-ok); }
.badge-error { background: rgba(239,68,68,0.15); color: var(--status-error); }
.badge-broken { background: rgba(185,28,28,0.2); color: #fca5a5; font-weight: 600; }
.badge-pending { background: rgba(148,163,184,0.15); color: var(--status-pending); }
.badge-unchanged { background: rgba(59,130,246,0.15); color: var(--status-unchanged); }

.badge-web { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-rss { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-api { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-document { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-question { background: rgba(236,72,153,0.15); color: #f472b6; }

/* ── Forms ── */
.form-group { margin-bottom: var(--space-lg); }

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea { min-height: 80px; resize: vertical; }

.form-select { cursor: pointer; }

.form-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    appearance: none;
    background: var(--border-light);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.form-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.form-toggle:checked { background: var(--accent); }
.form-toggle:checked::after { transform: translateX(16px); }

.form-checkbox-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
}

/* ── Search bar ── */
.search-bar {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.search-bar .form-input { flex: 1; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: var(--space-md);
}

.empty-state-text {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-lg);
}

/* ── Extraction preview (collapsible) ── */
.extraction-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Detail header ── */
.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.detail-header-info { flex: 1; }

.detail-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.detail-section {
    margin-bottom: var(--space-xl);
}

.detail-section-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: var(--font-size-lg); font-weight: 600; }

.modal-body { padding: var(--space-lg); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
}

/* ── Toast ── */
#toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
    z-index: 300;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toast-in 0.2s ease;
    border-left: 3px solid var(--text-muted);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Loading spinner ── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: var(--space-sm);
}

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

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ── Space cards grid ── */
.space-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

/* ── Relative time ── */
.time-relative { color: var(--text-muted); font-size: var(--font-size-xs); }

/* ── Section tabs ── */
.section-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.section-tab {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.section-tab:hover { color: var(--text-primary); }
.section-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
