:root {
  --bg: #f3f6f1;
  --bg-accent: #e4ecdf;
  --ink: #1c2a1a;
  --muted: #5a6b57;
  --brand: #2f5d3a;
  --brand-dark: #1e3d26;
  --surface: #ffffffcc;
  --line: #c5d2c0;
  --danger: #8b2e2e;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(28, 42, 26, 0.08);
  --font-display: Georgia, "Palatino Linotype", Palatino, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 10% 0%, #d9e8d2 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, #cfe0d8 0%, transparent 40%),
    linear-gradient(180deg, #eef4ea 0%, var(--bg) 40%, #e8efe4 100%);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.btn, button.btn, input[type="submit"].btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary {
  background: transparent;
  color: var(--brand-dark);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.card-panel {
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.muted { color: var(--muted); }

.unit-list {
  display: grid;
  gap: 0.9rem;
}

.unit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.unit-item:last-child { border-bottom: none; }
.unit-item a.title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--ink);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.photo-card {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #dfe8da;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.35s ease;
}

.photo-card:hover img { transform: scale(1.04); }

.photo-card > input[type="checkbox"] {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
}
.photo-select {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: flex;
  margin: 0;
  padding: 0.45rem;
  width: 3.25rem;
  height: 3.25rem;
}
.photo-card input[type="checkbox"] {
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  accent-color: var(--brand);
}
.photo-card:has(.photo-check:checked) {
  box-shadow: inset 0 0 0 3px var(--brand);
}
.check-inline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1rem 0;
}

.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

body.lightbox-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 12, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 100%;
}
.lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 78vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  background: #111;
}
.lightbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}
.lightbox .nav-btn,
.lightbox .close {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.lightbox .nav-btn:hover,
.lightbox .close:hover {
  background: rgba(255, 255, 255, 0.18);
}
.lightbox .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}
.lightbox .nav-btn.prev {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox .nav-btn.next {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}
@media (max-width: 640px) {
  .lightbox .nav-btn.prev,
  .lightbox .nav-btn.next {
    position: static;
    transform: none;
  }
  .lightbox-actions { margin-top: 0.25rem; }
}

form.stack {
  display: grid;
  gap: 0.75rem;
  max-width: 420px;
}
label { display: grid; gap: 0.3rem; font-weight: 600; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.error {
  background: #f8e8e8;
  color: var(--danger);
  border: 1px solid #e2bcbc;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.admin-nav a {
  color: var(--muted);
  font-weight: 600;
}
.admin-nav a:hover, .admin-nav a.active { color: var(--brand-dark); }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.qr-print {
  text-align: center;
  padding: 2rem 1rem;
}
.qr-print .qr-box {
  display: inline-block;
  padding: 1.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.qr-print svg { width: 220px; height: 220px; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.hero-empty {
  padding: 3rem 1rem;
  text-align: center;
}
.hero-empty h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--brand-dark);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.wrap > * { animation: fade-up 0.45s ease both; }

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .unit-item { flex-direction: column; align-items: flex-start; }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table thead { display: none; }
  .responsive-table tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
  }
  .responsive-table td {
    border: 0;
    padding: 0.45rem 0;
  }
  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.3rem;
    color: var(--muted);
    font-weight: 700;
  }
  .children-table form.stack { max-width: none !important; }
}
