:root {
	--bg: #eff2f7;
	--text: #222222;
	--muted: #6c757d;
	--card-bg: #ffffff;
	--surface: #ffffff;
	--surface-alt: #f8fafc;
	--surface-hover: #eef2f7;
	--border: #d6dbe3;
	--thead-bg: #212529;
	--thead-text: #ffffff;
	--thead-light-bg: #f1f5f9;
	--thead-light-text: #111827;
	--input-bg: #ffffff;
	--input-text: #212529;
	--input-placeholder: #6b7280;
	--input-border: #c8d0dc;
	--pagination-bg: #ffffff;
	--pagination-text: #212529;
	--toggle-bg: #111827;
	--toggle-text: #f9fafb;
}

body[data-theme="dark"] {
	--bg: #0f172a;
	--text: #e5e7eb;
	--muted: #9ca3af;
	--card-bg: #1f2937;
	--surface: #111827;
	--surface-alt: #1f2937;
	--surface-hover: #273449;
	--border: #334155;
	--thead-bg: #0b1220;
	--thead-text: #f8fafc;
	--thead-light-bg: #1e293b;
	--thead-light-text: #f8fafc;
	--input-bg: #0b1220;
	--input-text: #f8fafc;
	--input-placeholder: #94a3b8;
	--input-border: #334155;
	--pagination-bg: #1f2937;
	--pagination-text: #f8fafc;
	--toggle-bg: #f9fafb;
	--toggle-text: #111827;
}

body {
	background: var(--bg);
	color: var(--text);
	transition: background-color 0.2s ease, color 0.2s ease;
}

.container,
.container-fluid,
h1,
h2,
h3,
h4,
h5,
h6,
label,
p,
small {
	color: var(--text);
}

.text-muted {
	color: var(--muted) !important;
}

.card {
	border-radius: 0.75rem;
	background: var(--card-bg);
	border-color: var(--border);
}

.card .card-body,
.card .card-title,
.card h6,
.card .h3,
.card p {
	color: var(--text);
}

.table {
	color: var(--text);
	border-color: var(--border);
	--bs-table-color: var(--text);
	--bs-table-bg: var(--surface);
	--bs-table-border-color: var(--border);
	--bs-table-striped-color: var(--text);
	--bs-table-striped-bg: var(--surface-alt);
	--bs-table-hover-color: var(--text);
	--bs-table-hover-bg: var(--surface-hover);
}

.table td,
.table th {
	vertical-align: middle;
	border-color: var(--border);
}

.table > :not(caption) > * > * {
	background-color: var(--surface);
}

.table thead.table-dark th {
	background-color: var(--thead-bg) !important;
	color: var(--thead-text) !important;
	border-color: var(--border) !important;
}

.table thead.table-light th {
	background-color: var(--thead-light-bg) !important;
	color: var(--thead-light-text) !important;
	border-color: var(--border) !important;
}

.table tbody td {
	color: var(--text) !important;
}

.form-control,
.form-select {
	background-color: var(--input-bg);
	color: var(--input-text);
	border-color: var(--input-border);
}

.form-control::placeholder {
	color: var(--input-placeholder);
	opacity: 1;
}

.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
	-webkit-text-fill-color: var(--input-text);
	-webkit-box-shadow: 0 0 0px 1000px var(--input-bg) inset;
}

.form-control:focus,
.form-select:focus {
	background-color: var(--input-bg);
	color: var(--input-text);
}

.pagination .page-link {
	background-color: var(--pagination-bg);
	color: var(--pagination-text);
	border-color: var(--border);
}

.pagination .page-item.disabled .page-link {
	background-color: var(--pagination-bg);
	color: var(--muted);
}

.badge {
	font-size: 0.95em;
}

.bg-status-open,
.status-open {
	background-color: #fd7e14 !important;
	color: #ffffff !important;
}

.card .card-body p {
	margin-bottom: 0.5rem;
}

.navbar-brand {
	font-weight: 700;
}

.navbar {
	padding-top: 0.15rem;
	padding-bottom: 0.15rem;
}

.navbar .navbar-brand {
	padding-left: 0;
	margin-right: 0.2rem;
	line-height: 1.1;
	min-height: 20px;
	display: inline-flex;
	align-items: center;
}

.navbar .navbar-brand .brand-logo {
	position: static;
	transform: none;
}

.brand-logo {
	width: auto;
	height: 72px;
	object-fit: contain;
}

.brand-logo-page {
	width: min(360px, 100%);
	height: auto;
	max-height: 180px;
	object-fit: contain;
}

.occurrences-brand-hero {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.navbar,
.navbar .nav-link,
.navbar .navbar-brand {
	color: #f8fafc !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success {
	border-width: 1px;
}

body[data-theme="dark"] .btn-outline-secondary {
	color: #d1d5db;
	border-color: #64748b;
}

body[data-theme="dark"] .btn-outline-secondary:hover {
	background-color: #334155;
	color: #f8fafc;
}

body[data-theme="dark"] .btn-outline-primary {
	color: #93c5fd;
	border-color: #3b82f6;
}

body[data-theme="dark"] .btn-outline-primary:hover {
	background-color: #1d4ed8;
	color: #f8fafc;
}

body[data-theme="dark"] .btn-outline-success {
	color: #86efac;
	border-color: #22c55e;
}

body[data-theme="dark"] .btn-outline-success:hover {
	background-color: #166534;
	color: #f8fafc;
}

.table a,
.card a,
.page-link {
	text-decoration: none;
}

.autocomplete {
	position: relative;
}

.autocomplete-menu {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	display: none;
	max-height: 220px;
	overflow-y: auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 0.75rem;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
	z-index: 1055;
}

.autocomplete-menu.is-open {
	display: block;
}

.autocomplete-option {
	display: block;
	width: 100%;
	padding: 0.65rem 0.85rem;
	border: none;
	border-bottom: 1px solid var(--border);
	background: transparent;
	color: var(--text);
	text-align: left;
}

.autocomplete-option:last-child {
	border-bottom: none;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
	background: var(--surface-hover);
}

.occurrence-summary-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 1rem;
}

.occurrence-summary-item {
	padding: 1rem;
	border: 1px solid var(--border);
	border-radius: 0.85rem;
	background: var(--surface-alt);
	min-height: 92px;
}

.occurrence-summary-item-wide {
	grid-column: span 2;
}

.occurrence-summary-label {
	display: block;
	margin-bottom: 0.45rem;
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--muted);
}

.occurrence-summary-value {
	font-size: 1.02rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--text);
	word-break: break-word;
}

.occurrence-description-panel {
	padding: 1.1rem 1.2rem;
	border: 1px solid var(--border);
	border-radius: 0.95rem;
	background: var(--surface);
}

.occurrence-description-text {
	font-size: 1rem;
	line-height: 1.7;
	white-space: pre-wrap;
	word-break: break-word;
}

.occurrence-header {
	padding: 0.25rem 0;
}

.occurrence-header h3 {
	margin-bottom: 0.35rem;
}

.occurrence-header-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;
	gap: 0.75rem;
	width: 100%;
}

.occurrence-status-form {
	display: flex;
	align-items: stretch;
	gap: 0.55rem;
	margin: 0;
}

.occurrence-status-form .form-select {
	min-width: 190px;
	height: 44px;
	border-radius: 0.65rem;
}

.occurrence-status-form .occurrence-type-select {
	min-width: 320px;
}

.occurrence-status-form .btn {
	height: 44px;
	padding-inline: 1rem;
	white-space: nowrap;
	border-radius: 0.65rem;
}

.occurrence-action-buttons {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.55rem;
}

.occurrence-action-buttons .btn,
.occurrence-action-buttons form .btn {
	height: 44px;
	padding-inline: 1rem;
	white-space: nowrap;
	border-radius: 0.65rem;
}

.occurrence-action-buttons form {
	margin: 0;
}

@media (max-width: 991.98px) {
	.occurrence-summary-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.brand-logo {
		height: 56px;
	}

	.occurrence-header-actions {
		justify-content: flex-start;
	}
}

@media (max-width: 575.98px) {
	.container {
		padding-left: 0.8rem;
		padding-right: 0.8rem;
	}

	.occurrence-header-actions {
		width: 100%;
		flex-direction: column;
		align-items: stretch;
	}

	.occurrence-status-form,
	.occurrence-action-buttons {
		width: 100%;
		flex-direction: column;
		align-items: stretch;
	}

	.occurrence-header-actions .btn,
	.occurrence-status-form .form-select {
		width: 100%;
	}

	.occurrence-header-actions form {
		width: 100%;
	}

	.occurrence-header-actions form .btn {
		width: 100%;
	}

	.navbar .container-fluid {
		padding-left: 0.8rem;
		padding-right: 0.8rem;
	}

	.brand-logo {
		height: 44px;
	}

	.brand-logo-page {
		width: min(260px, 88vw);
		max-height: 120px;
	}

	.occurrences-brand-hero {
		margin-bottom: 1rem !important;
	}

	.occurrence-summary-grid {
		grid-template-columns: 1fr;
	}

	.occurrence-summary-item-wide {
		grid-column: span 1;
	}

	.form-label {
		font-size: 0.9rem;
	}

	.table {
		font-size: 0.9rem;
	}

	.navbar .navbar-collapse {
		margin-top: 0.4rem;
	}

	.theme-toggle {
		right: 10px;
		bottom: 10px;
		padding: 0.45rem 0.7rem;
		font-size: 0.86rem;
	}
}

.visits-table-wrap {
	border-radius: 0.75rem;
}

.visits-table {
	min-width: 1220px;
	font-size: 0.94rem;
}

.visits-table th,
.visits-table td {
	white-space: nowrap;
	vertical-align: middle;
}

.visits-table .cell-truncate {
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.visits-table .cell-wide {
	max-width: 260px;
}

.visits-table .btn {
	white-space: nowrap;
}

.theme-toggle {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 1080;
	border: none;
	border-radius: 999px;
	padding: 0.6rem 0.9rem;
	background: var(--toggle-bg);
	color: var(--toggle-text);
	font-weight: 600;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.theme-toggle:hover {
	opacity: 0.92;
}
