/* Signal Sentinels site-wide styles. No inline styles anywhere: the CSP is
   style-src 'self', so everything must live in this file. */

:root {
	--bg: #0b1220;
	--bg-raised: #111a2e;
	--border: #1f2a44;
	--text: #e6ebf4;
	--text-muted: #8b98b4;
	--accent: #38bdf8;
	--accent-strong: #0ea5e9;
	--danger: #f87171;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	line-height: 1.6;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 32px;
	border-bottom: 1px solid var(--border);
}

.brand {
	color: var(--text);
	text-decoration: none;
	font-weight: 700;
	font-size: 20px;
	letter-spacing: 0.02em;
}

.brand-accent { color: var(--accent); }

.nav { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--text-muted); text-decoration: none; font-size: 15px; }
.nav-link:hover { color: var(--text); }
.nav-user { color: var(--text-muted); font-size: 14px; }
.inline-form { margin: 0; }

.nav-button {
	background: none;
	border: 1px solid var(--border);
	color: var(--text);
	padding: 6px 14px;
	border-radius: 6px;
	font-size: 14px;
	cursor: pointer;
}
.nav-button:hover { border-color: var(--accent); color: var(--accent); }

.page {
	flex: 1;
	width: 100%;
	max-width: 1040px;
	margin: 0 auto;
	padding: 40px 24px 64px;
}

.hero { padding: 48px 0 24px; max-width: 720px; }

.eyebrow {
	color: var(--accent);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 13px;
	font-weight: 600;
	margin: 0 0 12px;
}

.hero h1 { font-size: 40px; line-height: 1.15; margin: 0 0 16px; }
.lead { color: var(--text-muted); font-size: 18px; margin: 0 0 24px; }

.button {
	display: inline-block;
	background: var(--accent-strong);
	color: #06121f;
	font-weight: 600;
	border: none;
	padding: 10px 20px;
	border-radius: 8px;
	text-decoration: none;
	font-size: 15px;
	cursor: pointer;
}
.button:hover { background: var(--accent); }

.section { padding: 24px 0; }
.section h2 { font-size: 22px; margin: 0 0 16px; }

/* Homepage narrative: the life of one signal, drawn as the sweep infographic
   (templates/_sweep.html). The SVG hardcodes the palette; on phones it keeps a
   readable minimum width and scrolls sideways inside its own figure. */
.signal-art { margin: 4px 0 0; max-width: 720px; overflow-x: auto; }
.signal-art svg { display: block; width: 100%; min-width: 560px; height: auto; }

/* Narrow prose sections between the bigger beats. */
.prose { max-width: 720px; }
.prose p { color: var(--text-muted); font-size: 16px; line-height: 1.7; margin: 0 0 14px; }
.prose p strong { color: var(--text); }
.prose p:last-child { margin-bottom: 0; }

.chip-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
.chip-list li {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 6px 16px;
	font-size: 14px;
	color: var(--text-muted);
}

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 16px;
}

.card {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 20px 24px;
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 18px; }
.card p { margin: 0 0 8px; color: var(--text-muted); font-size: 15px; }

.card-placeholder { border-style: dashed; }
.card p.placeholder-title { font-size: 17px; font-weight: 600; color: var(--text); }

.detail-list {
	margin: 0;
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 6px 24px;
}
.detail-list dt { color: var(--text-muted); font-size: 14px; }
.detail-list dd { margin: 0; font-size: 15px; }

.auth-card {
	max-width: 380px;
	margin: 48px auto 0;
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 32px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.auth-card label { font-size: 14px; color: var(--text-muted); }
.auth-card input {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 10px 12px;
	font-size: 15px;
}
.auth-card input:focus { outline: 2px solid var(--accent-strong); border-color: transparent; }
.auth-card .button { margin-top: 12px; }

.form-error {
	background: rgba(248, 113, 113, 0.1);
	border: 1px solid var(--danger);
	color: var(--danger);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	margin: 12px 0 0;
}

.form-notice {
	background: rgba(52, 211, 153, 0.1);
	border: 1px solid #34d399;
	color: #34d399;
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	margin: 12px 0 0;
}

.nav-button { text-decoration: none; display: inline-block; }

.muted, .card p.muted { color: var(--text-muted); font-size: 14px; }
.footnote { color: var(--text-muted); font-size: 13px; margin-top: 32px; }

.footer {
	border-top: 1px solid var(--border);
	padding: 16px 32px;
	color: var(--text-muted);
	font-size: 13px;
}
.footer p { margin: 0; }

.page-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

.stats-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 24px; }
.stat {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 14px 22px;
	display: flex;
	flex-direction: column;
	min-width: 120px;
}
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; background: var(--bg-raised); font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 13px; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.table-link { color: var(--accent); text-decoration: none; }
.table-link:hover { text-decoration: underline; }

.badge {
	display: inline-block;
	border-radius: 999px;
	padding: 2px 10px;
	font-size: 12px;
	font-weight: 600;
}
.badge-active { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.badge-paused { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.badge-running { background: rgba(56, 189, 248, 0.15); color: var(--accent); }
.badge-failed { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); border-color: var(--danger); color: var(--danger); }
.btn-small { padding: 4px 10px; font-size: 13px; }

.stacked-form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.stacked-form .card, .mini-form { display: flex; flex-direction: column; gap: 8px; }
.stacked-form label, .mini-form label { font-size: 14px; color: var(--text-muted); margin-top: 6px; }
.stacked-form input, .stacked-form select, .stacked-form textarea,
.mini-form input, .mini-form select, .mini-form textarea {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 9px 12px;
	font-size: 15px;
	font-family: inherit;
}
.stacked-form input:focus, .stacked-form select:focus, .stacked-form textarea:focus,
.mini-form input:focus, .mini-form select:focus, .mini-form textarea:focus {
	outline: 2px solid var(--accent-strong);
	border-color: transparent;
}
.stacked-form .button { align-self: flex-start; }
.mini-form { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.mini-form button { align-self: flex-start; margin-top: 8px; }

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.preset-chip {
	display: inline-block;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 5px 14px;
	font-size: 13px;
	color: var(--text-muted);
	text-decoration: none;
}
.preset-chip:hover { border-color: var(--accent); color: var(--accent); }
.preset-active { border-color: var(--accent-strong); color: var(--accent); background: rgba(56, 189, 248, 0.08); font-weight: 600; }

.mini-form select[multiple], .stacked-form select[multiple] { min-height: 120px; }
.btn-disabled { opacity: 0.45; cursor: not-allowed; }

.check-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; accent-color: var(--accent-strong); }
.check-row label { margin-top: 0; font-size: 13px; line-height: 1.5; }

.row-item {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--border);
}
.row-item:last-of-type { border-bottom: none; }
/* Long unbroken URLs must wrap inside the card instead of pushing the Remove
   button past its edge: let the text column shrink, keep the button intact. */
.row-item > div:first-child { min-width: 0; flex: 1 1 auto; }
.row-item .row-title, .row-item .muted { overflow-wrap: anywhere; }
.row-item .inline-form { flex-shrink: 0; }
.row-nested { padding-left: 18px; }

/* A column of stacked cards inside the .grid (listing card + its add-form
   card directly below it). */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* mini-form as a card's sole content (Add source / Add target boxes): no
   inherited separator from the embedded-at-bottom-of-card variant. */
.mini-form.standalone { margin-top: 0; border-top: none; padding-top: 0; }

/* Collapsible rows: target definitions and a feed's discovered pages —
   collapsed by default, expand for the details. */
details.collapse {
	border-bottom: 1px solid var(--border);
	padding: 10px 0;
}
details.collapse:last-of-type { border-bottom: none; }
details.collapse > summary {
	cursor: pointer;
	font-size: 15px;
	font-weight: 600;
	color: var(--text);
}
details.collapse > summary:hover { color: var(--accent); }
details.collapse .collapse-body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 5px;
	padding: 8px 0 2px 18px;
}
details.collapse .collapse-body p { margin: 0; }
/* Rule-group condition rows. The collapsed rows live inside .collapse-body,
   which is align-items:flex-start, so each row claims full width itself. */
.rule-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
	padding: 8px 0;
	border-top: 1px solid var(--border);
}
.rule-row:first-child { border-top: none; }
details.collapse .collapse-body .rule-row { padding-right: 4px; }

/* Sub-list variant (discovered pages under a feed source). */
details.collapse.sub { padding: 4px 0 8px; }
details.collapse.sub > summary { font-size: 13px; font-weight: 600; color: var(--accent); }

/* Bold field names inside detail lines stay readable against the muted text. */
.muted strong, .card p.muted strong { color: var(--text); font-weight: 600; }
.row-title { margin: 0; font-size: 15px; }
.row-item p { margin: 0 0 2px; }

.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-item {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 10px 16px;
}
.event-item p { margin: 0 0 3px; overflow-wrap: anywhere; }
.event-head { display: flex; align-items: center; gap: 10px; }
.event-time { color: var(--text-muted); font-size: 12px; font-family: Consolas, monospace; }
.event-pre {
	white-space: pre-wrap;
	word-break: break-word;
	font-family: Consolas, "Courier New", monospace;
	font-size: 12px;
	color: var(--text-muted);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 12px;
	margin-top: 6px;
}
.event-item details { margin-top: 6px; }
.event-item summary {
	cursor: pointer;
	color: var(--accent);
	font-size: 13px;
}
/* Full model prompts can run to tens of KB; scroll inside the box. */
.prompt-full { max-height: 420px; overflow: auto; }

/* Review queue: approve/dismiss buttons side by side under a held alert. */
.inline-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Run page: the seven-stage watch loop drawn as a rail, then one section per
   stage. Status classes: ran (normal), skipped (dimmed), proposed (dashed —
   the Enrich stage exists in the product plan but is not built). */
.stage-rail {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 18px 0 8px;
	padding: 0;
}
.stage-node {
	flex: 1 1 120px;
	min-width: 120px;
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 8px 12px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.stage-name { font-weight: 600; font-size: 13px; }
.stage-summary { color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.stage-ran { border-color: var(--accent-strong); }
.stage-skipped { opacity: 0.55; }
.stage-proposed { border-style: dashed; opacity: 0.65; }
.stage-section { margin-top: 22px; }
.stage-section-skipped, .stage-section-proposed { opacity: 0.75; }
.stage-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 17px;
	margin: 0 0 2px;
}

.alert-list { display: flex; flex-direction: column; gap: 12px; }
.alert-item {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 14px 18px;
}
.alert-item p { margin: 0 0 4px; }
.alert-title { font-size: 15px; font-weight: 600; }
.alert-meta { color: var(--text-muted); font-size: 12px; }

/* Toast popups: every alert (flash messages, form errors, AJAX outcomes)
   renders as a fixed top-right popup that fades out. */
#toasts {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 1000;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: min(420px, calc(100vw - 32px));
	pointer-events: none;
}
.toast {
	pointer-events: auto;
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-left: 4px solid var(--accent);
	border-radius: 10px;
	padding: 12px 16px;
	font-size: 14px;
	color: var(--text);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	opacity: 0;
	transform: translateX(12px);
	transition: opacity 0.3s ease, transform 0.3s ease;
	overflow-wrap: anywhere;
	cursor: pointer; /* click to dismiss */
}
.toast-show { opacity: 1; transform: translateX(0); }
.toast-hide { opacity: 0; transform: translateX(12px); }
.toast-error { border-left-color: var(--danger); color: var(--danger); background: #1d1220; }
.toast-success { border-left-color: #34d399; }

/* Busy state while an AJAX form is in flight. */
form.ss-busy button[type="submit"] { opacity: 0.55; cursor: progress; }

/* Accounts + coverage pages. */
.filter-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px;
	margin: 0 0 18px;
}
.filter-form label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 3px; }
.filter-form input,
.filter-form select {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 7px 10px;
	font-size: 14px;
}
.filter-form .filter-actions { display: flex; align-items: center; gap: 10px; }
.bulk-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 0 0 12px;
}
.bulk-bar select {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 7px 10px;
	font-size: 14px;
}
.bulk-bar .muted { font-size: 13px; }
.pager { display: flex; align-items: center; gap: 14px; margin: 14px 0 22px; }
.badge-sf { background: rgba(56, 189, 248, 0.15); color: var(--accent); }
.badge-custom { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.cell-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cell-chips .chip {
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 1px 8px;
	font-size: 12px;
	color: var(--text-muted);
	white-space: nowrap;
}

/* CSP-safe percentage meter: an SVG whose fill width is a presentation
   attribute (templates/_meter.html); colors live here. */
.meter {
	display: block;
	width: 100%;
	height: 10px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 999px;
	overflow: hidden;
}
.meter-wide { height: 14px; }
.meter-fill { fill: var(--accent-strong); }
.table td .meter { min-width: 120px; }

@media (max-width: 640px) {
	.hero h1 { font-size: 30px; }
	.topbar { padding: 12px 16px; }
	.page { padding: 24px 16px 48px; }
	#toasts { top: 8px; right: 8px; left: 8px; max-width: none; }
}
