:root {
	--navy: #283583;
	--navy-dark: #1b2462;
	--red: #c8102e;
	--ink: #1f2430;
	--muted: #5c6475;
	--line: #e3e6ef;
	--bg: #f2f4f9;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--navy); }
a:hover { color: var(--red); }
h1 { font-size: 1.6rem; margin: 0 0 18px; color: var(--navy-dark); }
h2 { font-size: 1.15rem; margin: 0 0 12px; color: var(--navy-dark); }
code { background: #eef0f7; padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; height: auto; }

/* Top bar */
.admin-top { background: #fff; border-bottom: 3px solid var(--navy); display: flex; align-items: center; gap: 20px; padding: 0 20px; min-height: 64px; position: sticky; top: 0; z-index: 20; }
.admin-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy-dark); font-weight: 700; white-space: nowrap; }
.admin-brand img { height: 44px; width: auto; }
.admin-panel { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.admin-nav { flex: 1; }
.admin-menu, .admin-sub { list-style: none; margin: 0; padding: 0; }
.admin-menu { display: flex; align-items: center; gap: 2px; }
.admin-menu > li { position: relative; }
.admin-link { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.admin-link svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.admin-link:hover, .admin-link.active, .admin-group.active > .admin-link, .admin-group.open > .admin-link { background: rgba(40, 53, 131, 0.09); color: var(--navy); }
.admin-link.active, .admin-group.active > .admin-link { font-weight: 600; }
.admin-group.open > .admin-link svg { transform: rotate(180deg); }
.admin-link:focus-visible, .admin-sub a:focus-visible, .admin-user a:focus-visible, .link-button:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.admin-sub { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: #fff; border-top: 3px solid var(--red); border-radius: 8px; box-shadow: 0 10px 28px rgba(27, 36, 98, 0.18); padding: 6px; z-index: 30; }
.admin-sub::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.admin-group.open > .admin-sub { display: block; }
.admin-sub a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.admin-sub a:hover, .admin-sub a.active { background: rgba(40, 53, 131, 0.08); color: var(--navy); }
.admin-sub a.active { font-weight: 600; }
.nav-badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 0.75rem; font-weight: 700; line-height: 1.4; text-align: center; }
.admin-user { display: flex; align-items: center; gap: 4px; }
.admin-user a { padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.admin-user a:hover, .admin-user a.active { background: rgba(40, 53, 131, 0.09); color: var(--navy); }
.admin-user form { margin: 0; }
.link-button { background: none; border: 0; padding: 8px 12px; font: inherit; color: var(--red); cursor: pointer; border-radius: 6px; }
.link-button:hover { background: rgba(200, 16, 46, 0.08); }
.admin-nav-toggle { display: none; margin-left: auto; background: var(--navy); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
@media (min-width: 1041px) and (hover: hover) {
	.admin-group:hover > .admin-sub { display: block; }
	.admin-group:hover > .admin-link svg { transform: rotate(180deg); }
}
@media (max-width: 1040px) {
	.admin-top { flex-wrap: wrap; gap: 12px; padding: 8px 16px; min-height: 60px; }
	.admin-brand img { height: 38px; }
	.admin-brand span { font-size: 0.95rem; }
	.admin-nav-toggle { display: block; }
	.admin-panel { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; padding: 4px 0 12px; max-height: calc(100vh - 70px); overflow-y: auto; }
	.admin-top.open .admin-panel { display: flex; }
	.admin-menu { flex-direction: column; align-items: stretch; gap: 0; }
	.admin-menu > li { border-top: 1px solid var(--line); padding: 6px 0; }
	.admin-group > .admin-link { cursor: default; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 6px 12px 2px; background: none; pointer-events: none; }
	.admin-group > .admin-link svg { display: none; }
	.admin-group.active > .admin-link { background: none; color: var(--muted); }
	.admin-sub, .admin-group.open > .admin-sub { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px; position: static; min-width: 0; padding: 0; border: 0; box-shadow: none; background: none; }
	.admin-sub::before { display: none; }
	.admin-user { border-top: 1px solid var(--line); padding-top: 10px; flex-wrap: wrap; }
}

.admin-main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.panel { background: #fff; border-radius: 10px; box-shadow: 0 1px 6px rgba(27, 36, 98, 0.07); padding: 20px; margin-bottom: 20px; }
.hint { color: var(--muted); font-size: 0.88rem; font-weight: 400; }
.required { color: var(--red); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid; margin-bottom: 16px; }
.alert-success { background: #ecf8f0; border-color: #b7e2c4; color: #1d6b37; }
.alert-error { background: #fdeeee; border-color: #f2c0c0; color: #9b1c1c; }
.alert-info { background: #eef2fd; border-color: #c5d0f5; color: #24357f; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-light { background: #fff; }
.btn-success { background: #1f8a4c; border-color: #1f8a4c; color: #fff; }
.btn-success:hover { background: #17703d; color: #fff; border-color: #17703d; }
.btn-warning { background: #fff7e6; border-color: #f0c36d; color: #8a5a00; }
.btn-danger { background: #fff; border-color: #f0b8b8; color: #b3122b; }
.btn-danger:hover { background: #b3122b; color: #fff; border-color: #b3122b; }
.btn-small { padding: 5px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 10px; box-shadow: 0 1px 6px rgba(27, 36, 98, 0.07); padding: 18px; text-decoration: none; color: var(--muted); border-left: 4px solid var(--navy); }
.stat-card strong { display: block; font-size: 1.9rem; color: var(--navy-dark); }
.stat-card.stat-alert { border-left-color: var(--red); }
.stat-card.stat-alert strong { color: var(--red); }

/* Lists */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar h2, .toolbar p { margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 7px; text-decoration: none; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-row input { flex: 1 1 260px; padding: 9px 12px; border: 1px solid #cfd4e2; border-radius: 7px; font: inherit; }
.search-row select { padding: 9px 12px; border: 1px solid #cfd4e2; border-radius: 7px; font: inherit; background: #fff; }
.memoriam-tag { display: inline-block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; background: #4a5060; color: #fff; border-radius: 4px; padding: 1px 6px; vertical-align: middle; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: 0 1px 6px rgba(27, 36, 98, 0.07); }
.panel .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: #fafbfd; }
.table tbody tr:hover { background: #fafbff; }
.thumb-col { width: 56px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; display: block; }
.actions-col { text-align: right; white-space: nowrap; }
.inline-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.actions-col .inline-actions { flex-wrap: nowrap; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span { padding: 5px 11px; border-radius: 6px; background: #fff; border: 1px solid var(--line); text-decoration: none; }
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full, .form-grid h2 { grid-column: 1 / -1; }
.form-grid h2 { margin: 8px 0 0; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0; }
.field > input, .field > select, .field > textarea, .field > .pass-wrap, .field > .hint { display: block; margin-top: 6px; }
.field > .tox-tinymce { margin-top: 6px; }
.field > .hint { font-weight: 400; }
.auth-card .field { margin-bottom: 14px; }
.field input, .field select, .field textarea { font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #cfd4e2; border-radius: 7px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus, .search-row input:focus { outline: 2px solid rgba(40, 53, 131, 0.3); border-color: var(--navy); }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form-actions { display: flex; gap: 10px; }
.danger-zone { margin-top: 10px; text-align: right; }
.image-input { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.image-input legend { font-weight: 700; padding: 0 6px; color: var(--navy-dark); }
.image-preview { max-height: 110px; width: auto; align-self: flex-start; background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.doc-preview { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.install-list { padding-left: 20px; }

/* Menu and pages */
.menu-indent { display: inline-block; width: calc(var(--depth, 0) * 28px); }
.menu-level-2 td:first-child, .menu-level-3 td:first-child { color: var(--muted); }
.menu-level-2 .menu-indent::after, .menu-level-3 .menu-indent::after { content: "\2514"; float: right; margin-right: 8px; color: #b6bccd; }
.level-tag { font-size: 0.75rem; background: #eef0f7; color: var(--muted); border-radius: 99px; padding: 1px 8px; margin-left: 6px; }
.btn:disabled { opacity: 0.35; cursor: default; border-color: var(--line); color: var(--ink); }
.link-choice { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.link-choice legend { font-weight: 700; padding: 0 6px; color: var(--navy-dark); }
.link-option { margin: 0 0 6px 26px; display: flex; flex-direction: column; gap: 6px; }
.link-option[hidden] { display: none; }
.link-option select, .link-option input { font: inherit; padding: 9px 12px; border: 1px solid #cfd4e2; border-radius: 7px; max-width: 520px; }
.slide-thumb-col { width: 150px; }
.slide-thumb { width: 130px; height: 60px; object-fit: cover; border-radius: 6px; display: block; background: #eef0f7; }
.committee-add { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 14px; align-items: end; }
@media (max-width: 760px) { .committee-add { grid-template-columns: 1fr; } }
.thumb-initials { display: flex; align-items: center; justify-content: center; background: var(--navy); color: #fff; font-weight: 700; font-size: 0.85rem; }
.committee-who { display: flex; gap: 14px; align-items: center; }
.committee-who img { width: 64px; height: 80px; object-fit: cover; object-position: center top; border-radius: 6px; }
.person-thumb { width: 44px; height: 58px; object-fit: cover; object-position: center top; border-radius: 4px; display: block; }
.map-admin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.map-preview { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 860px) { .map-admin { grid-template-columns: 1fr; } }
.slide-speed { align-items: center; margin: 14px 0 0; }
.slide-speed input { flex: 0 0 80px; }
.tox-tinymce { border-radius: 8px !important; border-color: #cfd4e2 !important; }

/* Show/hide password */
.pass-wrap { position: relative; display: block; }
.pass-wrap input { padding-right: 46px; }
.pass-toggle { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: #5c6475; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pass-toggle:hover, .pass-toggle:focus-visible { background: rgba(40, 53, 131, 0.09); color: var(--navy); outline: none; }
.pass-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Login, forgot and reset pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #eef0f8 0%, #dfe3f2 100%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(27, 36, 98, 0.14); padding: 28px 28px 20px; border-top: 4px solid var(--navy); }
.auth-logo { text-align: center; margin-bottom: 6px; }
.auth-logo img { max-height: 110px; width: auto; }
.auth-title { text-align: center; font-size: 1.3rem; margin: 10px 0 20px; }
.auth-links { text-align: center; margin: 16px 0 0; }
.auth-home { text-align: center; margin: 18px 0 0; font-size: 0.88rem; border-top: 1px solid var(--line); padding-top: 14px; }
.auth-home a { color: var(--muted); text-decoration: none; }
