:root {
  --navy: #1D512B;
  --blue: #2d7040;
  --sky: #eaf7ee;
  --ink: #142033;
  --muted: #667085;
  --line: #e2ebe5;
  --card: #ffffff;
  --bg: #f6faf7;
  --ok: #1D512B;
  --warn: #b7791f;
  --bad: #c24141;
  --shadow: 0 18px 45px rgba(29, 81, 43, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scrollbar-width: none; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body::-webkit-scrollbar { display: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #1D512B 0%, #2d7040 54%, #f6faf7 54%);
}
.auth-card {
  width: min(440px, 100%);
  background: white;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.auth-logo { height: 54px; width: auto; margin-bottom: 24px; }
.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.auth-card p { color: var(--muted); margin: 0 0 24px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--navy);
  color: white;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand img { width: 46px; height: 46px; object-fit: contain; background: white; border-radius: 12px; padding: 6px; }
.brand strong { display: block; font-weight: 700; letter-spacing: 0; }
.brand span { color: #bfd3eb; font-size: 13px; }
.nav { display: grid; gap: 7px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 14px;
  color: #dce8f6;
  font-weight: 600;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); color: white; }
.nav .ico {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  background: rgba(255,255,255,.1);
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  color: #bfd3eb;
  font-size: 13px;
  padding: 10px;
}
.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 13px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 600;
  gap: 8px;
}
.logout-link:hover { background: rgba(255,255,255,.18); }

.main { padding: 34px 34px 96px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin: 0 auto 26px; max-width: 1180px; }
.topbar h1 { margin: 0; font-size: clamp(26px, 3vw, 38px); line-height: 1.15; font-weight: 700; letter-spacing: 0; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.user-pill { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; color: var(--muted); white-space: nowrap; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.content-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fcfa;
}
.content-tabs::-webkit-scrollbar { display: none; }
.content-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  padding: 8px 13px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.content-tabs button.active {
  background: var(--navy);
  color: white;
  box-shadow: 0 8px 18px rgba(29,81,43,.16);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.main > .grid,
.main > .card,
.main > .feed,
.main > p {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2, .card h3 { margin: 0 0 14px; line-height: 1.25; font-weight: 700; }
.stat { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 112px; }
.stat > div { display: grid; gap: 6px; min-width: 0; }
.stat strong { display: block; font-size: 30px; line-height: 1.08; color: var(--navy); font-weight: 700; }
.muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
}
.btn.primary { background: var(--navy); color: white; }
.btn.soft { background: var(--sky); color: var(--blue); }
.btn.danger { background: #fff0f0; color: var(--bad); }
.btn.ok { background: #ecfdf5; color: var(--ok); }

label { display: grid; gap: 7px; color: var(--muted); font-weight: 600; font-size: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 13px 14px;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
form.grid { align-items: end; }

.list { display: grid; gap: 12px; }
.item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  display: grid;
  gap: 10px;
}
.item-row { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: #39465a;
}
.badge.pending { background: #fff7dd; color: var(--warn); }
.badge.accepted, .badge.completed, .badge.paid_confirmed { background: #e7f8ef; color: var(--ok); }
.badge.declined, .badge.cancelled { background: #ffe9e9; color: var(--bad); }
.badge.unpaid { background: #fff7dd; color: var(--warn); }
.badge.parent_marked_paid { background: var(--sky); color: var(--blue); }

.timeline { display: grid; gap: 12px; }
.timeline .item { border-left: 5px solid var(--blue); }
.report-body { display: grid; gap: 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 14px; cursor: zoom-in; }
.photo-dialog { border: 0; padding: 0; border-radius: 18px; max-width: min(92vw, 900px); background: transparent; }
.photo-dialog::backdrop { background: rgba(15,48,24,.75); }
.photo-dialog img { max-height: 86vh; border-radius: 18px; }
.photo-dialog button { position: fixed; top: 18px; right: 18px; border: 0; border-radius: 999px; width: 44px; height: 44px; font-size: 28px; }

.feed { display: grid; gap: 18px; max-width: 860px; }
.post-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.post-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 20px 12px;
}
.avatar, .comment-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: white;
  font-weight: 700;
}
.avatar { width: 44px; height: 44px; }
.comment-avatar { width: 32px; height: 32px; font-size: 13px; }
.post-header strong { display: block; line-height: 1.2; }
.post-header span { display: block; font-size: 14px; }
.post-content { padding: 0 20px 16px; }
.post-content h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; }
.post-content p { margin: 0; }
.post-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  background: var(--line);
}
.post-photos.single { display: block; }
.post-photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  cursor: zoom-in;
  background: #f0f4f1;
}
.post-photos.single img { max-height: 520px; aspect-ratio: auto; }
.post-details {
  display: grid;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.post-details details {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfb;
  padding: 10px 12px;
}
.post-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--navy);
}
.post-details p { margin: 8px 0 0; color: var(--muted); }
.comments {
  display: grid;
  gap: 12px;
  padding: 14px 20px 18px;
  background: #fbfdfb;
}
.comment-count { color: var(--muted); font-size: 14px; }
.comment {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.comment-bubble {
  min-width: 0;
  max-width: 100%;
  border-radius: 15px;
  background: #eef6f0;
  padding: 9px 12px;
}
.comment-bubble strong { display: block; font-size: 14px; }
.comment-bubble strong span { color: var(--muted); font-weight: 600; }
.comment-bubble p { margin: 3px 0 0; }
.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.comment-form input { border-radius: 999px; }
.comment-form .btn {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 999px;
}

.flash { border-radius: 14px; padding: 12px 14px; margin-bottom: 18px; background: var(--sky); color: var(--blue); font-weight: 600; }
.flash.error { background: #ffe9e9; color: var(--bad); }
.flash.success { background: #e7f8ef; color: var(--ok); }
.bottom-nav { display: none; }
.password-lock {
  max-width: 720px;
  text-align: center;
}
.password-lock form { margin-top: 18px; text-align: left; }
.password-lock .btn { grid-column: 1 / -1; width: 100%; }
.lock-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--sky);
  color: var(--navy);
  font-size: 22px;
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 20px 14px calc(92px + env(safe-area-inset-bottom)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .topbar h1 { font-size: 30px; }
  .user-pill { white-space: normal; }
  .content-tabs {
    position: sticky;
    top: 0;
    z-index: 6;
    margin-left: -2px;
    margin-right: -2px;
    background: rgba(249,252,250,.96);
    backdrop-filter: blur(12px);
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: white;
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px rgba(29,81,43,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav.locked {
    grid-template-columns: 1fr;
  }
  .bottom-nav a { text-align: center; padding: 10px 4px 12px; color: var(--muted); font-size: 11px; font-weight: 600; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 24px;
    margin: 0 auto 2px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
  }
  .bottom-nav a.active span { background: var(--sky); color: var(--blue); }
}

@media (max-width: 560px) {
  .auth-shell { padding: 14px; background: var(--bg); }
  .auth-card { padding: 24px; border-radius: 18px; }
  .card { padding: 16px; border-radius: 16px; }
  .main { padding-left: 12px; padding-right: 12px; }
  .topbar h1 { font-size: 28px; }
  .topbar p { font-size: 15px; }
  .user-pill { width: 100%; border-radius: 14px; }
  .content-tabs { border-radius: 14px; }
  .content-tabs button { min-height: 36px; padding: 7px 11px; font-size: 14px; }
  .item-row, .stat { flex-direction: column; align-items: flex-start; }
  .stat { gap: 14px; }
  .stat strong { font-size: 28px; }
  .actions .btn { flex: 1 1 100%; }
  .post-card { border-radius: 16px; }
  .post-header { padding: 15px 15px 10px; }
  .post-content { padding: 0 15px 14px; }
  .post-content h2 { font-size: 20px; }
  .post-details, .comments { padding-left: 15px; padding-right: 15px; }
  .post-photos { grid-template-columns: 1fr 1fr; }
  .comment-form { grid-template-columns: 1fr 44px; }
  .comment-form .btn { width: 44px; height: 44px; }
  input, textarea, select { font-size: 16px; }
}
