:root {
	--text: #1d1d1f;
	--muted: #555b62;
	--bg: #ffffff;
	--bg-soft: #f3f5f8;
	--border: #8a929b;
	--line: #d5dae0;
	--primary: #0b5394;
	--primary-dark: #073763;
	--focus: #c94a00;
	--error: #b00020;
	--error-bg: #fdecee;
	--success: #1b6e2b;
	--success-bg: #e8f5ea;
	--info-bg: #e8f0fb;
	--danger: #a4161a;
	font-size: 100%;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 1rem;
	line-height: 1.5;
	color: var(--text);
	background: var(--bg);
}

.wrap { max-width: 1400px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 760px; }

a { color: var(--primary); text-underline-offset: 0.15em; }
a:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

.skip-link {
	position: absolute;
	left: 1rem;
	top: -100px;
	background: var(--primary-dark);
	color: #fff;
	padding: 0.6rem 1rem;
	z-index: 100;
}
.skip-link:focus { top: 0.5rem; color: #fff; }

.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}

/* Hlavička */
.site-header { background: var(--primary-dark); color: #fff; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.site-name { margin: 0; font-size: 1.25rem; font-weight: 700; }
.site-name a { color: #fff; text-decoration: none; }
.site-name span { font-weight: 400; opacity: 0.9; }
.user-box { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; font-size: 0.95rem; }
.user-box a, .user-box .link-button { color: #fff; }
.site-header :focus-visible { outline-color: #ffd27a; }

.main-nav { background: var(--primary); }
.main-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0; margin: 0 auto; }
.main-nav a { display: block; padding: 0.7rem 1rem; color: #fff; text-decoration: none; font-weight: 600; }
.main-nav a:hover { background: var(--primary-dark); text-decoration: underline; }
.main-nav a[aria-current="page"] { background: #fff; color: var(--primary-dark); }

main { padding-top: 1.25rem; padding-bottom: 3rem; }
main:focus { outline: none; }
.site-footer { border-top: 1px solid var(--line); padding: 1rem 0; color: var(--muted); font-size: 0.9rem; }

h1 { font-size: 1.85rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.92em; }

/* Hlásenia */
.flash, .notice, .error-summary { padding: 0.9rem 1rem; border-left: 6px solid; margin: 1rem 0; }
.flash-success { background: var(--success-bg); border-color: var(--success); }
.flash-info, .notice { background: var(--info-bg); border-color: var(--primary); }
.flash-error, .error-summary { background: var(--error-bg); border-color: var(--error); }
.error-summary h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--error); font-weight: 600; }
.error-summary p { margin: 0; }

/* Formuláre */
.app-form { max-width: 640px; }
.field { margin: 0 0 1.1rem; }
.field label, .field legend { display: block; font-weight: 600; margin-bottom: 0.3rem; }
fieldset { border: 1px solid var(--line); padding: 0.75rem 1rem 0.5rem; margin: 0 0 1.1rem; }
fieldset legend { padding: 0 0.3rem; }
.req { font-weight: 400; color: var(--muted); }
.hint { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.92rem; }
.field-error { margin: 0 0 0.3rem; color: var(--error); font-weight: 600; }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"], select, textarea {
	width: 100%;
	font: inherit;
	padding: 0.5rem 0.6rem;
	border: 2px solid var(--border);
	border-radius: 4px;
	background: #fff;
	color: var(--text);
	min-height: 2.75rem;
}
input.short, input.date { max-width: 12rem; }
[aria-invalid="true"] { border-color: var(--error) !important; box-shadow: inset 0 0 0 1px var(--error); }

.choice { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.35rem 0; flex-wrap: wrap; }
.choice input { width: 1.35rem; height: 1.35rem; margin: 0.15rem 0 0; flex: none; accent-color: var(--primary); }
.choice label { font-weight: 400; margin: 0; flex: 1; }
.choice .hint { flex-basis: 100%; margin-left: 1.85rem; margin-top: 0; }
.field.choice label { font-weight: 400; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.button, button.button {
	display: inline-block;
	font: inherit;
	font-weight: 600;
	padding: 0.6rem 1.2rem;
	min-height: 2.75rem;
	border: 2px solid var(--primary);
	border-radius: 4px;
	background: var(--primary);
	color: #fff;
	text-decoration: none;
	cursor: pointer;
}
.button:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.button.secondary { background: #fff; color: var(--primary); }
.button.secondary:hover { background: var(--bg-soft); color: var(--primary-dark); }
.button.danger { background: var(--danger); border-color: var(--danger); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline; cursor: pointer; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* Filtre */
.filters { background: var(--bg-soft); border: 1px solid var(--line); padding: 0.5rem 1rem 0.25rem; margin: 1rem 0 1.5rem; }
.filters h2 { margin: 0.5rem 0 0.75rem; font-size: 1.15rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr)); gap: 0 1rem; }
.filter-groups { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.filter-groups fieldset { background: #fff; flex: 1 1 20rem; min-width: 0; }
.filter-groups fieldset .choice { display: inline-flex; margin-right: 1rem; }
.badge { font-size: 0.85rem; font-weight: 600; background: var(--primary); color: #fff; padding: 0.1rem 0.5rem; border-radius: 1rem; vertical-align: middle; }

/* Tabuľky */
.table-scroll { overflow-x: auto; margin: 0 0 1rem; position: relative; }
.table-scroll:focus-visible { outline-offset: 0; }
table.data { border-collapse: collapse; width: 100%; margin: 0 0 1.5rem; font-size: 0.95rem; }
table.data caption { text-align: left; font-weight: 700; font-size: 1.1rem; padding: 0.5rem 0; }
table.data th, table.data td { border: 1px solid var(--line); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
table.data thead th { background: var(--bg-soft); border-bottom: 2px solid var(--border); }
table.data tbody th { font-weight: 600; }
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data tfoot { font-weight: 700; background: var(--bg-soft); }
.num { text-align: right !important; white-space: nowrap; }
abbr[title] { text-decoration: none; }

.state { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 1rem; border: 1px solid; font-size: 0.88rem; white-space: nowrap; }
.state-nova { background: #fff4d6; border-color: #8a6100; color: #5c4100; }
.state-kontaktovana { background: #e8f0fb; border-color: #0b5394; color: #073763; }
.state-naplanovana { background: #ece6fa; border-color: #5b3fa8; color: #3d2876; }
.state-odmerana { background: var(--success-bg); border-color: var(--success); color: #134d1e; }
.state-zrusena { background: #f1f1f1; border-color: #666; color: #333; }
.state-archiv { background: #f1f1f1; border-color: #888; color: #444; }

/* Detail */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 0 2rem; }
dl.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
dl.details dt { font-weight: 600; }
dl.details dd { margin: 0; overflow-wrap: anywhere; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 0.25rem 1.25rem 0.5rem; margin: 1.5rem 0; }
.card h2 { margin-top: 1rem; }
.grid-form { max-width: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); gap: 0 1.25rem; }
.grid-form .span-all { grid-column: 1 / -1; }
details.card > summary { cursor: pointer; padding: 0.5rem 0; }
details.card > summary h2 { display: inline; font-size: 1.2rem; margin: 0; }
ul.log { padding-left: 1.25rem; }
ul.log > li { margin-bottom: 0.5rem; }
.danger-zone { border-top: 2px solid var(--danger); margin-top: 2.5rem; }

.pagination ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; }
.pagination a { display: inline-block; padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; text-decoration: none; }
.pagination a[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* Verejný a vložený formulár */
body.embed { background: transparent; }
body.embed main { padding: 0.5rem; }
body.embed h1 { font-size: 1.5rem; }

@media (max-width: 640px) {
	h1 { font-size: 1.5rem; }
	dl.details { grid-template-columns: 1fr; }
	dl.details dd { margin-bottom: 0.5rem; }
}

@media print {
	.site-header, .main-nav, .filters, .actions, .site-footer, .skip-link, .flash { display: none !important; }
	.wrap { max-width: none; padding: 0; }
	table.data { font-size: 9pt; }
	table.data th:last-child, table.data td:last-child { display: none; }
	.table-scroll { overflow: visible; }
	a { color: inherit; text-decoration: none; }
	@page { size: A4 landscape; margin: 1cm; }
}

@media (prefers-reduced-motion: reduce) {
	* { scroll-behavior: auto !important; transition: none !important; }
}

/* Nastavenie e-mailu */
.app-form.wide { max-width: 960px; }
textarea.code { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 0.92rem; line-height: 1.45; }
.mail-preview { width: 100%; max-width: 960px; height: 38rem; border: 2px solid var(--line); background: #fff; display: block; margin: 0.75rem 0; }
pre.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-soft); border: 1px solid var(--line); padding: 1rem; max-width: 960px; }
code { font-family: ui-monospace, Consolas, "Courier New", monospace; }

/* Zobrazenie hesla */
.password-wrap { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.password-wrap input { flex: 1 1 14rem; width: auto; }
.password-toggle { flex: none; white-space: nowrap; }
