:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2937;
  --accent: #0f766e;
  --danger: #b91c1c;
  --border: #d1d5db;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 400px at top left, color-mix(in srgb, var(--accent) 10%, #fff), var(--bg));
  color: var(--text);
  overflow-x: hidden;
}
img, video, iframe { max-width: 100%; height: auto; }
.site-banner {
  height: var(--banner-height, 140px);
  width: 100%;
  background-color: #f3f4f6;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.site-banner-link {
  display: block;
  text-decoration: none;
}
.site-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--banner-url);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  opacity: var(--banner-bg-alpha, 0.10);
  pointer-events: none;
  z-index: 0;
}
.site-banner-foreground {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: auto;
  max-width: 100%;
  height: var(--banner-foreground-height, 100%);
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}
.topbar { position: sticky; top: 0; z-index: 20; display:flex; justify-content:space-between; align-items:center; gap:1rem; padding:0.8rem 1.2rem; background:color-mix(in srgb, var(--surface) 88%, white); backdrop-filter: blur(8px); border-bottom:1px solid var(--border); flex-wrap: wrap; }
.brand-block h1 { margin: 0; font-size: 1.15rem; }
.muted { margin: 0.2rem 0 0; font-size: 0.8rem; opacity: 0.75; }
.menu-toggle { display:none; }
.main-nav { display:flex; align-items:center; gap:0.5rem; flex-wrap:wrap; }
.main-nav a { text-decoration:none; color:var(--text); padding:0.45rem 0.7rem; border-radius:999px; border:1px solid transparent; }
.main-nav a:hover { border-color: var(--border); background: color-mix(in srgb, var(--accent) 9%, white); }
.container { width: min(1100px, 100%); margin:1.2rem auto 2rem; padding:0 1rem; }
.container-wide { width: 100%; max-width: none; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:1rem; box-shadow: 0 6px 20px rgba(0,0,0,0.04); }
.document-subcard { background: var(--document-subcard-bg, #ffffff); }
.photo-subcard { background: var(--photo-subcard-bg, #ffffff); }
.narrow { max-width:520px; margin:0 auto; }
.login-card.login-text-top { display: flex; flex-direction: column; justify-content: flex-start; min-height: 540px; }
.login-card.login-text-center { display: flex; flex-direction: column; justify-content: center; min-height: 540px; }
.login-card.login-text-bottom { display: flex; flex-direction: column; justify-content: flex-end; min-height: 540px; }
.login-image-wrap { margin: 0.5rem 0 0.8rem; }
.login-image {
  width: 100%;
  max-height: var(--login-image-height, 260px);
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.login-message {
  font-size: var(--login-text-size, 16px);
}
.login-card.login-image-left .login-image { object-position: left center; }
.login-card.login-image-center .login-image { object-position: center center; }
.login-card.login-image-right .login-image { object-position: right center; }
label { display:block; margin-top:0.75rem; }
input, button, select, textarea { width:100%; max-width:100%; margin-top:0.35rem; padding:0.65rem 0.75rem; border-radius:10px; border:1px solid var(--border); background:#fff; }
button { cursor:pointer; }
.btn { width:auto; display:inline-flex; align-items:center; justify-content:center; gap:0.35rem; padding:0.5rem 0.8rem; border-radius:10px; border:1px solid var(--border); background:var(--accent); color:#fff; }
.btn-ghost { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.alert { background:#fee2e2; color:var(--danger); border:1px solid #fecaca; border-radius:8px; padding:0.75rem; margin-bottom:0.75rem; }
.flash { padding:0.6rem 0.8rem; border-radius:8px; background:#ecfeff; border:1px solid #a5f3fc; }
.table { width:100%; border-collapse:collapse; margin-top:1rem; font-size:0.92rem; }
.table th, .table td { border-bottom:1px solid var(--border); padding:0.55rem; text-align:left; vertical-align:top; }
.inline-form { display:inline-block; margin-right:0.35rem; }
.inline-form input, .inline-form button, .inline-form select { width:auto; padding:0.35rem 0.5rem; margin-top:0; }
.roles-box { border:1px solid var(--border); border-radius:8px; padding:0.4rem; }
.role-item { display:flex; gap:0.45rem; align-items:center; margin-bottom:0.35rem; }
.gallery { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:0.8rem; }
.thumb { margin:0; border:1px solid var(--border); border-radius:8px; padding:0.4rem; }
.thumb img {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border-radius: 6px;
  background: #f3f4f6;
}
.thumb video {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border-radius: 6px;
  background: #f3f4f6;
}
select[multiple] { width:100%; min-height:120px; }

.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; padding: 1rem; z-index: 40; }
.modal { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal-header { display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); padding:0.8rem 1rem; }
.modal-body { padding: 1rem; }
main, section, article, form { min-width: 0; }

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; width:auto; margin-left:auto; padding:0.45rem 0.7rem; border-radius:9px; border:1px solid var(--border); background:#fff; }
  .main-nav { display:none; width:100%; flex-direction:column; align-items:stretch; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:0.5rem; order:3; }
  .main-nav.open { display:flex; }
  .topbar { align-items:flex-start; }
  .brand-block { max-width: calc(100% - 90px); }
}

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

.dashboard-3cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-3cards { grid-template-columns: 1fr; }
}

.dashboard-3col {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1rem;
}

.blog-mini {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.blog-mini img {
  width: 110px;
  height: auto;
  max-height: 140px;
  object-fit: contain;
  border-radius: 10px;
  background: #f3f4f6;
}
.blog-mini h4 {
  margin: 0;
  font-size: 0.95rem;
}
.blog-mini p {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.35;
}
.blog-mini.no-image {
  grid-template-columns: 1fr;
}
.ref-select-btn {
  min-height: 34px;
  padding: 0.35rem 0.65rem;
  font-size: 0.92rem;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
}

.photos-only-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.photos-only-grid img {
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

@media (max-width: 1024px) {
  .dashboard-3col { grid-template-columns: 1fr; }
}

.zoomable-image {
  cursor: zoom-in;
}

.zoom-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.zoom-full {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 10px;
}

.welcome-strip {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  align-items: center;
}
.rotating-banner {
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-size: cover;
  background-position: center;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}
.stats-grid h3 { margin: 0; font-size: 1.6rem; }
.stats-grid p { margin: 0.2rem 0 0; }
.app-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, white);
}
.app-footer .container { margin: 0 auto; padding: 0.9rem 1rem; }
.app-footer p { margin: 0; font-size: 0.9rem; opacity: 0.85; }
.click-card { display:block; color: inherit; text-decoration:none; }
.click-card:hover { opacity: 0.95; }

@media (max-width: 1024px) {
  .welcome-strip { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.wysiwyg-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}

.wysiwyg-editor {
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fff;
}

.post-content img {
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.library-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  max-height: 55vh;
  overflow: auto;
}

.lib-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
}

.lib-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, white);
}

.lib-photo-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.6rem;
  align-items: center;
}

.lib-photo-thumb {
  width: 90px;
  height: 70px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f3f4f6;
}

.marquee-wrap {
  margin-top: 0.7rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, white);
}

.marquee-track {
  display: inline-block;
  white-space: nowrap;
  padding: 0.45rem 0.9rem;
  animation: marqueeSlide 18s linear infinite;
  font-weight: 600;
}

@keyframes marqueeSlide {
  0% { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon .ico {
  line-height: 1;
  font-size: 0.95rem;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.list-no-bullets {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.welcome-marquee-full {
  grid-column: 1 / -1;
  margin-top: 0.2rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--marquee-bg, #e8f6f4);
  color: var(--marquee-text, #1f2937);
}

.btn,
.btn:link,
.btn:visited,
.btn:hover,
.btn:active,
.btn:focus,
.btn-ghost,
.btn-ghost:link,
.btn-ghost:visited,
.btn-ghost:hover,
.btn-ghost:active,
.btn-ghost:focus,
.btn-icon,
.btn-icon:link,
.btn-icon:visited,
.btn-icon:hover,
.btn-icon:active,
.btn-icon:focus {
  text-decoration: none;
}

.activities-compact {
  max-height: 210px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.activities-compact ul {
  margin: 0;
  padding-left: 1.1rem;
}

.activities-compact li {
  margin-bottom: 0.35rem;
}

.site-banner {
  position: relative;
}

.site-banner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  z-index: 2;
}

.site-banner-overlay span {
  background: rgba(15, 23, 42, 0.55);
  color: var(--banner-text-color, #ffffff);
  font-size: var(--banner-text-size, 28px);
  font-weight: 700;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  text-align: center;
  max-width: 92%;
}

.site-banner-overlay.pos-top-left { align-items: flex-start; justify-content: flex-start; }
.site-banner-overlay.pos-top-center { align-items: flex-start; justify-content: center; }
.site-banner-overlay.pos-top-right { align-items: flex-start; justify-content: flex-end; }
.site-banner-overlay.pos-center-left { align-items: center; justify-content: flex-start; }
.site-banner-overlay.pos-center { align-items: center; justify-content: center; }
.site-banner-overlay.pos-center-right { align-items: center; justify-content: flex-end; }
.site-banner-overlay.pos-bottom-left { align-items: flex-end; justify-content: flex-start; }
.site-banner-overlay.pos-bottom-center { align-items: flex-end; justify-content: center; }
.site-banner-overlay.pos-bottom-right { align-items: flex-end; justify-content: flex-end; }

@media (max-width: 768px) {
  .container { padding: 0 0.7rem; margin-top: 0.8rem; }
  .card { padding: 0.8rem; border-radius: 12px; }
  .row-actions { flex-direction: column; align-items: flex-start; }
  .blog-mini { grid-template-columns: 1fr; }
  .blog-mini img { width: 100%; max-height: 220px; }
  .photos-only-grid { grid-template-columns: 1fr 1fr; }
  .table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { white-space: nowrap; }
  .inline-form { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
  .inline-form input, .inline-form button, .inline-form select { max-width: 100%; }
}

@media (max-width: 520px) {
  .topbar { padding: 0.7rem; }
  .brand-block h1 { font-size: 1rem; }
  .photos-only-grid { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .modal { width: 100%; border-radius: 12px; }
  .modal-header, .modal-body { padding: 0.75rem; }
  .activities-compact { max-height: 160px; }
}
