/* Component layer — plain CSS driven by theme variables, so it works with the Tailwind CDN or a compiled build.
   Z-index scale: header 40 · dropdown/sidebar 50 · modal 60 · lightbox 65 · toast 70 · skip-link 80 */
:root { --c-brand: 225 29 72; --c-accent: 15 23 42; --radius: .75rem; --font: Inter, ui-sans-serif, system-ui, sans-serif; }
body { font-family: var(--font); }
.rounded-theme { border-radius: var(--radius); }
[hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1.05rem; border-radius: var(--radius);
  font-weight: 600; font-size: .875rem; line-height: 1.25rem; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .12s ease, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgb(var(--c-brand) / .35); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-primary { background: rgb(var(--c-brand)); color: #fff; }
.btn-primary:hover { background: rgb(var(--c-brand) / .88); box-shadow: 0 8px 20px -8px rgb(var(--c-brand) / .7); }
.btn-accent { background: rgb(var(--c-accent)); color: #fff; }
.btn-accent:hover { background: rgb(var(--c-accent) / .85); }
.btn-ghost { background: transparent; color: inherit; border-color: rgb(148 163 184 / .45); }
.btn-ghost:hover { background: rgb(148 163 184 / .15); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; width: 1rem; height: 1rem; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.input { display: block; width: 100%; border: 1px solid #cbd5e1; border-radius: calc(var(--radius) * .7); padding: .55rem .75rem; font-size: .9rem;
  background: #fff; color: #0f172a; transition: border-color .2s, box-shadow .2s; }
.input:focus { outline: none; border-color: rgb(var(--c-brand)); box-shadow: 0 0 0 3px rgb(var(--c-brand) / .18); }
.file-input { padding: .4rem; font-size: .8rem; }
.label { display: block; font-size: .8rem; font-weight: 600; color: #334155; margin-bottom: .3rem; }
.field.has-error .input { border-color: #dc2626; }
input[type=checkbox].toggle, .check { width: 1.05rem; height: 1.05rem; accent-color: rgb(var(--c-brand)); }

/* Surfaces */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: var(--radius); box-shadow: 0 1px 2px rgb(15 23 42 / .04); }
.card-hover { transition: transform .25s ease, box-shadow .25s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgb(15 23 42 / .25); }
.badge { display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.badge-ok { background: #dcfce7; color: #166534; } .badge-warn { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; } .badge-muted { background: #f1f5f9; color: #475569; }
.badge-brand { background: rgb(var(--c-brand) / .12); color: rgb(var(--c-brand)); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 600; padding: .65rem .85rem; border-bottom: 1px solid #e2e8f0; background: #f8fafc; white-space: nowrap; }
.table td { padding: .65rem .85rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: #f8fafc; }

/* Navigation */
.nav-link { padding: .45rem .75rem; border-radius: calc(var(--radius) * .7); opacity: .85; transition: opacity .2s, background-color .2s; }
.nav-link:hover { opacity: 1; background: rgb(148 163 184 / .15); }
.dropdown-menu { opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
[data-dropdown].open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.menu-item { display: flex; flex-direction: column; padding: .5rem .7rem; border-radius: calc(var(--radius) * .7); font-size: .875rem; transition: background-color .15s; }
.menu-item small { color: #64748b; font-size: .75rem; }
.menu-item:hover { background: #f1f5f9; }
.mobile-menu { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.mobile-menu.open { max-height: 24rem; }

/* Tabs */
.tab-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; border-radius: var(--radius); font-size: .875rem; font-weight: 600; color: #475569; transition: background-color .2s, color .2s; white-space: nowrap; }
.tab-btn:hover { background: #f1f5f9; }
.tab-btn.active { background: rgb(var(--c-brand)); color: #fff; }
.tab-count { min-width: 1.25rem; padding: 0 .35rem; border-radius: 999px; font-size: .7rem; background: rgb(var(--c-brand) / .15); color: rgb(var(--c-brand)); text-align: center; }
.tab-btn.active .tab-count { background: rgb(255 255 255 / .25); color: #fff; }
[data-tab-panel]:not([hidden]) { animation: fadeUp .3s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgb(15 23 42 / .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; overflow-y: auto; opacity: 0; transition: opacity .2s ease; }
.modal-overlay.open { opacity: 1; }
.modal-panel { width: 100%; max-width: 40rem; background: #fff; border-radius: var(--radius); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .35);
  transform: translateY(14px) scale(.98); opacity: 0; transition: transform .26s cubic-bezier(.2,.8,.2,1), opacity .2s ease; }
.modal-sm { max-width: 26rem; } .modal-lg { max-width: 56rem; }
.modal-overlay.open .modal-panel { transform: none; opacity: 1; }
.modal-x { width: 2rem; height: 2rem; border-radius: 999px; font-size: 1.5rem; line-height: 1; color: #64748b; transition: background-color .15s; }
.modal-x:hover { background: #f1f5f9; }
body.modal-lock { overflow: hidden; }

/* Toasts */
.toast { opacity: 0; transform: translateY(10px); transition: opacity .3s ease, transform .3s ease; }
.toast.show { opacity: 1; transform: none; }

/* Gallery — uniform square grid with smooth fade/zoom */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
@media (min-width: 768px) { .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.g-item { position: relative; display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: var(--radius); background: #e2e8f0; }
.g-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.8,.2,1), opacity .5s ease; }
.js .g-item img[data-fade] { opacity: 0; }
.js .g-item img[data-fade].loaded { opacity: 1; }
.g-item:hover img { transform: scale(1.07); }
.g-item .g-cap { position: absolute; inset: auto 0 0 0; padding: .6rem .7rem; font-size: .75rem; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / .65)); opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
.g-item:hover .g-cap { opacity: 1; transform: none; }
.g-item.dragging { opacity: .4; }
.g-item.selected { outline: 3px solid rgb(var(--c-brand)); outline-offset: 2px; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 65; background: rgb(2 6 23 / .92); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .25s ease; }
.lightbox.open { opacity: 1; }
.lb-figure { max-width: 92vw; max-height: 88vh; text-align: center; }
.lb-figure img { max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: .5rem; opacity: 0; transform: scale(.97); transition: opacity .3s, transform .3s; }
.lb-figure img.loaded { opacity: 1; transform: none; }
.lb-figure figcaption { color: #cbd5e1; font-size: .875rem; margin-top: .6rem; }
.lb-btn { position: absolute; color: #fff; font-size: 2.4rem; width: 3rem; height: 3rem; border-radius: 999px; background: rgb(255 255 255 / .08); transition: background-color .2s; }
.lb-btn:hover { background: rgb(255 255 255 / .2); }
.lb-close { top: 1rem; right: 1rem; } .lb-prev { left: 1rem; } .lb-next { right: 1rem; }

/* Map: own stacking context keeps Leaflet's internal z-indexes (400–1000) under the sticky header & modals */
.map-wrap { position: relative; z-index: 0; isolation: isolate; }
.map-canvas { height: 100%; min-height: 320px; background: #e2e8f0; }

/* Scroll reveal */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); }
.js .reveal.in { opacity: 1; transform: none; }

/* Admin */
.admin-sidebar { transform: translateX(-100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.admin-sidebar.open { transform: none; }
@media (min-width: 1024px) { .admin-sidebar { transform: none; } }
.sidebar-backdrop { opacity: 0; pointer-events: none; transition: opacity .25s; }
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
.side-link { width: 100%; display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: calc(var(--radius) * .7); text-align: left; transition: background-color .15s, color .15s; }
.side-link:hover { background: rgb(255 255 255 / .06); color: #fff; }
.side-link.active { background: rgb(var(--c-brand)); color: #fff; }
.dropzone { border: 2px dashed #cbd5e1; border-radius: var(--radius); transition: border-color .2s, background-color .2s; }
.dropzone.over { border-color: rgb(var(--c-brand)); background: rgb(var(--c-brand) / .05); }
.progress { height: .4rem; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: rgb(var(--c-brand)); transition: width .2s; }

[data-unread] { position: relative; }
[data-unread]::before { content: ''; position: absolute; left: .4rem; top: 50%; width: .45rem; height: .45rem; margin-top: -.22rem; border-radius: 999px; background: rgb(var(--c-brand)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
