:root {
  --green: #4CAF50;
  --green-dark: #3d9440;
  --green-soft: #eaf7eb;
  --bg: #FFFFFF;
  --ink: #14201a;
  --muted: #7b8a82;
  --line: #ececec;
  --line-soft: #f4f4f4;
  --shadow: 0 10px 30px rgba(20, 32, 26, 0.06);
  --shadow-hover: 0 18px 44px rgba(76, 175, 80, 0.16);
  --radius: 24px;
  --radius-sm: 16px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body { background: var(--bg); }

body {
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

::selection { background: var(--green); color: #fff; }

a { color: var(--green-dark); text-decoration: none; }

/* ---------------- Header ---------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(20,32,26,0.05);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img { height: 64px; width: auto; display: block; filter: drop-shadow(0 4px 10px rgba(76,175,80,0.22)); transition: transform .25s ease; }
.brand:hover img { transform: translateY(-1px) scale(1.02); }
.brand .brand-sub {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------- Buttons ---------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .2s var(--spring), box-shadow .2s var(--spring), background-color .2s ease, color .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(1px) scale(.94); }
.btn-primary {
  background: var(--green); color: #fff;
  box-shadow: 0 6px 0 var(--green-dark), 0 14px 22px rgba(76,175,80,0.30);
}
.btn-primary:hover {
  background: var(--green);
  box-shadow: 0 8px 0 var(--green-dark), 0 18px 30px rgba(76,175,80,0.40);
  transform: translateY(-3px) scale(1.04);
}
.btn-primary:active {
  transform: translateY(3px) scale(.97);
  box-shadow: 0 2px 0 var(--green-dark), 0 6px 12px rgba(76,175,80,0.28);
}
.btn-ghost { background: #fff; color: var(--green-dark); border: 2px solid var(--green); box-shadow: 0 4px 0 rgba(76,175,80,0.18); }
.btn-ghost:hover { background: var(--green-soft); box-shadow: 0 6px 0 rgba(76,175,80,0.22); }
.btn-ghost:active { transform: translateY(2px) scale(.96); box-shadow: 0 2px 0 rgba(76,175,80,0.16); }
.btn-outline { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-outline:hover { border-color: var(--green); color: var(--green-dark); }
.btn-danger { background: #fff; color: #c0392b; border: 2px solid #f0d3ce; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 9px 16px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ---------------- Hero ---------------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 24px 24px;
}
.hero h1 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  max-width: 16ch;
}
.hero h1 .accent { color: var(--green); font-style: italic; display: inline-block; animation: float 3.2s ease-in-out infinite; }
.hero p {
  margin-top: 18px;
  color: var(--muted);
  font-size: 17px;
  max-width: 52ch;
}
.hero-meta {
  margin-top: 26px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.hero-meta .stat { display: flex; flex-direction: column; }
.hero-meta .stat b { font-family: var(--font-head); font-size: 26px; color: var(--ink); }
.hero-meta .stat span { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------------- Filters ---------------- */
.filters {
  max-width: 1200px;
  margin: 8px auto 0;
  padding: 18px 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: transform .2s var(--spring), background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.chip:hover { border-color: var(--green); color: var(--green-dark); transform: translateY(-2px) scale(1.06); }
.chip:active { transform: scale(.93); }
.chip.active {
  background: var(--green); border-color: var(--green); color: #fff;
  box-shadow: 0 5px 0 var(--green-dark), 0 10px 16px rgba(76,175,80,0.25);
  transform: translateY(-1px);
  animation: pop .35s var(--spring) both;
}

/* ---------------- Grid ---------------- */
.grid-wrap { max-width: 1200px; margin: 0 auto; padding: 14px 24px 80px; perspective: 1400px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 26px;
  perspective: 1400px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-style: preserve-3d;
  will-change: transform;
  box-shadow: 0 2px 6px rgba(20,32,26,0.05), 0 12px 24px rgba(20,32,26,0.05);
  transition: transform .3s var(--spring), box-shadow .3s ease, border-color .25s ease;
  animation: rise .5s ease both;
}
.card:hover {
  transform: translateY(-10px) scale(1.025);
  box-shadow: 0 10px 22px rgba(76,175,80,0.14), 0 30px 56px rgba(20,32,26,0.18);
  border-color: #cdeccd;
}
.card-cover {
  aspect-ratio: 4 / 3;
  background: var(--line-soft);
  overflow: hidden;
  position: relative;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.card:hover .card-cover img { transform: scale(1.05); }
.card-tag {
  position: absolute; top: 12px; left: 12px;
  background: var(--green);
  color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 13px; border-radius: 999px;
  box-shadow: 0 5px 0 var(--green-dark), 0 8px 14px rgba(76,175,80,0.28);
  animation: pop .5s var(--spring) both;
}
.card-body { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.card-actions { display: flex; gap: 10px; margin-top: auto; }
.card-actions .btn { flex: 1; }

/* ---------------- Empty / loading ---------------- */
.state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.state h3 { font-family: var(--font-head); font-size: 24px; color: var(--ink); margin-bottom: 8px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--green-soft); border-top-color: var(--green);
  animation: spin .8s linear infinite; margin: 0 auto 14px;
}

/* ---------------- PDF Viewer overlay ---------------- */
.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: #FFFFFF;
  display: none;
  flex-direction: column;
}
.viewer.open { display: flex; animation: fade .2s ease; }
.viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.viewer-title {
  font-family: var(--font-head); font-weight: 600; font-size: 18px;
  margin-right: auto; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viewer-ctrl {
  display: flex; align-items: center; gap: 6px;
  background: var(--line-soft); border-radius: 999px; padding: 4px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px;
  border: none; background: transparent; color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: #fff; color: var(--green-dark); box-shadow: var(--shadow); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-ind { font-size: 13px; font-weight: 600; min-width: 66px; text-align: center; color: var(--muted); }
.zoom-ind { font-size: 13px; font-weight: 600; min-width: 48px; text-align: center; color: var(--muted); }
.viewer-canvas-wrap {
  flex: 1; overflow: auto; background: #FFFFFF;
  display: flex; justify-content: center; align-items: center;
  padding: 20px 16px;
  -webkit-overflow-scrolling: touch;
}
#pdf-canvas {
  background: #fff;
  box-shadow: 0 6px 30px rgba(20,32,26,.10);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  margin: auto;
}
.viewer-loading { align-self: center; margin: auto; }

/* Bottom page slider (slider-form navigation) */
.viewer-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-top: 1px solid var(--line); background: #fff;
}
.viewer-foot .foot-nav { flex: 0 0 auto; }
.pv-slider {
  flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
  background: var(--line);
  border-radius: 999px; outline: none; cursor: pointer; accent-color: var(--green);
}
.pv-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer;
}
.pv-slider::-moz-range-thumb {
  width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%;
  background: var(--green); cursor: pointer;
}

/* ---------------- Admin ---------------- */
.auth-wrap {
  min-height: calc(100vh - 78px);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 30px;
  box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.auth-card h2 { font-family: var(--font-head); font-size: 28px; font-weight: 600; }
.auth-card p.sub { color: var(--muted); font-size: 14px; margin-top: 6px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.field input, .field select {
  width: 100%; font-family: var(--font-body); font-size: 15px;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.file-drop {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px;
  font-size: 13.5px; color: var(--muted); background: #fafcfa;
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer; display: block;
}
.file-drop:hover { border-color: var(--green); background: var(--green-soft); }
.file-drop.has-file { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }
.file-drop input { display: none; }

/* Administrator accounts list */
.admin-accounts { display: flex; flex-direction: column; gap: 10px; }
.admin-acc {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; transition: border-color .18s ease, transform .18s var(--spring);
}
.admin-acc:hover { border-color: #cdeccd; transform: translateY(-1px); }
.admin-acc-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-acc-info b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-badge {
  background: var(--green); color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 999px; letter-spacing: .04em; text-transform: uppercase;
}
.admin-acc-note { color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.form-error { color: #c0392b; font-size: 13.5px; margin-top: 4px; min-height: 18px; }

.dash { max-width: 1200px; margin: 0 auto; padding: 30px 24px 80px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-head h1 { font-family: var(--font-head); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.dash-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 26px; box-shadow: var(--shadow);
}
.panel h3 { font-family: var(--font-head); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.panel .hint { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.cat-manage { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cat-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-soft); color: var(--green-dark);
  font-size: 13px; font-weight: 600; padding: 7px 8px 7px 14px; border-radius: 999px;
}
.cat-pill button {
  border: none; background: rgba(61,148,64,.15); color: var(--green-dark);
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.cat-pill button:hover { background: #c0392b; color: #fff; }

.admin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.admin-item {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
  transition: box-shadow .18s ease;
}
.admin-item:hover { box-shadow: var(--shadow); }
.admin-item .thumb { aspect-ratio: 4/3; background: var(--line-soft); overflow: hidden; }
.admin-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-item .info { padding: 14px; }
.admin-item .info b { font-family: var(--font-head); font-size: 17px; font-weight: 600; display: block; }
.admin-item .info small { color: var(--muted); font-size: 12px; }
.admin-item .row { display: flex; gap: 8px; padding: 0 14px 14px; }
.admin-item .row .btn { flex: 1; }

/* ---------------- Toast ---------------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: 0 12px 30px rgba(0,0,0,.18);
  animation: rise .3s ease both;
}
.toast.ok { background: var(--green); }
.toast.err { background: #c0392b; }

/* ---------------- Modal (edit) ---------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 150; background: rgba(20,32,26,.4);
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-back.open { display: flex; animation: fade .2s ease; }
.modal {
  background: #fff; border-radius: 20px; width: 100%; max-width: 460px;
  padding: 28px; box-shadow: var(--shadow); animation: rise .3s ease both;
  max-height: 90vh; overflow: auto;
}
.modal h3 { font-family: var(--font-head); font-size: 24px; font-weight: 600; margin-bottom: 20px; }

.footer { border-top: 1px solid var(--line); padding: 26px 24px; text-align: center; color: var(--muted); font-size: 13px; }
.footer a { font-weight: 600; }

/* ---------------- Animations ---------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
  .header-inner { padding: 12px 16px; }
  .brand img { height: 52px; }
  .hero { padding: 34px 16px 12px; }
  .hero p { font-size: 15px; margin-top: 14px; }
  .hero-meta { gap: 22px; margin-top: 20px; }
  .filters { padding: 14px 16px; gap: 8px; }
  .chip { font-size: 13px; padding: 8px 14px; }
  .grid-wrap { padding: 12px 16px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .card-title { font-size: 16px; }
  .card-body { padding: 13px 13px 14px; gap: 11px; }
  .card-actions { flex-direction: column; }
  .footer { padding: 22px 16px; }
}

@media (max-width: 620px) {
  .form-grid { grid-template-columns: 1fr; }
  .hero h1 { max-width: 100%; }
  .dash { padding: 20px 16px 60px; }
  .dash-head h1 { font-size: 28px; }
  .panel { padding: 18px; }
  .admin-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .auth-card { padding: 26px 22px; }

  /* PDF viewer: stack title, keep controls compact, use bottom slider for paging */
  .viewer-bar { padding: 10px 12px; gap: 6px; }
  .viewer-title { flex-basis: 100%; max-width: 100%; order: -1; font-size: 16px; }
  .ctrl-page { display: none; } /* paging handled by the bottom slider on mobile */
  .ctrl-zoom { flex: 0 0 auto; }
  #pv-download { padding: 9px 16px; }
  .viewer-canvas-wrap { padding: 12px 8px; }
  .viewer-foot { padding: 10px 12px; gap: 10px; }
  .icon-btn { width: 40px; height: 40px; }
}
