/*
 * Watchdog — vizuální styl.
 *
 * Východisko: tohle je přístroj na čísla, ne marketingová stránka. Ceny proto
 * dostávají výrazné monospace písmo s tabulkovými číslicemi (sloupce jdou číst
 * shora dolů), zatímco rozhraní kolem nich zůstává tiché.
 *
 * Nosný prvek je „práh" (.rail) v přehledu: vodorovná osa, na které je vidět
 * rozpětí dosud viděných cen, kde je cena teď a kde je cíl.
 */

:root {
	--paper: #eff1f4;
	--surface: #ffffff;
	--surface-sunken: #f6f7f9;
	--ink: #14161c;
	--ink-soft: #5c6472;
	--ink-faint: #8b93a1;
	--line: #dde1e7;
	--accent: #4b45c6;
	--accent-soft: #ecebfb;
	--good: #0d7355;
	--good-soft: #e2f2ec;
	--bad: #a8452a;
	--bad-soft: #f8eae5;
	--track: #e2e6ec;

	--font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	--font-num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	--radius: 10px;
	--gap: 20px;
	--shadow: 0 1px 2px rgb(20 22 28 / 6%), 0 4px 16px rgb(20 22 28 / 4%);
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #0e1014;
		--surface: #181b21;
		--surface-sunken: #14171c;
		--ink: #e7eaef;
		--ink-soft: #98a0ae;
		--ink-faint: #6d7583;
		--line: #292e37;
		--accent: #8d88f2;
		--accent-soft: #23233c;
		--good: #38bd90;
		--good-soft: #16302a;
		--bad: #e07a5c;
		--bad-soft: #33211c;
		--track: #242932;
		--shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 24%);
	}
}

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

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-ui);
	font-size: 15px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
	margin: 0;
	line-height: 1.2;
	letter-spacing: -0.015em;
}

h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 620; }

p { margin: 0; }

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover { text-decoration: underline; }

code {
	font-family: var(--font-num);
	font-size: 0.88em;
	background: var(--surface-sunken);
	padding: 1px 5px;
	border-radius: 4px;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 4px;
}


/* ---------- Kostra ---------- */

.topbar {
	display: flex;
	align-items: center;
	gap: var(--gap);
	padding: 14px 24px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 10;
}

.brand {
	font-weight: 660;
	font-size: 1.02rem;
	color: var(--ink);
	letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

.topbar-nav {
	display: flex;
	gap: 4px;
	margin-inline-start: 8px;
}

.topbar-nav a {
	padding: 5px 11px;
	border-radius: 7px;
	color: var(--ink-soft);
	font-size: 0.92rem;
}

.topbar-nav a:hover,
.topbar-nav a.active {
	background: var(--surface-sunken);
	color: var(--ink);
	text-decoration: none;
}

.topbar-actions {
	margin-inline-start: auto;
	display: flex;
	align-items: center;
	gap: 10px;
}

.wrap {
	max-width: 940px;
	margin: 0 auto;
	padding: 32px 24px 64px;
}

.foot {
	max-width: 940px;
	margin: 0 auto;
	padding: 0 24px 40px;
	color: var(--ink-faint);
	font-size: 0.82rem;
}

.badge-dev {
	margin-inline-start: 8px;
	padding: 1px 7px;
	border-radius: 20px;
	background: var(--bad-soft);
	color: var(--bad);
	font-size: 0.72rem;
}


/* ---------- Hlavičky stránek ---------- */

.page-head { margin-bottom: 28px; }

.page-head-row {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--gap);
	flex-wrap: wrap;
}

.page-actions {
	display: flex;
	gap: 8px;
}

.lede {
	margin-top: 6px;
	color: var(--ink-soft);
	font-size: 0.92rem;
}

.back {
	display: inline-block;
	margin-bottom: 6px;
	color: var(--ink-soft);
	font-size: 0.85rem;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.ok { color: var(--good); }
.bad { color: var(--bad); }
.hint { margin-top: 16px; font-size: 0.87rem; }


/* ---------- Tlačítka ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 15px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-size: 0.9rem;
	font-weight: 500;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}

.btn:hover {
	border-color: var(--ink-faint);
	text-decoration: none;
}

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.btn-primary:hover {
	filter: brightness(1.08);
	border-color: var(--accent);
}

.btn-small { padding: 5px 10px; font-size: 0.82rem; }

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	color: var(--ink-soft);
	font-size: 1.1rem;
	transition: background 0.15s, transform 0.3s;
}

.icon-btn:hover {
	background: var(--surface-sunken);
	color: var(--ink);
	text-decoration: none;
	transform: rotate(45deg);
}


/* ---------- Seznam hlídání ---------- */

.watchlist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.watch {
	display: flex;
	align-items: center;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	transition: border-color 0.15s, box-shadow 0.15s;
}

.watch:hover {
	border-color: var(--ink-faint);
	box-shadow: var(--shadow);
}

/* Vypnuté hlídání ztlumíme, ale přepínač musí zůstat čitelný. */
.watch.is-paused .watch-link { opacity: 0.55; }

.watch-link {
	flex: 1;
	min-width: 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(160px, 1.1fr) auto;
	align-items: center;
	gap: 24px;
	padding: 16px 20px;
	color: inherit;
}

.watch-link:hover { text-decoration: none; }

.watch-name {
	font-size: 0.98rem;
	font-weight: 580;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.watch-meta {
	margin-top: 2px;
	color: var(--ink-faint);
	font-size: 0.8rem;
}

.watch-price { text-align: right; }

.price {
	font-family: var(--font-num);
	font-variant-numeric: tabular-nums;
	font-size: 1.34rem;
	font-weight: 600;
	letter-spacing: -0.02em;
	white-space: nowrap;
}

.price.is-good { color: var(--good); }

.unit {
	margin-inline-start: 4px;
	font-size: 0.68em;
	font-weight: 500;
	color: var(--ink-faint);
}

.watch-delta {
	margin-top: 2px;
	font-size: 0.78rem;
	white-space: nowrap;
}

.delta {
	font-family: var(--font-num);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.delta.is-down { color: var(--good); }
.delta.is-up { color: var(--bad); }


/* ---------- Přepínač hlídání ---------- */

.switch {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 14px 20px 14px 16px;
	border-inline-start: 1px solid var(--line);
	align-self: stretch;
	justify-content: center;
	color: var(--ink-faint);
}

.switch:hover { text-decoration: none; }

.switch-track {
	position: relative;
	display: block;
	width: 38px;
	height: 22px;
	border-radius: 11px;
	background: var(--track);
	transition: background 0.18s;
}

.switch-knob {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--ink-faint);
	transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1), background 0.18s;
}

.switch.is-on .switch-track { background: var(--good-soft); }

.switch.is-on .switch-knob {
	transform: translateX(16px);
	background: var(--good);
}

.switch-label {
	font-size: 0.66rem;
	text-transform: uppercase;
	letter-spacing: 0.07em;
}

.switch.is-on .switch-label { color: var(--good); }

.switch:hover .switch-track { background: var(--line); }
.switch.is-on:hover .switch-track { background: var(--good-soft); filter: brightness(1.1); }


/* ---------- Práh: nosný prvek přehledu ---------- */

.rail {
	position: relative;
	height: 8px;
	background: var(--track);
	border-radius: 4px;
}

/* Rozpětí cen, které jsme u produktu za dobu hlídání viděli. */
.rail-band {
	position: absolute;
	inset-block: 0;
	background: var(--accent);
	opacity: 0.24;
	border-radius: 4px;
	animation: rail-in 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* Cílová cena — zářez, který chceš překročit směrem doleva. */
.rail-target {
	position: absolute;
	inset-block: -5px;
	width: 2px;
	margin-inline-start: -1px;
	background: var(--ink);
	border-radius: 1px;
}

/* Aktuální nejlepší skutečná cena. */
.rail-now {
	position: absolute;
	top: 50%;
	width: 13px;
	height: 13px;
	margin: -6.5px 0 0 -6.5px;
	background: var(--surface);
	border: 3px solid var(--ink);
	border-radius: 50%;
	transition: left 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.rail-now.is-hit {
	border-color: var(--good);
	box-shadow: 0 0 0 4px var(--good-soft);
}

.rail-scale {
	display: flex;
	justify-content: space-between;
	margin-top: 6px;
	color: var(--ink-faint);
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.07em;
}

.watch-rail-empty {
	font-size: 0.82rem;
	text-align: center;
}

@keyframes rail-in {
	from { transform: scaleX(0.1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}


/* ---------- Panely, statistiky, tabulky ---------- */

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 22px;
	margin-bottom: 16px;
}

.panel h2 { margin-bottom: 14px; }

.panel-narrow { max-width: 520px; }

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

.stat {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px 16px;
}

.stat-label {
	display: block;
	color: var(--ink-faint);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.07em;
}

.stat-value {
	display: block;
	margin-top: 4px;
	font-family: var(--font-num);
	font-variant-numeric: tabular-nums;
	font-size: 1.15rem;
	font-weight: 600;
	letter-spacing: -0.02em;
}

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

.table th {
	padding: 0 10px 8px 0;
	border-bottom: 1px solid var(--line);
	color: var(--ink-faint);
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	text-align: left;
}

.table th.num { text-align: right; }

.table td {
	padding: 11px 10px 11px 0;
	border-bottom: 1px solid var(--line);
	vertical-align: top;
}

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

.table tr.best td { background: var(--good-soft); }

.table tr.off td { opacity: 0.5; }

.row-actions {
	display: flex;
	gap: 6px;
	justify-content: flex-end;
	white-space: nowrap;
}

.add-source {
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid var(--line);
}

.add-source summary {
	color: var(--accent);
	font-size: 0.88rem;
	cursor: pointer;
}

.add-source[open] summary { margin-bottom: 14px; }

.add-source form { max-width: 520px; }

.breakdown summary {
	color: var(--ink-faint);
	font-size: 0.75rem;
	cursor: pointer;
	text-align: right;
	list-style: none;
}

.breakdown summary::after { content: " ▾"; }
.breakdown[open] summary::after { content: " ▴"; }

.breakdown-table {
	margin-top: 6px;
	font-size: 0.78rem;
	border-collapse: collapse;
	width: 100%;
}

.breakdown-table td {
	padding: 2px 0;
	border: 0;
	color: var(--ink-soft);
}

.breakdown-table td.num { color: var(--ink); }

.research summary {
	color: var(--accent);
	font-size: 0.88rem;
	cursor: pointer;
}

.research-text {
	margin-top: 12px;
	padding: 14px 16px;
	max-height: 420px;
	overflow: auto;
	background: var(--surface-sunken);
	border-radius: 8px;
	font-family: var(--font-ui);
	font-size: 0.85rem;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
}

.timeline {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 0.88rem;
}

.timeline li {
	padding: 7px 0;
	border-bottom: 1px solid var(--line);
}

.timeline li:last-child { border-bottom: 0; }


/* ---------- Odznaky ---------- */

.tag,
.badge {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 20px;
	font-size: 0.71rem;
	font-weight: 550;
	letter-spacing: 0.01em;
	vertical-align: 1px;
}

.tag-good,
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--surface-sunken); color: var(--ink-soft); }


/* ---------- Graf ---------- */

.chart {
	width: 100%;
	height: 260px;
	overflow-x: auto;
}

.chart svg { display: block; width: 100%; height: 100%; }

.chart-legend {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 10px;
	font-size: 0.78rem;
}

.key {
	display: inline-block;
	width: 14px;
	height: 3px;
	border-radius: 2px;
}

.key:not(:first-child) { margin-inline-start: 10px; }
.key-effective { background: var(--accent); }
.key-price { background: var(--ink-faint); }
.key-target { background: var(--good); height: 0; border-top: 2px dashed var(--good); }


/* ---------- Prázdný stav ---------- */

.empty {
	text-align: center;
	padding: 64px 24px;
	background: var(--surface);
	border: 1px dashed var(--line);
	border-radius: var(--radius);
}

.empty-mark {
	font-family: var(--font-num);
	font-size: 2rem;
	color: var(--ink-faint);
	letter-spacing: 0.2em;
}

.empty h2 { margin: 8px 0 6px; }
.empty .btn { margin-top: 18px; }


/* ---------- Hlášky ---------- */

.flash {
	padding: 11px 15px;
	border-radius: 8px;
	margin-bottom: 16px;
	font-size: 0.9rem;
	border: 1px solid transparent;
}

.flash-success { background: var(--good-soft); color: var(--good); border-color: currentcolor; }
.flash-warning,
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: currentcolor; }


/* ---------- Formuláře ---------- */

form { font-size: 0.92rem; }

label {
	display: block;
	margin-bottom: 5px;
	color: var(--ink-soft);
	font-size: 0.85rem;
	font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface-sunken);
	color: var(--ink);
	font: inherit;
	font-size: 0.92rem;
}

input:focus,
textarea:focus {
	outline: none;
	border-color: var(--accent);
	background: var(--surface);
}

input[type="text"],
input[type="password"] { font-family: var(--font-num); }

form p,
form > table td { padding-bottom: 14px; }

form > table { width: 100%; border-collapse: collapse; }
form > table th { text-align: left; font-weight: 500; padding-right: 14px; vertical-align: top; }

fieldset {
	border: 0;
	border-top: 1px solid var(--line);
	margin: 0 0 18px;
	padding: 16px 0 0;
}

fieldset legend {
	padding-inline-end: 10px;
	color: var(--ink-faint);
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.07em;
}

.error, ul.error {
	color: var(--bad);
	font-size: 0.85rem;
	list-style: none;
	padding: 0;
	margin: 6px 0 0;
}


/* ---------- Přihlášení ---------- */

.signin-page {
	display: grid;
	place-items: center;
	min-height: 100vh;
	background: var(--paper);
}

.signin {
	width: min(340px, calc(100vw - 40px));
	padding: 36px 30px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 14px;
	box-shadow: var(--shadow);
	text-align: center;
}

.signin-logo { font-size: 2.2rem; }
.signin h1 { margin-top: 10px; font-size: 1.3rem; }
.signin .muted { font-size: 0.85rem; margin-bottom: 22px; }
.signin form { text-align: left; }
.signin label { text-align: left; }
.signin input[type="submit"],
.signin .btn { width: 100%; }

.signin input[type="submit"] {
	margin-top: 4px;
	padding: 10px;
	border: 0;
	border-radius: 8px;
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 550;
	cursor: pointer;
}


/* ---------- Mobil ---------- */

@media (max-width: 720px) {
	.wrap { padding: 24px 16px 48px; }
	.topbar { padding: 12px 16px; gap: 12px; }
	.topbar-nav { display: none; }

	.watch-link {
		grid-template-columns: 1fr auto;
		gap: 12px 16px;
		padding: 14px 16px;
	}

	.watch-rail {
		grid-column: 1 / -1;
		order: 3;
	}

	.price { font-size: 1.2rem; }
	.panel { padding: 18px 16px; }
	.table { font-size: 0.84rem; }
}

.budget-rail {
	max-width: 320px;
	margin: 10px 0 14px;
}

.budget-rail .rail-band { opacity: 0.55; }


/* ---------- Průběh AI průzkumu ---------- */

.working {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 56px 24px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	text-align: center;
}

.spinner {
	width: 34px;
	height: 34px;
	margin-bottom: 8px;
	border: 3px solid var(--track);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

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

.working-name {
	font-weight: 580;
	font-size: 1.02rem;
}

/* Popisek se mění v čase, tak ať pod ním neposkakuje zbytek stránky. */
.working-step {
	min-height: 1.6em;
	color: var(--accent);
	font-size: 0.92rem;
}

/* Bez animace zůstane statický kroužek — pořád je vidět, že se čeká. */
@media (prefers-reduced-motion: reduce) {
	.spinner {
		animation: none;
		border-top-color: var(--accent);
	}
}
