:root {
  --bg: #eef2ef;
  --bg-elevated: #fbfcfb;
  --ink: #14201b;
  --muted: #5a6b63;
  --line: #d5ddd8;
  --accent: #0d6b56;
  --accent-soft: rgba(13, 107, 86, 0.1);
  --accent-hover: #095544;
  --danger: #a33b3b;
  --ok: #1f6b3a;
  --shadow: 0 12px 32px rgba(20, 32, 27, 0.07);
  --shadow-hover: 0 18px 40px rgba(20, 32, 27, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -8%, #d9ebe4 0%, transparent 55%),
    radial-gradient(800px 380px at 100% 0%, #e8e4d8 0%, transparent 50%),
    linear-gradient(180deg, #f4f7f5 0%, var(--bg) 40%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
a:hover { color: var(--accent-hover); }

.icon {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}
.icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* —— Topbar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 252, 251, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(213, 221, 216, 0.85);
  transition: box-shadow 0.25s var(--ease);
}

.topbar.is-scrolled {
  box-shadow: 0 8px 24px rgba(20, 32, 27, 0.06);
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: transform 0.25s var(--ease);
}
.brand:hover {
  transform: translateY(-1px);
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: linear-gradient(145deg, #127a63, #0a4f40);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(13, 107, 86, 0.28);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.brand:hover .brand-mark {
  transform: rotate(-6deg) scale(1.05);
  box-shadow: 0 8px 18px rgba(13, 107, 86, 0.35);
}
.brand-icon { width: 1.05rem; height: 1.05rem; color: #fff; }
.brand-text { font-size: 1.05rem; }

.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.15rem 0;
}
.nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  position: relative;
  transition:
    color 0.22s var(--ease),
    background 0.22s var(--ease),
    transform 0.22s var(--ease),
    box-shadow 0.22s var(--ease);
}
.nav-link .icon {
  width: 0.95rem;
  height: 0.95rem;
  transition: transform 0.28s var(--ease), color 0.22s var(--ease);
}
.nav-link:hover {
  color: var(--ink);
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateY(-1px);
}
.nav-link:hover .icon {
  transform: translateY(-2px) scale(1.12);
  color: var(--accent);
}
.nav-link.is-active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(13, 107, 86, 0.25);
}
.nav-link.is-active .icon {
  color: #fff;
  transform: none;
}
.nav-link.is-active:hover {
  background: var(--accent-hover);
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: 12px;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.nav-toggle:hover {
  background: #fff;
  border-color: #bcc9c2;
}

.burger {
  width: 1.1rem;
  height: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.burger span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.28s var(--ease), opacity 0.2s ease;
  transform-origin: center;
}
.nav-toggle.is-open .burger span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
.nav-toggle.is-open .burger span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open .burger span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

.nav-mobile {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 1rem 1.1rem;
  border-top: 1px solid var(--line);
  animation: slideDown 0.28s var(--ease);
}
.nav-mobile:not([hidden]) { display: flex; }

.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.nav-mobile-link .icon {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--accent);
  transition: transform 0.25s var(--ease);
}
.nav-mobile-link:hover,
.nav-mobile-link.is-active {
  background: var(--accent-soft);
  text-decoration: none;
}
.nav-mobile-link:hover .icon {
  transform: scale(1.12) rotate(-4deg);
}
.nav-mobile-link.is-active {
  background: var(--accent);
  color: #fff;
}
.nav-mobile-link.is-active .icon { color: #fff; }

.nav-mobile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* —— Main —— */
.main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

.page-head,
.hero-home {
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-head h1,
.hero-home h1 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.45;
  font-size: 0.95rem;
}

/* —— Cards —— */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.card-grid-fit {
  align-content: start;
}

.panel-card {
  --delay: 0ms;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  color: inherit;
  transition:
    transform 0.25s var(--ease),
    border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease),
    background 0.25s var(--ease);
}
.panel-card:hover {
  transform: translateY(-2px);
  border-color: #b7cfc6;
  box-shadow: var(--shadow-hover);
  background: #fff;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.panel-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.75;
  display: grid;
  place-items: center;
  transition: opacity 0.2s var(--ease), transform 0.25s var(--ease);
}
.panel-icon .icon {
  width: 1.05rem;
  height: 1.05rem;
}
.panel-card:hover .panel-icon {
  opacity: 1;
  transform: scale(1.08);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

.panel-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
}

.panel-cta {
  align-self: flex-start;
  margin-top: 0.15rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  text-decoration: none;
}
.panel-cta:hover {
  text-decoration: none;
  color: #fff;
}

.reveal {
  animation: riseIn 0.45s var(--ease) both;
  animation-delay: var(--delay, 0ms);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* —— Buttons —— */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 11px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition:
    transform 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    color 0.2s var(--ease);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(20, 32, 27, 0.08);
}
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-danger {
  background: #fff5f5;
  border-color: #e8b4b4;
  color: var(--danger);
}
.btn-danger:hover { background: #ffe8e8; }

.btn-ghost {
  background: transparent;
}
.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: transparent;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.btn-icon .icon {
  width: 1rem;
  height: 1rem;
}

.inline { display: inline; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

input[type="text"],
input[type="password"],
input[type="url"] {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-weight: 500;
  background: #fff;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus {
  outline: none;
  border-color: #8fb8ab;
  box-shadow: 0 0 0 4px rgba(13, 107, 86, 0.12);
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.form-row.compact { margin-bottom: 0.6rem; }

.alert {
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  animation: riseIn 0.35s var(--ease);
}
.alert-ok {
  background: #e8f6ec;
  color: var(--ok);
  border: 1px solid #b7dfc2;
}
.alert-error {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #efc0c0;
}

/* —— Login —— */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.25rem;
  background:
    radial-gradient(700px 360px at 15% 10%, #d5ebe3 0%, transparent 55%),
    radial-gradient(600px 320px at 90% 90%, #ebe6d8 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: rgba(251, 252, 251, 0.94);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.75rem 1.6rem;
  box-shadow: var(--shadow-hover);
  animation: riseIn 0.5s var(--ease);
  backdrop-filter: blur(8px);
}
.login-card h1 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
}
.login-card .btn-primary {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.25rem;
}

/* —— Embed / links —— */
.embed-wrap {
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: min(78vh, 900px);
  box-shadow: var(--shadow);
}
.embed-wrap iframe {
  width: 100%;
  height: min(78vh, 900px);
  min-height: 560px;
  border: 0;
  display: block;
  background: #f3f3f3;
}
.embed-help {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 52rem;
}
.embed-help code {
  font-size: 0.82em;
  background: rgba(20, 32, 27, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.page-head-compact {
  margin-bottom: 0.85rem;
}
.page-head-compact .lede {
  margin-top: 0.35rem;
}

.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.dash-open {
  display: flex;
  justify-content: flex-start;
  padding: 0.5rem 0 1rem;
}

.btn-xl {
  padding: 1.05rem 1.6rem;
  font-size: 1.15rem;
  border-radius: 14px;
  min-width: min(100%, 320px);
  gap: 0.65rem;
  box-shadow: 0 12px 28px rgba(13, 107, 86, 0.22);
}
.btn-xl .icon {
  width: 1.35rem;
  height: 1.35rem;
}
.btn-xl:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(13, 107, 86, 0.28);
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

/* Modal */
body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal[hidden] { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 32, 27, 0.45);
  backdrop-filter: blur(3px);
  animation: riseIn 0.2s var(--ease);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-hover);
  padding: 1.15rem 1.2rem 1.25rem;
  animation: riseIn 0.28s var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}
.modal-body { margin: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.link-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem 1rem;
  align-items: start;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.link-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #b7cfc6;
}
.link-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.link-delete {
  margin-top: 0.45rem;
}
.link-manage {
  max-width: 520px;
}
.link-manage .stack .btn {
  align-self: flex-start;
}
.link-item-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  transition: transform 0.28s var(--ease), background 0.28s var(--ease), color 0.28s var(--ease);
}
.link-item:hover .link-item-icon {
  transform: scale(1.08);
  background: var(--accent);
  color: #fff;
}
.link-title {
  font-weight: 750;
  font-size: 1.05rem;
  color: var(--ink);
  transition: color 0.2s var(--ease);
}
.link-item:hover .link-title { color: var(--accent); }
.link-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  background: var(--bg-elevated);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2.25rem 1.5rem;
  text-align: center;
}

/* —— Admin —— */
.admin-grid {
  display: grid;
  gap: 1.25rem;
}

.admin-block {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s var(--ease);
}
.admin-block:hover { box-shadow: var(--shadow-hover); }
.admin-block h2 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.admin-block h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.admin-form {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  margin-bottom: 0.75rem;
  background: #fff;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.user-card:hover {
  border-color: #c5d4cd;
  box-shadow: 0 8px 20px rgba(20, 32, 27, 0.05);
}
.user-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.access-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.access-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0;
}
.access-pages.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.admin-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.admin-link-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

/* —— Mobile —— */
@media (max-width: 920px) {
  .nav-label { display: none; }
  .nav-link {
    padding: 0.55rem;
    border-radius: 12px;
  }
  .nav-link .icon { width: 1.25rem; height: 1.25rem; }
  .user-name { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 58px; }

  .nav,
  .topbar-right { display: none; }

  .nav-toggle { display: inline-flex; margin-left: auto; }

  .main { padding: 1.25rem 1rem 2.5rem; }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .panel-card {
    padding: 0.85rem 0.95rem;
  }

  .panel-head h2 {
    font-size: 1.1rem;
  }

  .page-head-row .btn {
    width: 100%;
  }
  .btn-xl {
    width: 100%;
    min-width: 0;
  }
  .embed-wrap iframe {
    height: 70vh;
    min-height: 420px;
  }
  .embed-wrap { min-height: 70vh; }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .form-row .btn,
  .form-row input {
    width: 100%;
  }

  .admin-link-list li {
    flex-direction: column;
    gap: 0.65rem;
  }

  .login-card { padding: 1.4rem 1.2rem; }

  .btn-icon span { display: none; }
  .nav-mobile-footer .btn-icon span { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
