:root {
  --green: #16874a;
  --green-hover: #116b3b;
  --green-deep: #0f5c33;
  --green-soft: #e8f5ee;
  --green-mid: #2ea86a;
  --ink: #17161c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f5f6f8;
  --white: #fff;
  --shadow: 0 8px 24px rgba(15, 92, 51, 0.08);
  --radius: 18px;
  --font: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  direction: ltr;
}
a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.flash-wrap {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}
.flash {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.flash.success { background: #f1faf4; border-color: #b7e4c7; color: var(--green-deep); }
.flash.error { background: #fff5f5; border-color: #f5c2c0; color: #b42318; }
.flash.info { background: var(--green-soft); border-color: #b7e4c7; color: var(--green-deep); }

/* Login */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-brand {
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 40px;
  text-align: center;
}
.auth-brand .logo-mark {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  object-fit: cover;
  display: block;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}
.auth-brand h1 { margin: 0; font-size: 36px; }
.auth-brand p { margin: 0; opacity: .9; }
.auth-form-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: #fff;
}
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.auth-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  line-height: 1.7;
}
.field { display: grid; gap: 8px; }
.field[hidden],
.hint[hidden],
[hidden] { display: none !important; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,135,74,.12);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--green);
  color: #fff;
}
.btn:hover { background: var(--green-hover); }
.btn-block { width: 100%; }
.btn-outline {
  background: #fff;
  color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-ghost {
  background: var(--green-soft);
  color: var(--green-deep);
}
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 999px; }

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 18px;
  padding: 18px;
}
.sidebar {
  background: linear-gradient(175deg, #1a9a56 0%, var(--green-deep) 72%);
  color: #fff;
  border-radius: 24px;
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  box-shadow: 0 12px 32px rgba(15, 92, 51, 0.18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 10px;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.brand-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.brand-text strong {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.brand-text span {
  font-size: 11px;
  font-weight: 500;
  opacity: .72;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: 0 2px;
  scrollbar-width: thin;
}
.nav-section {
  margin: 12px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
}
.nav-section:first-child { margin-top: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(255,255,255,.88);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.nav-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.nav-item:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.nav-item.active {
  background: #fff;
  color: var(--green-deep);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.nav-item .ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: .95;
}
.nav-item .ico svg {
  width: 20px;
  height: 20px;
  display: block;
}
.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  padding: 14px 8px 2px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 11px;
}
.sidebar-foot a {
  color: rgba(255,255,255,.7);
  text-decoration: none;
}
.sidebar-foot a:hover {
  color: #fff;
  text-decoration: underline;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
}
.profile-chip img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-soft);
}
.profile-chip .meta { display: grid; gap: 2px; }
.profile-chip .meta strong { font-size: 13px; }
.profile-chip .meta span { font-size: 11px; color: var(--muted); }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-pad { padding: 18px; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: var(--green-soft);
  border: 1px solid #cdead9;
  border-radius: var(--radius);
}
.banner h3 { margin: 0 0 6px; }
.banner p { margin: 0; color: var(--muted); font-size: 14px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.feature-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: inherit;
  transition: .15s ease;
}
.feature-card:hover {
  border-color: #b7e4c7;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.feature-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green-deep);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: 0 0 auto;
}
.feature-card h3 { margin: 0 0 6px; font-size: 16px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.search {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}

.account-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.account-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.account-user img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-soft);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-mid);
}

/* Inbox */
.inbox-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 70vh;
  overflow: hidden;
}
.conv-list {
  border-right: 1px solid var(--line);
  overflow: auto;
  max-height: 75vh;
}
.conv-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.conv-item:hover, .conv-item.active { background: var(--green-soft); }
.conv-item img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #dff0e6;
}
.conv-item .body { min-width: 0; flex: 1; }
.conv-item .body strong { display: block; font-size: 14px; }
.conv-item .body p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread {
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
.thread {
  display: flex;
  flex-direction: column;
  min-height: 70vh;
}
.thread-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.thread-head img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green-soft);
}
.thread-messages {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(#fafcfa, #f3f7f4);
  max-height: 58vh;
}
.bubble {
  max-width: min(420px, 85%);
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
}
.bubble.out {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.bubble .type-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  opacity: .8;
  margin-bottom: 6px;
}
.bubble .media {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,.04);
}
.bubble .media img, .bubble .media video {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
}
.bubble audio { width: 100%; margin-top: 8px; }
.story-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: rgba(22,135,74,.08);
  margin-top: 8px;
}
.story-card img {
  width: 56px;
  height: 84px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--green);
}
.thread-compose {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  gap: 10px;
  background: #fff;
}
.thread-compose input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

/* Comments */
.comments-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 70vh;
  overflow: hidden;
}
.posts-list { border-right: 1px solid var(--line); overflow: auto; max-height: 75vh; }
.post-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.post-item:hover, .post-item.active { background: var(--green-soft); }
.post-item img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: #dff0e6;
}
.post-item h4 { margin: 0 0 4px; font-size: 14px; }
.post-item p { margin: 0; color: var(--muted); font-size: 12px; }
.comment-panel { padding: 16px; display: grid; gap: 14px; }
.comment {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.comment.reply {
  margin-right: 28px;
  background: var(--green-soft);
  border-color: #cdead9;
}
.comment-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.comment form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.comment form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
.table th { color: var(--muted); font-weight: 600; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.hint {
  background: #fff8e8;
  border: 1px solid #f3e0b5;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  color: #7a5a10;
  line-height: 1.7;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
  justify-content: space-around;
  align-items: flex-end;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06);
}
.mobile-nav a {
  color: var(--muted);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-weight: 650;
  min-width: 52px;
  padding: 4px;
  text-decoration: none;
}
.mobile-nav a.active { color: var(--green); }
.mobile-nav .m-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.mobile-nav .m-ico svg {
  width: 20px;
  height: 20px;
  display: block;
}
.mobile-nav .fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  margin-top: -18px;
  box-shadow: 0 8px 18px rgba(22, 135, 74, 0.35);
}
.mobile-nav .fab svg {
  width: 22px;
  height: 22px;
  display: block;
}

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 220px; }
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px 12px 84px;
  }
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .feature-grid, .form-grid, .inbox-layout, .comments-layout {
    grid-template-columns: 1fr;
  }
  .conv-list, .posts-list {
    max-height: 28vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

/* UI helpers */
.mode-pill {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}
.mode-pill.human { background: #111; color: #fff; }
.mode-pill.bot { background: var(--green-soft); color: var(--green); }
.thread-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.thread-compose {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.thread-compose input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}
.human-agent-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
}
.reaction-emoji { font-size: 28px; line-height: 1; }
.media-gone {
  padding: 12px;
  background: #f3f4f6;
  border-radius: 12px;
  color: #6b7280;
  font-size: 13px;
}
.audio-wrap { display: grid; gap: 8px; }
.comment-actions { display: grid; gap: 8px; margin-top: 10px; }
.inline-reply { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-reply input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}
.mod-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.comment.is-hidden { opacity: .55; border-style: dashed; }
.legal-page {
  max-width: 760px;
  margin: 40px auto;
  padding: 0 20px 60px;
  font-family: var(--font);
  line-height: 1.7;
}
.legal-page h1 { margin-bottom: 8px; }
.legal-page h2 { margin-top: 28px; }
