/* ============================================================
   Data Manager — Mobile-first CSS
   ============================================================ */

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

:root {
	--blue: #1a73e8;
	--blue-dark: #1557b0;
	--blue-light: #e8f0fe;
	--green: #1e8e3e;
	--green-light: #e6f4ea;
	--red: #d93025;
	--red-light: #fce8e6;
	--amber: #f29900;
	--amber-light: #fef7e0;
	--purple: #7c4dff;
	--purple-light: #ede7f6;
	--gray-50: #f8f9fa;
	--gray-100: #f1f3f4;
	--gray-200: #e8eaed;
	--gray-400: #bdc1c6;
	--gray-600: #80868b;
	--gray-800: #3c4043;
	--gray-900: #202124;
	--white: #ffffff;
	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
	--shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
	--shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.18);
	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 16px;
	--tr: 0.2s ease;
}

html {
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
}
body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--gray-900);
	background: var(--gray-50);
	min-height: 100vh;
	overflow-x: hidden;
}

/* ── App shell ─────────────────────────────────────────────── */
body {
	display: flex;
	flex-direction: column;
}
#app {
	flex: 1;
	display: flex;
	flex-direction: column;
}
.page {
	display: none;
	flex-direction: column;
	flex: 1;
}
.page.active {
	display: flex;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
	background: var(--blue);
	color: var(--white);
	padding: 0 14px;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: var(--shadow-md);
	flex-shrink: 0;
}
.topbar-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.topbar-title {
	font-size: 1rem;
	font-weight: 600;
	white-space: nowrap;
}
.topbar-sub {
	font-size: 0.75rem;
	opacity: 0.85;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 160px;
}
.topbar-btn {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: white;
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 0.82rem;
	cursor: pointer;
	min-height: 34px;
	white-space: nowrap;
}
.topbar-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}
.topbar-actions {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}

/* ── Page content ──────────────────────────────────────────── */
.page-content {
	flex: 1;
	padding: 14px;
	max-width: 600px;
	width: 100%;
	margin: 0 auto;
	padding-bottom: 90px;
}
.page-content.no-save {
	padding-bottom: 14px;
}

/* ── LOGIN PAGE ────────────────────────────────────────────── */
#page-login {
	background: linear-gradient(155deg, #1a73e8 0%, #0d47a1 100%);
	justify-content: center;
	align-items: center;
	padding: 20px;
}
.login-card {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 28px 22px;
	width: 100%;
	max-width: 380px;
	box-shadow: var(--shadow-lg);
}
.login-logo {
	text-align: center;
	margin-bottom: 10px;
}
.login-logo img {
	width: 130px;
	height: 130px;
	object-fit: contain;
	margin-bottom: 8px;
	border-radius: 12px;
}
.login-logo .logo-fallback {
	width: 52px;
	height: 82px;
	background: var(--blue-light);
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 5px;
	font-size: 32px;
}
.login-logo h1 {
	font-size: 1.4rem;
	color: var(--gray-900);
}
.login-logo p {
	font-size: 0.82rem;
	color: var(--gray-600);
	margin-top: 3px;
}
/* ── Login error dialog ─────────────────────────────────────── */
.login-error-dialog {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 28px 24px 20px;
	width: 90%;
	max-width: 320px;
	text-align: center;
	box-shadow: var(--shadow-lg);
	animation: dialogPop 0.25s ease;
}
.login-error-icon {
	font-size: 2.4rem;
	color: var(--red);
	margin-bottom: 8px;
	line-height: 1;
}
.login-error-title {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--gray-900);
	margin-bottom: 8px;
}
.login-error-msg {
	font-size: 0.88rem;
	color: var(--gray-600);
	line-height: 1.5;
	margin-bottom: 20px;
}
@keyframes dialogPop {
	from { opacity: 0; transform: scale(0.9); }
	to   { opacity: 1; transform: scale(1); }
}

.need-help-btn {
	background: none;
	border: none;
	color: var(--blue);
	font-size: 0.85rem;
	cursor: pointer;
	text-decoration: underline;
	padding: 4px 0;
	margin-top: 8px;
	display: block;
	width: 100%;
	text-align: center;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
	margin-bottom: 14px;
}
.form-label {
	display: block;
	font-size: 0.8rem;
	font-weight: 600;
	background: var(--gray-100);
	padding: 5px 8px;
	border-radius: 4px;
	color: var(--gray-800);
	margin-bottom: 4px;
}

.form-input,
.form-select,
.form-textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1.5px solid var(--gray-200);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	color: var(--gray-900);
	background: var(--white);
	transition:
		border-color var(--tr),
		box-shadow var(--tr);
	-webkit-appearance: none;
	appearance: none;
	min-height: 44px;
	font-family: inherit;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
	outline: none;
	border-color: var(--blue);
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
.form-input.error {
	border-color: var(--red);
}
.form-select {
	background-color: var(--gray-50);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2380868b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	padding-right: 34px;
	cursor: pointer;
}
.form-select:disabled {
	background-color: var(--gray-100);
	color: var(--gray-600);
	cursor: not-allowed;
}
.form-textarea {
	min-height: 72px;
	resize: vertical;
	line-height: 1.5;
}
.form-input.readonly,
.form-textarea.readonly {
	background: var(--gray-50);
	color: var(--gray-600);
	cursor: default;
	border-color: var(--gray-100);
}
.radio-group {
	display: flex;
	gap: 16px;
}
.radio-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.9rem;
	cursor: pointer;
}
.radio-label input[type="radio"] {
	accent-color: var(--blue);
	width: 16px;
	height: 16px;
	cursor: pointer;
}
.form-hint {
	font-size: 0.72rem;
	color: var(--gray-600);
	margin-top: 3px;
}
.form-error {
	font-size: 0.76rem;
	color: var(--red);
	margin-top: 3px;
	display: none;
}
.form-error.visible {
	display: block;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 11px 18px;
	border-radius: var(--radius-sm);
	font-size: 0.9rem;
	font-weight: 500;
	border: none;
	cursor: pointer;
	min-height: 46px;
	transition:
		background var(--tr),
		transform var(--tr);
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}
.btn:active {
	transform: scale(0.97);
}
.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}
.btn-primary {
	background: var(--blue);
	color: var(--white);
	width: 100%;
}
.btn-primary:hover:not(:disabled) {
	background: var(--blue-dark);
}
.btn-success {
	background: var(--green);
	color: var(--white);
}
.btn-success:hover:not(:disabled) {
	background: #166430;
}
.btn-danger {
	background: var(--red);
	color: var(--white);
}
.btn-danger:hover:not(:disabled) {
	background: #b71c1c;
}
.btn-outline {
	background: transparent;
	color: var(--blue);
	border: 1.5px solid var(--blue);
}
.btn-outline:hover:not(:disabled) {
	background: var(--blue-light);
}
.btn-ghost {
	background: transparent;
	color: var(--gray-800);
	border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover:not(:disabled) {
	background: var(--gray-100);
}
.btn-purple {
	background: var(--purple);
	color: var(--white);
}
.btn-purple:hover:not(:disabled) {
	background: #6200ea;
}
.btn-block {
	width: 100%;
}
.btn .spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	flex-shrink: 0;
}

/* ── Admin panel ────────────────────────────────────────────── */
.admin-panel {
	background: var(--white);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	padding: 14px;
	margin-bottom: 14px;
	border: 1px solid var(--gray-200);
}
.admin-panel-header {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 12px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--gray-100);
}
.admin-panel-icon {
	font-size: 1rem;
}
.admin-panel-title {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--gray-600);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}
.admin-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-bottom: 10px;
}
.admin-grid:last-child {
	margin-bottom: 0;
}
.admin-tool-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 14px 8px;
	border-radius: var(--radius-sm);
	border: 1.5px solid var(--gray-200);
	background: var(--gray-50);
	cursor: pointer;
	transition: all 0.2s ease;
	min-height: 72px;
}
.admin-tool-btn:active {
	transform: scale(0.97);
}
.admin-tool-icon {
	font-size: 1.3rem;
	line-height: 1;
}
.admin-tool-label {
	font-size: 0.76rem;
	font-weight: 600;
	text-align: center;
	line-height: 1.2;
}

/* ── Admin tool color variants ─────────────────────────────── */
.admin-tool--blue {
	border-color: #c5d9f2;
	background: #f0f6ff;
	color: var(--blue);
}
.admin-tool--blue:hover {
	background: #dde9fa;
	border-color: var(--blue);
}
.admin-tool--purple {
	border-color: #d4c5f9;
	background: #f5f0ff;
	color: var(--purple);
}
.admin-tool--purple:hover {
	background: #e8dff8;
	border-color: var(--purple);
}
.admin-tool--green {
	border-color: #b7e1c4;
	background: #f0faf3;
	color: var(--green);
}
.admin-tool--green:hover {
	background: #daf1e2;
	border-color: var(--green);
}
.admin-tool--amber {
	border-color: #f0d9a0;
	background: #fffbf0;
	color: #b87400;
}
.admin-tool--amber:hover {
	background: #fef3da;
	border-color: var(--amber);
}
.admin-tool--red {
	border-color: #f5c6c6;
	background: #fff5f5;
	color: #c0392b;
}
.admin-tool--red:hover {
	background: #fde4e4;
	border-color: #c0392b;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
	background: var(--white);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	overflow: hidden;
}
.card-body {
	padding: 13px;
}
.card-header {
	padding: 11px 13px;
	border-bottom: 1px solid var(--gray-100);
	font-weight: 600;
	font-size: 0.88rem;
}

/* ── People grid ────────────────────────────────────────────── */
.people-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
}
@media (min-width: 500px) {
	.people-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}
@media (min-width: 700px) {
	.people-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

.person-thumb {
	background: var(--white);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	overflow: hidden;
	cursor: pointer;
	transition: transform var(--tr);
	-webkit-tap-highlight-color: transparent;
}
.person-thumb:active {
	transform: scale(0.96);
}
.person-thumb-img {
	width: 100%;
	aspect-ratio: 3/4;
	object-fit: cover;
	background: var(--gray-100);
	display: block;
}
.person-thumb-img.loaded {
	animation: fadeIn 0.3s ease;
}
.person-thumb-info {
	padding: 6px 9px;
	border-top: 1px solid var(--gray-100);
}
.person-thumb-name {
	font-size: 0.8rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.person-thumb-sub {
	font-size: 0.7rem;
	color: var(--gray-600);
	margin-top: 1px;
}
.person-thumb-updated {
	font-size: 0.62rem;
	color: var(--gray-400);
	margin-top: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Grid toolbar */
.grid-toolbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.grid-toolbar .back-btn { margin-bottom:0; }
.grid-count { font-size:0.75rem; color:var(--gray-600); margin-bottom:8px; font-weight:500; }

/* ── Grid tabs ─────────────────────────────────────────────── */
.grid-tabs {
	display: flex;
	gap: 0;
	background: var(--gray-100);
	border-radius: var(--radius-sm);
	padding: 3px;
	margin-bottom: 8px;
}
.grid-tab {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 6px;
	border: none;
	border-radius: 4px;
	background: transparent;
	color: var(--gray-600);
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}
.grid-tab:active { transform: scale(0.97); }
.grid-tab.active {
	background: var(--white);
	color: var(--gray-900);
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.grid-tab-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--gray-200);
	color: var(--gray-600);
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 1;
}
.grid-tab.active .grid-tab-count {
	background: var(--blue);
	color: var(--white);
}
.tab-hint {
	font-size: 0.72rem;
	color: var(--gray-400);
	margin-bottom: 6px;
	font-style: italic;
}

/* Search box */
.search-box-wrap {
	margin-bottom: 10px;
}
.search-box-wrap .form-input {
	font-size: 0.88rem;
}

/* Remark badge on thumb */
.remark-badge {
	position: absolute;
	top: 4px;
	right: 4px;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	font-size: 0.62rem;
	padding: 2px 6px;
	border-radius: 10px;
}
.person-thumb {
	position: relative;
}

.no-photo-ph {
	width: 100%;
	aspect-ratio: 3/4;
	background: var(--gray-100);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: var(--gray-400);
	font-size: 0.7rem;
	gap: 5px;
	cursor: pointer;
	transition: background var(--tr);
}
.no-photo-ph:hover {
	background: var(--gray-200);
}
.no-photo-icon {
	font-size: 22px;
}

/* ── Skeleton ───────────────────────────────────────────────── */
.skeleton {
	background: linear-gradient(
		90deg,
		var(--gray-100) 25%,
		var(--gray-200) 50%,
		var(--gray-100) 75%
	);
	background-size: 200% 100%;
	animation: shimmer 1.4s infinite;
	border-radius: var(--radius-sm);
}
.sk-card {
	background: var(--white);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	overflow: hidden;
}
.sk-img {
	width: 100%;
	aspect-ratio: 3/4;
}
.sk-line {
	height: 12px;
	margin: 7px 8px 3px;
}
.sk-line2 {
	height: 10px;
	margin: 0 8px 8px;
	width: 55%;
}

/* ── Detail page ────────────────────────────────────────────── */
.detail-photo-wrap {
	position: relative;
	width: 120px;
	flex-shrink: 0;
}
.detail-photo-img {
	width: 120px;
	height: 155px;
	object-fit: cover;
	border-radius: var(--radius-md);
	display: block;
	cursor: pointer;
	box-shadow: var(--shadow-md);
	transition: opacity var(--tr);
}
.detail-photo-img:hover {
	opacity: 0.9;
}
.tap-hint {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, 0.45);
	color: white;
	font-size: 0.64rem;
	text-align: center;
	padding: 4px;
	border-radius: 0 0 var(--radius-md) var(--radius-md);
	pointer-events: none;
}
.detail-no-photo {
	width: 120px;
	height: 155px;
	border-radius: var(--radius-md);
	background: var(--gray-100);
	border: 2px dashed var(--gray-400);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	cursor: pointer;
	transition:
		background var(--tr),
		border-color var(--tr);
}
.detail-no-photo:hover {
	background: var(--blue-light);
	border-color: var(--blue);
}
.detail-no-photo-icon {
	font-size: 26px;
	color: var(--gray-400);
}
.detail-no-photo-text {
	font-size: 0.7rem;
	color: var(--blue);
	font-weight: 500;
	text-align: center;
	line-height: 1.3;
}

.detail-header {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	margin-bottom: 16px;
}
.detail-meta {
	flex: 1;
	min-width: 0;
}
.detail-meta h2 {
	font-size: 1.05rem;
	margin-bottom: 4px;
	word-break: break-word;
}

/* Extra photo columns */
.extra-photo-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 12px;
}
.extra-photo-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
}
.extra-photo-label {
	font-size: 0.7rem;
	color: var(--gray-600);
	font-weight: 500;
	text-transform: capitalize;
}
.extra-photo-thumb {
	width: 70px;
	height: 90px;
	object-fit: cover;
	border-radius: var(--radius-sm);
	cursor: pointer;
	border: 1.5px solid var(--gray-200);
	box-shadow: var(--shadow-sm);
}
.extra-photo-ph {
	width: 70px;
	height: 90px;
	border-radius: var(--radius-sm);
	background: var(--gray-100);
	border: 1.5px dashed var(--gray-400);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	cursor: pointer;
	font-size: 0.62rem;
	color: var(--blue);
}
.extra-photo-ph-icon {
	font-size: 18px;
	color: var(--gray-400);
}

/* ── Field cards ────────────────────────────────────────────── */
.fields-card {
	background: var(--white);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	padding: 13px;
	margin-bottom: 13px;
}
.fields-title {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--gray-600);
	margin-bottom: 10px;
}
.field-row {
	margin-bottom: 10px;
}
.field-row:last-child {
	margin-bottom: 0;
}
.field-label {
	font-size: 0.76rem;
	font-weight: 600;
	color: var(--gray-600);
	margin-bottom: 3px;
	display: block;
	background: var(--gray-100);
	padding: 4px 8px;
	border-radius: 4px;
}
.field-input {
	width: 100%;
	padding: 9px 10px;
	border: 1.5px solid var(--gray-200);
	border-radius: var(--radius-sm);
	font-size: 0.88rem;
	color: var(--gray-900);
	background: var(--white);
	font-family: inherit;
	transition:
		border-color var(--tr),
		box-shadow var(--tr);
	min-height: 40px;
}
.field-input:focus {
	outline: none;
	border-color: var(--blue);
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
.field-input.ro {
	background: var(--gray-50);
	color: var(--gray-600);
	cursor: default;
	border-color: var(--gray-100);
}
.field-select {
	width: 100%;
	padding: 9px 32px 9px 10px;
	border: 1.5px solid var(--gray-200);
	border-radius: var(--radius-sm);
	font-size: 0.88rem;
	color: var(--gray-900);
	background: var(--gray-50)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2380868b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")
		no-repeat right 8px center;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	min-height: 40px;
}
.field-select:focus {
	outline: none;
	border-color: var(--blue);
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
.field-textarea {
	width: 100%;
	padding: 9px 10px;
	border: 1.5px solid var(--gray-200);
	border-radius: var(--radius-sm);
	font-size: 0.88rem;
	color: var(--gray-900);
	background: var(--white);
	font-family: inherit;
	resize: vertical;
	min-height: 64px;
}
.field-textarea:focus {
	outline: none;
	border-color: var(--blue);
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
.field-row-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 10px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
	padding: 12px 16px 14px;
	text-align: center;
	border-top: 1px solid var(--gray-100);
	margin-top: auto;
}
.footer-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	flex-wrap: wrap;
}
.footer-logo {
	width: 18px;
	height: 18px;
	object-fit: contain;
	opacity: 0.45;
	flex-shrink: 0;
}
.footer-text {
	font-size: 0.68rem;
	color: var(--gray-400);
	letter-spacing: 0.01em;
}
/* On login page: footer blends with blue background */
body[data-page="login"] {
	background: var(--blue);
}
body[data-page="login"] .app-footer {
	border-top: none;
	background: transparent;
	padding: 6px 16px 10px;
}
body[data-page="login"] .app-footer .footer-text {
	color: rgba(255, 255, 255, 0.7);
}
body[data-page="login"] .app-footer .footer-logo {
	display: none;
}
/* Hide footer when save bar is visible to avoid overlap */
.save-bar.visible ~ .app-footer,
.page-content:not(.no-save) ~ .app-footer {
	padding-bottom: 70px;
}

/* ── Sticky save bar ────────────────────────────────────────── */
.save-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: var(--white);
	border-top: 1px solid var(--gray-200);
	padding: 10px 14px;
	padding-bottom: calc(10px + env(safe-area-inset-bottom));
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
	z-index: 200;
	display: none;
}
.save-bar.visible {
	display: block;
}
.save-bar-inner {
	max-width: 600px;
	margin: 0 auto;
}
.btn-save {
	background: var(--green);
	color: white;
	width: 100%;
	font-size: 0.95rem;
	font-weight: 600;
	min-height: 48px;
	border: none;
	border-radius: var(--radius-md);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	transition:
		background var(--tr),
		transform var(--tr);
	-webkit-tap-highlight-color: transparent;
}
.btn-save:hover:not(:disabled) {
	background: #166430;
}
.btn-save:active:not(:disabled) {
	transform: scale(0.98);
}
.btn-save:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
.btn-save .spinner {
	width: 19px;
	height: 19px;
	border: 2.5px solid rgba(255, 255, 255, 0.4);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}

/* ── Lightbox ───────────────────────────────────────────────── */
.lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.95);
	z-index: 2000;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.lightbox.open {
	display: flex;
	animation: fadeIn 0.18s ease;
}
.lightbox-img {
	max-width: 100vw;
	max-height: calc(100vh - 110px);
	object-fit: contain;
	border-radius: 4px;
}
.lightbox-actions {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 14px;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
}
.lb-btn {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: white;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	font-size: 1rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.lb-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}
.lb-del {
	background: rgba(217, 48, 37, 0.75);
	border: none;
	color: white;
	padding: 9px 18px;
	border-radius: 22px;
	font-size: 0.86rem;
	font-weight: 500;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 5px;
}
.lb-del:hover {
	background: rgba(183, 28, 28, 0.9);
}
.lb-label {
	color: rgba(255, 255, 255, 0.65);
	font-size: 0.78rem;
}

/* ── Confirm dialog ─────────────────────────────────────────── */
.confirm-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 3000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 18px;
}
.confirm-overlay.open {
	display: flex;
	animation: fadeIn 0.15s ease;
}
.confirm-dialog {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 22px 18px 18px;
	width: 100%;
	max-width: 310px;
	box-shadow: var(--shadow-lg);
	animation: slideUp 0.18s ease;
}
.confirm-icon {
	font-size: 34px;
	text-align: center;
	margin-bottom: 10px;
}
.confirm-title {
	font-size: 1rem;
	font-weight: 600;
	text-align: center;
	margin-bottom: 6px;
}
.confirm-msg {
	font-size: 0.85rem;
	color: var(--gray-600);
	text-align: center;
	margin-bottom: 18px;
	line-height: 1.5;
}
.confirm-btns {
	display: flex;
	gap: 8px;
}
.confirm-btns .btn {
	flex: 1;
}

/* ── Photo modal ────────────────────────────────────────────── */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	z-index: 1000;
	display: none;
	align-items: flex-end;
	justify-content: center;
}
.modal-overlay.open {
	display: flex;
	animation: fadeIn 0.16s ease;
}
.modal-sheet {
	background: var(--white);
	border-radius: var(--radius-lg) var(--radius-lg) 0 0;
	width: 100%;
	max-width: 500px;
	max-height: 88vh;
	overflow-y: auto;
	padding: 16px 16px 30px;
	animation: slideUp 0.22s ease;
}
.modal-handle {
	width: 38px;
	height: 4px;
	background: var(--gray-200);
	border-radius: 2px;
	margin: 0 auto 16px;
}
.modal-title {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 14px;
}
.photo-preview {
	width: 100%;
	max-height: 270px;
	object-fit: contain;
	border-radius: var(--radius-md);
	background: var(--gray-100);
	display: none;
	margin: 8px 0;
}
.photo-preview.visible {
	display: block;
}
.upload-opts {
	display: flex;
	flex-direction: column;
	gap: 9px;
}
.upload-opt-btn {
	display: flex;
	align-items: center;
	gap: 13px;
	padding: 13px 14px;
	border: 1.5px solid var(--gray-200);
	border-radius: var(--radius-md);
	background: var(--white);
	cursor: pointer;
	transition: all var(--tr);
	font-size: 0.9rem;
	min-height: 58px;
}
.upload-opt-btn:hover {
	border-color: var(--blue);
	background: var(--blue-light);
}
.upload-opt-icon {
	font-size: 21px;
	flex-shrink: 0;
}
.upload-opt-text strong {
	display: block;
	font-weight: 600;
	font-size: 0.87rem;
}
.upload-opt-text span {
	font-size: 0.75rem;
	color: var(--gray-600);
}
#file-input, #xlsx-file-input, #photos-zip-input {
	display: none;
}

/* ── Progress ───────────────────────────────────────────────── */
.progress-wrap {
	background: var(--gray-100);
	border-radius: 4px;
	height: 7px;
	overflow: hidden;
	margin: 9px 0;
}
.progress-bar {
	height: 100%;
	background: var(--blue);
	border-radius: 4px;
	transition: width 0.3s ease;
	width: 0%;
}
.progress-label {
	font-size: 0.8rem;
	color: var(--gray-600);
	text-align: center;
	margin-top: 4px;
}

/* ── Help popup ─────────────────────────────────────────────── */
.help-popup {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 22px 18px 18px;
	width: 100%;
	max-width: 300px;
	box-shadow: var(--shadow-lg);
	animation: slideUp 0.18s ease;
	text-align: center;
}
.help-popup h3 {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 8px;
}
.help-popup p {
	font-size: 0.85rem;
	color: var(--gray-600);
	margin-bottom: 16px;
	line-height: 1.5;
}
.call-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--green);
	color: white;
	border: none;
	padding: 12px 24px;
	border-radius: 24px;
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
	position: fixed;
	bottom: 75px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 9999;
	display: flex;
	flex-direction: column-reverse;
	align-items: center;
	gap: 7px;
	width: calc(100% - 28px);
	max-width: 380px;
	pointer-events: none;
}
.toast {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 11px 14px;
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-lg);
	font-size: 0.85rem;
	font-weight: 500;
	width: 100%;
	pointer-events: all;
	animation: slideUp 0.22s ease;
	cursor: pointer;
}
.toast-success {
	background: #1e8e3e;
	color: white;
}
.toast-error {
	background: #d93025;
	color: white;
}
.toast-warning {
	background: #f29900;
	color: white;
}
.toast-info {
	background: #1a73e8;
	color: white;
}
.toast-icon {
	font-size: 0.95rem;
	flex-shrink: 0;
}
.toast-msg {
	flex: 1;
}
.toast-close {
	background: none;
	border: none;
	color: white;
	font-size: 0.95rem;
	cursor: pointer;
	opacity: 0.8;
	padding: 0;
}

/* ── Offline ────────────────────────────────────────────────── */
#offline-banner {
	display: none;
	background: var(--red);
	color: white;
	text-align: center;
	padding: 6px 14px;
	font-size: 0.8rem;
	font-weight: 500;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 9998;
}
#offline-banner.visible {
	display: block;
}

/* ── Loading overlay ────────────────────────────────────────── */
.loading-overlay {
	position: fixed;
	inset: 0;
	background: rgba(255, 255, 255, 0.85);
	display: none;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: 11px;
	z-index: 500;
}
.loading-overlay.active {
	display: flex;
}
.loading-spinner {
	width: 42px;
	height: 42px;
	border: 4px solid var(--gray-200);
	border-top-color: var(--blue);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}
.loading-text {
	font-size: 0.9rem;
	color: var(--gray-600);
	font-weight: 500;
}

/* ── Misc ───────────────────────────────────────────────────── */
.back-btn {
	display: flex;
	align-items: center;
	gap: 5px;
	background: none;
	border: none;
	color: var(--blue);
	font-size: 0.88rem;
	font-weight: 500;
	cursor: pointer;
	padding: 7px 0;
	margin-bottom: 12px;
	min-height: 42px;
}
.badge {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 18px;
	font-size: 0.7rem;
	font-weight: 600;
}
.badge-blue {
	background: var(--blue-light);
	color: var(--blue-dark);
}
.badge-green {
	background: var(--green-light);
	color: var(--green);
}
.badge-amber {
	background: var(--amber-light);
	color: #8a5900;
}
.badge-gray {
	background: var(--gray-100);
	color: var(--gray-800);
}
.section-lbl {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--gray-600);
	margin: 16px 0 7px;
}
.controls-card {
	background: var(--white);
	border-radius: var(--radius-md);
	padding: 13px;
	box-shadow: var(--shadow-sm);
	margin-bottom: 13px;
}
.controls-row {
	display: flex;
	gap: 9px;
	margin-bottom: 9px;
}
.controls-row .form-group {
	flex: 1;
	margin-bottom: 0;
}
.empty-state {
	text-align: center;
	padding: 36px 18px;
	color: var(--gray-600);
	grid-column: 1/-1;
}
.empty-icon {
	font-size: 42px;
	margin-bottom: 9px;
}
.empty-state h3 {
	font-size: 0.9rem;
	font-weight: 600;
	margin-bottom: 5px;
	color: var(--gray-800);
}
.empty-state p {
	font-size: 0.82rem;
}
.empty-state-action {
	padding: 48px 24px;
}
.empty-add-btn {
	margin-top: 16px;
	font-size: 0.88rem;
	padding: 10px 28px;
}

/* ── Empty filter banner (no data yet) ──────────────────────── */
.empty-filter-banner {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	margin-bottom: 14px;
	background: var(--blue-light);
	border: 1px solid rgba(26, 115, 232, 0.18);
	border-radius: var(--radius-sm);
}
.empty-filter-icon {
	font-size: 28px;
	flex-shrink: 0;
}
.empty-filter-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.empty-filter-text strong {
	font-size: 0.88rem;
	color: var(--gray-900);
}
.empty-filter-text span {
	font-size: 0.8rem;
	color: var(--gray-600);
}

/* ── Filter "Back to list" button ────────────────────────────── */
.filter-back-btn {
	display: inline-block;
	margin-top: 6px;
	background: none;
	border: none;
	color: var(--blue);
	font-size: 0.78rem;
	cursor: pointer;
	padding: 2px 0;
	font-weight: 500;
}
.filter-back-btn:hover {
	text-decoration: underline;
}

.hidden {
	display: none !important;
}
.mt-8 {
	margin-top: 8px;
}
.mt-12 {
	margin-top: 12px;
}
.mt-16 {
	margin-top: 16px;
}
.mb-12 {
	margin-bottom: 12px;
}
.mb-16 {
	margin-bottom: 16px;
}
.flex {
	display: flex;
}
.gap-8 {
	gap: 8px;
}
.gap-10 {
	gap: 10px;
}
.text-muted {
	color: var(--gray-600);
	font-size: 0.82rem;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
@keyframes shimmer {
	to {
		background-position: -200% 0;
	}
}
@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
@keyframes slideUp {
	from {
		transform: translateY(14px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}
@keyframes shake {
	0%,
	100% {
		transform: translateX(0);
	}
	20%,
	60% {
		transform: translateX(-5px);
	}
	40%,
	80% {
		transform: translateX(5px);
	}
}
.shake {
	animation: shake 0.38s ease;
}
