*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	margin: 0;
	padding: 0;
	background: #f5f5f5;
	color: #333;
	line-height: 1.5;
}

.controls {
	display: flex;
	gap: 20px;
	flex-wrap: wrap;
	background: white;
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 20px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.control-group label {
	font-weight: 500;
	color: #374151;
	font-size: 14px;
}

select,
button,
input[type='date'] {
	padding: 8px 16px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
}

select,
input[type='date'] {
	min-width: 160px;
	background: white;
}

button {
	background: #007cba;
	color: white;
	cursor: pointer;
	border: none;
	font-weight: 500;
}

button:hover {
	background: #005a87;
}

button:disabled {
	background: #ccc;
	cursor: not-allowed;
}

.error {
	background: #f8d7da;
	color: #721c24;
	padding: 12px 16px;
	border-radius: 4px;
	margin-bottom: 20px;
	border: 1px solid #f5c6cb;
}

.loading {
	text-align: center;
	padding: 40px;
	color: #666;
	background: white;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-message {
	text-align: center;
}

.loading-message p {
	margin: 8px 0;
}

.loading-message .loading-hint {
	font-size: 13px;
	color: #888;
	font-style: italic;
}

.report-header {
	background: white;
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 16px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.report-header h2 {
	margin: 0 0 4px 0;
}

.report-domain {
	font-weight: 400;
	color: #6c757d;
}

.report-header p {
	margin: 0;
	color: #666;
	font-size: 14px;
}

.resource-data {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-shrink: 0;
	font-size: 13px;
	color: #6c757d;
}

.resource-stat-value {
	font-weight: 600;
	color: #333;
}

.resource-divider {
	width: 1px;
	height: 14px;
	background: #ddd;
}

/* Waterfall chart */
.waterfall-chart {
	background: white;
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 16px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.waterfall-title {
	margin: 0 0 16px 0;
	font-size: 15px;
	color: #333;
}

.waterfall-subtitle {
	font-weight: 400;
	font-size: 13px;
	color: #999;
}

.waterfall-rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.waterfall-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.waterfall-row--child {
	padding-left: 24px;
}

.waterfall-label {
	width: 130px;
	flex-shrink: 0;
	font-size: 13px;
	font-weight: 600;
	color: #333;
	text-align: right;
}

.waterfall-bar-container {
	flex: 1;
	min-width: 0;
}

.waterfall-bar-track {
	display: flex;
	height: 28px;
	border-radius: 4px;
	overflow: hidden;
	background: #f0f0f0;
}

.waterfall-segment {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 600;
	color: white;
	white-space: nowrap;
	overflow: hidden;
	min-width: 2px;
	transition: opacity 0.15s;
}

.waterfall-segment:hover {
	opacity: 0.85;
}

.waterfall-value {
	width: 70px;
	flex-shrink: 0;
	font-size: 14px;
	font-weight: 600;
	color: #212529;
	text-align: right;
}


/* Performance breakdown */
.metric-groups {
	margin-bottom: 16px;
}

.perf-breakdown {
	background: white;
	border-radius: 8px;
	padding: 24px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.perf-breakdown-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.perf-breakdown-title {
	margin: 0;
	font-size: 16px;
	color: #333;
}

.perf-toggles {
	display: flex;
	gap: 4px;
}

.perf-toggle {
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	border: 2px solid #007cba;
	border-radius: 20px;
	background: white;
	color: #007cba;
	cursor: pointer;
	min-width: auto;
}

.perf-toggle:hover {
	background: #f0f7fc;
}

.perf-toggle.active {
	background: #007cba;
	color: white;
}

.perf-toggle.active:hover {
	background: #005a87;
	border-color: #005a87;
}

.perf-section {
	margin-bottom: 20px;
}

.perf-section-label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: #6c757d;
	text-transform: uppercase;
	margin-bottom: 8px;
}

.perf-stacked-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}

.perf-stacked-bar {
	flex: 1;
	display: flex;
	height: 28px;
	border-radius: 4px;
	overflow: hidden;
	background: #f0f0f0;
}

.perf-stacked-value {
	min-width: 80px;
	flex-shrink: 0;
	font-size: 15px;
	font-weight: 600;
	color: #212529;
	text-align: right;
	white-space: nowrap;
}

.perf-metric-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 6px 0;
}

.perf-metric-name {
	width: 200px;
	flex-shrink: 0;
	font-size: 13px;
	font-weight: 500;
	color: #333;
	display: flex;
	align-items: center;
	gap: 4px;
}

.perf-metric-count {
	font-weight: 400;
	font-size: 11px;
	color: #adb5bd;
}

.perf-metric-bar {
	flex: 1;
	min-width: 0;
}

.perf-metric-bar-track {
	height: 7px;
	background: #f0f0f0;
	border-radius: 4px;
	position: relative;
	overflow: visible;
}

.perf-metric-bar-fill {
	height: 100%;
	border-radius: 4px;
	transition: width 0.2s ease;
	overflow: hidden;
}

.perf-metric-value {
	min-width: 80px;
	flex-shrink: 0;
	font-size: 14px;
	font-weight: 600;
	color: #212529;
	text-align: right;
	white-space: nowrap;
}

.metric-info-btn {
	flex-shrink: 0;
	background: none;
	border: none;
	padding: 2px;
	color: #adb5bd;
	cursor: pointer;
	min-width: auto;
	line-height: 1;
}

.metric-info-btn:hover {
	color: #007cba;
	background: none;
}

.metric-unit {
	font-size: 12px;
	font-weight: 400;
	color: #999;
	margin-left: 1px;
}


.metric-popover {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
}

.metric-popover-content {
	background: white;
	border-radius: 8px;
	padding: 24px;
	max-width: 440px;
	width: 90%;
	position: relative;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.metric-popover-content h4 {
	margin: 0 0 12px 0;
	font-size: 16px;
	color: #333;
	padding-right: 24px;
}

.metric-popover-content p {
	margin: 0;
	color: #555;
	font-size: 14px;
	line-height: 1.6;
}

.metric-popover-close {
	position: absolute;
	top: 12px;
	right: 12px;
	background: none;
	border: none;
	font-size: 20px;
	color: #999;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	min-width: auto;
}

.metric-popover-close:hover {
	color: #333;
	background: none;
}

/* Comparison controls */
.compare-toggle-group {
	width: 100%;
	padding-top: 4px;
}

.compare-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 500;
	color: #495057;
	cursor: pointer;
}

.compare-label input[type='checkbox'] {
	margin: 0;
}

.compare-controls {
	width: 100%;
	padding: 14px 16px;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	margin-top: 8px;
	background: #f8fafc;
}

.compare-controls-label {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #6c757d;
	margin-bottom: 10px;
}

.compare-controls-row {
	display: flex;
	gap: 20px;
	flex-wrap: wrap;
}

/* Comparison delta indicators */
.perf-delta {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	margin-left: 6px;
	padding: 1px 5px;
	border-radius: 3px;
}

.perf-delta--good {
	color: #155724;
	background: #d4edda;
}

.perf-delta--bad {
	color: #721c24;
	background: #f8d7da;
}

.perf-delta--neutral {
	color: #495057;
	background: #e9ecef;
}

.perf-compare-badge {
	font-size: 11px;
	font-weight: 600;
	color: #007cba;
	background: #e7f1ff;
	padding: 2px 8px;
	border-radius: 10px;
	margin-left: 8px;
	vertical-align: middle;
}

.perf-compare-legend {
	font-size: 13px;
	color: #6c757d;
	margin-bottom: 16px;
}

.perf-compare-legend-current {
	font-weight: 600;
	color: #333;
}

.perf-compare-legend-previous {
	font-weight: 500;
	color: #007cba;
}

/* Comparison marker on metric bar */
.perf-metric-bar-compare {
	position: absolute;
	top: -2px;
	width: 2px;
	height: calc(100% + 4px);
	background: #007cba;
	border-radius: 1px;
	pointer-events: none;
}

.perf-metric-bar-compare::after {
	content: '';
	position: absolute;
	top: -3px;
	left: -2px;
	width: 6px;
	height: 6px;
	background: #007cba;
	border-radius: 50%;
}

.trends-section {
	background: white;
	border-radius: 8px;
	padding: 20px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.trends-section h2 {
	margin: 0 0 20px 0;
}

.trends-controls {
	display: flex;
	gap: 20px;
	flex-wrap: wrap;
	margin-bottom: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid #e9ecef;
}

.chart-controls-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.chart-toggles {
	display: flex;
	gap: 8px;
}

.chart-legend {
	display: flex;
	gap: 16px;
	align-items: center;
	font-size: 13px;
	color: #495057;
}

.chart-legend-item {
	display: flex;
	align-items: center;
	gap: 6px;
}

.chart-legend-line {
	display: inline-block;
	width: 24px;
	height: 0;
	border-top: 2.5px solid #495057;
}

.chart-legend-line--dashed {
	border-top-style: dashed;
}

.chart-toggle {
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 600;
	border: 2px solid var(--toggle-color);
	border-radius: 4px;
	background: var(--toggle-color);
	color: white;
	cursor: pointer;
	min-width: auto;
}

.chart-toggle:hover {
	opacity: 0.85;
}

.chart-toggle:not(.active) {
	background: white;
	color: var(--toggle-color);
}

.chart-container {
	height: 400px;
	position: relative;
}

@media (max-width: 768px) {
	body {
		padding: 10px;
	}

	.controls {
		flex-direction: column;
	}

	.control-group {
		width: 100%;
	}

	select {
		min-width: auto;
		width: 100%;
	}

	button {
		width: 100%;
	}

	.report-header-top {
		flex-direction: column;
	}

	.resource-data {
		flex-wrap: wrap;
	}

	.perf-breakdown-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 12px;
	}

	.perf-metric-name {
		width: 140px;
		font-size: 12px;
	}

	.perf-metric-row {
		gap: 8px;
	}

	.perf-stacked-value,
	.perf-metric-value {
		min-width: 50px;
		font-size: 13px;
	}

	.trends-controls {
		flex-direction: column;
	}

	.compare-controls-row {
		flex-direction: column;
	}

	.chart-controls-row {
		flex-direction: column;
		align-items: flex-start;
	}

	.chart-legend {
		flex-wrap: wrap;
	}
}


/* ===== Link Monitor ===== */

.links-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 12px;
	margin-bottom: 20px;
}

.stat-card {
	background: white;
	border-radius: 8px;
	padding: 16px;
	text-align: center;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	cursor: pointer;
	border-left: 4px solid #e9ecef;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.stat-card--total { border-left-color: #007cba; }
.stat-card--working { border-left-color: #28a745; }
.stat-card--broken { border-left-color: #dc3545; }
.stat-card--redirected { border-left-color: #fd7e14; }
.stat-card--unreachable { border-left-color: #6c757d; }
.stat-card--pending { border-left-color: #adb5bd; }

.stat-value {
	font-size: 28px;
	font-weight: 700;
	color: #212529;
	line-height: 1.2;
}

.stat-label {
	font-size: 12px;
	color: #6c757d;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-top: 4px;
}

.links-search-input {
	padding: 8px 16px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
	min-width: 200px;
	background: white;
}

.links-table {
	width: 100%;
	background: white;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	border-collapse: collapse;
	font-size: 14px;
}

.links-table thead {
	background: #f8f9fa;
}

.links-table th {
	padding: 10px 12px;
	text-align: left;
	font-weight: 600;
	color: #495057;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	border-bottom: 2px solid #e9ecef;
}

.links-table td {
	padding: 10px 12px;
	border-bottom: 1px solid #f0f0f0;
	vertical-align: middle;
}

.links-row {
	cursor: pointer;
	transition: background 0.1s;
}

.links-row:hover {
	background: #f8f9fa;
}

.links-th-status { width: 80px; }
.links-th-code { width: 60px; }
.links-th-time { width: 70px; }
.links-th-scanned { width: 100px; }

.links-url {
	display: block;
	font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
	font-size: 13px;
	color: #212529;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 500px;
}

.links-page-title {
	display: block;
	font-size: 12px;
	color: #6c757d;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 500px;
	margin-top: 2px;
}

.links-redirect-dest {
	display: block;
	font-size: 12px;
	color: #0d6efd;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 500px;
	margin-top: 2px;
}

.detail-redirect-chain {
	margin-top: 12px;
}

.detail-redirect-chain h4 {
	font-size: 13px;
	margin: 0 0 6px;
	color: #495057;
}

.redirect-chain-list {
	margin: 0;
	padding-left: 20px;
	font-size: 13px;
}

.redirect-chain-list li {
	margin-bottom: 4px;
}

.redirect-code {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	color: #0d6efd;
	background: #e7f1ff;
	padding: 1px 5px;
	border-radius: 3px;
}

.links-td-code,
.links-td-time,
.links-td-scanned {
	color: #495057;
	font-size: 13px;
	white-space: nowrap;
}

/* Status badges */
.status-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.status-badge--working { background: #d4edda; color: #155724; }
.status-badge--broken { background: #f8d7da; color: #721c24; }
.status-badge--redirected { background: #fff3cd; color: #856404; }
.status-badge--unreachable { background: #e2e3e5; color: #383d41; }
.status-badge--pending { background: #f0f0f0; color: #6c757d; }
.status-badge--unknown { background: #f0f0f0; color: #6c757d; }

/* Pagination */
.links-pagination {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 0;
}

.pagination-info {
	font-size: 13px;
	color: #6c757d;
}

.pagination-nav {
	display: flex;
	gap: 8px;
}

.pagination-nav button {
	padding: 6px 14px;
	font-size: 13px;
}

/* Detail panel (slide-over) */
.link-detail-panel {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.3);
	display: flex;
	justify-content: flex-end;
	z-index: 1000;
}

.link-detail-content {
	background: white;
	width: 520px;
	max-width: 90vw;
	height: 100vh;
	overflow-y: auto;
	padding: 24px;
	position: relative;
	box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.link-detail-close {
	position: absolute;
	top: 16px;
	right: 16px;
	background: none;
	border: none;
	font-size: 24px;
	color: #999;
	cursor: pointer;
	min-width: auto;
	padding: 0;
}

.link-detail-close:hover {
	color: #333;
	background: none;
}

.link-detail-content h3 {
	font-size: 15px;
	word-break: break-all;
	margin: 0 0 16px;
	padding-right: 32px;
	font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

.link-detail-content h4 {
	font-size: 14px;
	color: #495057;
	margin: 20px 0 8px;
	padding-top: 16px;
	border-top: 1px solid #e9ecef;
}

.detail-meta-item {
	font-size: 13px;
	margin-bottom: 4px;
	color: #495057;
}

.detail-meta-label {
	font-weight: 600;
	color: #333;
}

.detail-scan-table {
	width: 100%;
	font-size: 12px;
	border-collapse: collapse;
}

.detail-scan-table th {
	text-align: left;
	padding: 6px 8px;
	background: #f8f9fa;
	font-weight: 600;
	border-bottom: 1px solid #e9ecef;
}

.detail-scan-table td {
	padding: 6px 8px;
	border-bottom: 1px solid #f0f0f0;
}

.detail-empty {
	color: #6c757d;
	font-style: italic;
	font-size: 13px;
}

.detail-site {
	font-size: 13px;
	padding: 6px 0;
	border-bottom: 1px solid #f0f0f0;
}

.detail-site-post {
	color: #6c757d;
	font-size: 12px;
}

.detail-site-freq {
	color: #adb5bd;
	font-size: 11px;
	text-transform: uppercase;
}

/* Stale Content */

.stat-card--stale {
	border-left-color: #dc3545;
	cursor: pointer;
}

.stat-card--fresh {
	border-left-color: #198754;
	cursor: pointer;
}

.sc-row--stale {
	background: #fff5f5;
}

.sc-meta {
	display: block;
	font-size: 12px;
	color: #6c757d;
	margin-top: 2px;
}

.sc-td-title a {
	color: inherit;
	text-decoration: none;
}

.sc-td-title a:hover {
	text-decoration: underline;
}

.sc-review-btn {
	font-size: 12px;
	padding: 3px 8px;
	background: #0d6efd;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

.sc-review-btn:hover {
	background: #0b5ed7;
}

.sc-review-btn:disabled {
	background: #6c757d;
	cursor: default;
}

.sc-rules-section {
	margin-top: 32px;
	padding-top: 24px;
	border-top: 1px solid #dee2e6;
}

.sc-rules-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.sc-rules-header h3 {
	margin: 0;
	font-size: 16px;
}

.sc-add-rule-btn {
	font-size: 13px;
	padding: 6px 12px;
	background: #198754;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

.sc-add-rule-btn:hover {
	background: #157347;
}

.sc-rule-form {
	display: flex;
	gap: 12px;
	align-items: flex-end;
	margin-bottom: 16px;
	padding: 12px;
	background: #f8f9fa;
	border-radius: 6px;
}

.sc-rules-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.sc-rules-table th,
.sc-rules-table td {
	padding: 8px 12px;
	text-align: left;
	border-bottom: 1px solid #dee2e6;
}

.sc-rules-table th {
	font-weight: 600;
	color: #495057;
	font-size: 12px;
	text-transform: uppercase;
}

.sc-rules-empty {
	color: #6c757d;
	font-style: italic;
}

.sc-delete-rule-btn {
	font-size: 12px;
	padding: 2px 8px;
	background: none;
	color: #dc3545;
	border: 1px solid #dc3545;
	border-radius: 4px;
	cursor: pointer;
}

.sc-delete-rule-btn:hover {
	background: #dc3545;
	color: #fff;
}
