:root {
	--yg-navy: #0c3a6d;
	--yg-navy-dark: #082951;
	--yg-gold: #f0c020;
	--yg-bg: #f7f8fb;
	--yg-surface: #ffffff;
	--yg-text: #1a1d29;
	--yg-text-muted: #5a6072;
	--yg-border: #e3e6ee;
	--yg-radius: 10px;
	--yg-shadow: 0 2px 10px rgba(28, 43, 91, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: var(--yg-bg);
	color: var(--yg-text);
	line-height: 1.55;
}
a { color: var(--yg-navy); }
h1, h2, h3 { color: var(--yg-navy); line-height: 1.2; }
.page-container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.page-container-fluid { width: 100%; padding: 0 1.5rem; }

/* Login page */
.login-screen {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--yg-navy) 0%, var(--yg-navy-dark) 100%);
	padding: 2rem 1rem;
	position: relative;
}
.login-lang-switch { position: absolute; top: 1.5rem; right: 1.5rem; }
.login-card {
	background: var(--yg-surface);
	border-radius: var(--yg-radius);
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
	padding: 2.5rem;
	max-width: 380px;
	width: 100%;
	text-align: center;
}
.login-card img.logo { max-width: 220px; margin-bottom: 1.5rem; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 1.5rem; }
.login-card label { display: block; text-align: left; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.3rem; }
.login-card input[type="text"],
.login-card input[type="password"] {
	width: 100%;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--yg-border);
	border-radius: 6px;
	font-size: 1rem;
}
.login-card button {
	width: 100%;
	margin-top: 1.5rem;
	padding: 0.7rem;
	background: var(--yg-navy);
	color: white;
	border: none;
	border-radius: 999px;
	font-weight: 700;
	font-size: 1rem;
	cursor: pointer;
}
.login-card button:hover { background: var(--yg-navy-dark); }
.login-error {
	background: #fdecea;
	color: #9a3324;
	border-radius: 6px;
	padding: 0.6rem 0.8rem;
	font-size: 0.9rem;
	margin-bottom: 1rem;
	text-align: left;
}

/* App header (authenticated pages) */
.app-header { background: var(--yg-surface); border-bottom: 1px solid var(--yg-border); }
.app-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 1.5rem; }
.app-header img.logo { height: 40px; }
.app-nav { display: flex; align-items: center; gap: 1.25rem; }
.app-nav a { color: var(--yg-navy); text-decoration: none; font-weight: 600; font-size: 0.95rem; padding-bottom: 0.2rem; border-bottom: 2px solid transparent; }
.app-nav a.active, .app-nav a:hover { border-bottom-color: var(--yg-gold); }
.app-nav .logout { color: var(--yg-text-muted); font-weight: 500; }
main.app-main { padding: 2rem 0 3rem; }

/* Full-width pages (the map) fit the viewport exactly — no page scroll,
   only the map/list panes scroll internally if their content overflows. */
body.full-width-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.full-width-page .app-header { flex-shrink: 0; }
body.full-width-page main.app-main { flex: 1; min-height: 0; padding: 0.5rem 0; display: flex; }
body.full-width-page .page-container-fluid { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.full-width-page h1 { display: none; }

.lang-switch { display: flex; gap: 0.4rem; font-size: 0.85rem; }
.lang-switch a { color: var(--yg-text-muted); text-decoration: none; padding: 0.15rem 0.45rem; border-radius: 4px; font-weight: 600; }
.lang-switch a[aria-current="true"] { color: var(--yg-navy-dark); background: rgba(240, 192, 32, 0.25); }
.login-lang-switch a { color: rgba(255, 255, 255, 0.7); }
.login-lang-switch a[aria-current="true"] { color: white; background: rgba(255, 255, 255, 0.15); }

/* Trip cards */
.trip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; list-style: none; margin: 1.5rem 0 0; padding: 0; }
.trip-card { background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: var(--yg-radius); overflow: hidden; box-shadow: var(--yg-shadow); cursor: pointer; }
.trip-card:hover { border-color: var(--yg-gold); }
.trip-card-body { padding: 0.9rem 1.25rem 1.1rem; }
.trip-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.trip-card .meta { color: var(--yg-text-muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
.trip-card .report-attachment { margin: 0; }

/* Carousel (used on both trip cards and inside the modal) */
.carousel { display: flex; gap: 0.5rem; overflow-x: auto; scroll-snap-type: x mandatory; height: 140px; background: var(--yg-bg); }
.carousel-item { position: relative; flex: 0 0 auto; height: 100%; scroll-snap-align: start; }
.carousel-item img { height: 100%; width: auto; display: block; object-fit: cover; cursor: zoom-in; }
.carousel-remove {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: none;
	background: rgba(19, 29, 64, 0.7);
	color: white;
	font-size: 0.9rem;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
}
.carousel-item:hover .carousel-remove { opacity: 1; }
.carousel-remove:hover { background: #b23b3b; }
.enlarged-photo { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 6px; }
.carousel-empty { display: flex; align-items: center; justify-content: center; width: 100%; color: #c4c8d4; }

/* Dropzone */
.dropzone {
	margin-top: 0.75rem;
	border: 2px dashed var(--yg-border);
	border-radius: var(--yg-radius);
	padding: 1.5rem;
	text-align: center;
	color: var(--yg-text-muted);
	font-size: 0.9rem;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.dropzone.dragover { border-color: var(--yg-gold); background: rgba(240, 192, 32, 0.08); color: var(--yg-navy); }
.dropzone.uploading {
	pointer-events: none;
	border-style: solid;
	border-color: var(--yg-navy);
	color: var(--yg-navy);
	position: relative;
	padding-left: 2.5rem;
}
.dropzone.uploading::before {
	content: '';
	position: absolute;
	left: 1.5rem;
	top: 50%;
	width: 16px;
	height: 16px;
	margin-top: -8px;
	border: 2px solid rgba(12, 58, 109, 0.25);
	border-top-color: var(--yg-navy);
	border-radius: 50%;
	animation: yg-spin 0.7s linear infinite;
}
@keyframes yg-spin {
	to { transform: rotate(360deg); }
}
.dropzone.upload-success { pointer-events: none; border-style: solid; border-color: #2e7d32; background: rgba(46, 125, 50, 0.08); color: #2e7d32; font-weight: 600; }
.dropzone.upload-error { pointer-events: none; border-style: solid; border-color: #b23b3b; background: rgba(178, 59, 59, 0.08); color: #b23b3b; font-weight: 600; }

/* Modal (shared by trips catalogue, map, participants) */
dialog#detail-modal { border: none; border-radius: var(--yg-radius); padding: 0; max-width: 760px; width: 92vw; max-height: 85vh; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
dialog#detail-modal::backdrop { background: rgba(19, 29, 64, 0.55); }
#modal-content { padding: 1.5rem; max-height: 85vh; overflow-y: auto; position: relative; }
.modal-close-btn { position: absolute; top: 0.75rem; right: 0.9rem; background: rgba(255,255,255,0.85); border-radius: 50%; width: 30px; height: 30px; border: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--yg-text-muted); z-index: 2; }

/* Minimized modal tabs, docked at the bottom of the viewport */
#modal-tab-bar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; gap: 0.5rem; padding: 0.6rem 1rem; pointer-events: none; }
.modal-tab { display: flex; align-items: center; gap: 0.5rem; background: var(--yg-navy); color: white; border-radius: 10px; padding: 0.5rem 0.75rem; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.2); max-width: 220px; pointer-events: auto; }
.modal-tab:hover { background: var(--yg-navy-dark); }
.modal-tab.active { background: var(--yg-gold); color: var(--yg-navy-dark); }
.modal-tab-label { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-tab-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1rem; line-height: 1; cursor: pointer; flex-shrink: 0; }
.modal-tab-close:hover { color: var(--yg-gold); }
.modal-tab.active .modal-tab-close { color: rgba(8,41,81,0.6); }
.modal-tab.active .modal-tab-close:hover { color: var(--yg-navy-dark); }

.modal-hero {
	margin: -1.5rem -1.5rem 1rem;
	height: 200px;
	background-size: cover;
	background-position: center;
	position: relative;
}
.modal-hero-gradient {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: 1rem 1.5rem;
	background: linear-gradient(to top, rgba(8, 41, 81, 0.85) 0%, rgba(8, 41, 81, 0) 60%);
}
.modal-hero-gradient h2 { color: white; margin: 0; }

.trip-block { background: var(--yg-bg); border: 1px solid var(--yg-border); border-radius: var(--yg-radius); padding: 1rem; margin-top: 1rem; }
.trip-block h4 { margin: 0 0 0.5rem; }
.trip-block.clickable { cursor: pointer; }
.trip-block.clickable:hover { border-color: var(--yg-gold); }
.people-list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0.5rem 0; padding: 0; }
.person-chip { background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.8rem; }
.facility-links { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.facility-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: var(--yg-navy);
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	background: rgba(12, 58, 109, 0.08);
	border: 1px solid rgba(12, 58, 109, 0.15);
	border-radius: 6px;
	padding: 0.25rem 0.55rem;
	margin: 0.15rem 0.25rem 0.15rem 0;
	line-height: 1.2;
}
.facility-link:hover { background: var(--yg-gold); border-color: var(--yg-gold); color: var(--yg-navy-dark); }

.report-attachment { display: flex; align-items: center; gap: 0.6rem; background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: 8px; padding: 0.6rem 0.8rem; margin-top: 0.75rem; cursor: pointer; }
.report-attachment:hover { border-color: var(--yg-gold); }
.report-attachment .report-icon { color: #6b7086; flex-shrink: 0; }
.report-attachment .report-name { font-size: 0.85rem; font-weight: 600; color: var(--yg-text); }
.pdf-preview { width: 100%; height: 420px; border: 1px solid var(--yg-border); border-radius: 6px; margin-top: 0.75rem; }
.pdf-preview.large { height: 65vh; }

/* Sidebar layout: filters column on the left, content filling the rest.
   Used by the trips catalogue and participants pages (desktop); stacks
   vertically on narrow viewports, filters above content. */
.sidebar-layout { display: flex; align-items: flex-start; gap: 1.5rem; margin-top: 1rem; }
.filters-sidebar { flex: 0 0 240px; max-width: 240px; position: sticky; top: 1rem; }
.filters-sidebar .map-filters { flex-direction: column; margin: 0; }
.filters-sidebar .map-filters select { width: 100%; }
.sidebar-content { flex: 1; min-width: 0; }
.sidebar-content .trip-grid { margin-top: 0; }

@media (max-width: 900px) {
	.sidebar-layout { flex-direction: column; }
	.filters-sidebar { flex: 1 1 auto; max-width: none; width: 100%; position: static; }
}

/* Page header row: title left, controls (e.g. search) right, same line */
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header-row h1 { margin: 0; }
.page-header-row .search-input { margin: 0; }

@media (max-width: 600px) {
	.page-header-row { flex-direction: column; align-items: stretch; }
}

/* Participants table */
.search-input { width: 100%; max-width: 340px; padding: 0.55rem 0.8rem; border: 1px solid var(--yg-border); border-radius: 6px; font-size: 0.95rem; margin: 1rem 0; display: block; }
.participants-table { width: 100%; border-collapse: collapse; background: var(--yg-surface); box-shadow: var(--yg-shadow); border-radius: var(--yg-radius); overflow: hidden; }
.participants-table th, .participants-table td { text-align: left; padding: 0.65rem 1rem; border-bottom: 1px solid var(--yg-border); font-size: 0.92rem; }
.participants-table th { background: var(--yg-bg); color: var(--yg-navy); font-weight: 700; }
.participants-table th[data-sort] { cursor: pointer; user-select: none; }
.participants-table th[data-sort]:after { content: '↕'; color: var(--yg-text-muted); margin-left: 0.3rem; font-size: 0.8rem; }
.participants-table th.sort-asc:after { content: '↑'; color: var(--yg-gold); }
.participants-table th.sort-desc:after { content: '↓'; color: var(--yg-gold); }
.participants-table tr:last-child td { border-bottom: none; }

/* Map page (full width, split pane) */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: 1rem; margin: 0.75rem 0 1rem; flex-shrink: 0; }
.stat-card { background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: 16px; box-shadow: 0 4px 18px rgba(28, 43, 91, 0.07); padding: 0.85rem 1.25rem; transition: transform 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.stat-card:not(.filters-card):hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(28, 43, 91, 0.12); }
.stat-number { font-size: 2.3rem; font-weight: 800; color: var(--yg-navy); line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.85rem; color: var(--yg-text-muted); margin-top: 0.3rem; font-weight: 600; }
.filters-card { background: linear-gradient(135deg, var(--yg-navy) 0%, var(--yg-navy-dark) 100%); }
.filters-card .map-filters { margin: 0; flex-direction: column; width: 100%; }
.filters-card select { width: 100%; }

@media (min-width: 1400px) {
	.stat-number { font-size: 3.4rem; }
}

.yg-pin-teardrop {
	cursor: pointer;
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.map-filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 1.25rem; }
.map-filters select { border: 1px solid var(--yg-border); border-radius: 6px; padding: 0.45rem 0.7rem; font-size: 0.9rem; background: var(--yg-surface); }
.map-layout { display: flex; gap: 1.25rem; align-items: stretch; flex: 1; min-height: 0; }
.map-pane { flex: 1.6 1 0; min-width: 0; display: flex; }
#map { flex: 1; border-radius: var(--yg-radius); overflow: hidden; box-shadow: var(--yg-shadow); border: 1px solid var(--yg-border); }
.facility-list-pane { flex: 1 1 300px; max-width: 380px; background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: var(--yg-radius); padding: 1rem; overflow-y: auto; }
.facility-list-pane h2 { font-size: 1rem; margin: 0 0 0.75rem; }
.facility-list-pane ul { list-style: none; margin: 0; padding: 0; }
.facility-list-pane li { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0; border-top: 1px solid var(--yg-border); cursor: pointer; }
.facility-list-pane li:first-child { border-top: none; }
.facility-list-pane li:hover { color: var(--yg-navy); }
.facility-list-pane .thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.facility-list-pane .thumb.placeholder { background: var(--yg-bg); border: 1px solid var(--yg-border); display: flex; align-items: center; justify-content: center; color: #c4c8d4; }
.facility-list-pane .meta { color: var(--yg-text-muted); font-size: 0.85rem; }

@media (max-width: 900px) {
	.stats-row { grid-template-columns: repeat(2, 1fr); }
	.map-layout { flex-direction: column; }
	.facility-list-pane { max-width: none; }
}

/* Manage (CRUD) pages */
.manage-flash { border-radius: 8px; padding: 0.7rem 1rem; margin: 1rem 0; font-weight: 600; font-size: 0.9rem; }
.manage-flash-success { background: rgba(46, 125, 50, 0.1); color: #2e7d32; }
.manage-flash-error { background: #fdecea; color: #9a3324; }

.manage-tabs { display: flex; gap: 0.4rem; margin: 1rem 0 1.5rem; border-bottom: 1px solid var(--yg-border); }
.manage-tabs a { color: var(--yg-text-muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; padding: 0.6rem 1rem; border-bottom: 2px solid transparent; }
.manage-tabs a.active, .manage-tabs a:hover { color: var(--yg-navy); border-bottom-color: var(--yg-gold); }

.manage-form-card { background: var(--yg-surface); border: 1px solid var(--yg-border); border-radius: var(--yg-radius); box-shadow: var(--yg-shadow); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.manage-form-card h2 { font-size: 1.1rem; margin: 0 0 1rem; }
.manage-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.manage-field-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.85rem; color: var(--yg-text-muted); }
.manage-field-grid input[type="text"],
.manage-field-grid input[type="number"],
.manage-field-grid input[type="date"],
.manage-field-grid input[type="file"],
.manage-field-grid select {
	font-weight: 400;
	color: var(--yg-text);
	padding: 0.5rem 0.65rem;
	border: 1px solid var(--yg-border);
	border-radius: 6px;
	font-size: 0.95rem;
	background: var(--yg-surface);
}
.manage-checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.manage-hint { font-weight: 400; color: var(--yg-text-muted); font-size: 0.8rem; }

.manage-form-actions { display: flex; gap: 0.6rem; margin-top: 1.25rem; }
.manage-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.55rem 1.1rem;
	border-radius: 999px;
	border: 1px solid var(--yg-border);
	background: var(--yg-surface);
	color: var(--yg-text);
	font-weight: 600;
	font-size: 0.9rem;
	cursor: pointer;
	text-decoration: none;
}
.manage-btn:hover { border-color: var(--yg-navy); }
.manage-btn-primary { background: var(--yg-navy); border-color: var(--yg-navy); color: white; }
.manage-btn-primary:hover { background: var(--yg-navy-dark); }
.manage-btn-danger { background: #fdecea; border-color: #f2c2bb; color: #9a3324; }
.manage-btn-danger:hover { background: #f8d5cf; }
.manage-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.manage-table { width: 100%; border-collapse: collapse; background: var(--yg-surface); box-shadow: var(--yg-shadow); border-radius: var(--yg-radius); overflow: hidden; }
.manage-table th, .manage-table td { text-align: left; padding: 0.6rem 1rem; border-bottom: 1px solid var(--yg-border); font-size: 0.9rem; vertical-align: middle; }
.manage-table th { background: var(--yg-bg); color: var(--yg-navy); font-weight: 700; }
.manage-table tr:last-child td { border-bottom: none; }
.manage-row-actions { display: flex; gap: 0.4rem; white-space: nowrap; }

.manage-visits { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--yg-border); }
.manage-visits h3 { font-size: 1rem; margin: 0 0 0.75rem; }
.manage-visit-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.manage-visit-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--yg-border); }
.manage-visit-list li span:first-child { flex: 1; font-weight: 600; }
.manage-visit-date { color: var(--yg-text-muted); font-size: 0.85rem; }
.manage-inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.manage-inline-form select, .manage-inline-form input[type="date"] { padding: 0.5rem 0.65rem; border: 1px solid var(--yg-border); border-radius: 6px; font-size: 0.9rem; }
.manage-empty { color: var(--yg-text-muted); font-size: 0.9rem; }
